Tidy up some configuration options.

MP_ALLOC_* -> MICROPY_ALLOC_*
MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX
MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL
MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX
MICROPY_EXTRA_* -> MICROPY_PORT_*

See issue #35.
This commit is contained in:
Damien George 2014-05-21 20:32:59 +01:00
parent aa7cf6f72f
commit 58ebde4664
18 changed files with 99 additions and 93 deletions

View File

@ -2,14 +2,15 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_ALLOC_PATH_MAX (512)
#define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (0) #define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (0) #define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_ENABLE_GC (0) #define MICROPY_ENABLE_GC (0)
#define MICROPY_ENABLE_REPL_HELPERS (0) #define MICROPY_HELPER_REPL (0)
#define MICROPY_ENABLE_LEXER_UNIX (0) #define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_ENABLE_MOD_COLLECTIONS (0) #define MICROPY_ENABLE_MOD_COLLECTIONS (0)
#define MICROPY_ENABLE_MOD_MATH (0) #define MICROPY_ENABLE_MOD_MATH (0)
@ -21,7 +22,6 @@
#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_PATH_MAX (512)
// type definitions for the specific machine // type definitions for the specific machine
@ -37,6 +37,6 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
// extra built in names to add to the global namespace // extra built in names to add to the global namespace
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
#define MICROPY_EXTRA_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },

View File

@ -278,7 +278,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
DEBUG_printf("Module not yet loaded\n"); DEBUG_printf("Module not yet loaded\n");
uint last = 0; uint last = 0;
VSTR_FIXED(path, MICROPY_PATH_MAX) VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX)
module_obj = MP_OBJ_NULL; module_obj = MP_OBJ_NULL;
mp_obj_t top_module_obj = MP_OBJ_NULL; mp_obj_t top_module_obj = MP_OBJ_NULL;
mp_obj_t outer_module_obj = MP_OBJ_NULL; mp_obj_t outer_module_obj = MP_OBJ_NULL;

View File

@ -140,7 +140,7 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
// TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation // TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
// Extra builtins as defined by a port // Extra builtins as defined by a port
MICROPY_EXTRA_BUILTINS MICROPY_PORT_BUILTINS
}; };
const mp_obj_dict_t mp_builtin_object_dict_obj = { const mp_obj_dict_t mp_builtin_object_dict_obj = {
@ -183,7 +183,7 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
#endif #endif
// extra builtin modules as defined by a port // extra builtin modules as defined by a port
MICROPY_EXTRA_BUILTIN_MODULES MICROPY_PORT_BUILTIN_MODULES
}; };
const mp_obj_dict_t mp_builtin_module_dict_obj = { const mp_obj_dict_t mp_builtin_module_dict_obj = {

View File

@ -104,7 +104,7 @@ STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const cha
STATIC const mp_map_elem_t mp_constants_table[] = { STATIC const mp_map_elem_t mp_constants_table[] = {
// Extra constants as defined by a port // Extra constants as defined by a port
MICROPY_EXTRA_CONSTANTS MICROPY_PORT_CONSTANTS
}; };
STATIC const mp_map_t mp_constants_map = { STATIC const mp_map_t mp_constants_map = {
@ -119,7 +119,7 @@ STATIC const mp_map_t mp_constants_map = {
STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_map_t *consts) { STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_map_t *consts) {
if (0) { if (0) {
// dummy // dummy
#if MICROPY_ENABLE_CONST #if MICROPY_COMP_CONST
} else if (MP_PARSE_NODE_IS_ID(pn)) { } else if (MP_PARSE_NODE_IS_ID(pn)) {
// lookup identifier in table of dynamic constants // lookup identifier in table of dynamic constants
qstr qst = MP_PARSE_NODE_LEAF_ARG(pn); qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
@ -133,7 +133,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
// fold some parse nodes before folding their arguments // fold some parse nodes before folding their arguments
switch (MP_PARSE_NODE_STRUCT_KIND(pns)) { switch (MP_PARSE_NODE_STRUCT_KIND(pns)) {
#if MICROPY_ENABLE_CONST #if MICROPY_COMP_CONST
case PN_expr_stmt: case PN_expr_stmt:
if (!MP_PARSE_NODE_IS_NULL(pns->nodes[1])) { if (!MP_PARSE_NODE_IS_NULL(pns->nodes[1])) {
mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];

View File

@ -218,8 +218,8 @@ STATIC void next_char(mp_lexer_t *lex) {
void indent_push(mp_lexer_t *lex, uint indent) { void indent_push(mp_lexer_t *lex, uint indent) {
if (lex->num_indent_level >= lex->alloc_indent_level) { if (lex->num_indent_level >= lex->alloc_indent_level) {
// TODO use m_renew_maybe and somehow indicate an error if it fails... probably by using MP_TOKEN_MEMORY_ERROR // TODO use m_renew_maybe and somehow indicate an error if it fails... probably by using MP_TOKEN_MEMORY_ERROR
lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MP_ALLOC_LEXEL_INDENT_INC); lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC);
lex->alloc_indent_level += MP_ALLOC_LEXEL_INDENT_INC; lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC;
} }
lex->indent_level[lex->num_indent_level++] = indent; lex->indent_level[lex->num_indent_level++] = indent;
} }
@ -731,7 +731,7 @@ mp_lexer_t *mp_lexer_new(qstr src_name, void *stream_data, mp_lexer_stream_next_
lex->column = 1; lex->column = 1;
lex->emit_dent = 0; lex->emit_dent = 0;
lex->nested_bracket_level = 0; lex->nested_bracket_level = 0;
lex->alloc_indent_level = MP_ALLOC_LEXER_INDENT_INIT; lex->alloc_indent_level = MICROPY_ALLOC_LEXER_INDENT_INIT;
lex->num_indent_level = 1; lex->num_indent_level = 1;
lex->indent_level = m_new_maybe(uint16_t, lex->alloc_indent_level); lex->indent_level = m_new_maybe(uint16_t, lex->alloc_indent_level);
vstr_init(&lex->vstr, 32); vstr_init(&lex->vstr, 32);

View File

@ -27,7 +27,7 @@
#include "misc.h" #include "misc.h"
#include "mpconfig.h" #include "mpconfig.h"
#if MICROPY_ENABLE_LEXER_UNIX #if MICROPY_HELPER_LEXER_UNIX
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -81,4 +81,4 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_char_t)file_buf_next_char, (mp_lexer_stream_close_t)file_buf_close); return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_char_t)file_buf_next_char, (mp_lexer_stream_close_t)file_buf_close);
} }
#endif // MICROPY_ENABLE_LEXER_UNIX #endif // MICROPY_HELPER_LEXER_UNIX

View File

@ -37,43 +37,49 @@
/* Memory allocation policy */ /* Memory allocation policy */
// Initial amount for lexer indentation level // Initial amount for lexer indentation level
#ifndef MP_ALLOC_LEXER_INDENT_INIT #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
#define MP_ALLOC_LEXER_INDENT_INIT (10) #define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
#endif #endif
// Increment for lexer indentation level // Increment for lexer indentation level
#ifndef MP_ALLOC_LEXEL_INDENT_INC #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
#define MP_ALLOC_LEXEL_INDENT_INC (8) #define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
#endif #endif
// Initial amount for parse rule stack // Initial amount for parse rule stack
#ifndef MP_ALLOC_PARSE_RULE_INIT #ifndef MICROPY_ALLOC_PARSE_RULE_INIT
#define MP_ALLOC_PARSE_RULE_INIT (64) #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
#endif #endif
// Increment for parse rule stack // Increment for parse rule stack
#ifndef MP_ALLOC_PARSE_RULE_INC #ifndef MICROPY_ALLOC_PARSE_RULE_INC
#define MP_ALLOC_PARSE_RULE_INC (16) #define MICROPY_ALLOC_PARSE_RULE_INC (16)
#endif #endif
// Initial amount for parse result stack // Initial amount for parse result stack
#ifndef MP_ALLOC_PARSE_RESULT_INIT #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
#define MP_ALLOC_PARSE_RESULT_INIT (32) #define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
#endif #endif
// Increment for parse result stack // Increment for parse result stack
#ifndef MP_ALLOC_PARSE_RESULT_INC #ifndef MICROPY_ALLOC_PARSE_RESULT_INC
#define MP_ALLOC_PARSE_RESULT_INC (16) #define MICROPY_ALLOC_PARSE_RESULT_INC (16)
#endif #endif
// Initial amount for ids in a scope // Initial amount for ids in a scope
#ifndef MP_ALLOC_SCOPE_ID_INIT #ifndef MICROPY_ALLOC_SCOPE_ID_INIT
#define MP_ALLOC_SCOPE_ID_INIT (4) #define MICROPY_ALLOC_SCOPE_ID_INIT (4)
#endif #endif
// Increment for ids in a scope // Increment for ids in a scope
#ifndef MP_ALLOC_SCOPE_ID_INC #ifndef MICROPY_ALLOC_SCOPE_ID_INC
#define MP_ALLOC_SCOPE_ID_INC (6) #define MICROPY_ALLOC_SCOPE_ID_INC (6)
#endif
// Maximum length of a path in the filesystem
// So we can allocate a buffer on the stack for path manipulation in import
#ifndef MICROPY_ALLOC_PATH_MAX
#define MICROPY_ALLOC_PATH_MAX (512)
#endif #endif
/*****************************************************************************/ /*****************************************************************************/
@ -100,6 +106,14 @@
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#endif #endif
/*****************************************************************************/
/* Compiler configuration */
// Whether to enable constant optimisation; id = const(value)
#ifndef MICROPY_COMP_CONST
#define MICROPY_COMP_CONST (1)
#endif
/*****************************************************************************/ /*****************************************************************************/
/* Internal debugging stuff */ /* Internal debugging stuff */
@ -119,11 +133,6 @@
/*****************************************************************************/ /*****************************************************************************/
/* Fine control over Python features */ /* Fine control over Python features */
// Whether to enable constant optimisation; id = const(value)
#ifndef MICROPY_ENABLE_CONST
#define MICROPY_ENABLE_CONST (1)
#endif
// Whether to include the garbage collector // Whether to include the garbage collector
#ifndef MICROPY_ENABLE_GC #ifndef MICROPY_ENABLE_GC
#define MICROPY_ENABLE_GC (0) #define MICROPY_ENABLE_GC (0)
@ -135,13 +144,13 @@
#endif #endif
// Whether to include REPL helper function // Whether to include REPL helper function
#ifndef MICROPY_ENABLE_REPL_HELPERS #ifndef MICROPY_HELPER_REPL
#define MICROPY_ENABLE_REPL_HELPERS (0) #define MICROPY_HELPER_REPL (0)
#endif #endif
// Whether to include lexer helper function for unix // Whether to include lexer helper function for unix
#ifndef MICROPY_ENABLE_LEXER_UNIX #ifndef MICROPY_HELPER_LEXER_UNIX
#define MICROPY_ENABLE_LEXER_UNIX (0) #define MICROPY_HELPER_LEXER_UNIX (0)
#endif #endif
// Long int implementation // Long int implementation
@ -277,12 +286,6 @@ typedef double mp_float_t;
#define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_CPYTHON_COMPAT (1)
#endif #endif
// Maximum length of a path in the filesystem
// So we can allocate a buffer on the stack for path manipulation in import
#ifndef MICROPY_PATH_MAX
#define MICROPY_PATH_MAX (512)
#endif
// Whether POSIX-semantics non-blocking streams are supported // Whether POSIX-semantics non-blocking streams are supported
#ifndef MICROPY_STREAMS_NON_BLOCK #ifndef MICROPY_STREAMS_NON_BLOCK
#define MICROPY_STREAMS_NON_BLOCK (0) #define MICROPY_STREAMS_NON_BLOCK (0)
@ -290,23 +293,26 @@ typedef double mp_float_t;
// Whether to use computed gotos in the VM, or a switch // Whether to use computed gotos in the VM, or a switch
// Computed gotos are roughly 10% faster, and increase VM code size by a little // Computed gotos are roughly 10% faster, and increase VM code size by a little
#ifndef MICROPY_USE_COMPUTED_GOTO #ifndef MICROPY_OPT_COMPUTED_GOTO
#define MICROPY_USE_COMPUTED_GOTO (0) #define MICROPY_OPT_COMPUTED_GOTO (0)
#endif #endif
/*****************************************************************************/
/* Hooks for a port to add builtins */
// Additional builtin function definitions - see builtintables.c:builtin_object_table for format. // Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
#ifndef MICROPY_EXTRA_BUILTINS #ifndef MICROPY_PORT_BUILTINS
#define MICROPY_EXTRA_BUILTINS #define MICROPY_PORT_BUILTINS
#endif #endif
// Additional builtin module definitions - see builtintables.c:builtin_module_table for format. // Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
#ifndef MICROPY_EXTRA_BUILTIN_MODULES #ifndef MICROPY_PORT_BUILTIN_MODULES
#define MICROPY_EXTRA_BUILTIN_MODULES #define MICROPY_PORT_BUILTIN_MODULES
#endif #endif
// Additional constant definitions for the compiler - see compile.c:mp_constants_table. // Additional constant definitions for the compiler - see compile.c:mp_constants_table.
#ifndef MICROPY_EXTRA_CONSTANTS #ifndef MICROPY_PORT_CONSTANTS
#define MICROPY_EXTRA_CONSTANTS #define MICROPY_PORT_CONSTANTS
#endif #endif
/*****************************************************************************/ /*****************************************************************************/

View File

@ -134,13 +134,13 @@ STATIC void push_rule(parser_t *parser, int src_line, const rule_t *rule, int ar
return; return;
} }
if (parser->rule_stack_top >= parser->rule_stack_alloc) { if (parser->rule_stack_top >= parser->rule_stack_alloc) {
rule_stack_t *rs = m_renew_maybe(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MP_ALLOC_PARSE_RULE_INC); rule_stack_t *rs = m_renew_maybe(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC);
if (rs == NULL) { if (rs == NULL) {
memory_error(parser); memory_error(parser);
return; return;
} }
parser->rule_stack = rs; parser->rule_stack = rs;
parser->rule_stack_alloc += MP_ALLOC_PARSE_RULE_INC; parser->rule_stack_alloc += MICROPY_ALLOC_PARSE_RULE_INC;
} }
rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++]; rule_stack_t *rs = &parser->rule_stack[parser->rule_stack_top++];
rs->src_line = src_line; rs->src_line = src_line;
@ -263,13 +263,13 @@ STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
return; return;
} }
if (parser->result_stack_top >= parser->result_stack_alloc) { if (parser->result_stack_top >= parser->result_stack_alloc) {
mp_parse_node_t *pn = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MP_ALLOC_PARSE_RESULT_INC); mp_parse_node_t *pn = m_renew_maybe(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC);
if (pn == NULL) { if (pn == NULL) {
memory_error(parser); memory_error(parser);
return; return;
} }
parser->result_stack = pn; parser->result_stack = pn;
parser->result_stack_alloc += MP_ALLOC_PARSE_RESULT_INC; parser->result_stack_alloc += MICROPY_ALLOC_PARSE_RESULT_INC;
} }
parser->result_stack[parser->result_stack_top++] = pn; parser->result_stack[parser->result_stack_top++] = pn;
} }
@ -350,11 +350,11 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p
parser.had_memory_error = false; parser.had_memory_error = false;
parser.rule_stack_alloc = MP_ALLOC_PARSE_RULE_INIT; parser.rule_stack_alloc = MICROPY_ALLOC_PARSE_RULE_INIT;
parser.rule_stack_top = 0; parser.rule_stack_top = 0;
parser.rule_stack = m_new_maybe(rule_stack_t, parser.rule_stack_alloc); parser.rule_stack = m_new_maybe(rule_stack_t, parser.rule_stack_alloc);
parser.result_stack_alloc = MP_ALLOC_PARSE_RESULT_INIT; parser.result_stack_alloc = MICROPY_ALLOC_PARSE_RESULT_INIT;
parser.result_stack_top = 0; parser.result_stack_top = 0;
parser.result_stack = m_new_maybe(mp_parse_node_t, parser.result_stack_alloc); parser.result_stack = m_new_maybe(mp_parse_node_t, parser.result_stack_alloc);

View File

@ -28,7 +28,7 @@
#include "mpconfig.h" #include "mpconfig.h"
#include "repl.h" #include "repl.h"
#if MICROPY_ENABLE_REPL_HELPERS #if MICROPY_HELPER_REPL
bool str_startswith_word(const char *str, const char *head) { bool str_startswith_word(const char *str, const char *head) {
int i; int i;
@ -107,4 +107,4 @@ bool mp_repl_continue_with_input(const char *input) {
return false; return false;
} }
#endif // MICROPY_ENABLE_REPL_HELPERS #endif // MICROPY_HELPER_REPL

View File

@ -24,6 +24,6 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#if MICROPY_ENABLE_REPL_HELPERS #if MICROPY_HELPER_REPL
bool mp_repl_continue_with_input(const char *input); bool mp_repl_continue_with_input(const char *input);
#endif #endif

View File

@ -71,7 +71,7 @@ scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint
} }
scope->raw_code = mp_emit_glue_new_raw_code(); scope->raw_code = mp_emit_glue_new_raw_code();
scope->emit_options = emit_options; scope->emit_options = emit_options;
scope->id_info_alloc = MP_ALLOC_SCOPE_ID_INIT; scope->id_info_alloc = MICROPY_ALLOC_SCOPE_ID_INIT;
scope->id_info = m_new(id_info_t, scope->id_info_alloc); scope->id_info = m_new(id_info_t, scope->id_info_alloc);
return scope; return scope;
@ -92,8 +92,8 @@ id_info_t *scope_find_or_add_id(scope_t *scope, qstr qstr, bool *added) {
// make sure we have enough memory // make sure we have enough memory
if (scope->id_info_len >= scope->id_info_alloc) { if (scope->id_info_len >= scope->id_info_alloc) {
scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MP_ALLOC_SCOPE_ID_INC); scope->id_info = m_renew(id_info_t, scope->id_info, scope->id_info_alloc, scope->id_info_alloc + MICROPY_ALLOC_SCOPE_ID_INC);
scope->id_info_alloc += MP_ALLOC_SCOPE_ID_INC; scope->id_info_alloc += MICROPY_ALLOC_SCOPE_ID_INC;
} }
// add new id to end of array of all ids; this seems to match CPython // add new id to end of array of all ids; this seems to match CPython

View File

@ -222,7 +222,7 @@ mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_
mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out,
mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out,
volatile mp_obj_t inject_exc) { volatile mp_obj_t inject_exc) {
#if MICROPY_USE_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
#include "vmentrytable.h" #include "vmentrytable.h"
#define DISPATCH() do { \ #define DISPATCH() do { \
TRACE(ip); \ TRACE(ip); \
@ -276,7 +276,7 @@ outer_dispatch_loop:
// loop to execute byte code // loop to execute byte code
for (;;) { for (;;) {
dispatch_loop: dispatch_loop:
#if MICROPY_USE_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
DISPATCH(); DISPATCH();
#else #else
TRACE(ip); TRACE(ip);
@ -982,7 +982,7 @@ yield:
fastn[0] = obj1; fastn[0] = obj1;
return MP_VM_RETURN_EXCEPTION; return MP_VM_RETURN_EXCEPTION;
#if !MICROPY_USE_COMPUTED_GOTO #if !MICROPY_OPT_COMPUTED_GOTO
} // switch } // switch
#endif #endif
} // for loop } // for loop

View File

@ -2,18 +2,18 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_ALLOC_PATH_MAX (512)
#define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (0) #define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (0) #define MICROPY_DEBUG_PRINTERS (0)
#define MICROPY_ENABLE_GC (0) #define MICROPY_ENABLE_GC (0)
#define MICROPY_ENABLE_REPL_HELPERS (0) #define MICROPY_HELPER_REPL (0)
#define MICROPY_ENABLE_LEXER_UNIX (0) #define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_PATH_MAX (512)
#define MICROPY_ENABLE_MOD_IO (0) #define MICROPY_ENABLE_MOD_IO (0)
// type definitions for the specific machine // type definitions for the specific machine
@ -30,6 +30,6 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
// extra built in names to add to the global namespace // extra built in names to add to the global namespace
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
#define MICROPY_EXTRA_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },

View File

@ -26,17 +26,17 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_ALLOC_PATH_MAX (128)
#define MICROPY_EMIT_THUMB (1) #define MICROPY_EMIT_THUMB (1)
#define MICROPY_EMIT_INLINE_THUMB (1) #define MICROPY_EMIT_INLINE_THUMB (1)
#define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_FINALISER (1) #define MICROPY_ENABLE_FINALISER (1)
#define MICROPY_ENABLE_REPL_HELPERS (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_ENABLE_SOURCE_LINE (1) #define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_ENABLE_FROZENSET (1) #define MICROPY_ENABLE_FROZENSET (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_PATH_MAX (128) #define MICROPY_OPT_COMPUTED_GOTO (1)
#define MICROPY_USE_COMPUTED_GOTO (1)
/* Enable FatFS LFNs /* Enable FatFS LFNs
0: Disable LFN feature. 0: Disable LFN feature.
1: Enable LFN with static working buffer on the BSS. Always NOT reentrant. 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
@ -53,7 +53,7 @@
extern const struct _mp_obj_fun_native_t mp_builtin_help_obj; extern const struct _mp_obj_fun_native_t mp_builtin_help_obj;
extern const struct _mp_obj_fun_native_t mp_builtin_input_obj; extern const struct _mp_obj_fun_native_t mp_builtin_input_obj;
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
#define MICROPY_EXTRA_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
@ -63,14 +63,14 @@ extern const struct _mp_obj_module_t os_module;
extern const struct _mp_obj_module_t pyb_module; extern const struct _mp_obj_module_t pyb_module;
extern const struct _mp_obj_module_t stm_module; extern const struct _mp_obj_module_t stm_module;
extern const struct _mp_obj_module_t time_module; extern const struct _mp_obj_module_t time_module;
#define MICROPY_EXTRA_BUILTIN_MODULES \ #define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
// extra constants // extra constants
#define MICROPY_EXTRA_CONSTANTS \ #define MICROPY_PORT_CONSTANTS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \

View File

@ -5,7 +5,7 @@
#define MICROPY_EMIT_THUMB (1) #define MICROPY_EMIT_THUMB (1)
#define MICROPY_EMIT_INLINE_THUMB (1) #define MICROPY_EMIT_INLINE_THUMB (1)
#define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_REPL_HELPERS (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_ENABLE_FLOAT (1) #define MICROPY_ENABLE_FLOAT (1)
// type definitions for the specific machine // type definitions for the specific machine

View File

@ -27,7 +27,7 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_EMIT_CPYTHON (1) #define MICROPY_EMIT_CPYTHON (1)
#define MICROPY_ENABLE_LEXER_UNIX (1) #define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_ENABLE_MOD_IO (0) #define MICROPY_ENABLE_MOD_IO (0)

View File

@ -26,6 +26,7 @@
// options to control how Micro Python is built // options to control how Micro Python is built
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
#define MICROPY_EMIT_X64 (1) #define MICROPY_EMIT_X64 (1)
#define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
@ -34,14 +35,13 @@
#define MICROPY_ENABLE_FROZENSET (1) #define MICROPY_ENABLE_FROZENSET (1)
#define MICROPY_MEM_STATS (1) #define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_ENABLE_REPL_HELPERS (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_ENABLE_LEXER_UNIX (1) #define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (1) #define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_PATH_MAX (PATH_MAX)
#define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_STREAMS_NON_BLOCK (1)
#define MICROPY_USE_COMPUTED_GOTO (1) #define MICROPY_OPT_COMPUTED_GOTO (1)
#define MICROPY_MOD_SYS_EXIT (1) #define MICROPY_MOD_SYS_EXIT (1)
#define MICROPY_MOD_SYS_STDFILES (1) #define MICROPY_MOD_SYS_STDFILES (1)
#define MICROPY_ENABLE_MOD_CMATH (1) #define MICROPY_ENABLE_MOD_CMATH (1)
@ -66,7 +66,7 @@ extern const struct _mp_obj_module_t mp_module_ffi;
#define MICROPY_MOD_TIME_DEF #define MICROPY_MOD_TIME_DEF
#endif #endif
#define MICROPY_EXTRA_BUILTIN_MODULES \ #define MICROPY_PORT_BUILTIN_MODULES \
MICROPY_MOD_FFI_DEF \ MICROPY_MOD_FFI_DEF \
MICROPY_MOD_TIME_DEF \ MICROPY_MOD_TIME_DEF \
{ MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
@ -91,6 +91,6 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
extern const struct _mp_obj_fun_native_t mp_builtin_input_obj; extern const struct _mp_obj_fun_native_t mp_builtin_input_obj;
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
#define MICROPY_EXTRA_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },

View File

@ -31,14 +31,14 @@
#define MICROPY_USE_READLINE (0) #define MICROPY_USE_READLINE (0)
#endif #endif
#define MICROPY_PATH_MAX (260) //see minwindef.h for msvc or limits.h for mingw #define MICROPY_ALLOC_PATH_MAX (260) //see minwindef.h for msvc or limits.h for mingw
#define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (1) #define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_ENABLE_REPL_HELPERS (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_ENABLE_LEXER_UNIX (1) #define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_MOD_CMATH (1) #define MICROPY_ENABLE_MOD_CMATH (1)
#define MICROPY_MOD_SYS_STDFILES (1) #define MICROPY_MOD_SYS_STDFILES (1)
#define MICROPY_MOD_SYS_EXIT (1) #define MICROPY_MOD_SYS_EXIT (1)
@ -69,11 +69,11 @@ typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
#define MICROPY_EXTRA_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
extern const struct _mp_obj_module_t mp_module_time; extern const struct _mp_obj_module_t mp_module_time;
#define MICROPY_EXTRA_BUILTIN_MODULES \ #define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, \
#include "realpath.h" #include "realpath.h"
@ -95,7 +95,7 @@ void msec_sleep(double msec);
// CL specific overrides from mpconfig // CL specific overrides from mpconfig
#define NORETURN __declspec(noreturn) #define NORETURN __declspec(noreturn)
#define MICROPY_EXTRA_CONSTANTS { "dummy", 0 } //can't have zero-sized array #define MICROPY_PORT_CONSTANTS { "dummy", 0 } //can't have zero-sized array
// CL specific definitions // CL specific definitions