py: Simplify stack get/set to become stack adjust in emitters.
Can do this now that the stack size calculation is improved.
diff --git a/py/compile.c b/py/compile.c
index ebc144b..ca3ee9d 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -1595,7 +1595,7 @@
EMIT_ARG(label_assign, top_label);
// at this point we actually have 1 less element on the stack
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) - 1);
+ EMIT_ARG(adjust_stack_size, -1);
// store next value to var
c_assign(comp, pn_var, ASSIGN_STORE);
@@ -1728,7 +1728,7 @@
EMIT_ARG(jump, success_label); // jump over exception handler
EMIT_ARG(label_assign, l1); // start of exception handler
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) + 6); // stack adjust for the 3 exception items, +3 for possible UNWIND_JUMP state
+ EMIT_ARG(adjust_stack_size, 6); // stack adjust for the 3 exception items, +3 for possible UNWIND_JUMP state
uint l2 = comp_next_label(comp);
@@ -1795,12 +1795,12 @@
}
EMIT_ARG(jump, l2);
EMIT_ARG(label_assign, end_finally_label);
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) + 3); // stack adjust for the 3 exception items
+ EMIT_ARG(adjust_stack_size, 3); // stack adjust for the 3 exception items
}
compile_decrease_except_level(comp);
EMIT(end_finally);
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) - 5); // stack adjust
+ EMIT_ARG(adjust_stack_size, -5); // stack adjust
EMIT_ARG(label_assign, success_label);
compile_node(comp, pn_else); // else block, can be null
@@ -1815,9 +1815,9 @@
if (n_except == 0) {
assert(MP_PARSE_NODE_IS_NULL(pn_else));
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) + 3); // stack adjust for possible UNWIND_JUMP state
+ EMIT_ARG(adjust_stack_size, 3); // stack adjust for possible UNWIND_JUMP state
compile_node(comp, pn_body);
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) - 3);
+ EMIT_ARG(adjust_stack_size, -3);
} else {
compile_try_except(comp, pn_body, n_except, pn_except, pn_else);
}
@@ -2027,7 +2027,7 @@
compile_node(comp, pns->nodes[0]); // success value
EMIT_ARG(jump, l_end);
EMIT_ARG(label_assign, l_fail);
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) - 1); // adjust stack size
+ EMIT_ARG(adjust_stack_size, -1); // adjust stack size
compile_node(comp, pns_test_if_else->nodes[1]); // failure value
EMIT_ARG(label_assign, l_end);
}
@@ -2134,7 +2134,7 @@
uint l_end = comp_next_label(comp);
EMIT_ARG(jump, l_end);
EMIT_ARG(label_assign, l_fail);
- EMIT_ARG(set_stack_size, EMIT(get_stack_size) + 1);
+ EMIT_ARG(adjust_stack_size, 1);
EMIT(rot_two);
EMIT(pop_top);
EMIT_ARG(label_assign, l_end);