1
1
/*
2
- * Copyright (c) 2018, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
40
40
*/
41
41
package com .oracle .graal .python .nodes .expression ;
42
42
43
+ import com .oracle .graal .python .PythonLanguage ;
43
44
import static com .oracle .graal .python .nodes .SpecialMethodNames .__EQ__ ;
44
45
45
46
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
47
+ import com .oracle .graal .python .builtins .objects .PNone ;
46
48
import com .oracle .graal .python .builtins .objects .cext .CExtNodes ;
47
49
import com .oracle .graal .python .builtins .objects .cext .PythonAbstractNativeObject ;
48
50
import com .oracle .graal .python .builtins .objects .code .PCode ;
49
51
import com .oracle .graal .python .builtins .objects .ints .PInt ;
50
52
import com .oracle .graal .python .builtins .objects .type .PythonBuiltinClass ;
53
+ import com .oracle .graal .python .nodes .PGuards ;
54
+ import com .oracle .graal .python .runtime .PythonContext ;
55
+ import com .oracle .graal .python .runtime .PythonOptions ;
51
56
import com .oracle .truffle .api .RootCallTarget ;
52
57
import com .oracle .truffle .api .dsl .Cached ;
58
+ import com .oracle .truffle .api .dsl .CachedContext ;
53
59
import com .oracle .truffle .api .dsl .Fallback ;
54
60
import com .oracle .truffle .api .dsl .GenerateUncached ;
61
+ import com .oracle .truffle .api .dsl .ImportStatic ;
55
62
import com .oracle .truffle .api .dsl .Specialization ;
56
63
import com .oracle .truffle .api .nodes .Node ;
57
64
@@ -67,6 +74,7 @@ boolean doIt(Object left, Object right,
67
74
}
68
75
69
76
@ GenerateUncached
77
+ @ ImportStatic ({PGuards .class })
70
78
public abstract static class IsNode extends Node {
71
79
72
80
public abstract boolean execute (Object left , Object right );
@@ -210,6 +218,22 @@ boolean doCode(PCode left, PCode right) {
210
218
return left == right ;
211
219
}
212
220
221
+ @ Specialization
222
+ boolean doObjectPNone (Object left , PNone right ,
223
+ @ CachedContext (PythonLanguage .class ) PythonContext ctxt ) {
224
+ if (PythonOptions .getFlag (ctxt , PythonOptions .EmulateJython ) && ctxt .getEnv ().isHostObject (left ) && ctxt .getEnv ().asHostObject (left ) == null &&
225
+ right == PNone .NONE ) {
226
+ return true ;
227
+ }
228
+ return doGeneric (left , right );
229
+ }
230
+
231
+ @ Specialization
232
+ boolean doPNoneObject (PNone left , Object right ,
233
+ @ CachedContext (PythonLanguage .class ) PythonContext ctxt ) {
234
+ return doObjectPNone (right , left , ctxt );
235
+ }
236
+
213
237
@ Fallback
214
238
boolean doGeneric (Object left , Object right ) {
215
239
return left == right ;
0 commit comments