summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core/parse.y
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-07-21 13:20:34 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-07-21 13:20:34 +0900
commite42f192827102a6aa7a398d0360e310ed2ae20d2 (patch)
tree0a1acdc15f99a9dc59b7875b09be01de300f5b78 /mrbgems/mruby-compiler/core/parse.y
parent2ef6e944896072687bdd28c846a62e5be37eec48 (diff)
downloadmruby-e42f192827102a6aa7a398d0360e310ed2ae20d2.tar.gz
mruby-e42f192827102a6aa7a398d0360e310ed2ae20d2.zip
codegen.c: skip `-@` call if the argument is a literal integer.
Diffstat (limited to 'mrbgems/mruby-compiler/core/parse.y')
-rw-r--r--mrbgems/mruby-compiler/core/parse.y12
1 files changed, 6 insertions, 6 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 7d9db4a2b..00d40ec64 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -1248,7 +1248,7 @@ call_with_block(parser_state *p, node *a, node *b)
}
static node*
-negate_lit(parser_state *p, node *n)
+new_negate(parser_state *p, node *n)
{
return cons((node*)NODE_NEGATE, n);
}
@@ -2292,11 +2292,11 @@ arg : lhs '=' arg_rhs
}
| tUMINUS_NUM tINTEGER tPOW arg
{
- $$ = call_uni_op(p, call_bin_op(p, $2, "**", $4), "-@");
+ $$ = new_negate(p, call_bin_op(p, $2, "**", $4));
}
| tUMINUS_NUM tFLOAT tPOW arg
{
- $$ = call_uni_op(p, call_bin_op(p, $2, "**", $4), "-@");
+ $$ = new_negate(p, call_bin_op(p, $2, "**", $4));
}
| tUPLUS arg
{
@@ -2304,7 +2304,7 @@ arg : lhs '=' arg_rhs
}
| tUMINUS arg
{
- $$ = call_uni_op(p, $2, "-@");
+ $$ = new_negate(p, $2);
}
| arg '|' arg
{
@@ -3463,11 +3463,11 @@ numeric : tINTEGER
| tFLOAT
| tUMINUS_NUM tINTEGER %prec tLOWEST
{
- $$ = negate_lit(p, $2);
+ $$ = new_negate(p, $2);
}
| tUMINUS_NUM tFLOAT %prec tLOWEST
{
- $$ = negate_lit(p, $2);
+ $$ = new_negate(p, $2);
}
;