|
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.runtime.PythonContext; |
| 54 | +import com.oracle.graal.python.runtime.PythonOptions; |
51 | 55 | import com.oracle.truffle.api.RootCallTarget;
|
52 | 56 | import com.oracle.truffle.api.dsl.Cached;
|
| 57 | +import com.oracle.truffle.api.dsl.CachedContext; |
53 | 58 | import com.oracle.truffle.api.dsl.Fallback;
|
54 | 59 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
55 | 60 | import com.oracle.truffle.api.dsl.Specialization;
|
@@ -210,6 +215,22 @@ boolean doCode(PCode left, PCode right) {
|
210 | 215 | return left == right;
|
211 | 216 | }
|
212 | 217 |
|
| 218 | + @Specialization |
| 219 | + boolean doObjectPNone(Object left, PNone right, |
| 220 | + @Cached.Shared("ctxt") @CachedContext(PythonLanguage.class) PythonContext ctxt) { |
| 221 | + if (PythonOptions.getFlag(ctxt, PythonOptions.EmulateJython) && ctxt.getEnv().isHostObject(left) && ctxt.getEnv().asHostObject(left) == null && |
| 222 | + right == PNone.NONE) { |
| 223 | + return true; |
| 224 | + } |
| 225 | + return doGeneric(left, right); |
| 226 | + } |
| 227 | + |
| 228 | + @Specialization |
| 229 | + boolean doPNoneObject(PNone left, Object right, |
| 230 | + @CachedContext(PythonLanguage.class) PythonContext ctxt) { |
| 231 | + return doObjectPNone(right, left, ctxt); |
| 232 | + } |
| 233 | + |
213 | 234 | @Fallback
|
214 | 235 | boolean doGeneric(Object left, Object right) {
|
215 | 236 | return left == right;
|
|
0 commit comments