Permalink
Browse files

Check before generating special operators (e.g. OP_ADD); fix #3557

  • Loading branch information...
matz committed Apr 3, 2017
1 parent a49c9f8 commit 8193c0b566d78a1cf0e0e7b6b2c3a56e3e0dfac0
Showing with 9 additions and 9 deletions.
  1. +9 −9 mrbgems/mruby-compiler/core/codegen.c
@@ -904,31 +904,31 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe)
mrb_int symlen;
const char *symname = mrb_sym2name_len(s->mrb, sym, &symlen);
if (!noop && symlen == 1 && symname[0] == '+') {
if (!noop && symlen == 1 && symname[0] == '+' && n == 1) {
genop_peep(s, MKOP_ABC(OP_ADD, cursp(), idx, n), val);
}
else if (!noop && symlen == 1 && symname[0] == '-') {
else if (!noop && symlen == 1 && symname[0] == '-' && n == 1) {
genop_peep(s, MKOP_ABC(OP_SUB, cursp(), idx, n), val);
}
else if (!noop && symlen == 1 && symname[0] == '*') {
else if (!noop && symlen == 1 && symname[0] == '*' && n == 1) {
genop(s, MKOP_ABC(OP_MUL, cursp(), idx, n));
}
else if (!noop && symlen == 1 && symname[0] == '/') {
else if (!noop && symlen == 1 && symname[0] == '/' && n == 1) {
genop(s, MKOP_ABC(OP_DIV, cursp(), idx, n));
}
else if (!noop && symlen == 1 && symname[0] == '<') {
else if (!noop && symlen == 1 && symname[0] == '<' && n == 1) {
genop(s, MKOP_ABC(OP_LT, cursp(), idx, n));
}
else if (!noop && symlen == 2 && symname[0] == '<' && symname[1] == '=') {
else if (!noop && symlen == 2 && symname[0] == '<' && symname[1] == '=' && n == 1) {
genop(s, MKOP_ABC(OP_LE, cursp(), idx, n));
}
else if (!noop && symlen == 1 && symname[0] == '>') {
else if (!noop && symlen == 1 && symname[0] == '>' && n == 1) {
genop(s, MKOP_ABC(OP_GT, cursp(), idx, n));
}
else if (!noop && symlen == 2 && symname[0] == '>' && symname[1] == '=') {
else if (!noop && symlen == 2 && symname[0] == '>' && symname[1] == '=' && n == 1) {
genop(s, MKOP_ABC(OP_GE, cursp(), idx, n));
}
else if (!noop && symlen == 2 && symname[0] == '=' && symname[1] == '=') {
else if (!noop && symlen == 2 && symname[0] == '=' && symname[1] == '=' && n == 1) {
genop(s, MKOP_ABC(OP_EQ, cursp(), idx, n));
}
else {

0 comments on commit 8193c0b

Please sign in to comment.