diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-04-25 14:29:58 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:20:41 +0900 |
| commit | eddd3249793b3b307da2fe7734d5923cd238a35b (patch) | |
| tree | 8575bd761c26472c9dbb6a81cdeb65a2b3ecc3bd /mrbgems/mruby-compiler | |
| parent | f221f4e0fa08da25498042b2cd61331af40294e5 (diff) | |
| download | mruby-eddd3249793b3b307da2fe7734d5923cd238a35b.tar.gz mruby-eddd3249793b3b307da2fe7734d5923cd238a35b.zip | |
Add `MRB_SYM()` for inline symbols.
Diffstat (limited to 'mrbgems/mruby-compiler')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 16 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index c64ffc473..c0d130182 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -737,7 +737,7 @@ for_body(codegen_scope *s, node *tree) genop_2(s, OP_BLOCK, cursp(), s->irep->rlen-1); push();pop(); /* space for a block */ pop(); - idx = new_sym(s, mrb_intern_lit(s->mrb, "each")); + idx = new_sym(s, MRB_SYM(each)); genop_3(s, OP_SENDB, cursp(), idx, 0); } @@ -1489,14 +1489,14 @@ codegen(codegen_scope *s, node *tree, int val) gen_move(s, cursp(), exc, 0); push_n(2); pop_n(2); /* space for one arg and a block */ pop(); - genop_3(s, OP_SEND, cursp(), new_sym(s, mrb_intern_lit(s->mrb, "__case_eqq")), 1); + genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM(__case_eqq)), 1); } else { if (n4) { codegen(s, n4->car, VAL); } else { - genop_2(s, OP_GETCONST, cursp(), new_sym(s, mrb_intern_lit(s->mrb, "StandardError"))); + genop_2(s, OP_GETCONST, cursp(), new_sym(s, MRB_SYM(StandardError))); push(); } pop(); @@ -1739,7 +1739,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_move(s, cursp(), head, 0); push(); push(); pop(); pop(); pop(); if (nint(n->car->car) == NODE_SPLAT) { - genop_3(s, OP_SEND, cursp(), new_sym(s, mrb_intern_lit(s->mrb, "__case_eqq")), 1); + genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM(__case_eqq)), 1); } else { genop_3(s, OP_SEND, cursp(), new_sym(s, mrb_intern_lit(s->mrb, "===")), 1); @@ -2266,7 +2266,7 @@ codegen(codegen_scope *s, node *tree, int val) pop_n(n+1); genop_2S(s, OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf)); if (sendv) n = CALL_MAXARGS; - genop_3(s, OP_SEND, cursp(), new_sym(s, mrb_intern_lit(s->mrb, "call")), n); + genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM(call)), n); if (val) push(); } break; @@ -2618,7 +2618,7 @@ codegen(codegen_scope *s, node *tree, int val) { node *n; int ai = mrb_gc_arena_save(s->mrb); - int sym = new_sym(s, mrb_intern_lit(s->mrb, "Kernel")); + int sym = new_sym(s, MRB_SYM(Kernel)); genop_1(s, OP_LOADSELF, cursp()); push(); @@ -2698,7 +2698,7 @@ codegen(codegen_scope *s, node *tree, int val) } push(); /* space for a block */ pop_n(argc+2); - sym = new_sym(s, mrb_intern_lit(s->mrb, "compile")); + sym = new_sym(s, MRB_SYM(compile)); genop_3(s, OP_SEND, cursp(), sym, argc); mrb_gc_arena_restore(s->mrb, ai); push(); @@ -2752,7 +2752,7 @@ codegen(codegen_scope *s, node *tree, int val) } push(); /* space for a block */ pop_n(argc+2); - sym = new_sym(s, mrb_intern_lit(s->mrb, "compile")); + sym = new_sym(s, MRB_SYM(compile)); genop_3(s, OP_SEND, cursp(), sym, argc); mrb_gc_arena_restore(s->mrb, ai); push(); diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 9de45a536..393d6b098 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -311,14 +311,14 @@ static void local_add_blk(parser_state *p, mrb_sym blk) { /* allocate register for block */ - local_add_f(p, blk ? blk : mrb_intern_lit(p->mrb, "&")); + local_add_f(p, blk ? blk : intern_lit("&")); } static void local_add_kw(parser_state *p, mrb_sym kwd) { /* allocate register for keywords hash */ - local_add_f(p, kwd ? kwd : mrb_intern_lit(p->mrb, "**")); + local_add_f(p, kwd ? kwd : intern_lit("**")); } static node* @@ -932,13 +932,13 @@ new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b) static node* new_imaginary(parser_state *p, node *imaginary) { - return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Complex"), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1); + return new_call(p, new_const(p, MRB_SYM(Kernel)), MRB_SYM(Complex), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1); } static node* new_rational(parser_state *p, node *rational) { - return new_call(p, new_const(p, intern_lit("Kernel")), intern_lit("Rational"), list1(list1(rational)), 1); + return new_call(p, new_const(p, MRB_SYM(Kernel)), MRB_SYM(Rational), list1(list1(rational)), 1); } /* (:int . i) */ @@ -3010,11 +3010,11 @@ method_call : operation paren_args } | primary_value call_op paren_args { - $$ = new_call(p, $1, intern_lit("call"), $3, $2); + $$ = new_call(p, $1, MRB_SYM(call), $3, $2); } | primary_value tCOLON2 paren_args { - $$ = new_call(p, $1, intern_lit("call"), $3, tCOLON2); + $$ = new_call(p, $1, MRB_SYM(call), $3, tCOLON2); } | keyword_super paren_args { @@ -3580,7 +3580,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail } | /* none */ { - local_add_f(p, mrb_intern_lit(p->mrb, "&")); + local_add_f(p, intern_lit("&")); $$ = new_args(p, 0, 0, 0, 0, 0); } ; @@ -3704,7 +3704,7 @@ f_rest_arg : restarg_mark tIDENTIFIER } | restarg_mark { - local_add_f(p, mrb_intern_lit(p->mrb, "*")); + local_add_f(p, intern_lit("*")); $$ = -1; } ; |
