Skip to content

Commit c5ab7ea

Browse files
eregonansalond
authored andcommitted
Make it easier to set the base in PythonBuiltinClassType
(cherry picked from commit bcd576f)
1 parent 17c4bf0 commit c5ab7ea

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ public enum PythonBuiltinClassType implements TruffleObject {
302302

303303
// Foreign
304304
ForeignObject("ForeignObject", J_POLYGLOT, Flags.PUBLIC_BASE_WDICT, ForeignObjectBuiltins.SLOTS),
305-
ForeignNumber("ForeignNumber", J_POLYGLOT, Flags.PUBLIC_BASE_WDICT, FOREIGNNUMBER_M_FLAGS, ForeignNumberBuiltins.SLOTS),
306-
ForeignBoolean("ForeignBoolean", J_POLYGLOT, Flags.PUBLIC_BASE_WDICT, FOREIGNNUMBER_M_FLAGS, ForeignBooleanBuiltins.SLOTS),
307-
ForeignAbstractClass("ForeignAbstractClass", J_POLYGLOT, Flags.PUBLIC_BASE_WDICT),
305+
ForeignNumber("ForeignNumber", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT, FOREIGNNUMBER_M_FLAGS, ForeignNumberBuiltins.SLOTS),
306+
ForeignBoolean("ForeignBoolean", J_POLYGLOT, ForeignNumber, Flags.PUBLIC_BASE_WDICT, FOREIGNNUMBER_M_FLAGS, ForeignBooleanBuiltins.SLOTS),
307+
ForeignAbstractClass("ForeignAbstractClass", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT),
308308

309309
// bz2
310310
BZ2Compressor("BZ2Compressor", "_bz2"),
@@ -628,6 +628,11 @@ private static class Flags {
628628
this(name, module, module, flags);
629629
}
630630

631+
PythonBuiltinClassType(String name, String module, PythonBuiltinClassType base, Flags flags) {
632+
this(name, module, module, flags);
633+
this.base = base;
634+
}
635+
631636
PythonBuiltinClassType(String name, String module, Flags flags, TpSlots slots) {
632637
this(name, module, module, flags, DEFAULT_M_FLAGS, slots);
633638
}
@@ -640,6 +645,11 @@ private static class Flags {
640645
this(name, module, module, flags, methodsFlags, slots);
641646
}
642647

648+
PythonBuiltinClassType(String name, String module, PythonBuiltinClassType base, Flags flags, long methodsFlags, TpSlots slots) {
649+
this(name, module, module, flags, methodsFlags, slots);
650+
this.base = base;
651+
}
652+
643653
PythonBuiltinClassType(String name, String publishInModule, String moduleName, Flags flags) {
644654
this(name, publishInModule, moduleName, flags, DEFAULT_M_FLAGS, TpSlots.createEmpty());
645655
}
@@ -838,10 +848,6 @@ public final Shape getInstanceShape(PythonLanguage lang) {
838848

839849
Boolean.base = PInt;
840850

841-
ForeignNumber.base = ForeignObject;
842-
ForeignBoolean.base = ForeignNumber;
843-
ForeignAbstractClass.base = ForeignObject;
844-
845851
PBaseExceptionGroup.base = PBaseException;
846852
SystemExit.base = PBaseException;
847853
KeyboardInterrupt.base = PBaseException;

0 commit comments

Comments
 (0)