mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
ops.h: rename OP_LOADT/OP_LOADF to OP_LOADTRUE/OP_LOADFALSE
Rename boolean load opcodes for consistency with LOADNIL/LOADSELF. Backward compatibility aliases are provided in opcode.h. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
+2
-2
@@ -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]] */
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
};
|
||||
|
||||
|
||||
+4
-4
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user