diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-09 15:26:46 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-09 15:26:46 +0100 |
commit | 2bf7c092225645d8c5b15e536afdce39e3593e42 (patch) | |
tree | e257514a3008411367ea5e62eaea4b101ccac257 /py/compile.c | |
parent | 11d8cd54c992eee55f27d3779738626bdc095c03 (diff) |
py: Properly implement deletion of locals and derefs, and detect errors.
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c index 49dddb0bd..3ea6dd3a6 100644 --- a/py/compile.c +++ b/py/compile.c @@ -797,7 +797,7 @@ void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_d EMIT_ARG(load_closure, id->qstr, id->local_num); #else // in Micro Python we load closures using LOAD_FAST - EMIT_ARG(load_fast, id->qstr, id->local_num); + EMIT_ARG(load_fast, id->qstr, id->flags, id->local_num); #endif nfree += 1; } @@ -2208,8 +2208,8 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar // get first argument to function bool found = false; for (int i = 0; i < comp->scope_cur->id_info_len; i++) { - if (comp->scope_cur->id_info[i].flags && ID_FLAG_IS_PARAM) { - EMIT_ARG(load_fast, MP_QSTR_, comp->scope_cur->id_info[i].local_num); + if (comp->scope_cur->id_info[i].flags & ID_FLAG_IS_PARAM) { + EMIT_ARG(load_fast, MP_QSTR_, comp->scope_cur->id_info[i].flags, comp->scope_cur->id_info[i].local_num); found = true; break; } @@ -2990,7 +2990,7 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { #if MICROPY_EMIT_CPYTHON EMIT_ARG(load_closure, MP_QSTR___class__, 0); // XXX check this is the correct local num #else - EMIT_ARG(load_fast, MP_QSTR___class__, id->local_num); + EMIT_ARG(load_fast, MP_QSTR___class__, id->flags, id->local_num); #endif } EMIT(return_value); @@ -3154,7 +3154,7 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) { if (num_free > 0) { for (int i = 0; i < scope->id_info_len; i++) { id_info_t *id = &scope->id_info[i]; - if (id->kind != ID_INFO_KIND_FREE || (id->flags && ID_FLAG_IS_PARAM)) { + if (id->kind != ID_INFO_KIND_FREE || (id->flags & ID_FLAG_IS_PARAM)) { id->local_num += num_free; } } |