summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-11-22 12:16:59 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-11-22 12:16:59 +0900
commitbce75e2746f00590a5a6c330725e12805e30fbc1 (patch)
tree8778661bda9cefb2889ed0a4ab24c885403103fd /src
parentb28ec1bc88d29d8e7205401a6e323f20581d642f (diff)
downloadmruby-bce75e2746f00590a5a6c330725e12805e30fbc1.tar.gz
mruby-bce75e2746f00590a5a6c330725e12805e30fbc1.zip
should support recursive mlhs decomposition, e.g. (a,b),c = [1,2],3
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c14
-rw-r--r--src/parse.y4
2 files changed, 15 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c
index ebab9e11e..4801f6cff 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -953,6 +953,18 @@ gen_assignment(codegen_scope *s, node *tree, int sp, int val)
}
break;
+ case NODE_MASGN:
+ gen_vmassignment(s, tree->car, sp, val);
+ break;
+
+ push();
+ gen_call(s, tree, attrsym(s, sym(tree->cdr->car)), sp, NOVAL);
+ pop();
+ if (val) {
+ genop_peep(s, MKOP_AB(OP_MOVE, cursp(), sp), val);
+ }
+ break;
+
default:
#ifdef ENABLE_STDIO
printf("unknown lhs %d\n", type);
@@ -1006,7 +1018,7 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
}
}
}
- else {
+ else if (val) {
pop();
}
}
diff --git a/src/parse.y b/src/parse.y
index b98a2c2e2..f8e1ff9aa 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -1468,7 +1468,7 @@ mlhs : mlhs_basic
mlhs_inner : mlhs_basic
| tLPAREN mlhs_inner rparen
{
- $$ = list1($2);
+ $$ = $2;
}
;
@@ -1517,7 +1517,7 @@ mlhs_basic : mlhs_list
mlhs_item : mlhs_node
| tLPAREN mlhs_inner rparen
{
- $$ = $2;
+ $$ = new_masgn(p, $2, NULL);
}
;