mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm.c: OP_DEF to push a symbol to a register.
The code generator no longer need to emit `OP_LOADSYM` after `OP_DEF`. `doc/opcode.md` is also updated.
This commit is contained in:
+1
-1
@@ -117,7 +117,7 @@ sign) of operands.
|
||||
| `OP_CLASS` | `BB` | `R(a) = newclass(R(a),Syms(b),R(a+1))` |
|
||||
| `OP_MODULE` | `BB` | `R(a) = newmodule(R(a),Syms(b))` |
|
||||
| `OP_EXEC` | `BB` | `R(a) = blockexec(R(a),SEQ[b])` |
|
||||
| `OP_DEF` | `BB` | `R(a).newmethod(Syms(b),R(a+1))` |
|
||||
| `OP_DEF` | `BB` | `R(a).newmethod(Syms(b),R(a+1)); R(a) = Syms(b)` |
|
||||
| `OP_ALIAS` | `BB` | `alias_method(target_class,Syms(a),Syms(b))` |
|
||||
| `OP_UNDEF` | `B` | `undef_method(target_class,Syms(a))` |
|
||||
| `OP_SCLASS` | `B` | `R(a) = R(a).singleton_class` |
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ OPCODE(OCLASS, B) /* R(a) = ::Object */
|
||||
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
||||
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
||||
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
||||
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
||||
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)); R(a) = Syms(b) */
|
||||
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
||||
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
||||
OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
|
||||
|
||||
@@ -3049,10 +3049,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
push(); pop();
|
||||
pop();
|
||||
genop_2(s, OP_DEF, cursp(), sym);
|
||||
if (val) {
|
||||
genop_2(s, OP_LOADSYM, cursp(), sym);
|
||||
push();
|
||||
}
|
||||
if (val) push();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3069,10 +3066,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
genop_2(s, OP_METHOD, cursp(), idx);
|
||||
pop();
|
||||
genop_2(s, OP_DEF, cursp(), sym);
|
||||
if (val) {
|
||||
genop_2(s, OP_LOADSYM, cursp(), sym);
|
||||
push();
|
||||
}
|
||||
if (val) push();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user