summaryrefslogtreecommitdiffhomepage
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
parent1bcf6d9f3cacf6a5c54ee0c74d0dad0f0e9ed436 (diff)
downloadmruby-e3e559696027b7c65fa27b26223c6aabd08faa76.tar.gz
mruby-e3e559696027b7c65fa27b26223c6aabd08faa76.zip
Use `MRB_OPSYM()` instead of `mrb_intern_lit()`.
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c8
-rw-r--r--mrbgems/mruby-compiler/core/parse.y74
-rw-r--r--src/array.c4
-rw-r--r--src/kernel.c2
-rw-r--r--src/proc.c2
-rw-r--r--src/vm.c24
6 files changed, 57 insertions, 57 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)));
diff --git a/src/array.c b/src/array.c
index 567ed7d8b..02d792657 100644
--- a/src/array.c
+++ b/src/array.c
@@ -1086,7 +1086,7 @@ mrb_ary_splat(mrb_state *mrb, mrb_value v)
return mrb_obj_value(a);
}
- if (!mrb_respond_to(mrb, v, mrb_intern_lit(mrb, "to_a"))) {
+ if (!mrb_respond_to(mrb, v, MRB_SYM(to_a))) {
return mrb_ary_new_from_values(mrb, 1, &v);
}
@@ -1314,7 +1314,7 @@ init_ary_each(mrb_state *mrb, struct RClass *ary)
each_irep->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*5);
each_irep->syms[0] = MRB_SYM(each);
each_irep->syms[1] = MRB_SYM(to_enum);
- each_irep->syms[2] = mrb_intern_lit(mrb, "[]");
+ each_irep->syms[2] = MRB_OPSYM(aref);
each_irep->syms[3] = MRB_SYM(call);
each_irep->syms[4] = MRB_SYM(length);
each_irep->slen = 5;
diff --git a/src/kernel.c b/src/kernel.c
index e192ed752..d2074c16b 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -766,7 +766,7 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self)
{
mrb_value v = mrb_get_arg1(mrb);
mrb_int i, len;
- mrb_sym eqq = mrb_intern_lit(mrb, "===");
+ mrb_sym eqq = MRB_OPSYM(eqq);
mrb_value ary;
if (mrb_array_p(self)) {
diff --git a/src/proc.c b/src/proc.c
index 743e9610c..bb678558d 100644
--- a/src/proc.c
+++ b/src/proc.c
@@ -326,7 +326,7 @@ mrb_init_proc(mrb_state *mrb)
irep_obj->data = NULL;
MRB_METHOD_FROM_PROC(m, p);
mrb_define_method_raw(mrb, mrb->proc_class, MRB_SYM(call), m);
- mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "[]"), m);
+ mrb_define_method_raw(mrb, mrb->proc_class, MRB_OPSYM(aref), m);
mrb_define_class_method(mrb, mrb->kernel_module, "lambda", proc_lambda, MRB_ARGS_NONE()|MRB_ARGS_BLOCK()); /* 15.3.1.2.6 */
mrb_define_method(mrb, mrb->kernel_module, "lambda", proc_lambda, MRB_ARGS_NONE()|MRB_ARGS_BLOCK()); /* 15.3.1.3.27 */
diff --git a/src/vm.c b/src/vm.c
index d032f2794..5c305908e 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -2142,7 +2142,7 @@ RETRY_TRY_BLOCK:
OP_MATH_CASE_STRING_##op_name(); \
default: \
c = 1; \
- mid = mrb_intern_lit(mrb, MRB_STRINGIZE(OP_MATH_OP_##op_name)); \
+ mid = MRB_OPSYM(op_name); \
goto L_SEND_SYM; \
} \
NEXT;
@@ -2229,7 +2229,7 @@ RETRY_TRY_BLOCK:
#endif
default:
c = 1;
- mid = mrb_intern_lit(mrb, "/");
+ mid = MRB_OPSYM(div);
goto L_SEND_SYM;
}
@@ -2255,7 +2255,7 @@ RETRY_TRY_BLOCK:
default: \
SET_INT_VALUE(regs[a+1], b); \
c = 1; \
- mid = mrb_intern_lit(mrb, MRB_STRINGIZE(OP_MATH_OP_##op_name)); \
+ mid = MRB_OPSYM(op_name); \
goto L_SEND_SYM; \
} \
NEXT;
@@ -2292,7 +2292,7 @@ RETRY_TRY_BLOCK:
#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))
#ifdef MRB_WITHOUT_FLOAT
-#define OP_CMP(op) do {\
+#define OP_CMP(op,sym) do {\
int result;\
/* need to check if - is overridden */\
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
@@ -2301,7 +2301,7 @@ RETRY_TRY_BLOCK:
break;\
default:\
c = 1;\
- mid = mrb_intern_lit(mrb, # op);\
+ mid = MRB_OPSYM(sym);\
goto L_SEND_SYM;\
}\
if (result) {\
@@ -2312,7 +2312,7 @@ RETRY_TRY_BLOCK:
}\
} while(0)
#else
-#define OP_CMP(op) do {\
+#define OP_CMP(op, sym) do {\
int result;\
/* need to check if - is overridden */\
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
@@ -2330,7 +2330,7 @@ RETRY_TRY_BLOCK:
break;\
default:\
c = 1;\
- mid = mrb_intern_lit(mrb, # op);\
+ mid = MRB_OPSYM(sym);\
goto L_SEND_SYM;\
}\
if (result) {\
@@ -2347,28 +2347,28 @@ RETRY_TRY_BLOCK:
SET_TRUE_VALUE(regs[a]);
}
else {
- OP_CMP(==);
+ OP_CMP(==,eq);
}
NEXT;
}
CASE(OP_LT, B) {
- OP_CMP(<);
+ OP_CMP(<,lt);
NEXT;
}
CASE(OP_LE, B) {
- OP_CMP(<=);
+ OP_CMP(<=,le);
NEXT;
}
CASE(OP_GT, B) {
- OP_CMP(>);
+ OP_CMP(>,gt);
NEXT;
}
CASE(OP_GE, B) {
- OP_CMP(>=);
+ OP_CMP(>=,ge);
NEXT;
}