Commits

Anonymous committed 16e1ea1

Fixed a bug in the compiler that caused TMPOP to break. The pointer returned was invalidated on opcode list resizing.

  • Participants
  • Parent commits f6ef704

Comments (0)

Files changed (1)

File arana/compile.c

 
 #define OP1(x) arana_compiler_add_op(COMPILER_ISIG, AR_OP_##x, 0)
 #define OP2(x, y) arana_compiler_add_op(COMPILER_ISIG, AR_OP_##x, y)
-#define SETOP1(o, x) (o->op = AR_OP_##x)
-#define SETOP2(o, x, y) (SETOP1(o, x), o->arg = y)
+#define SETOP1(i, x) (compiler->unit->ops[i].op = AR_OP_##x)
+#define SETOP2(i, x, y) (SETOP1(i, x), compiler->unit->ops[i].arg = y)
 #define CONST(v) arana_compiler_register_constant(COMPILER_ISIG, v)
 #define NEXTINSTR compiler->unit->op_count
 #define CURINSTR (NEXTINSTR - 1)
 #define LOCAL(name) arana_compiler_register_local(COMPILER_ISIG, name)
 #define MAKEJUMP(t, o, p) SETOP2(o, t, p)
-#define TMPOP() (                               \
-            OP1(UNSET),                         \
-            &compiler->unit->ops[CURINSTR]      \
-        )
+#define TMPOP() (OP1(UNSET), CURINSTR)
 
 static void arana_compiler_visit(COMPILER_SIG, ArAstNode *node);
 
 static void
 arana_compile_if_stmt(COMPILER_SIG, ArStmtNode *node)
 {
-    ArOp *jump1, *jump2;
+    Ar_size_t jump1, jump2;
     VISIT(node->v.If.test);
     jump1 = TMPOP();
     OP1(POP_TOP);
 static void
 arana_compile_for_stmt(COMPILER_SIG, ArStmtNode *node)
 {
-    Ar_size_t next_pos;
-    ArOp *next_jump, *iter_jump;
+    Ar_size_t next_pos, next_jump, iter_jump;
     VISIT(node->v.For.seq);
     iter_jump = TMPOP();
     OP1(GET_ITERATOR);