summaryrefslogtreecommitdiffstatshomepage
path: root/py/vm.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-11 13:38:30 +0000
committerDamien George <damien.p.george@gmail.com>2014-04-11 13:38:30 +0000
commit69b89d21b2dcbe61c9abe1744cc0ec77d89422de (patch)
treebb467f417445eef1af49054d2a5363044380505b /py/vm.c
parent0e3329a6b82873531f63fb1358f57852723fad05 (diff)
downloadmicropython-69b89d21b2dcbe61c9abe1744cc0ec77d89422de.tar.gz
micropython-69b89d21b2dcbe61c9abe1744cc0ec77d89422de.zip
py: Change compile order for default positional and keyword args.
This simplifies the compiler a little, since now it can do 1 pass over a function declaration, to determine default arguments. I would have done this originally, but CPython 3.3 somehow had the default keyword args compiled before the default position args (even though they appear in the other order in the text of the script), and I thought it was important to have the same order of execution when evaluating default arguments. CPython 3.4 has changed the order to the more obvious one, so we can also change.
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/vm.c b/py/vm.c
index 47d6bf8f59..1ea0c5eaa1 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -718,9 +718,9 @@ unwind_jump:
case MP_BC_MAKE_FUNCTION_DEFARGS:
DECODE_UINT;
- // Stack layout: def_dict def_tuple <- TOS
+ // Stack layout: def_tuple def_dict <- TOS
obj1 = POP();
- SET_TOP(mp_make_function_from_id(unum, obj1, TOP()));
+ SET_TOP(mp_make_function_from_id(unum, TOP(), obj1));
break;
case MP_BC_MAKE_CLOSURE:
@@ -731,10 +731,10 @@ unwind_jump:
case MP_BC_MAKE_CLOSURE_DEFARGS:
DECODE_UINT;
- // Stack layout: def_dict def_tuple closure_tuple <- TOS
+ // Stack layout: def_tuple def_dict closure_tuple <- TOS
obj1 = POP();
obj2 = POP();
- SET_TOP(mp_make_closure_from_id(unum, obj1, obj2, TOP()));
+ SET_TOP(mp_make_closure_from_id(unum, obj1, TOP(), obj2));
break;
case MP_BC_CALL_FUNCTION: