py, unix, stmhal: Allow to compile with -Wshadow.

See issue #699.
This commit is contained in:
Damien George 2015-01-20 11:55:10 +00:00
parent 640e0b221e
commit 50912e7f5d
13 changed files with 139 additions and 137 deletions

View File

@ -84,7 +84,7 @@ void mp_arg_parse_all(mp_uint_t n_pos, const mp_obj_t *pos, mp_map_t *kws, mp_ui
pos_found++; pos_found++;
given_arg = pos[i]; given_arg = pos[i];
} else { } else {
mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qstr), MP_MAP_LOOKUP); mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP);
if (kw == NULL) { if (kw == NULL) {
if (allowed[i].flags & MP_ARG_REQUIRED) { if (allowed[i].flags & MP_ARG_REQUIRED) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
@ -92,7 +92,7 @@ void mp_arg_parse_all(mp_uint_t n_pos, const mp_obj_t *pos, mp_map_t *kws, mp_ui
} else { } else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"'%s' argument required", "'%s' argument required",
qstr_str(allowed[i].qstr))); qstr_str(allowed[i].qst)));
} }
} }
out_vals[i] = allowed[i].defval; out_vals[i] = allowed[i].defval;

View File

@ -1229,9 +1229,9 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
// compile the decorator function // compile the decorator function
compile_node(comp, name_nodes[0]); compile_node(comp, name_nodes[0]);
for (int i = 1; i < name_len; i++) { for (int j = 1; j < name_len; j++) {
assert(MP_PARSE_NODE_IS_ID(name_nodes[i])); // should be assert(MP_PARSE_NODE_IS_ID(name_nodes[j])); // should be
EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[i])); EMIT_ARG(load_attr, MP_PARSE_NODE_LEAF_ARG(name_nodes[j]));
} }
// nodes[1] contains arguments to the decorator function, if any // nodes[1] contains arguments to the decorator function, if any
@ -2778,9 +2778,9 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
// process rest of elements // process rest of elements
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
mp_parse_node_t pn = nodes[i]; mp_parse_node_t pn_i = nodes[i];
bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dictorsetmaker_item); bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND(pn_i, PN_dictorsetmaker_item);
compile_node(comp, pn); compile_node(comp, pn_i);
if (is_dict) { if (is_dict) {
if (!is_key_value) { if (!is_key_value) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dictionary"); compile_syntax_error(comp, (mp_parse_node_t)pns, "expecting key:value for dictionary");
@ -3489,12 +3489,12 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
} }
if (pass > MP_PASS_SCOPE) { if (pass > MP_PASS_SCOPE) {
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]); mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
for (uint i = 1; i < n_args; i++) { for (uint j = 1; j < n_args; j++) {
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[i])) { if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
compile_syntax_error(comp, nodes[i], "inline assembler 'data' requires integer arguments"); compile_syntax_error(comp, nodes[i], "inline assembler 'data' requires integer arguments");
return; return;
} }
EMIT_INLINE_ASM_ARG(data, bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[i])); EMIT_INLINE_ASM_ARG(data, bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j]));
} }
} }
} else { } else {

View File

@ -215,6 +215,6 @@ mp_obj_t mp_module_get(qstr module_name) {
return el->value; return el->value;
} }
void mp_module_register(qstr qstr, mp_obj_t module) { void mp_module_register(qstr qst, mp_obj_t module) {
mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_map), MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_map), MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module;
} }

View File

@ -1243,15 +1243,15 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwa
break; break;
case 's': { case 's': {
mp_uint_t len; mp_uint_t slen;
const char *s = mp_obj_str_get_data(arg, &len); const char *s = mp_obj_str_get_data(arg, &slen);
if (precision < 0) { if (precision < 0) {
precision = len; precision = slen;
} }
if (len > (mp_uint_t)precision) { if (slen > (mp_uint_t)precision) {
len = precision; slen = precision;
} }
pfenv_print_strn(&pfenv_vstr, s, len, flags, fill, width); pfenv_print_strn(&pfenv_vstr, s, slen, flags, fill, width);
break; break;
} }
@ -1379,9 +1379,9 @@ not_enough_args:
switch (*str) { switch (*str) {
case 'c': case 'c':
if (MP_OBJ_IS_STR(arg)) { if (MP_OBJ_IS_STR(arg)) {
mp_uint_t len; mp_uint_t slen;
const char *s = mp_obj_str_get_data(arg, &len); const char *s = mp_obj_str_get_data(arg, &slen);
if (len != 1) { if (slen != 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
"%%c requires int or char")); "%%c requires int or char"));
} }
@ -1425,14 +1425,14 @@ not_enough_args:
vstr_t *arg_vstr = vstr_new(); vstr_t *arg_vstr = vstr_new();
mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf,
arg_vstr, arg, *str == 'r' ? PRINT_REPR : PRINT_STR); arg_vstr, arg, *str == 'r' ? PRINT_REPR : PRINT_STR);
uint len = vstr_len(arg_vstr); uint vlen = vstr_len(arg_vstr);
if (prec < 0) { if (prec < 0) {
prec = len; prec = vlen;
} }
if (len > (uint)prec) { if (vlen > (uint)prec) {
len = prec; vlen = prec;
} }
pfenv_print_strn(&pfenv_vstr, vstr_str(arg_vstr), len, flags, ' ', width); pfenv_print_strn(&pfenv_vstr, vstr_str(arg_vstr), vlen, flags, ' ', width);
vstr_free(arg_vstr); vstr_free(arg_vstr);
break; break;
} }

View File

@ -273,12 +273,12 @@ 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 + MICROPY_ALLOC_PARSE_RESULT_INC); mp_parse_node_t *stack = 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 (stack == NULL) {
memory_error(parser); memory_error(parser);
return; return;
} }
parser->result_stack = pn; parser->result_stack = stack;
parser->result_stack_alloc += MICROPY_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;

View File

@ -104,67 +104,67 @@ void mp_deinit(void) {
#endif #endif
} }
mp_obj_t mp_load_const_int(qstr qstr) { mp_obj_t mp_load_const_int(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr)); DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
mp_uint_t len; mp_uint_t len;
const byte* data = qstr_data(qstr, &len); const byte* data = qstr_data(qst, &len);
return mp_parse_num_integer((const char*)data, len, 0); return mp_parse_num_integer((const char*)data, len, 0);
} }
mp_obj_t mp_load_const_dec(qstr qstr) { mp_obj_t mp_load_const_dec(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr)); DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
mp_uint_t len; mp_uint_t len;
const byte* data = qstr_data(qstr, &len); const byte* data = qstr_data(qst, &len);
return mp_parse_num_decimal((const char*)data, len, true, false); return mp_parse_num_decimal((const char*)data, len, true, false);
} }
mp_obj_t mp_load_const_str(qstr qstr) { mp_obj_t mp_load_const_str(qstr qst) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr)); DEBUG_OP_printf("load '%s'\n", qstr_str(qst));
return MP_OBJ_NEW_QSTR(qstr); return MP_OBJ_NEW_QSTR(qst);
} }
mp_obj_t mp_load_const_bytes(qstr qstr) { mp_obj_t mp_load_const_bytes(qstr qst) {
DEBUG_OP_printf("load b'%s'\n", qstr_str(qstr)); DEBUG_OP_printf("load b'%s'\n", qstr_str(qst));
mp_uint_t len; mp_uint_t len;
const byte *data = qstr_data(qstr, &len); const byte *data = qstr_data(qst, &len);
return mp_obj_new_bytes(data, len); return mp_obj_new_bytes(data, len);
} }
mp_obj_t mp_load_name(qstr qstr) { mp_obj_t mp_load_name(qstr qst) {
// logic: search locals, globals, builtins // logic: search locals, globals, builtins
DEBUG_OP_printf("load name %s\n", qstr_str(qstr)); DEBUG_OP_printf("load name %s\n", qstr_str(qst));
// If we're at the outer scope (locals == globals), dispatch to load_global right away // If we're at the outer scope (locals == globals), dispatch to load_global right away
if (MP_STATE_CTX(dict_locals) != MP_STATE_CTX(dict_globals)) { if (MP_STATE_CTX(dict_locals) != MP_STATE_CTX(dict_globals)) {
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_locals)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP); mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_locals)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem != NULL) { if (elem != NULL) {
return elem->value; return elem->value;
} }
} }
return mp_load_global(qstr); return mp_load_global(qst);
} }
mp_obj_t mp_load_global(qstr qstr) { mp_obj_t mp_load_global(qstr qst) {
// logic: search globals, builtins // logic: search globals, builtins
DEBUG_OP_printf("load global %s\n", qstr_str(qstr)); DEBUG_OP_printf("load global %s\n", qstr_str(qst));
mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_globals)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP); mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_CTX(dict_globals)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem == NULL) { if (elem == NULL) {
#if MICROPY_CAN_OVERRIDE_BUILTINS #if MICROPY_CAN_OVERRIDE_BUILTINS
if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) { if (MP_STATE_VM(mp_module_builtins_override_dict) != NULL) {
// lookup in additional dynamic table of builtins first // lookup in additional dynamic table of builtins first
elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP); elem = mp_map_lookup(&MP_STATE_VM(mp_module_builtins_override_dict)->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem != NULL) { if (elem != NULL) {
return elem->value; return elem->value;
} }
} }
#endif #endif
elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP); elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
if (elem == NULL) { if (elem == NULL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_NameError, nlr_raise(mp_obj_new_exception_msg(&mp_type_NameError,
"name not defined")); "name not defined"));
} else { } else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError, nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError,
"name '%s' is not defined", qstr_str(qstr))); "name '%s' is not defined", qstr_str(qst)));
} }
} }
} }
@ -185,26 +185,26 @@ mp_obj_t mp_load_build_class(void) {
return (mp_obj_t)&mp_builtin___build_class___obj; return (mp_obj_t)&mp_builtin___build_class___obj;
} }
void mp_store_name(qstr qstr, mp_obj_t obj) { void mp_store_name(qstr qst, mp_obj_t obj) {
DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qstr), obj); DEBUG_OP_printf("store name %s <- %p\n", qstr_str(qst), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qstr), obj); mp_obj_dict_store(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qst), obj);
} }
void mp_delete_name(qstr qstr) { void mp_delete_name(qstr qst) {
DEBUG_OP_printf("delete name %s\n", qstr_str(qstr)); DEBUG_OP_printf("delete name %s\n", qstr_str(qst));
// TODO convert KeyError to NameError if qstr not found // TODO convert KeyError to NameError if qst not found
mp_obj_dict_delete(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qstr)); mp_obj_dict_delete(MP_STATE_CTX(dict_locals), MP_OBJ_NEW_QSTR(qst));
} }
void mp_store_global(qstr qstr, mp_obj_t obj) { void mp_store_global(qstr qst, mp_obj_t obj) {
DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qstr), obj); DEBUG_OP_printf("store global %s <- %p\n", qstr_str(qst), obj);
mp_obj_dict_store(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qstr), obj); mp_obj_dict_store(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qst), obj);
} }
void mp_delete_global(qstr qstr) { void mp_delete_global(qstr qst) {
DEBUG_OP_printf("delete global %s\n", qstr_str(qstr)); DEBUG_OP_printf("delete global %s\n", qstr_str(qst));
// TODO convert KeyError to NameError if qstr not found // TODO convert KeyError to NameError if qst not found
mp_obj_dict_delete(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qstr)); mp_obj_dict_delete(MP_STATE_CTX(dict_globals), MP_OBJ_NEW_QSTR(qst));
} }
mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) { mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg) {

View File

@ -51,7 +51,7 @@ typedef union _mp_arg_val_t {
} mp_arg_val_t; } mp_arg_val_t;
typedef struct _mp_arg_t { typedef struct _mp_arg_t {
qstr qstr; qstr qst;
mp_uint_t flags; mp_uint_t flags;
mp_arg_val_t defval; mp_arg_val_t defval;
} mp_arg_t; } mp_arg_t;
@ -70,21 +70,21 @@ static inline void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_locals) =
static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_CTX(dict_globals); } static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_CTX(dict_globals); }
static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_globals) = d; } static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_globals) = d; }
mp_obj_t mp_load_name(qstr qstr); mp_obj_t mp_load_name(qstr qst);
mp_obj_t mp_load_global(qstr qstr); mp_obj_t mp_load_global(qstr qst);
mp_obj_t mp_load_build_class(void); mp_obj_t mp_load_build_class(void);
void mp_store_name(qstr qstr, mp_obj_t obj); void mp_store_name(qstr qst, mp_obj_t obj);
void mp_store_global(qstr qstr, mp_obj_t obj); void mp_store_global(qstr qst, mp_obj_t obj);
void mp_delete_name(qstr qstr); void mp_delete_name(qstr qst);
void mp_delete_global(qstr qstr); void mp_delete_global(qstr qst);
mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg); mp_obj_t mp_unary_op(mp_uint_t op, mp_obj_t arg);
mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs); mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_load_const_int(qstr qstr); mp_obj_t mp_load_const_int(qstr qst);
mp_obj_t mp_load_const_dec(qstr qstr); mp_obj_t mp_load_const_dec(qstr qst);
mp_obj_t mp_load_const_str(qstr qstr); mp_obj_t mp_load_const_str(qstr qst);
mp_obj_t mp_load_const_bytes(qstr qstr); mp_obj_t mp_load_const_bytes(qstr qst);
mp_obj_t mp_call_function_0(mp_obj_t fun); mp_obj_t mp_call_function_0(mp_obj_t fun);
mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg); mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg);

View File

@ -43,9 +43,9 @@ extern const qstr mp_binary_op_method_name[];
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0) #define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0) #define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
#define DECODE_QSTR { \ #define DECODE_QSTR { \
qstr = 0; \ qst = 0; \
do { \ do { \
qstr = (qstr << 7) + (*ip & 0x7f); \ qst = (qst << 7) + (*ip & 0x7f); \
} while ((*ip++ & 0x80) != 0); \ } while ((*ip++ & 0x80) != 0); \
} }
#define DECODE_PTR do { \ #define DECODE_PTR do { \
@ -131,7 +131,7 @@ void mp_bytecode_print(const void *descr, mp_uint_t n_total_args, const byte *ip
const byte *mp_bytecode_print_str(const byte *ip) { const byte *mp_bytecode_print_str(const byte *ip) {
mp_uint_t unum; mp_uint_t unum;
qstr qstr; qstr qst;
switch (*ip++) { switch (*ip++) {
case MP_BC_LOAD_CONST_FALSE: case MP_BC_LOAD_CONST_FALSE:
@ -165,22 +165,22 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_CONST_INT: case MP_BC_LOAD_CONST_INT:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_CONST_INT %s", qstr_str(qstr)); printf("LOAD_CONST_INT %s", qstr_str(qst));
break; break;
case MP_BC_LOAD_CONST_DEC: case MP_BC_LOAD_CONST_DEC:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_CONST_DEC %s", qstr_str(qstr)); printf("LOAD_CONST_DEC %s", qstr_str(qst));
break; break;
case MP_BC_LOAD_CONST_BYTES: case MP_BC_LOAD_CONST_BYTES:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_CONST_BYTES %s", qstr_str(qstr)); printf("LOAD_CONST_BYTES %s", qstr_str(qst));
break; break;
case MP_BC_LOAD_CONST_STRING: case MP_BC_LOAD_CONST_STRING:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_CONST_STRING '%s'", qstr_str(qstr)); printf("LOAD_CONST_STRING '%s'", qstr_str(qst));
break; break;
case MP_BC_LOAD_CONST_OBJ: case MP_BC_LOAD_CONST_OBJ:
@ -205,7 +205,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_NAME: case MP_BC_LOAD_NAME:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_NAME %s", qstr_str(qstr)); printf("LOAD_NAME %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++); printf(" (cache=%u)", *ip++);
} }
@ -213,7 +213,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_GLOBAL: case MP_BC_LOAD_GLOBAL:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_GLOBAL %s", qstr_str(qstr)); printf("LOAD_GLOBAL %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++); printf(" (cache=%u)", *ip++);
} }
@ -221,7 +221,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_ATTR: case MP_BC_LOAD_ATTR:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_ATTR %s", qstr_str(qstr)); printf("LOAD_ATTR %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++); printf(" (cache=%u)", *ip++);
} }
@ -229,7 +229,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_LOAD_METHOD: case MP_BC_LOAD_METHOD:
DECODE_QSTR; DECODE_QSTR;
printf("LOAD_METHOD %s", qstr_str(qstr)); printf("LOAD_METHOD %s", qstr_str(qst));
break; break;
case MP_BC_LOAD_BUILD_CLASS: case MP_BC_LOAD_BUILD_CLASS:
@ -252,17 +252,17 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_STORE_NAME: case MP_BC_STORE_NAME:
DECODE_QSTR; DECODE_QSTR;
printf("STORE_NAME %s", qstr_str(qstr)); printf("STORE_NAME %s", qstr_str(qst));
break; break;
case MP_BC_STORE_GLOBAL: case MP_BC_STORE_GLOBAL:
DECODE_QSTR; DECODE_QSTR;
printf("STORE_GLOBAL %s", qstr_str(qstr)); printf("STORE_GLOBAL %s", qstr_str(qst));
break; break;
case MP_BC_STORE_ATTR: case MP_BC_STORE_ATTR:
DECODE_QSTR; DECODE_QSTR;
printf("STORE_ATTR %s", qstr_str(qstr)); printf("STORE_ATTR %s", qstr_str(qst));
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
printf(" (cache=%u)", *ip++); printf(" (cache=%u)", *ip++);
} }
@ -284,7 +284,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_DELETE_NAME: case MP_BC_DELETE_NAME:
DECODE_QSTR; DECODE_QSTR;
printf("DELETE_NAME %s", qstr_str(qstr)); printf("DELETE_NAME %s", qstr_str(qst));
break; break;
case MP_BC_DUP_TOP: case MP_BC_DUP_TOP:
@ -502,12 +502,12 @@ const byte *mp_bytecode_print_str(const byte *ip) {
case MP_BC_IMPORT_NAME: case MP_BC_IMPORT_NAME:
DECODE_QSTR; DECODE_QSTR;
printf("IMPORT_NAME '%s'", qstr_str(qstr)); printf("IMPORT_NAME '%s'", qstr_str(qst));
break; break;
case MP_BC_IMPORT_FROM: case MP_BC_IMPORT_FROM:
DECODE_QSTR; DECODE_QSTR;
printf("IMPORT_FROM '%s'", qstr_str(qstr)); printf("IMPORT_FROM '%s'", qstr_str(qst));
break; break;
case MP_BC_IMPORT_STAR: case MP_BC_IMPORT_STAR:

View File

@ -240,7 +240,7 @@ STATIC mp_obj_t poll_poll(uint n_args, const mp_obj_t *args) {
if (n_ready > 0 || (timeout != -1 && HAL_GetTick() - start_tick >= timeout)) { if (n_ready > 0 || (timeout != -1 && HAL_GetTick() - start_tick >= timeout)) {
// one or more objects are ready, or we had a timeout // one or more objects are ready, or we had a timeout
mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL); mp_obj_list_t *ret_list = mp_obj_new_list(n_ready, NULL);
mp_uint_t n_ready = 0; n_ready = 0;
for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) { for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) {
if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) { if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) {
continue; continue;

View File

@ -365,7 +365,7 @@ friendly_repl_reset:
while (mp_repl_continue_with_input(vstr_str(&line))) { while (mp_repl_continue_with_input(vstr_str(&line))) {
vstr_add_char(&line, '\n'); vstr_add_char(&line, '\n');
int ret = readline(&line, "... "); ret = readline(&line, "... ");
if (ret == CHAR_CTRL_C) { if (ret == CHAR_CTRL_C) {
// cancel everything // cancel everything
stdout_tx_str("\r\n"); stdout_tx_str("\r\n");
@ -380,7 +380,7 @@ friendly_repl_reset:
if (lex == NULL) { if (lex == NULL) {
printf("MemoryError\n"); printf("MemoryError\n");
} else { } else {
int ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL); ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL);
if (ret & PYEXEC_FORCED_EXIT) { if (ret & PYEXEC_FORCED_EXIT) {
return ret; return ret;
} }

View File

@ -77,7 +77,7 @@
#include "storage.h" #include "storage.h"
extern void __fatal_error(const char*); extern void __fatal_error(const char*);
extern PCD_HandleTypeDef hpcd; extern PCD_HandleTypeDef pcd_handle;
/******************************************************************************/ /******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */ /* Cortex-M4 Processor Exceptions Handlers */
@ -205,7 +205,7 @@ void SysTick_Handler(void) {
#if defined(OTG_XX_IRQHandler) #if defined(OTG_XX_IRQHandler)
void OTG_XX_IRQHandler(void) { void OTG_XX_IRQHandler(void) {
HAL_PCD_IRQHandler(&hpcd); HAL_PCD_IRQHandler(&pcd_handle);
} }
#endif #endif
@ -217,7 +217,7 @@ void OTG_XX_IRQHandler(void) {
#if defined(OTG_XX_WKUP_IRQHandler) #if defined(OTG_XX_WKUP_IRQHandler)
void OTG_XX_WKUP_IRQHandler(void) { void OTG_XX_WKUP_IRQHandler(void) {
if ((&hpcd)->Init.low_power_enable) { if ((&pcd_handle)->Init.low_power_enable) {
/* Reset SLEEPDEEP bit of Cortex System Control Register */ /* Reset SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
@ -244,7 +244,7 @@ void OTG_XX_WKUP_IRQHandler(void) {
{} {}
/* ungate PHY clock */ /* ungate PHY clock */
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd)); __HAL_PCD_UNGATE_PHYCLOCK((&pcd_handle));
} }
#ifdef USE_USB_FS #ifdef USE_USB_FS
/* Clear EXTI pending Bit*/ /* Clear EXTI pending Bit*/

View File

@ -37,7 +37,7 @@
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
PCD_HandleTypeDef hpcd; PCD_HandleTypeDef pcd_handle;
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/
@ -331,62 +331,62 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{ {
#ifdef USE_USB_FS #ifdef USE_USB_FS
/*Set LL Driver parameters */ /*Set LL Driver parameters */
hpcd.Instance = USB_OTG_FS; pcd_handle.Instance = USB_OTG_FS;
hpcd.Init.dev_endpoints = 4; pcd_handle.Init.dev_endpoints = 4;
hpcd.Init.use_dedicated_ep1 = 0; pcd_handle.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40; pcd_handle.Init.ep0_mps = 0x40;
hpcd.Init.dma_enable = 0; pcd_handle.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0; pcd_handle.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; pcd_handle.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = 0; pcd_handle.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_FULL; pcd_handle.Init.speed = PCD_SPEED_FULL;
#if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN) #if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
hpcd.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0 pcd_handle.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
#else #else
hpcd.Init.vbus_sensing_enable = 1; pcd_handle.Init.vbus_sensing_enable = 1;
#endif #endif
/* Link The driver to the stack */ /* Link The driver to the stack */
hpcd.pData = pdev; pcd_handle.pData = pdev;
pdev->pData = &hpcd; pdev->pData = &pcd_handle;
/*Initialize LL Driver */ /*Initialize LL Driver */
HAL_PCD_Init(&hpcd); HAL_PCD_Init(&pcd_handle);
HAL_PCD_SetRxFiFo(&hpcd, 0x80); HAL_PCD_SetRxFiFo(&pcd_handle, 0x80);
HAL_PCD_SetTxFiFo(&hpcd, 0, 0x20); HAL_PCD_SetTxFiFo(&pcd_handle, 0, 0x20);
HAL_PCD_SetTxFiFo(&hpcd, 1, 0x40); HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x40);
HAL_PCD_SetTxFiFo(&hpcd, 2, 0x20); HAL_PCD_SetTxFiFo(&pcd_handle, 2, 0x20);
HAL_PCD_SetTxFiFo(&hpcd, 3, 0x40); HAL_PCD_SetTxFiFo(&pcd_handle, 3, 0x40);
#endif #endif
#ifdef USE_USB_HS #ifdef USE_USB_HS
/*Set LL Driver parameters */ /*Set LL Driver parameters */
hpcd.Instance = USB_OTG_HS; pcd_handle.Instance = USB_OTG_HS;
hpcd.Init.dev_endpoints = 6; pcd_handle.Init.dev_endpoints = 6;
hpcd.Init.use_dedicated_ep1 = 0; pcd_handle.Init.use_dedicated_ep1 = 0;
hpcd.Init.ep0_mps = 0x40; pcd_handle.Init.ep0_mps = 0x40;
/* Be aware that enabling USB-DMA mode will result in data being sent only by /* Be aware that enabling USB-DMA mode will result in data being sent only by
multiple of 4 packet sizes. This is due to the fact that USB-DMA does multiple of 4 packet sizes. This is due to the fact that USB-DMA does
not allow sending data from non word-aligned addresses. not allow sending data from non word-aligned addresses.
For this specific application, it is advised to not enable this option For this specific application, it is advised to not enable this option
unless required. */ unless required. */
hpcd.Init.dma_enable = 0; pcd_handle.Init.dma_enable = 0;
hpcd.Init.low_power_enable = 0; pcd_handle.Init.low_power_enable = 0;
hpcd.Init.phy_itface = PCD_PHY_ULPI; pcd_handle.Init.phy_itface = PCD_PHY_ULPI;
hpcd.Init.Sof_enable = 0; pcd_handle.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_HIGH; pcd_handle.Init.speed = PCD_SPEED_HIGH;
hpcd.Init.vbus_sensing_enable = 1; pcd_handle.Init.vbus_sensing_enable = 1;
/* Link The driver to the stack */ /* Link The driver to the stack */
hpcd.pData = pdev; pcd_handle.pData = pdev;
pdev->pData = &hpcd; pdev->pData = &pcd_handle;
/*Initialize LL Driver */ /*Initialize LL Driver */
HAL_PCD_Init(&hpcd); HAL_PCD_Init(&pcd_handle);
HAL_PCD_SetRxFiFo(&hpcd, 0x200); HAL_PCD_SetRxFiFo(&pcd_handle, 0x200);
HAL_PCD_SetTxFiFo(&hpcd, 0, 0x80); HAL_PCD_SetTxFiFo(&pcd_handle, 0, 0x80);
HAL_PCD_SetTxFiFo(&hpcd, 1, 0x174); HAL_PCD_SetTxFiFo(&pcd_handle, 1, 0x174);
#endif #endif

View File

@ -354,6 +354,7 @@ int main(int argc, char **argv) {
mp_obj_t *path_items; mp_obj_t *path_items;
mp_obj_list_get(mp_sys_path, &path_num, &path_items); mp_obj_list_get(mp_sys_path, &path_num, &path_items);
path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_);
{
char *p = path; char *p = path;
for (mp_uint_t i = 1; i < path_num; i++) { for (mp_uint_t i = 1; i < path_num; i++) {
char *p1 = strchr(p, PATHLIST_SEP_CHAR); char *p1 = strchr(p, PATHLIST_SEP_CHAR);
@ -371,6 +372,7 @@ int main(int argc, char **argv) {
} }
p = p1 + 1; p = p1 + 1;
} }
}
mp_obj_list_init(mp_sys_argv, 0); mp_obj_list_init(mp_sys_argv, 0);