|
27 | 27 | package com.oracle.graal.python.builtins.objects.type;
|
28 | 28 |
|
29 | 29 | import static com.oracle.graal.python.builtins.objects.PNone.NO_VALUE;
|
| 30 | +import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyHeapTypeObject__ht_qualname; |
30 | 31 | import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_name;
|
31 | 32 | import static com.oracle.graal.python.nodes.BuiltinNames.T_BUILTINS;
|
32 | 33 | import static com.oracle.graal.python.nodes.HiddenAttr.ALLOC;
|
@@ -1255,19 +1256,25 @@ static Object setName(PythonClass cls, Object value,
|
1255 | 1256 | }
|
1256 | 1257 |
|
1257 | 1258 | @Specialization(guards = "isNoValue(value)")
|
1258 |
| - static TruffleString getNative(PythonNativeClass cls, @SuppressWarnings("unused") PNone value, |
| 1259 | + static Object getNative(PythonNativeClass cls, @SuppressWarnings("unused") PNone value, |
| 1260 | + @Cached GetTypeFlagsNode getTypeFlagsNode, |
| 1261 | + @Cached CStructAccess.ReadObjectNode getHtName, |
1259 | 1262 | @Cached CStructAccess.ReadCharPtrNode getTpNameNode,
|
1260 | 1263 | @Cached TruffleString.CodePointLengthNode codePointLengthNode,
|
1261 | 1264 | @Cached TruffleString.IndexOfCodePointNode indexOfCodePointNode,
|
1262 | 1265 | @Cached TruffleString.SubstringNode substringNode) {
|
1263 |
| - // 'tp_name' contains the fully-qualified name, i.e., 'module.A.B...' |
1264 |
| - TruffleString tpName = getTpNameNode.readFromObj(cls, PyTypeObject__tp_name); |
1265 |
| - int nameLen = codePointLengthNode.execute(tpName, TS_ENCODING); |
1266 |
| - int firstDot = indexOfCodePointNode.execute(tpName, '.', 0, nameLen, TS_ENCODING); |
1267 |
| - if (firstDot < 0) { |
1268 |
| - return tpName; |
| 1266 | + if ((getTypeFlagsNode.execute(cls) & TypeFlags.HEAPTYPE) != 0) { |
| 1267 | + return getHtName.readFromObj(cls, PyHeapTypeObject__ht_qualname); |
| 1268 | + } else { |
| 1269 | + // 'tp_name' contains the fully-qualified name, i.e., 'module.A.B...' |
| 1270 | + TruffleString tpName = getTpNameNode.readFromObj(cls, PyTypeObject__tp_name); |
| 1271 | + int nameLen = codePointLengthNode.execute(tpName, TS_ENCODING); |
| 1272 | + int firstDot = indexOfCodePointNode.execute(tpName, '.', 0, nameLen, TS_ENCODING); |
| 1273 | + if (firstDot < 0) { |
| 1274 | + return tpName; |
| 1275 | + } |
| 1276 | + return substringNode.execute(tpName, firstDot + 1, nameLen - firstDot - 1, TS_ENCODING, true); |
1269 | 1277 | }
|
1270 |
| - return substringNode.execute(tpName, firstDot + 1, nameLen - firstDot - 1, TS_ENCODING, true); |
1271 | 1278 | }
|
1272 | 1279 |
|
1273 | 1280 | @Specialization(guards = "!isNoValue(value)")
|
|
0 commit comments