Skip to content

Commit a1567be

Browse files
matzclaude
andcommitted
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>
1 parent 60d981d commit a1567be

6 files changed

Lines changed: 30 additions & 26 deletions

File tree

include/mruby/opcode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ enum mrb_insn {
1313
#undef OPCODE
1414
};
1515

16+
/* backward compatibility aliases */
17+
#define OP_LOADT OP_LOADTRUE
18+
#define OP_LOADF OP_LOADFALSE
19+
1620
#define OP_L_STRICT 1
1721
#define OP_L_CAPTURE 2
1822
#define OP_L_METHOD OP_L_STRICT

include/mruby/ops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */
3131
OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */
3232
OPCODE(LOADNIL, B) /* R[a] = nil */
3333
OPCODE(LOADSELF, B) /* R[a] = self */
34-
OPCODE(LOADT, B) /* R[a] = true */
35-
OPCODE(LOADF, B) /* R[a] = false */
34+
OPCODE(LOADTRUE, B) /* R[a] = true */
35+
OPCODE(LOADFALSE, B) /* R[a] = false */
3636
OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */
3737
OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */
3838
OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */

mrbgems/mruby-compiler/core/codegen.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val)
841841
}
842842
break;
843843
case OP_LOADNIL:
844-
case OP_LOADF:
844+
case OP_LOADFALSE:
845845
if (data.a == a || data.a > s->nlocals) {
846846
s->pc = addr_pc(s, data.addr);
847847
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)
852852
}
853853
}
854854
break;
855-
case OP_LOADT: case OP_LOADI8: case OP_LOADINEG: case OP_LOADI__1:
855+
case OP_LOADTRUE: case OP_LOADI8: case OP_LOADINEG: case OP_LOADI__1:
856856
case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3:
857857
case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7:
858858
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)
937937
return;
938938
}
939939
break;
940-
case OP_LOADNIL: case OP_LOADSELF: case OP_LOADT: case OP_LOADF:
940+
case OP_LOADNIL: case OP_LOADSELF: case OP_LOADTRUE: case OP_LOADFALSE:
941941
case OP_LOADI__1:
942942
case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3:
943943
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)
27332733
genop_1(s, OP_LOADNIL, reg);
27342734
break;
27352735
case NODE_TRUE:
2736-
genop_1(s, OP_LOADT, reg);
2736+
genop_1(s, OP_LOADTRUE, reg);
27372737
break;
27382738
case NODE_FALSE:
2739-
genop_1(s, OP_LOADF, reg);
2739+
genop_1(s, OP_LOADFALSE, reg);
27402740
break;
27412741
default:
27422742
break;
@@ -5409,7 +5409,7 @@ codegen_op_asgn(codegen_scope *s, node *varnode, int val)
54095409
lp->type = LOOP_RESCUE;
54105410
catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc);
54115411
genop_1(s, OP_EXCEPT, exc);
5412-
genop_1(s, OP_LOADF, exc);
5412+
genop_1(s, OP_LOADFALSE, exc);
54135413
dispatch(s, noexc);
54145414
loop_pop(s, NOVAL);
54155415
}
@@ -5728,15 +5728,15 @@ codegen_nil(codegen_scope *s, node *varnode, int val)
57285728
static void
57295729
codegen_true(codegen_scope *s, node *varnode, int val)
57305730
{
5731-
/* Generate OP_LOADT instruction for true literal */
5732-
gen_load_op1(s, OP_LOADT, val);
5731+
/* Generate OP_LOADTRUE instruction for true literal */
5732+
gen_load_op1(s, OP_LOADTRUE, val);
57335733
}
57345734

57355735
static void
57365736
codegen_false(codegen_scope *s, node *varnode, int val)
57375737
{
5738-
/* Generate OP_LOADF instruction for false literal */
5739-
gen_load_op1(s, OP_LOADF, val);
5738+
/* Generate OP_LOADFALSE instruction for false literal */
5739+
gen_load_op1(s, OP_LOADFALSE, val);
57405740
}
57415741

57425742
static void
@@ -6579,7 +6579,7 @@ codegen(codegen_scope *s, node *tree, int val)
65796579
gen_load_nil(s, 1);
65806580
}
65816581
else {
6582-
genop_1(s, OP_LOADT, cursp());
6582+
genop_1(s, OP_LOADTRUE, cursp());
65836583
push();
65846584
}
65856585
}
@@ -6625,7 +6625,7 @@ codegen(codegen_scope *s, node *tree, int val)
66256625
gen_load_nil(s, 1); /* '=>' pattern returns nil */
66266626
}
66276627
else {
6628-
genop_1(s, OP_LOADT, cursp()); /* 'in' pattern returns true */
6628+
genop_1(s, OP_LOADTRUE, cursp()); /* 'in' pattern returns true */
66296629
push();
66306630
}
66316631
}
@@ -6664,7 +6664,7 @@ codegen(codegen_scope *s, node *tree, int val)
66646664
gen_load_nil(s, 1);
66656665
}
66666666
else {
6667-
genop_1(s, OP_LOADT, cursp());
6667+
genop_1(s, OP_LOADTRUE, cursp());
66686668
push();
66696669
}
66706670
}
@@ -6701,13 +6701,13 @@ codegen(codegen_scope *s, node *tree, int val)
67016701
pop(); /* pop the value */
67026702
if (mp->raise_on_fail) {
67036703
/* expr => pattern: raise NoMatchingPatternError */
6704-
genop_1(s, OP_LOADF, cursp()); /* Load false for MATCHERR */
6704+
genop_1(s, OP_LOADFALSE, cursp()); /* Load false for MATCHERR */
67056705
genop_1(s, OP_MATCHERR, cursp());
67066706
}
67076707
else {
67086708
/* expr in pattern: return false */
67096709
if (val) {
6710-
genop_1(s, OP_LOADF, cursp());
6710+
genop_1(s, OP_LOADFALSE, cursp());
67116711
push();
67126712
}
67136713
}
@@ -6726,7 +6726,7 @@ codegen(codegen_scope *s, node *tree, int val)
67266726
gen_load_nil(s, 1); /* '=>' pattern returns nil */
67276727
}
67286728
else {
6729-
genop_1(s, OP_LOADT, cursp()); /* 'in' pattern returns true */
6729+
genop_1(s, OP_LOADTRUE, cursp()); /* 'in' pattern returns true */
67306730
push();
67316731
}
67326732
}

src/class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,9 +4224,9 @@ static const mrb_code neq_iseq[] = {
42244224
OP_ENTER, 0x4, 0, 0, // 000 OP_ENTER 1:0:0:0:0:0:0
42254225
OP_EQ, 0, // 004 OP_EQ R0 (R1)
42264226
OP_JMPNOT, 0, 0, 5, // 006 OP_JMPNOT R0 015
4227-
OP_LOADF, 0, // 010 OP_LOADF R0 (false)
4227+
OP_LOADFALSE, 0, // 010 OP_LOADFALSE R0 (false)
42284228
OP_JMP, 0, 2, // 012 OP_JMP 017
4229-
OP_LOADT, 0, // 015 OP_LOADT R0 (true)
4229+
OP_LOADTRUE, 0, // 015 OP_LOADTRUE R0 (true)
42304230
OP_RETURN, 0 // 017 OP_RETURN R0
42314231
};
42324232

src/codedump.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep, FILE *out)
236236
fprintf(out, "LOADSELF\tR%d\t(R0)", a);
237237
print_lv_a(mrb, irep, a, out);
238238
break;
239-
CASE(OP_LOADT, B):
240-
fprintf(out, "LOADT\t\tR%d\t(true)", a);
239+
CASE(OP_LOADTRUE, B):
240+
fprintf(out, "LOADTRUE\tR%d\t(true)", a);
241241
print_lv_a(mrb, irep, a, out);
242242
break;
243-
CASE(OP_LOADF, B):
244-
fprintf(out, "LOADF\t\tR%d\t(false)", a);
243+
CASE(OP_LOADFALSE, B):
244+
fprintf(out, "LOADFALSE\tR%d\t(false)", a);
245245
print_lv_a(mrb, irep, a, out);
246246
break;
247247
CASE(OP_GETGV, BB):

src/vm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,12 +1815,12 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *begin_proc, const mrb_code *iseq
18151815
NEXT;
18161816
}
18171817

1818-
CASE(OP_LOADT, B) {
1818+
CASE(OP_LOADTRUE, B) {
18191819
SET_TRUE_VALUE(regs[a]);
18201820
NEXT;
18211821
}
18221822

1823-
CASE(OP_LOADF, B) {
1823+
CASE(OP_LOADFALSE, B) {
18241824
SET_FALSE_VALUE(regs[a]);
18251825
NEXT;
18261826
}

0 commit comments

Comments
 (0)