diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-10 10:23:28 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-10 10:23:28 +0900 |
| commit | 28b5c30b964c9e6121a2ee04454905c81a3e2646 (patch) | |
| tree | 8e63ca79d1404d32534dcb2a0022c064d6bfabc6 /mrbgems | |
| parent | b34713304a983a0a6e3259bd0b5f3215ac2ee14a (diff) | |
| download | mruby-28b5c30b964c9e6121a2ee04454905c81a3e2646.tar.gz mruby-28b5c30b964c9e6121a2ee04454905c81a3e2646.zip | |
ops.h: add `OP_SYMBOL` instruction.
It generates a symbol by interning from the pool string.
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index b8891cf1b..7327f2cef 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -1757,6 +1757,16 @@ static void gen_intern(codegen_scope *s) { pop(); + if (!no_peephole(s)) { + struct mrb_insn_data data = mrb_last_insn(s); + + if (data.insn == OP_STRING && data.a == cursp()) { + rewind_pc(s); + genop_2(s, OP_SYMBOL, data.a, data.b); + push(); + return; + } + } genop_1(s, OP_INTERN, cursp()); push(); } |
