summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-29 02:49:07 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-29 04:35:23 +0200
commit4fff26a35cf88765efc1ca0595fa2b26eff4fc84 (patch)
tree4d9a70cfa3b3c6b3aa4cd0b60368292861727550
parentc47fd2da8ec705a3c6f51d1a09b7bf4a180a01ff (diff)
downloadmicropython-4fff26a35cf88765efc1ca0595fa2b26eff4fc84.tar.gz
micropython-4fff26a35cf88765efc1ca0595fa2b26eff4fc84.zip
vm: Factor out exception block setup to a macro.
Will be reused in WITH bytecodes.
-rw-r--r--py/vm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/py/vm.c b/py/vm.c
index f939a7fdfd..710fd12535 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -44,6 +44,14 @@ typedef enum {
#define TOP() (*sp)
#define SET_TOP(val) *sp = (val)
+#define SETUP_BLOCK() \
+ DECODE_ULABEL; /* except labels are always forward */ \
+ ++exc_sp; \
+ exc_sp->opcode = op; \
+ exc_sp->handler = ip + unum; \
+ exc_sp->val_sp = MP_TAGPTR_MAKE(sp, currently_in_except_block); \
+ currently_in_except_block = 0; /* in a try block now */
+
mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret) {
const byte *ip = code;
@@ -398,12 +406,7 @@ unwind_jump:
// matched against: POP_BLOCK or POP_EXCEPT (anything else?)
case MP_BC_SETUP_EXCEPT:
case MP_BC_SETUP_FINALLY:
- DECODE_ULABEL; // except labels are always forward
- ++exc_sp;
- exc_sp->opcode = op;
- exc_sp->handler = ip + unum;
- exc_sp->val_sp = MP_TAGPTR_MAKE(sp, currently_in_except_block);
- currently_in_except_block = 0; // in a try block now
+ SETUP_BLOCK();
break;
case MP_BC_END_FINALLY: