diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-29 18:58:52 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-29 18:58:52 +0000 |
commit | 08d075592f3fa958ac3f24e176bee5ab56e78f49 (patch) | |
tree | 6b09520f0cabc7330dda34bd2da8c17bff3d8b79 /py/compile.c | |
parent | 1ba1facaaa112c02fd3dcc1bfcb8e228787629ed (diff) |
py: Fix bug with LOAD_METHOD; fix int->machine_int_t for small int.
LOAD_METHOD bug was: emitbc did not correctly calculate the amount of
stack usage for a LOAD_METHOD operation.
small int bug was: int was being used to pass small ints, when it should
have been machine_int_t.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/compile.c b/py/compile.c index ebd2abb5c..c1a7955dc 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2501,7 +2501,7 @@ void compile_node(compiler_t *comp, mp_parse_node_t pn) { if (MP_PARSE_NODE_IS_NULL(pn)) { // pass } else if (MP_PARSE_NODE_IS_LEAF(pn)) { - int arg = MP_PARSE_NODE_LEAF_ARG(pn); + machine_int_t arg = MP_PARSE_NODE_LEAF_ARG(pn); switch (MP_PARSE_NODE_LEAF_KIND(pn)) { case MP_PARSE_NODE_ID: EMIT_ARG(load_id, arg); break; case MP_PARSE_NODE_SMALL_INT: EMIT_ARG(load_const_small_int, arg); break; @@ -3030,7 +3030,8 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) { scope->flags |= SCOPE_FLAG_OPTIMISED; // TODO possibly other ways it can be nested - if (scope->parent->kind == SCOPE_FUNCTION || (scope->parent->kind == SCOPE_CLASS && scope->parent->parent->kind == SCOPE_FUNCTION)) { + // Note that we don't actually use this information at the moment (for CPython compat only) + if ((SCOPE_FUNCTION <= scope->parent->kind && scope->parent->kind <= SCOPE_SET_COMP) || (scope->parent->kind == SCOPE_CLASS && scope->parent->parent->kind == SCOPE_FUNCTION)) { scope->flags |= SCOPE_FLAG_NESTED; } } |