summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-01 20:08:18 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-01 20:08:18 +0000
commitcbddb279bba5395ad444cb46d78223c8f9064c56 (patch)
tree773644ba542ebb307d036526cdae4f5086e65633 /py/emitbc.c
parenta908202d60e15d37b47fb32b414658237119cd60 (diff)
downloadmicropython-cbddb279bba5395ad444cb46d78223c8f9064c56.tar.gz
micropython-cbddb279bba5395ad444cb46d78223c8f9064c56.zip
py: Implement break/continue from an exception with finally.
Still todo: break/continue from within the finally block itself.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 117a08cda5..a76e593363 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -540,14 +540,14 @@ static void emit_bc_setup_loop(emit_t *emit, int label) {
emit_write_byte_code_byte_unsigned_label(emit, MP_BC_SETUP_LOOP, label);
}
-static void emit_bc_break_loop(emit_t *emit, int label) {
- emit_pre(emit, 0);
- emit_write_byte_code_byte_unsigned_label(emit, MP_BC_BREAK_LOOP, label);
-}
-
-static void emit_bc_continue_loop(emit_t *emit, int label) {
- emit_pre(emit, 0);
- emit_write_byte_code_byte_unsigned_label(emit, MP_BC_CONTINUE_LOOP, label);
+static void emit_bc_unwind_jump(emit_t *emit, int label, int except_depth) {
+ if (except_depth == 0) {
+ emit_bc_jump(emit, label);
+ } else {
+ emit_pre(emit, 0);
+ emit_write_byte_code_byte_signed_label(emit, MP_BC_UNWIND_JUMP, label);
+ emit_write_byte_code_byte(emit, except_depth);
+ }
}
static void emit_bc_setup_with(emit_t *emit, int label) {
@@ -828,8 +828,8 @@ const emit_method_table_t emit_bc_method_table = {
emit_bc_jump_if_true_or_pop,
emit_bc_jump_if_false_or_pop,
emit_bc_setup_loop,
- emit_bc_break_loop,
- emit_bc_continue_loop,
+ emit_bc_unwind_jump,
+ emit_bc_unwind_jump,
emit_bc_setup_with,
emit_bc_with_cleanup,
emit_bc_setup_except,