kopia lustrzana https://github.com/micropython/micropython
py/emitnative: Consolidate where HASCONSTS is set to load-const-obj fun.
Simplifies the code and fixes handling of the Ellipsis const in native code generation (which also needs the constant table so must set this flag).pull/4535/head
rodzic
02cc288edb
commit
01a1f31f67
|
@ -2693,9 +2693,6 @@ STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
|
|||
}
|
||||
|
||||
STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
|
||||
#endif
|
||||
EMIT_ARG(load_const_obj, get_const_object(pns));
|
||||
}
|
||||
|
||||
|
@ -2730,9 +2727,6 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
|
|||
} else {
|
||||
EMIT_ARG(load_const_obj, mp_obj_new_int_from_ll(arg));
|
||||
}
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
EMIT_ARG(load_const_small_int, arg);
|
||||
|
@ -2751,9 +2745,6 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
|
|||
const byte *data = qstr_data(arg, &len);
|
||||
EMIT_ARG(load_const_obj, mp_obj_new_bytes(data, len));
|
||||
}
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
|
||||
#endif
|
||||
break;
|
||||
case MP_PARSE_NODE_TOKEN: default:
|
||||
if (arg == MP_TOKEN_NEWLINE) {
|
||||
|
|
|
@ -1250,6 +1250,7 @@ STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
|
|||
}
|
||||
|
||||
STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
|
||||
emit->scope->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
|
||||
emit_native_pre(emit);
|
||||
need_reg_single(emit, REG_RET, 0);
|
||||
emit_load_reg_with_object(emit, REG_RET, obj);
|
||||
|
|
Ładowanie…
Reference in New Issue