diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-02 15:56:31 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-02 15:56:31 +0100 |
commit | 882b363564b64204c12726d5d2cd7f596322729f (patch) | |
tree | c6f15da0c4cbbaa9413692685a0d6fa0c96f3079 /py/compile.c | |
parent | 929a675a3d2d37fb8c6acbec1b999b9bdd84ff23 (diff) | |
download | micropython-882b363564b64204c12726d5d2cd7f596322729f.tar.gz micropython-882b363564b64204c12726d5d2cd7f596322729f.zip |
py: Move to Python 3.4.0 compatibility.
Very little has changed. In Python 3.4 they removed the opcode
STORE_LOCALS, but in Micro Python we only ever used this for CPython
compatibility, so it was a trivial thing to remove. It also allowed to
clean up some dead code (eg the 0xdeadbeef in class construction), and
now class builders use 1 less stack word.
Python 3.4.0 introduced the LOAD_CLASSDEREF opcode, which I have not
yet understood. Still, all tests (apart from bytecode test) still pass.
Bytecode tests needs some more attention, but they are not that
important anymore.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/py/compile.c b/py/compile.c index 25830eb6f9..a27561334a 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2957,15 +2957,8 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { id_info_t *id_info = scope_find_or_add_id(scope, MP_QSTR___class__, &added); assert(added); id_info->kind = ID_INFO_KIND_LOCAL; - id_info = scope_find_or_add_id(scope, MP_QSTR___locals__, &added); - assert(added); - id_info->kind = ID_INFO_KIND_LOCAL; - id_info->param = true; - scope->num_params = 1; // __locals__ is the parameter } - EMIT_ARG(load_id, MP_QSTR___locals__); - EMIT(store_locals); EMIT_ARG(load_id, MP_QSTR___name__); EMIT_ARG(store_id, MP_QSTR___module__); EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name @@ -3155,8 +3148,10 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) { } // compute scope_flags - //scope->scope_flags = 0; since we set some things in parameters - if (scope->kind != SCOPE_MODULE) { + +#if MICROPY_EMIT_CPYTHON + // these flags computed here are for CPython compatibility only + if (scope->kind == SCOPE_FUNCTION) { scope->scope_flags |= MP_SCOPE_FLAG_NEWLOCALS; } if (scope->kind == SCOPE_FUNCTION || scope->kind == SCOPE_LAMBDA || scope->kind == SCOPE_LIST_COMP || scope->kind == SCOPE_DICT_COMP || scope->kind == SCOPE_SET_COMP || scope->kind == SCOPE_GEN_EXPR) { @@ -3169,6 +3164,8 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) { scope->scope_flags |= MP_SCOPE_FLAG_NESTED; } } +#endif + int num_free = 0; for (int i = 0; i < scope->id_info_len; i++) { id_info_t *id = &scope->id_info[i]; |