diff --git a/include/mruby/opcode.h b/include/mruby/opcode.h index a0f6644cb..0a954d96b 100644 --- a/include/mruby/opcode.h +++ b/include/mruby/opcode.h @@ -13,6 +13,10 @@ enum mrb_insn { #undef OPCODE }; +/* backward compatibility aliases */ +#define OP_LOADT OP_LOADTRUE +#define OP_LOADF OP_LOADFALSE + #define OP_L_STRICT 1 #define OP_L_CAPTURE 2 #define OP_L_METHOD OP_L_STRICT diff --git a/include/mruby/ops.h b/include/mruby/ops.h index 60ff1266d..187962c14 100644 --- a/include/mruby/ops.h +++ b/include/mruby/ops.h @@ -31,8 +31,8 @@ OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */ OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */ OPCODE(LOADNIL, B) /* R[a] = nil */ OPCODE(LOADSELF, B) /* R[a] = self */ -OPCODE(LOADT, B) /* R[a] = true */ -OPCODE(LOADF, B) /* R[a] = false */ +OPCODE(LOADTRUE, B) /* R[a] = true */ +OPCODE(LOADFALSE, B) /* R[a] = false */ OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */ OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */ OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */ diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 8b2d27a59..65718c429 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -841,7 +841,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val) } break; case OP_LOADNIL: - case OP_LOADF: + case OP_LOADFALSE: if (data.a == a || data.a > s->nlocals) { s->pc = addr_pc(s, data.addr); if (i == OP_JMPNOT || (i == OP_JMPNIL && data.insn == OP_LOADNIL)) { @@ -852,7 +852,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val) } } break; - case OP_LOADT: case OP_LOADI8: case OP_LOADINEG: case OP_LOADI__1: + case OP_LOADTRUE: case OP_LOADI8: case OP_LOADINEG: case OP_LOADI__1: case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3: case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7: if (data.a == a || data.a > s->nlocals) { @@ -937,7 +937,7 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) return; } break; - case OP_LOADNIL: case OP_LOADSELF: case OP_LOADT: case OP_LOADF: + case OP_LOADNIL: case OP_LOADSELF: case OP_LOADTRUE: case OP_LOADFALSE: case OP_LOADI__1: case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3: case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7: @@ -2733,10 +2733,10 @@ gen_literal_to_reg(codegen_scope *s, node *n, int reg) genop_1(s, OP_LOADNIL, reg); break; case NODE_TRUE: - genop_1(s, OP_LOADT, reg); + genop_1(s, OP_LOADTRUE, reg); break; case NODE_FALSE: - genop_1(s, OP_LOADF, reg); + genop_1(s, OP_LOADFALSE, reg); break; default: break; @@ -5409,7 +5409,7 @@ codegen_op_asgn(codegen_scope *s, node *varnode, int val) lp->type = LOOP_RESCUE; catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc); genop_1(s, OP_EXCEPT, exc); - genop_1(s, OP_LOADF, exc); + genop_1(s, OP_LOADFALSE, exc); dispatch(s, noexc); loop_pop(s, NOVAL); } @@ -5728,15 +5728,15 @@ codegen_nil(codegen_scope *s, node *varnode, int val) static void codegen_true(codegen_scope *s, node *varnode, int val) { - /* Generate OP_LOADT instruction for true literal */ - gen_load_op1(s, OP_LOADT, val); + /* Generate OP_LOADTRUE instruction for true literal */ + gen_load_op1(s, OP_LOADTRUE, val); } static void codegen_false(codegen_scope *s, node *varnode, int val) { - /* Generate OP_LOADF instruction for false literal */ - gen_load_op1(s, OP_LOADF, val); + /* Generate OP_LOADFALSE instruction for false literal */ + gen_load_op1(s, OP_LOADFALSE, val); } static void @@ -6579,7 +6579,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_load_nil(s, 1); } else { - genop_1(s, OP_LOADT, cursp()); + genop_1(s, OP_LOADTRUE, cursp()); push(); } } @@ -6625,7 +6625,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_load_nil(s, 1); /* '=>' pattern returns nil */ } else { - genop_1(s, OP_LOADT, cursp()); /* 'in' pattern returns true */ + genop_1(s, OP_LOADTRUE, cursp()); /* 'in' pattern returns true */ push(); } } @@ -6664,7 +6664,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_load_nil(s, 1); } else { - genop_1(s, OP_LOADT, cursp()); + genop_1(s, OP_LOADTRUE, cursp()); push(); } } @@ -6701,13 +6701,13 @@ codegen(codegen_scope *s, node *tree, int val) pop(); /* pop the value */ if (mp->raise_on_fail) { /* expr => pattern: raise NoMatchingPatternError */ - genop_1(s, OP_LOADF, cursp()); /* Load false for MATCHERR */ + genop_1(s, OP_LOADFALSE, cursp()); /* Load false for MATCHERR */ genop_1(s, OP_MATCHERR, cursp()); } else { /* expr in pattern: return false */ if (val) { - genop_1(s, OP_LOADF, cursp()); + genop_1(s, OP_LOADFALSE, cursp()); push(); } } @@ -6726,7 +6726,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_load_nil(s, 1); /* '=>' pattern returns nil */ } else { - genop_1(s, OP_LOADT, cursp()); /* 'in' pattern returns true */ + genop_1(s, OP_LOADTRUE, cursp()); /* 'in' pattern returns true */ push(); } } diff --git a/src/class.c b/src/class.c index 2b51fdc7b..46695e1b2 100644 --- a/src/class.c +++ b/src/class.c @@ -4224,9 +4224,9 @@ static const mrb_code neq_iseq[] = { OP_ENTER, 0x4, 0, 0, // 000 OP_ENTER 1:0:0:0:0:0:0 OP_EQ, 0, // 004 OP_EQ R0 (R1) OP_JMPNOT, 0, 0, 5, // 006 OP_JMPNOT R0 015 - OP_LOADF, 0, // 010 OP_LOADF R0 (false) + OP_LOADFALSE, 0, // 010 OP_LOADFALSE R0 (false) OP_JMP, 0, 2, // 012 OP_JMP 017 - OP_LOADT, 0, // 015 OP_LOADT R0 (true) + OP_LOADTRUE, 0, // 015 OP_LOADTRUE R0 (true) OP_RETURN, 0 // 017 OP_RETURN R0 }; diff --git a/src/codedump.c b/src/codedump.c index d5c882529..2444b6b43 100644 --- a/src/codedump.c +++ b/src/codedump.c @@ -236,12 +236,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep, FILE *out) fprintf(out, "LOADSELF\tR%d\t(R0)", a); print_lv_a(mrb, irep, a, out); break; - CASE(OP_LOADT, B): - fprintf(out, "LOADT\t\tR%d\t(true)", a); + CASE(OP_LOADTRUE, B): + fprintf(out, "LOADTRUE\tR%d\t(true)", a); print_lv_a(mrb, irep, a, out); break; - CASE(OP_LOADF, B): - fprintf(out, "LOADF\t\tR%d\t(false)", a); + CASE(OP_LOADFALSE, B): + fprintf(out, "LOADFALSE\tR%d\t(false)", a); print_lv_a(mrb, irep, a, out); break; CASE(OP_GETGV, BB): diff --git a/src/vm.c b/src/vm.c index bce231f74..eac9d021d 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1815,12 +1815,12 @@ RETRY_TRY_BLOCK: NEXT; } - CASE(OP_LOADT, B) { + CASE(OP_LOADTRUE, B) { SET_TRUE_VALUE(regs[a]); NEXT; } - CASE(OP_LOADF, B) { + CASE(OP_LOADFALSE, B) { SET_FALSE_VALUE(regs[a]); NEXT; }