@@ -310,7 +310,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
310
310
When called, it accepts no arguments and returns a new featureless
311
311
instance that has no instance attributes and cannot be given any.
312
312
""" )),
313
- PythonClass ("type" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict ().slots (TypeBuiltins .SLOTS ).doc ("""
313
+ PythonClass ("type" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict (264 ).slots (TypeBuiltins .SLOTS ).doc ("""
314
314
type(object) -> the object's type
315
315
type(name, bases, dict, **kwds) -> a new type""" )),
316
316
PArray ("array" , PythonObject , newBuilder ().publishInModule ("array" ).basetype ().slots (ArrayBuiltins .SLOTS )),
@@ -361,7 +361,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
361
361
- any object implementing the buffer API.
362
362
- an integer""" )),
363
363
PCell ("cell" , PythonObject , newBuilder ().slots (CellBuiltins .SLOTS )),
364
- PSimpleNamespace ("SimpleNamespace" , PythonObject , newBuilder ().publishInModule ("types" ).basetype ().addDict ().slots (SimpleNamespaceBuiltins .SLOTS ).doc ("""
364
+ PSimpleNamespace ("SimpleNamespace" , PythonObject , newBuilder ().publishInModule ("types" ).basetype ().addDict (16 ).slots (SimpleNamespaceBuiltins .SLOTS ).doc ("""
365
365
A simple attribute-based namespace.
366
366
367
367
SimpleNamespace(**kwargs)""" )),
@@ -405,7 +405,7 @@ This is equivalent to (real + imag*1j) where imag defaults to 0.""")),
405
405
dict(**kwargs) -> new dictionary initialized with the name=value pairs
406
406
in the keyword argument list. For example: dict(one=1, two=2)""" )),
407
407
PDefaultDict (J_DEFAULTDICT , PDict , newBuilder ().moduleName ("collections" ).publishInModule ("_collections" ).basetype ().slots (DefaultDictBuiltins .SLOTS )),
408
- POrderedDict (J_ORDERED_DICT , PDict , newBuilder ().publishInModule ("_collections" ).basetype ().addDict ().slots (OrderedDictBuiltins .SLOTS )),
408
+ POrderedDict (J_ORDERED_DICT , PDict , newBuilder ().publishInModule ("_collections" ).basetype ().addDict (96 ).slots (OrderedDictBuiltins .SLOTS )),
409
409
PDictItemIterator (J_DICT_ITEMITERATOR , PythonObject , newBuilder ().disallowInstantiation ().slots (IteratorBuiltins .SLOTS )),
410
410
PDictReverseItemIterator (J_DICT_REVERSE_ITEMITERATOR , PythonObject , newBuilder ().slots (IteratorBuiltins .SLOTS )),
411
411
PDictItemsView (J_DICT_ITEMS , PythonObject , newBuilder ().disallowInstantiation ().slots (DictViewBuiltins .SLOTS , DictReprBuiltin .SLOTS )),
@@ -579,7 +579,7 @@ or repr(object).
579
579
If iterable is specified the tuple is initialized from iterable's items.
580
580
581
581
If the argument is a tuple, the return value is the same object.""" )),
582
- PythonModule ("module" , PythonObject , newBuilder ().basetype ().addDict ().slots (ModuleBuiltins .SLOTS ).doc ("""
582
+ PythonModule ("module" , PythonObject , newBuilder ().basetype ().addDict (16 ).slots (ModuleBuiltins .SLOTS ).doc ("""
583
583
Create a module object.
584
584
585
585
The name must be a string; the optional doc argument can have any type.""" )),
@@ -624,7 +624,7 @@ passed as positional arguments to zip(). The i-th element in every tuple
624
624
PSemLock ("SemLock" , PythonObject , newBuilder ().publishInModule ("_multiprocessing" ).basetype ().slots (SemLockBuiltins .SLOTS )),
625
625
PGraalPySemLock ("SemLock" , PythonObject , newBuilder ().publishInModule ("_multiprocessing_graalpy" ).basetype ().slots (GraalPySemLockBuiltins .SLOTS )),
626
626
PSocket ("socket" , PythonObject , newBuilder ().publishInModule (J__SOCKET ).basetype ().slots (SocketBuiltins .SLOTS )),
627
- PStaticmethod ("staticmethod" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict ().slots (StaticmethodBuiltins .SLOTS ).doc ("""
627
+ PStaticmethod ("staticmethod" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict (24 ).slots (StaticmethodBuiltins .SLOTS ).doc ("""
628
628
staticmethod(function) -> method
629
629
630
630
Convert a function to be a static method.
@@ -643,7 +643,7 @@ It can be called either on the class (e.g. C.f()) or on an instance
643
643
644
644
Static methods in Python are similar to those found in Java or C++.
645
645
For a more advanced concept, see the classmethod builtin.""" )),
646
- PClassmethod ("classmethod" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict ().slots (ClassmethodCommonBuiltins .SLOTS , ClassmethodBuiltins .SLOTS ).doc ("""
646
+ PClassmethod ("classmethod" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict (24 ).slots (ClassmethodCommonBuiltins .SLOTS , ClassmethodBuiltins .SLOTS ).doc ("""
647
647
classmethod(function) -> method
648
648
649
649
Convert a function to be a class method.
@@ -715,7 +715,7 @@ It can be called either on the class (e.g. C.f()) or on an instance
715
715
// Errors and exceptions:
716
716
717
717
// everything after BaseException is considered to be an exception
718
- PBaseException ("BaseException" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict ().slots (BaseExceptionBuiltins .SLOTS ).doc ("""
718
+ PBaseException ("BaseException" , PythonObject , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict (16 ).slots (BaseExceptionBuiltins .SLOTS ).doc ("""
719
719
Common base class for all exceptions""" )),
720
720
PBaseExceptionGroup ("BaseExceptionGroup" , PBaseException , newBuilder ().publishInModule (J_BUILTINS ).basetype ().addDict ().slots (BaseExceptionGroupBuiltins .SLOTS ).doc ("""
721
721
A combination of multiple unrelated exceptions.""" )),
@@ -1440,6 +1440,7 @@ private static final class TypeBuilder {
1440
1440
private boolean basetype ;
1441
1441
private boolean heaptype ;
1442
1442
private boolean addDict ;
1443
+ private int dictoffset ;
1443
1444
private boolean disallowInstantiation ;
1444
1445
private TpSlots slots ;
1445
1446
private String doc ;
@@ -1472,6 +1473,12 @@ public TypeBuilder addDict() {
1472
1473
return this ;
1473
1474
}
1474
1475
1476
+ public TypeBuilder addDict (int dictoffset ) {
1477
+ this .addDict = true ;
1478
+ this .dictoffset = dictoffset ;
1479
+ return this ;
1480
+ }
1481
+
1475
1482
public TypeBuilder disallowInstantiation () {
1476
1483
this .disallowInstantiation = true ;
1477
1484
return this ;
@@ -1507,6 +1514,7 @@ public TypeBuilder doc(String doc) {
1507
1514
private final TruffleString printName ;
1508
1515
private final boolean basetype ;
1509
1516
private final boolean isBuiltinWithDict ;
1517
+ private final int dictoffset ;
1510
1518
private final boolean disallowInstantiation ;
1511
1519
private final TruffleString doc ;
1512
1520
@@ -1536,6 +1544,13 @@ public TypeBuilder doc(String doc) {
1536
1544
}
1537
1545
this .basetype = builder .basetype ;
1538
1546
this .isBuiltinWithDict = builder .addDict ;
1547
+ int dictoffset = 0 ;
1548
+ if (builder .dictoffset != 0 ) {
1549
+ dictoffset = builder .dictoffset ;
1550
+ } else if (base != null ) {
1551
+ dictoffset = base .dictoffset ;
1552
+ }
1553
+ this .dictoffset = dictoffset ;
1539
1554
this .weaklistoffset = -1 ;
1540
1555
this .declaredSlots = builder .slots != null ? builder .slots : TpSlots .createEmpty ();
1541
1556
boolean disallowInstantiation = builder .disallowInstantiation ;
@@ -1582,6 +1597,10 @@ public boolean isBuiltinWithDict() {
1582
1597
return isBuiltinWithDict ;
1583
1598
}
1584
1599
1600
+ public int getDictoffset () {
1601
+ return dictoffset ;
1602
+ }
1603
+
1585
1604
public boolean disallowInstantiation () {
1586
1605
return disallowInstantiation ;
1587
1606
}
0 commit comments