37
37
import com .oracle .graal .python .builtins .modules .BuiltinFunctionsFactory ;
38
38
import com .oracle .graal .python .nodes .PRaiseNode ;
39
39
import com .oracle .graal .python .nodes .attributes .LookupInheritedAttributeNode ;
40
+ import com .oracle .graal .python .nodes .builtins .ListNodes .CreateStorageFromIteratorNode ;
40
41
import com .oracle .graal .python .nodes .builtins .TupleNodes ;
42
+ import com .oracle .graal .python .nodes .control .GetIteratorExpressionNode .GetIteratorNode ;
41
43
import com .oracle .graal .python .nodes .expression .ExpressionNode ;
42
44
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
43
45
import com .oracle .graal .python .nodes .statement .StatementNode ;
54
56
import com .oracle .truffle .api .profiles .BranchProfile ;
55
57
56
58
public final class DestructuringAssignmentNode extends StatementNode implements WriteNode {
57
- @ Child private PythonObjectFactory factory ;
59
+ @ Child private PythonObjectFactory factory = PythonObjectFactory . create () ;
58
60
@ Child private PRaiseNode raiseNode ;
59
61
@ CompilationFinal private ContextReference <PythonContext > contextRef ;
60
62
@@ -68,6 +70,9 @@ public final class DestructuringAssignmentNode extends StatementNode implements
68
70
@ Child private LookupInheritedAttributeNode lookupGetItemNode = LookupInheritedAttributeNode .create (__GETITEM__ );
69
71
@ Child private TupleNodes .ConstructTupleNode constructTupleNode = TupleNodes .ConstructTupleNode .create ();
70
72
73
+ @ Child private CreateStorageFromIteratorNode storageNode = CreateStorageFromIteratorNode .create ();
74
+ @ Child private GetIteratorNode getIteratorNode = GetIteratorNode .create ();
75
+
71
76
private final IsBuiltinClassProfile notEnoughValuesProfile = IsBuiltinClassProfile .create ();
72
77
private final IsBuiltinClassProfile tooManyValuesErrorProfile = IsBuiltinClassProfile .create ();
73
78
private final BranchProfile tooManyValuesProfile = BranchProfile .create ();
@@ -120,10 +125,6 @@ private int fillFromArray(VirtualFrame frame, Object[] array, int startIndex) {
120
125
121
126
private int fillStarred (VirtualFrame frame , Object rhsValue ) {
122
127
int pos = starredIndex ;
123
- if (factory == null ) {
124
- CompilerDirectives .transferToInterpreterAndInvalidate ();
125
- factory = insert (PythonObjectFactory .create ());
126
- }
127
128
try {
128
129
// TODO(ls): proper cast to int
129
130
// TODO(ls): the result of the len call doesn't seem to be used in Python
@@ -175,7 +176,8 @@ public ExpressionNode getRhs() {
175
176
return rhs ;
176
177
}
177
178
178
- public void doWrite (VirtualFrame frame , Object rhsValue ) {
179
+ public void doWrite (VirtualFrame frame , Object rhsVal ) {
180
+ Object rhsValue = factory .createList (storageNode .execute (frame , getIteratorNode .executeWith (frame , rhsVal )));
179
181
int nonExistingItem ;
180
182
try {
181
183
if (starredIndex == -1 ) {
0 commit comments