55
55
import static com .oracle .graal .python .builtins .objects .cext .capi .transitions .ArgDescriptor .PyObjectTransfer ;
56
56
import static com .oracle .graal .python .builtins .objects .cext .capi .transitions .ArgDescriptor .PyTypeObject ;
57
57
import static com .oracle .graal .python .builtins .objects .cext .capi .transitions .ArgDescriptor .Py_ssize_t ;
58
+ import static com .oracle .graal .python .nodes .StringLiterals .T_EMPTY_STRING ;
58
59
import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
59
60
import static com .oracle .graal .python .util .PythonUtils .tsArray ;
60
61
import static com .oracle .graal .python .util .PythonUtils .tsLiteral ;
@@ -807,8 +808,16 @@ public String getSignature() {
807
808
}
808
809
}
809
810
811
+ private static Signature createSignature (boolean takesVarKeywordArgs , int varArgIndex , TruffleString [] parameters , boolean checkEnclosingType , boolean hidden ) {
812
+ return new Signature (-1 , takesVarKeywordArgs , varArgIndex , false , parameters , KEYWORDS_HIDDEN_CALLABLE , checkEnclosingType , T_EMPTY_STRING , hidden );
813
+ }
814
+
815
+ private static Signature createSignatureWithClosure (boolean takesVarKeywordArgs , int varArgIndex , TruffleString [] parameters , boolean checkEnclosingType , boolean hidden ) {
816
+ return new Signature (-1 , takesVarKeywordArgs , varArgIndex , false , parameters , KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE , checkEnclosingType , T_EMPTY_STRING , hidden );
817
+ }
818
+
810
819
static final class MethDirectRoot extends MethodDescriptorRoot {
811
- private static final Signature SIGNATURE = new Signature (- 1 , true , 0 , false , null , KEYWORDS_HIDDEN_CALLABLE );
820
+ private static final Signature SIGNATURE = createSignature ( true , 0 , null , false , true );
812
821
813
822
private MethDirectRoot (PythonLanguage lang , TruffleString name , PExternalFunctionWrapper provider ) {
814
823
super (lang , name , true , provider );
@@ -1117,7 +1126,7 @@ protected final Object readSelf(VirtualFrame frame) {
1117
1126
}
1118
1127
1119
1128
public static final class MethKeywordsRoot extends MethodDescriptorRoot {
1120
- private static final Signature SIGNATURE = new Signature (- 1 , true , 1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1129
+ private static final Signature SIGNATURE = createSignature ( true , 1 , tsArray ("self" ), true , true );
1121
1130
@ Child private PythonObjectFactory factory ;
1122
1131
@ Child private ReadVarArgsNode readVarargsNode ;
1123
1132
@ Child private ReadVarKeywordsNode readKwargsNode ;
@@ -1165,7 +1174,7 @@ public Signature getSignature() {
1165
1174
}
1166
1175
1167
1176
public static final class MethVarargsRoot extends MethodDescriptorRoot {
1168
- private static final Signature SIGNATURE = new Signature (- 1 , false , 1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1177
+ private static final Signature SIGNATURE = createSignature ( false , 1 , tsArray ("self" ), true , true );
1169
1178
@ Child private PythonObjectFactory factory ;
1170
1179
@ Child private ReadVarArgsNode readVarargsNode ;
1171
1180
@ Child private CreateArgsTupleNode createArgsTupleNode ;
@@ -1259,7 +1268,7 @@ public Signature getSignature() {
1259
1268
}
1260
1269
1261
1270
public static final class MethInquiryRoot extends MethodDescriptorRoot {
1262
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1271
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" ), true , false );
1263
1272
1264
1273
public MethInquiryRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
1265
1274
super (language , name , isStatic );
@@ -1286,7 +1295,7 @@ public Signature getSignature() {
1286
1295
}
1287
1296
1288
1297
public static final class MethNoargsRoot extends MethodDescriptorRoot {
1289
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1298
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" ), true , true );
1290
1299
1291
1300
public MethNoargsRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
1292
1301
super (language , name , isStatic );
@@ -1313,7 +1322,7 @@ public Signature getSignature() {
1313
1322
}
1314
1323
1315
1324
public static final class MethORoot extends MethodDescriptorRoot {
1316
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "arg" ), KEYWORDS_HIDDEN_CALLABLE , true );
1325
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "arg" ), true , true );
1317
1326
@ Child private ReadIndexedArgumentNode readArgNode ;
1318
1327
1319
1328
public MethORoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
@@ -1346,7 +1355,7 @@ public Signature getSignature() {
1346
1355
}
1347
1356
1348
1357
public static final class MethFastcallWithKeywordsRoot extends MethodDescriptorRoot {
1349
- private static final Signature SIGNATURE = new Signature (- 1 , true , 1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1358
+ private static final Signature SIGNATURE = createSignature ( true , 1 , tsArray ("self" ), true , true );
1350
1359
@ Child private PythonObjectFactory factory ;
1351
1360
@ Child private ReadVarArgsNode readVarargsNode ;
1352
1361
@ Child private ReadVarKeywordsNode readKwargsNode ;
@@ -1393,7 +1402,7 @@ public Signature getSignature() {
1393
1402
}
1394
1403
1395
1404
public static final class MethMethodRoot extends MethodDescriptorRoot {
1396
- private static final Signature SIGNATURE = new Signature (- 1 , true , 1 , false , tsArray ("self" , "cls" ), KEYWORDS_HIDDEN_CALLABLE , true );
1405
+ private static final Signature SIGNATURE = createSignature ( true , 1 , tsArray ("self" , "cls" ), true , true );
1397
1406
@ Child private PythonObjectFactory factory ;
1398
1407
@ Child private ReadIndexedArgumentNode readClsNode ;
1399
1408
@ Child private ReadVarArgsNode readVarargsNode ;
@@ -1444,7 +1453,7 @@ public Signature getSignature() {
1444
1453
}
1445
1454
1446
1455
public static final class MethFastcallRoot extends MethodDescriptorRoot {
1447
- private static final Signature SIGNATURE = new Signature (- 1 , false , 1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE , true );
1456
+ private static final Signature SIGNATURE = createSignature ( false , 1 , tsArray ("self" ), true , true );
1448
1457
@ Child private ReadVarArgsNode readVarargsNode ;
1449
1458
1450
1459
public MethFastcallRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
@@ -1481,7 +1490,7 @@ public Signature getSignature() {
1481
1490
* Wrapper root node for C function type {@code allocfunc} and {@code ssizeargfunc}.
1482
1491
*/
1483
1492
static class AllocFuncRootNode extends MethodDescriptorRoot {
1484
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "nitems" ), KEYWORDS_HIDDEN_CALLABLE , true );
1493
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "nitems" ), true , false );
1485
1494
@ Child private ReadIndexedArgumentNode readArgNode ;
1486
1495
@ Child private ConvertPIntToPrimitiveNode asSsizeTNode ;
1487
1496
@@ -1521,7 +1530,7 @@ public Signature getSignature() {
1521
1530
* Wrapper root node for a get attribute function (C type {@code getattrfunc}).
1522
1531
*/
1523
1532
static final class GetAttrFuncRootNode extends MethodDescriptorRoot {
1524
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "key" ), KEYWORDS_HIDDEN_CALLABLE , true );
1533
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "key" ), true , false );
1525
1534
@ Child private ReadIndexedArgumentNode readArgNode ;
1526
1535
@ Child private CExtNodes .AsCharPointerNode asCharPointerNode ;
1527
1536
@ Child private CStructAccess .FreeNode free ;
@@ -1562,7 +1571,7 @@ public Signature getSignature() {
1562
1571
* Wrapper root node for a set attribute function (C type {@code setattrfunc}).
1563
1572
*/
1564
1573
static final class SetAttrFuncRootNode extends MethodDescriptorRoot {
1565
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "key" , "value" ), KEYWORDS_HIDDEN_CALLABLE , true );
1574
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "key" , "value" ), true , false );
1566
1575
@ Child private ReadIndexedArgumentNode readArg1Node ;
1567
1576
@ Child private ReadIndexedArgumentNode readArg2Node ;
1568
1577
@ Child private CExtNodes .AsCharPointerNode asCharPointerNode ;
@@ -1608,7 +1617,7 @@ public Signature getSignature() {
1608
1617
* Wrapper root node for a rich compare function (C type {@code richcmpfunc}).
1609
1618
*/
1610
1619
static final class RichCmpFuncRootNode extends MethodDescriptorRoot {
1611
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "other" , "op" ), KEYWORDS_HIDDEN_CALLABLE , true );
1620
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "other" , "op" ), true , false );
1612
1621
@ Child private ReadIndexedArgumentNode readArg1Node ;
1613
1622
@ Child private ReadIndexedArgumentNode readArg2Node ;
1614
1623
@ Child private ConvertPIntToPrimitiveNode asSsizeTNode ;
@@ -1653,7 +1662,7 @@ public Signature getSignature() {
1653
1662
* Implements semantics of {@code typeobject.c: wrap_sq_item}.
1654
1663
*/
1655
1664
static final class GetItemRootNode extends MethodDescriptorRoot {
1656
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "i" ), KEYWORDS_HIDDEN_CALLABLE , true );
1665
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "i" ), true , false );
1657
1666
@ Child private ReadIndexedArgumentNode readArg1Node ;
1658
1667
@ Child private GetIndexNode getIndexNode ;
1659
1668
@@ -1689,7 +1698,7 @@ public Signature getSignature() {
1689
1698
* Implements semantics of {@code typeobject.c: wrap_sq_setitem}.
1690
1699
*/
1691
1700
static final class SetItemRootNode extends MethodDescriptorRoot {
1692
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "i" , "value" ), KEYWORDS_HIDDEN_CALLABLE , true );
1701
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "i" , "value" ), true , false );
1693
1702
@ Child private ReadIndexedArgumentNode readArg1Node ;
1694
1703
@ Child private ReadIndexedArgumentNode readArg2Node ;
1695
1704
@ Child private GetIndexNode getIndexNode ;
@@ -1730,7 +1739,7 @@ public Signature getSignature() {
1730
1739
* Implements semantics of {@code typeobject.c:wrap_descr_get}
1731
1740
*/
1732
1741
public static final class DescrGetRootNode extends MethodDescriptorRoot {
1733
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "obj" , "type" ), KEYWORDS_HIDDEN_CALLABLE , true );
1742
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "obj" , "type" ), true , false );
1734
1743
@ Child private ReadIndexedArgumentNode readObj ;
1735
1744
@ Child private ReadIndexedArgumentNode readType ;
1736
1745
@@ -1770,7 +1779,7 @@ public Signature getSignature() {
1770
1779
* Implements semantics of {@code typeobject.c:wrap_descr_delete}
1771
1780
*/
1772
1781
public static final class DescrDeleteRootNode extends MethodDescriptorRoot {
1773
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "obj" ), KEYWORDS_HIDDEN_CALLABLE , true );
1782
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "obj" ), true , false );
1774
1783
@ Child private ReadIndexedArgumentNode readObj ;
1775
1784
1776
1785
public DescrDeleteRootNode (PythonLanguage language , TruffleString name ) {
@@ -1806,7 +1815,7 @@ public Signature getSignature() {
1806
1815
* Implements semantics of {@code typeobject.c:wrap_delattr}
1807
1816
*/
1808
1817
public static final class DelAttrRootNode extends MethodDescriptorRoot {
1809
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "obj" ), KEYWORDS_HIDDEN_CALLABLE , true );
1818
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "obj" ), true , false );
1810
1819
@ Child private ReadIndexedArgumentNode readObj ;
1811
1820
1812
1821
public DelAttrRootNode (PythonLanguage language , TruffleString name ) {
@@ -1844,7 +1853,7 @@ public Signature getSignature() {
1844
1853
* NULL 3rd argument.
1845
1854
*/
1846
1855
static final class MpDelItemRootNode extends MethodDescriptorRoot {
1847
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "i" ), KEYWORDS_HIDDEN_CALLABLE , true );
1856
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "i" ), true , false );
1848
1857
@ Child private ReadIndexedArgumentNode readArg1Node ;
1849
1858
1850
1859
MpDelItemRootNode (PythonLanguage language , TruffleString name ) {
@@ -1881,7 +1890,7 @@ public Signature getSignature() {
1881
1890
* Wrapper root node for reverse binary operations.
1882
1891
*/
1883
1892
static final class MethReverseRootNode extends MethodDescriptorRoot {
1884
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "obj" ), KEYWORDS_HIDDEN_CALLABLE , true );
1893
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "obj" ), true , false );
1885
1894
@ Child private ReadIndexedArgumentNode readArg0Node ;
1886
1895
@ Child private ReadIndexedArgumentNode readArg1Node ;
1887
1896
@@ -1928,7 +1937,7 @@ public Signature getSignature() {
1928
1937
* Wrapper root node for native power function (with an optional third argument).
1929
1938
*/
1930
1939
static class MethPowRootNode extends MethodDescriptorRoot {
1931
- private static final Signature SIGNATURE = new Signature (false , 0 , false , tsArray ("args" ), KEYWORDS_HIDDEN_CALLABLE );
1940
+ private static final Signature SIGNATURE = createSignature (false , 0 , tsArray ("args" ), false , false );
1932
1941
1933
1942
@ Child private ReadVarArgsNode readVarargsNode ;
1934
1943
@@ -1995,7 +2004,7 @@ Object[] getArguments(Object arg0, Object arg1, Object arg2) {
1995
2004
* Wrapper root node for native power function (with an optional third argument).
1996
2005
*/
1997
2006
static final class MethRichcmpOpRootNode extends MethodDescriptorRoot {
1998
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "other" ), KEYWORDS_HIDDEN_CALLABLE , true );
2007
+ private static final Signature SIGNATURE = createSignature ( false , -1 , tsArray ("self" , "other" ), true , false );
1999
2008
@ Child private ReadIndexedArgumentNode readArgNode ;
2000
2009
2001
2010
private final int op ;
@@ -2093,7 +2102,7 @@ protected final Object readClosure(VirtualFrame frame) {
2093
2102
* Wrapper root node for C function type {@code getter}.
2094
2103
*/
2095
2104
public static class GetterRoot extends GetSetRootNode {
2096
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" ), KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE , true );
2105
+ private static final Signature SIGNATURE = createSignatureWithClosure ( false , -1 , tsArray ("self" ), true , false );
2097
2106
2098
2107
public GetterRoot (PythonLanguage language , TruffleString name , PExternalFunctionWrapper provider ) {
2099
2108
super (language , name , provider );
@@ -2120,7 +2129,7 @@ public Signature getSignature() {
2120
2129
* Wrapper root node for C function type {@code setter}.
2121
2130
*/
2122
2131
public static class SetterRoot extends GetSetRootNode {
2123
- private static final Signature SIGNATURE = new Signature (- 1 , false , -1 , false , tsArray ("self" , "value" ), KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE , true );
2132
+ private static final Signature SIGNATURE = createSignatureWithClosure ( false , -1 , tsArray ("self" , "value" ), true , false );
2124
2133
2125
2134
@ Child private ReadIndexedArgumentNode readArgNode ;
2126
2135
0 commit comments