42
42
43
43
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .TypeError ;
44
44
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .ValueError ;
45
- import static com .oracle .graal .python .nodes .SpecialMethodNames .__BOOL__ ;
46
- import static com .oracle .graal .python .nodes .SpecialMethodNames .__LEN__ ;
47
45
48
46
import com .oracle .graal .python .builtins .objects .PNone ;
49
47
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
50
48
import com .oracle .graal .python .builtins .objects .list .PList ;
51
49
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
50
+ import com .oracle .graal .python .builtins .objects .type .SpecialMethodSlot ;
52
51
import com .oracle .graal .python .nodes .ErrorMessages ;
53
52
import com .oracle .graal .python .nodes .PNodeWithContext ;
54
53
import com .oracle .graal .python .nodes .PRaiseNode ;
55
- import com .oracle .graal .python .nodes .SpecialMethodNames ;
56
54
import com .oracle .graal .python .nodes .call .special .CallUnaryMethodNode ;
57
- import com .oracle .graal .python .nodes .call .special .LookupSpecialMethodNode ;
58
55
import com .oracle .graal .python .nodes .call .special .LookupSpecialMethodSlotNode ;
59
56
import com .oracle .graal .python .nodes .object .GetClassNode ;
60
57
import com .oracle .graal .python .nodes .util .CannotCastException ;
76
73
* to true if neither is defined.
77
74
*/
78
75
@ GenerateUncached
79
- @ ImportStatic (SpecialMethodNames .class )
76
+ @ ImportStatic (SpecialMethodSlot .class )
80
77
public abstract class PyObjectIsTrueNode extends PNodeWithContext {
81
78
public abstract boolean execute (Frame frame , Object object );
82
79
@@ -129,15 +126,15 @@ static boolean doTuple(PTuple object,
129
126
@ Specialization (guards = {"!isBoolean(object)" , "!isPNone(object)" , "!isInteger(object)" , "!isDouble(object)" }, rewriteOn = UnexpectedResultException .class )
130
127
static boolean doObjectUnboxed (VirtualFrame frame , Object object ,
131
128
@ Shared ("getClassNode" ) @ Cached GetClassNode getClassNode ,
132
- @ Cached ( "create(__BOOL__) " ) LookupSpecialMethodSlotNode lookupBool ,
133
- @ Cached ( "create(__LEN__) " ) LookupSpecialMethodSlotNode lookupLen ,
134
- @ Cached CallUnaryMethodNode callBool ,
135
- @ Cached CallUnaryMethodNode callLen ,
136
- @ Cached CastToJavaBooleanNode cast ,
137
- @ Cached PyNumberIndexNode indexNode ,
138
- @ Cached CastToJavaIntLossyNode castLossy ,
139
- @ Cached PyNumberAsSizeNode asSizeNode ,
140
- @ Cached PRaiseNode raiseNode ) throws UnexpectedResultException {
129
+ @ Shared ( "lookupBool" ) @ Cached ( parameters = "Bool " ) LookupSpecialMethodSlotNode lookupBool ,
130
+ @ Shared ( "lookupLen" ) @ Cached ( parameters = "Len " ) LookupSpecialMethodSlotNode lookupLen ,
131
+ @ Shared ( "callBool" ) @ Cached CallUnaryMethodNode callBool ,
132
+ @ Shared ( "callLen" ) @ Cached CallUnaryMethodNode callLen ,
133
+ @ Shared ( "cast" ) @ Cached CastToJavaBooleanNode cast ,
134
+ @ Shared ( "index" ) @ Cached PyNumberIndexNode indexNode ,
135
+ @ Shared ( "castLossy" ) @ Cached CastToJavaIntLossyNode castLossy ,
136
+ @ Shared ( "asSize" ) @ Cached PyNumberAsSizeNode asSizeNode ,
137
+ @ Shared ( "raise" ) @ Cached PRaiseNode raiseNode ) throws UnexpectedResultException {
141
138
Object type = getClassNode .execute (object );
142
139
Object boolDescr = lookupBool .execute (frame , type , object );
143
140
if (boolDescr != PNone .NO_VALUE ) {
@@ -161,22 +158,22 @@ static boolean doObjectUnboxed(VirtualFrame frame, Object object,
161
158
@ Specialization (guards = {"!isBoolean(object)" , "!isPNone(object)" , "!isInteger(object)" , "!isDouble(object)" }, replaces = "doObjectUnboxed" )
162
159
static boolean doObject (VirtualFrame frame , Object object ,
163
160
@ Shared ("getClassNode" ) @ Cached GetClassNode getClassNode ,
164
- @ Cached LookupSpecialMethodNode . Dynamic lookupBool ,
165
- @ Cached LookupSpecialMethodNode . Dynamic lookupLen ,
166
- @ Cached CallUnaryMethodNode callBool ,
167
- @ Cached CallUnaryMethodNode callLen ,
168
- @ Cached CastToJavaBooleanNode cast ,
169
- @ Cached PyNumberIndexNode indexNode ,
170
- @ Cached CastToJavaIntLossyNode castLossy ,
171
- @ Cached PyNumberAsSizeNode asSizeNode ,
172
- @ Cached PRaiseNode raiseNode ) {
161
+ @ Shared ( "lookupBool" ) @ Cached ( parameters = "Bool" ) LookupSpecialMethodSlotNode lookupBool ,
162
+ @ Shared ( "lookupLen" ) @ Cached ( parameters = "Len" ) LookupSpecialMethodSlotNode lookupLen ,
163
+ @ Shared ( "callBool" ) @ Cached CallUnaryMethodNode callBool ,
164
+ @ Shared ( "callLen" ) @ Cached CallUnaryMethodNode callLen ,
165
+ @ Shared ( "cast" ) @ Cached CastToJavaBooleanNode cast ,
166
+ @ Shared ( "index" ) @ Cached PyNumberIndexNode indexNode ,
167
+ @ Shared ( "castLossy" ) @ Cached CastToJavaIntLossyNode castLossy ,
168
+ @ Shared ( "asSize" ) @ Cached PyNumberAsSizeNode asSizeNode ,
169
+ @ Shared ( "raise" ) @ Cached PRaiseNode raiseNode ) {
173
170
Object type = getClassNode .execute (object );
174
- Object boolDescr = lookupBool .execute (frame , type , __BOOL__ , object , false );
171
+ Object boolDescr = lookupBool .execute (frame , type , object );
175
172
if (boolDescr != PNone .NO_VALUE ) {
176
173
Object result = callBool .executeObject (frame , boolDescr , object );
177
174
return checkBoolResult (cast , raiseNode , result );
178
175
}
179
- Object lenDescr = lookupLen .execute (frame , type , __LEN__ , object , false );
176
+ Object lenDescr = lookupLen .execute (frame , type , object );
180
177
if (lenDescr != PNone .NO_VALUE ) {
181
178
Object result = callLen .executeObject (frame , lenDescr , object );
182
179
int len = convertLen (frame , indexNode , castLossy , asSizeNode , result );
0 commit comments