mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
should support recursive mlhs decomposition, e.g. (a,b),c = [1,2],3
This commit is contained in:
+13
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user