summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-05-15 17:41:00 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:20:52 +0900
commite3e559696027b7c65fa27b26223c6aabd08faa76 (patch)
tree1d5adf1bd1e6a9c64b7a8a84b6b8a1866ec53bf5 /mrbgems/mruby-compiler/core
parent1bcf6d9f3cacf6a5c54ee0c74d0dad0f0e9ed436 (diff)
downloadmruby-e3e559696027b7c65fa27b26223c6aabd08faa76.tar.gz
mruby-e3e559696027b7c65fa27b26223c6aabd08faa76.zip
Use `MRB_OPSYM()` instead of `mrb_intern_lit()`.
Diffstat (limited to 'mrbgems/mruby-compiler/core')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c8
-rw-r--r--mrbgems/mruby-compiler/core/parse.y74
2 files changed, 41 insertions, 41 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index c0d130182..eae1895a6 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -1742,7 +1742,7 @@ codegen(codegen_scope *s, node *tree, int val)
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);
+ genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_OPSYM(eqq)), 1);
}
}
else {
@@ -2545,7 +2545,7 @@ codegen(codegen_scope *s, node *tree, int val)
default:
if (val) {
- int sym = new_sym(s, mrb_intern_lit(s->mrb, "-@"));
+ int sym = new_sym(s, MRB_OPSYM(minus));
codegen(s, tree, VAL);
pop();
genop_3(s, OP_SEND, cursp(), sym, 0);
@@ -2637,7 +2637,7 @@ codegen(codegen_scope *s, node *tree, int val)
}
push(); /* for block */
pop_n(3);
- sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
+ sym = new_sym(s, MRB_OPSYM(tick)); /* ` */
genop_3(s, OP_SEND, cursp(), sym, 1);
if (val) push();
mrb_gc_arena_restore(s->mrb, ai);
@@ -2657,7 +2657,7 @@ codegen(codegen_scope *s, node *tree, int val)
genop_2(s, OP_STRING, cursp(), off);
push(); push();
pop_n(3);
- sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
+ sym = new_sym(s, MRB_OPSYM(tick)); /* ` */
genop_3(s, OP_SEND, cursp(), sym, 1);
if (val) push();
mrb_gc_arena_restore(s->mrb, ai);
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 393d6b098..806032e22 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 : intern_lit("&"));
+ local_add_f(p, blk ? blk : MRB_OPSYM(and));
}
static void
local_add_kw(parser_state *p, mrb_sym kwd)
{
/* allocate register for keywords hash */
- local_add_f(p, kwd ? kwd : intern_lit("**"));
+ local_add_f(p, kwd ? kwd : MRB_OPSYM(pow));
}
static node*
@@ -1671,7 +1671,7 @@ command_asgn : lhs '=' command_rhs
}
| primary_value '[' opt_call_args ']' tOP_ASGN command_rhs
{
- $$ = new_op_asgn(p, new_call(p, $1, intern_lit("[]"), $3, '.'), $5, $6);
+ $$ = new_op_asgn(p, new_call(p, $1, MRB_OPSYM(aref), $3, '.'), $5, $6);
}
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
{
@@ -1902,7 +1902,7 @@ mlhs_node : variable
}
| primary_value '[' opt_call_args ']'
{
- $$ = new_call(p, $1, intern_lit("[]"), $3, '.');
+ $$ = new_call(p, $1, MRB_OPSYM(aref), $3, '.');
}
| primary_value call_op tIDENTIFIER
{
@@ -1941,7 +1941,7 @@ lhs : variable
}
| primary_value '[' opt_call_args ']'
{
- $$ = new_call(p, $1, intern_lit("[]"), $3, '.');
+ $$ = new_call(p, $1, MRB_OPSYM(aref), $3, '.');
}
| primary_value call_op tIDENTIFIER
{
@@ -2029,36 +2029,36 @@ undef_list : fsym
}
;
-op : '|' { $$ = intern_lit("|"); }
- | '^' { $$ = intern_lit("^"); }
- | '&' { $$ = intern_lit("&"); }
- | tCMP { $$ = intern_lit("<=>"); }
- | tEQ { $$ = intern_lit("=="); }
- | tEQQ { $$ = intern_lit("==="); }
- | tMATCH { $$ = intern_lit("=~"); }
- | tNMATCH { $$ = intern_lit("!~"); }
- | '>' { $$ = intern_lit(">"); }
- | tGEQ { $$ = intern_lit(">="); }
- | '<' { $$ = intern_lit("<"); }
- | tLEQ { $$ = intern_lit("<="); }
- | tNEQ { $$ = intern_lit("!="); }
- | tLSHFT { $$ = intern_lit("<<"); }
- | tRSHFT { $$ = intern_lit(">>"); }
- | '+' { $$ = intern_lit("+"); }
- | '-' { $$ = intern_lit("-"); }
- | '*' { $$ = intern_lit("*"); }
- | tSTAR { $$ = intern_lit("*"); }
- | '/' { $$ = intern_lit("/"); }
- | '%' { $$ = intern_lit("%"); }
- | tPOW { $$ = intern_lit("**"); }
- | tDSTAR { $$ = intern_lit("**"); }
- | '!' { $$ = intern_lit("!"); }
- | '~' { $$ = intern_lit("~"); }
- | tUPLUS { $$ = intern_lit("+@"); }
- | tUMINUS { $$ = intern_lit("-@"); }
- | tAREF { $$ = intern_lit("[]"); }
- | tASET { $$ = intern_lit("[]="); }
- | '`' { $$ = intern_lit("`"); }
+op : '|' { $$ = MRB_OPSYM(or); }
+ | '^' { $$ = MRB_OPSYM(xor); }
+ | '&' { $$ = MRB_OPSYM(and); }
+ | tCMP { $$ = MRB_OPSYM(cmp); }
+ | tEQ { $$ = MRB_OPSYM(eq); }
+ | tEQQ { $$ = MRB_OPSYM(eqq); }
+ | tMATCH { $$ = MRB_OPSYM(match); }
+ | tNMATCH { $$ = MRB_OPSYM(nmatch); }
+ | '>' { $$ = MRB_OPSYM(gt); }
+ | tGEQ { $$ = MRB_OPSYM(ge); }
+ | '<' { $$ = MRB_OPSYM(lt); }
+ | tLEQ { $$ = MRB_OPSYM(le); }
+ | tNEQ { $$ = MRB_OPSYM(neq); }
+ | tLSHFT { $$ = MRB_OPSYM(lshift); }
+ | tRSHFT { $$ = MRB_OPSYM(rshift); }
+ | '+' { $$ = MRB_OPSYM(add); }
+ | '-' { $$ = MRB_OPSYM(sub); }
+ | '*' { $$ = MRB_OPSYM(mul); }
+ | tSTAR { $$ = MRB_OPSYM(mul); }
+ | '/' { $$ = MRB_OPSYM(div); }
+ | '%' { $$ = MRB_OPSYM(mod); }
+ | tPOW { $$ = MRB_OPSYM(pow); }
+ | tDSTAR { $$ = MRB_OPSYM(pow); }
+ | '!' { $$ = MRB_OPSYM(not); }
+ | '~' { $$ = MRB_OPSYM(neg); }
+ | tUPLUS { $$ = MRB_OPSYM(plus); }
+ | tUMINUS { $$ = MRB_OPSYM(minus); }
+ | tAREF { $$ = MRB_OPSYM(aref); }
+ | tASET { $$ = MRB_OPSYM(aset); }
+ | '`' { $$ = MRB_OPSYM(tick); }
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
@@ -2288,8 +2288,8 @@ paren_args : '(' opt_call_args ')'
| '(' tDOT3 rparen
{
#if 1
- mrb_sym r = mrb_intern_lit(p->mrb, "*");
- mrb_sym b = mrb_intern_lit(p->mrb, "&");
+ mrb_sym r = MRB_OPSYM(mul);
+ mrb_sym b = MRB_OPSYM(and);
if (local_var_p(p, r) && local_var_p(p, b)) {
$$ = cons(list1(new_splat(p, new_lvar(p, r))),
new_block_arg(p, new_lvar(p, b)));