Skip to content

Commit 51e9aa1

Browse files
committed
Define dictoffset for type
1 parent c93c402 commit 51e9aa1

File tree

1 file changed

+9
-9
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+9
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
*/
4141
package com.oracle.graal.python.builtins.objects.type;
4242

43-
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBaseException;
4443
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
4544
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
4645
import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_SUBCLASS_CHECK;
@@ -2603,14 +2602,15 @@ static long lookup(Object cls,
26032602
}
26042603

26052604
private static int getBuiltinDictoffset(PythonBuiltinClassType cls) {
2606-
// TODO properly specify for all builtin classes
2607-
PythonBuiltinClassType current = cls;
2608-
do {
2609-
if (current == PBaseException) {
2610-
return 16;
2611-
}
2612-
} while ((current = current.getBase()) != null);
2613-
return 0;
2605+
if (!cls.isBuiltinWithDict()) {
2606+
return 0;
2607+
}
2608+
// TODO there are more builtins with dict
2609+
return switch (cls) {
2610+
case PBaseException, PythonModule -> 16;
2611+
case PythonClass -> 264;
2612+
default -> cls.getBase() != null ? getBuiltinDictoffset(cls.getBase()) : 0;
2613+
};
26142614
}
26152615
}
26162616

0 commit comments

Comments
 (0)