40
40
*/
41
41
package com .oracle .graal .python .nodes .bytecode ;
42
42
43
+ import static com .oracle .graal .python .nodes .ErrorMessages .ANEXT_INVALID_OBJECT ;
44
+ import static com .oracle .graal .python .nodes .ErrorMessages .ASYNC_FOR_NO_ANEXT_ITERATION ;
45
+
43
46
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
44
47
import com .oracle .graal .python .builtins .objects .PNone ;
45
48
import com .oracle .graal .python .builtins .objects .asyncio .GetAwaitableNode ;
46
- import com .oracle .graal .python .builtins .objects .object .PythonObject ;
47
49
import com .oracle .graal .python .builtins .objects .type .SpecialMethodSlot ;
48
- import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
49
- import com .oracle .graal .python .nodes .ErrorMessages ;
50
50
import com .oracle .graal .python .nodes .PNodeWithContext ;
51
51
import com .oracle .graal .python .nodes .PRaiseNode ;
52
- import com .oracle .graal .python .nodes .SpecialMethodNames ;
53
52
import com .oracle .graal .python .nodes .call .special .CallUnaryMethodNode ;
54
- import com .oracle .graal .python .nodes .call .special .LookupSpecialMethodNode ;
55
53
import com .oracle .graal .python .nodes .call .special .LookupSpecialMethodSlotNode ;
56
- import com .oracle .graal .python .nodes .object .GetClassNode ;
57
54
import com .oracle .graal .python .nodes .object .InlinedGetClassNode ;
58
55
import com .oracle .graal .python .runtime .exception .PException ;
59
56
import com .oracle .truffle .api .dsl .Bind ;
64
61
import com .oracle .truffle .api .frame .Frame ;
65
62
import com .oracle .truffle .api .nodes .Node ;
66
63
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
67
- import com .oracle .truffle .api .strings .TruffleString ;
68
-
69
- import static com .oracle .graal .python .nodes .ErrorMessages .ANEXT_INVALID_OBJECT ;
70
- import static com .oracle .graal .python .nodes .ErrorMessages .ASYNC_FOR_NO_ANEXT_ITERATION ;
71
64
72
65
@ GenerateUncached
73
66
@ ImportStatic (SpecialMethodSlot .class )
@@ -84,34 +77,26 @@ public static GetANextNode create() {
84
77
85
78
@ Specialization
86
79
Object doGeneric (Frame frame , Object receiver ,
87
- @ Bind ("this" ) Node inliningTarget ,
88
- @ Cached (parameters = "ANext" ) LookupSpecialMethodSlotNode getANext ,
89
- @ Cached GetClassNode getAsyncIterType ,
90
- @ Cached InlinedGetClassNode .GetPythonObjectClassNode getANextType ,
91
- @ Cached PRaiseNode raiseNoANext ,
92
- @ Cached TypeNodes .GetNameNode getName ,
93
- @ Cached InlinedBranchProfile errorProfile ,
94
- @ Cached CallUnaryMethodNode callANext ,
95
- @ Cached PRaiseNode raiseInvalidObject ,
96
- @ Cached GetAwaitableNode getAwaitable ) {
97
- Object type = getAsyncIterType .execute (receiver );
80
+ @ Bind ("this" ) Node inliningTarget ,
81
+ @ Cached (parameters = "ANext" ) LookupSpecialMethodSlotNode getANext ,
82
+ @ Cached InlinedGetClassNode getAsyncIterType ,
83
+ @ Cached PRaiseNode raiseNoANext ,
84
+ @ Cached InlinedBranchProfile errorProfile ,
85
+ @ Cached CallUnaryMethodNode callANext ,
86
+ @ Cached PRaiseNode raiseInvalidObject ,
87
+ @ Cached (neverDefault = true ) GetAwaitableNode getAwaitable ) {
88
+ Object type = getAsyncIterType .execute (inliningTarget , receiver );
98
89
Object getter = getANext .execute (frame , type , receiver );
99
90
if (getter == PNone .NO_VALUE ) {
100
91
errorProfile .enter (inliningTarget );
101
- throw raiseNoANext .raise (PythonBuiltinClassType .TypeError , ASYNC_FOR_NO_ANEXT_ITERATION , getName . execute ( type ) );
92
+ throw raiseNoANext .raise (PythonBuiltinClassType .TypeError , ASYNC_FOR_NO_ANEXT_ITERATION , receiver );
102
93
}
103
94
Object anext = callANext .executeObject (frame , getter , receiver );
104
95
try {
105
96
return getAwaitable .execute (frame , anext );
106
- } catch (PException e ) {
97
+ } catch (PException e ) {
107
98
errorProfile .enter (inliningTarget );
108
- Object aNextName ;
109
- if (anext instanceof PythonObject ) {
110
- aNextName = getName .execute (getANextType .execute (inliningTarget , (PythonObject ) anext ));
111
- } else {
112
- aNextName = anext .getClass ().getName ();
113
- }
114
- throw raiseInvalidObject .raise (PythonBuiltinClassType .TypeError , e , ANEXT_INVALID_OBJECT , aNextName );
99
+ throw raiseInvalidObject .raise (PythonBuiltinClassType .TypeError , e , ANEXT_INVALID_OBJECT , anext );
115
100
}
116
101
}
117
102
}
0 commit comments