File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python
builtins/objects/generator Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 69
69
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
70
70
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
71
71
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
72
+ import com .oracle .graal .python .nodes .generator .AbstractYieldNode ;
73
+ import com .oracle .graal .python .nodes .generator .YieldFromNode ;
72
74
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
73
75
import com .oracle .graal .python .runtime .exception .PException ;
74
76
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
@@ -542,6 +544,21 @@ static Object getFrame(PGenerator self,
542
544
}
543
545
}
544
546
547
+ @ Builtin (name = "gi_yieldfrom" , minNumOfPositionalArgs = 1 , isGetter = true )
548
+ @ GenerateNodeFactory
549
+ public abstract static class GetYieldFromNode extends PythonUnaryBuiltinNode {
550
+ @ Specialization
551
+ static Object getYieldFrom (PGenerator self ) {
552
+ AbstractYieldNode currentYield = self .getCurrentYieldNode ();
553
+ if (currentYield instanceof YieldFromNode ) {
554
+ int iteratorSlot = ((YieldFromNode ) currentYield ).getIteratorSlot ();
555
+ return PArguments .getControlDataFromGeneratorArguments (self .getArguments ()).getIteratorAt (iteratorSlot );
556
+ } else {
557
+ return PNone .NONE ;
558
+ }
559
+ }
560
+ }
561
+
545
562
@ Builtin (name = __REPR__ , minNumOfPositionalArgs = 1 )
546
563
@ GenerateNodeFactory
547
564
abstract static class ReprNode extends PythonUnaryBuiltinNode {
Original file line number Diff line number Diff line change @@ -217,6 +217,10 @@ public Object execute(VirtualFrame frame) {
217
217
}
218
218
}
219
219
220
+ public int getIteratorSlot () {
221
+ return iteratorSlot ;
222
+ }
223
+
220
224
private GetAttributeNode getGetValue () {
221
225
if (getValue == null ) {
222
226
CompilerDirectives .transferToInterpreterAndInvalidate ();
You can’t perform that action at this time.
0 commit comments