mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm: add OP_RETTRUE and OP_RETFALSE for returning boolean literals
Add single-byte opcodes for returning true/false directly, completing the set of literal return opcodes (RETSELF, RETNIL, RETTRUE, RETFALSE). Codegen applies peephole optimization to fuse LOADTRUE/LOADFALSE + RETURN. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,8 @@ OPCODE(RETURN, B) /* return R[a] (normal) */
|
||||
OPCODE(RETURN_BLK, B) /* return R[a] (in-block return) */
|
||||
OPCODE(RETSELF, Z) /* return self */
|
||||
OPCODE(RETNIL, Z) /* return nil */
|
||||
OPCODE(RETTRUE, Z) /* return true */
|
||||
OPCODE(RETFALSE, Z) /* return false */
|
||||
OPCODE(BREAK, B) /* break R[a] */
|
||||
OPCODE(BLKPUSH, BS) /* R[a] = block (16=m5:r1:m5:d1:lv4) */
|
||||
OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
|
||||
|
||||
Reference in New Issue
Block a user