5555import static com .oracle .graal .python .builtins .objects .cext .capi .transitions .ArgDescriptor .PyObjectTransfer ;
5656import static com .oracle .graal .python .builtins .objects .cext .capi .transitions .ArgDescriptor .PyTypeObject ;
5757import 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 ;
5859import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
5960import static com .oracle .graal .python .util .PythonUtils .tsArray ;
6061import static com .oracle .graal .python .util .PythonUtils .tsLiteral ;
@@ -807,8 +808,16 @@ public String getSignature() {
807808 }
808809 }
809810
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+
810819 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 );
812821
813822 private MethDirectRoot (PythonLanguage lang , TruffleString name , PExternalFunctionWrapper provider ) {
814823 super (lang , name , true , provider );
@@ -1117,7 +1126,7 @@ protected final Object readSelf(VirtualFrame frame) {
11171126 }
11181127
11191128 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 );
11211130 @ Child private PythonObjectFactory factory ;
11221131 @ Child private ReadVarArgsNode readVarargsNode ;
11231132 @ Child private ReadVarKeywordsNode readKwargsNode ;
@@ -1165,7 +1174,7 @@ public Signature getSignature() {
11651174 }
11661175
11671176 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 );
11691178 @ Child private PythonObjectFactory factory ;
11701179 @ Child private ReadVarArgsNode readVarargsNode ;
11711180 @ Child private CreateArgsTupleNode createArgsTupleNode ;
@@ -1259,7 +1268,7 @@ public Signature getSignature() {
12591268 }
12601269
12611270 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 );
12631272
12641273 public MethInquiryRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
12651274 super (language , name , isStatic );
@@ -1286,7 +1295,7 @@ public Signature getSignature() {
12861295 }
12871296
12881297 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 );
12901299
12911300 public MethNoargsRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
12921301 super (language , name , isStatic );
@@ -1313,7 +1322,7 @@ public Signature getSignature() {
13131322 }
13141323
13151324 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 );
13171326 @ Child private ReadIndexedArgumentNode readArgNode ;
13181327
13191328 public MethORoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
@@ -1346,7 +1355,7 @@ public Signature getSignature() {
13461355 }
13471356
13481357 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 );
13501359 @ Child private PythonObjectFactory factory ;
13511360 @ Child private ReadVarArgsNode readVarargsNode ;
13521361 @ Child private ReadVarKeywordsNode readKwargsNode ;
@@ -1393,7 +1402,7 @@ public Signature getSignature() {
13931402 }
13941403
13951404 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 );
13971406 @ Child private PythonObjectFactory factory ;
13981407 @ Child private ReadIndexedArgumentNode readClsNode ;
13991408 @ Child private ReadVarArgsNode readVarargsNode ;
@@ -1444,7 +1453,7 @@ public Signature getSignature() {
14441453 }
14451454
14461455 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 );
14481457 @ Child private ReadVarArgsNode readVarargsNode ;
14491458
14501459 public MethFastcallRoot (PythonLanguage language , TruffleString name , boolean isStatic ) {
@@ -1481,7 +1490,7 @@ public Signature getSignature() {
14811490 * Wrapper root node for C function type {@code allocfunc} and {@code ssizeargfunc}.
14821491 */
14831492 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 );
14851494 @ Child private ReadIndexedArgumentNode readArgNode ;
14861495 @ Child private ConvertPIntToPrimitiveNode asSsizeTNode ;
14871496
@@ -1521,7 +1530,7 @@ public Signature getSignature() {
15211530 * Wrapper root node for a get attribute function (C type {@code getattrfunc}).
15221531 */
15231532 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 );
15251534 @ Child private ReadIndexedArgumentNode readArgNode ;
15261535 @ Child private CExtNodes .AsCharPointerNode asCharPointerNode ;
15271536 @ Child private CStructAccess .FreeNode free ;
@@ -1562,7 +1571,7 @@ public Signature getSignature() {
15621571 * Wrapper root node for a set attribute function (C type {@code setattrfunc}).
15631572 */
15641573 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 );
15661575 @ Child private ReadIndexedArgumentNode readArg1Node ;
15671576 @ Child private ReadIndexedArgumentNode readArg2Node ;
15681577 @ Child private CExtNodes .AsCharPointerNode asCharPointerNode ;
@@ -1608,7 +1617,7 @@ public Signature getSignature() {
16081617 * Wrapper root node for a rich compare function (C type {@code richcmpfunc}).
16091618 */
16101619 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 );
16121621 @ Child private ReadIndexedArgumentNode readArg1Node ;
16131622 @ Child private ReadIndexedArgumentNode readArg2Node ;
16141623 @ Child private ConvertPIntToPrimitiveNode asSsizeTNode ;
@@ -1653,7 +1662,7 @@ public Signature getSignature() {
16531662 * Implements semantics of {@code typeobject.c: wrap_sq_item}.
16541663 */
16551664 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 );
16571666 @ Child private ReadIndexedArgumentNode readArg1Node ;
16581667 @ Child private GetIndexNode getIndexNode ;
16591668
@@ -1689,7 +1698,7 @@ public Signature getSignature() {
16891698 * Implements semantics of {@code typeobject.c: wrap_sq_setitem}.
16901699 */
16911700 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 );
16931702 @ Child private ReadIndexedArgumentNode readArg1Node ;
16941703 @ Child private ReadIndexedArgumentNode readArg2Node ;
16951704 @ Child private GetIndexNode getIndexNode ;
@@ -1730,7 +1739,7 @@ public Signature getSignature() {
17301739 * Implements semantics of {@code typeobject.c:wrap_descr_get}
17311740 */
17321741 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 );
17341743 @ Child private ReadIndexedArgumentNode readObj ;
17351744 @ Child private ReadIndexedArgumentNode readType ;
17361745
@@ -1770,7 +1779,7 @@ public Signature getSignature() {
17701779 * Implements semantics of {@code typeobject.c:wrap_descr_delete}
17711780 */
17721781 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 );
17741783 @ Child private ReadIndexedArgumentNode readObj ;
17751784
17761785 public DescrDeleteRootNode (PythonLanguage language , TruffleString name ) {
@@ -1806,7 +1815,7 @@ public Signature getSignature() {
18061815 * Implements semantics of {@code typeobject.c:wrap_delattr}
18071816 */
18081817 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 );
18101819 @ Child private ReadIndexedArgumentNode readObj ;
18111820
18121821 public DelAttrRootNode (PythonLanguage language , TruffleString name ) {
@@ -1844,7 +1853,7 @@ public Signature getSignature() {
18441853 * NULL 3rd argument.
18451854 */
18461855 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 );
18481857 @ Child private ReadIndexedArgumentNode readArg1Node ;
18491858
18501859 MpDelItemRootNode (PythonLanguage language , TruffleString name ) {
@@ -1881,7 +1890,7 @@ public Signature getSignature() {
18811890 * Wrapper root node for reverse binary operations.
18821891 */
18831892 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 );
18851894 @ Child private ReadIndexedArgumentNode readArg0Node ;
18861895 @ Child private ReadIndexedArgumentNode readArg1Node ;
18871896
@@ -1928,7 +1937,7 @@ public Signature getSignature() {
19281937 * Wrapper root node for native power function (with an optional third argument).
19291938 */
19301939 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 );
19321941
19331942 @ Child private ReadVarArgsNode readVarargsNode ;
19341943
@@ -1995,7 +2004,7 @@ Object[] getArguments(Object arg0, Object arg1, Object arg2) {
19952004 * Wrapper root node for native power function (with an optional third argument).
19962005 */
19972006 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 );
19992008 @ Child private ReadIndexedArgumentNode readArgNode ;
20002009
20012010 private final int op ;
@@ -2093,7 +2102,7 @@ protected final Object readClosure(VirtualFrame frame) {
20932102 * Wrapper root node for C function type {@code getter}.
20942103 */
20952104 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 );
20972106
20982107 public GetterRoot (PythonLanguage language , TruffleString name , PExternalFunctionWrapper provider ) {
20992108 super (language , name , provider );
@@ -2120,7 +2129,7 @@ public Signature getSignature() {
21202129 * Wrapper root node for C function type {@code setter}.
21212130 */
21222131 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 );
21242133
21252134 @ Child private ReadIndexedArgumentNode readArgNode ;
21262135
0 commit comments