65
65
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeMember .TP_NAME ;
66
66
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeMember .TP_SUBCLASSES ;
67
67
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeMember .TP_VECTORCALL_OFFSET ;
68
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_CALL ;
69
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_GETATTRO ;
70
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_HASH ;
71
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_INIT ;
72
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_ITER ;
73
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_ITERNEXT ;
74
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_REPR ;
75
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_SETATTRO ;
76
- import static com .oracle .graal .python .builtins .objects .cext .capi .SlotMethodDef .TP_STR ;
77
68
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___BASICSIZE__ ;
78
69
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___DICTOFFSET__ ;
79
70
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___ITEMSIZE__ ;
@@ -404,12 +395,17 @@ protected static boolean eq(NativeMember expected, String actual) {
404
395
return expected .getMemberNameJavaString ().equals (actual );
405
396
}
406
397
398
+ protected static boolean eq (SlotMethodDef expected , String actual ) {
399
+ return expected .getMemberNameJavaString ().equals (actual );
400
+ }
401
+
407
402
protected final PythonContext getContext () {
408
403
return PythonContext .get (this );
409
404
}
410
405
}
411
406
412
407
@ GenerateUncached
408
+ @ ImportStatic (SlotMethodDef .class )
413
409
abstract static class ReadTypeNativeMemberNode extends ReadNativeMemberNode {
414
410
415
411
public static final TruffleString T_SEQUENCE_CLEAR = tsLiteral ("sequence_clear" );
@@ -514,9 +510,9 @@ Object doTpAsBuffer(PythonManagedClass object, @SuppressWarnings("unused") Pytho
514
510
515
511
@ Specialization (guards = "eq(TP_AS_SEQUENCE, key)" )
516
512
Object doTpAsSequence (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
517
- @ Cached LookupNativeSlotNode lookupLen ) {
513
+ @ Cached ( parameters = "SQ_LENGTH" ) LookupNativeSlotNode lookupLen ) {
518
514
Object nativeNull = getContext ().getNativeNull ().getPtr ();
519
- if (lookupLen .execute (object , SlotMethodDef . SQ_LENGTH ) != nativeNull ) {
515
+ if (lookupLen .execute (object ) != nativeNull ) {
520
516
return new PySequenceMethodsWrapper (object );
521
517
} else {
522
518
return nativeNull ;
@@ -525,9 +521,9 @@ Object doTpAsSequence(PythonManagedClass object, @SuppressWarnings("unused") Pyt
525
521
526
522
@ Specialization (guards = "eq(TP_AS_MAPPING, key)" )
527
523
Object doTpAsMapping (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
528
- @ Cached LookupNativeSlotNode lookupLen ) {
524
+ @ Cached ( parameters = "MP_LENGTH" ) LookupNativeSlotNode lookupLen ) {
529
525
Object nativeNull = getContext ().getNativeNull ().getPtr ();
530
- if (lookupLen .execute (object , SlotMethodDef . MP_LENGTH ) != nativeNull ) {
526
+ if (lookupLen .execute (object ) != nativeNull ) {
531
527
return new PyMappingMethodsWrapper (object );
532
528
} else {
533
529
return nativeNull ;
@@ -550,14 +546,14 @@ static Object doTpNew(PythonManagedClass object, @SuppressWarnings("unused") Pyt
550
546
551
547
@ Specialization (guards = "eq(TP_INIT, key)" )
552
548
static Object doTpInit (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
553
- @ Cached LookupNativeSlotNode lookup ) {
554
- return lookup .execute (object , TP_INIT );
549
+ @ Cached ( parameters = "TP_INIT" ) LookupNativeSlotNode lookup ) {
550
+ return lookup .execute (object );
555
551
}
556
552
557
553
@ Specialization (guards = "eq(TP_HASH, key)" )
558
554
static Object doTpHash (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
559
- @ Cached LookupNativeSlotNode lookup ) {
560
- return lookup .execute (object , TP_HASH );
555
+ @ Cached ( parameters = "TP_HASH" ) LookupNativeSlotNode lookup ) {
556
+ return lookup .execute (object );
561
557
}
562
558
563
559
@ Specialization (guards = "eq(TP_BASICSIZE, key)" )
@@ -655,38 +651,38 @@ static Object doTpSetattr(@SuppressWarnings("unused") PythonManagedClass object,
655
651
656
652
@ Specialization (guards = "eq(TP_GETATTRO, key)" )
657
653
static Object doTpGetattro (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
658
- @ Cached LookupNativeSlotNode lookup ) {
659
- return lookup .execute (object , TP_GETATTRO );
654
+ @ Cached ( parameters = "TP_GETATTRO" ) LookupNativeSlotNode lookup ) {
655
+ return lookup .execute (object );
660
656
}
661
657
662
658
@ Specialization (guards = "eq(TP_SETATTRO, key)" )
663
659
static Object doTpSetattro (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
664
- @ Cached LookupNativeSlotNode lookup ) {
665
- return lookup .execute (object , TP_SETATTRO );
660
+ @ Cached ( parameters = "TP_SETATTRO" ) LookupNativeSlotNode lookup ) {
661
+ return lookup .execute (object );
666
662
}
667
663
668
664
@ Specialization (guards = "eq(TP_ITER, key)" )
669
665
static Object doTpIter (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
670
- @ Cached LookupNativeSlotNode lookup ) {
671
- return lookup .execute (object , TP_ITER );
666
+ @ Cached ( parameters = "TP_ITER" ) LookupNativeSlotNode lookup ) {
667
+ return lookup .execute (object );
672
668
}
673
669
674
670
@ Specialization (guards = "eq(TP_ITERNEXT, key)" )
675
671
static Object doTpIternext (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
676
- @ Cached LookupNativeSlotNode lookup ) {
677
- return lookup .execute (object , TP_ITERNEXT );
672
+ @ Cached ( parameters = "TP_ITERNEXT" ) LookupNativeSlotNode lookup ) {
673
+ return lookup .execute (object );
678
674
}
679
675
680
676
@ Specialization (guards = "eq(TP_STR, key)" )
681
677
static Object doTpStr (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
682
- @ Cached LookupNativeSlotNode lookup ) {
683
- return lookup .execute (object , TP_STR );
678
+ @ Cached ( parameters = "TP_STR" ) LookupNativeSlotNode lookup ) {
679
+ return lookup .execute (object );
684
680
}
685
681
686
682
@ Specialization (guards = "eq(TP_REPR, key)" )
687
683
static Object doTpRepr (PythonManagedClass object , @ SuppressWarnings ("unused" ) PythonNativeWrapper nativeWrapper , @ SuppressWarnings ("unused" ) String key ,
688
- @ Cached LookupNativeSlotNode lookup ) {
689
- return lookup .execute (object , TP_REPR );
684
+ @ Cached ( parameters = "TP_REPR" ) LookupNativeSlotNode lookup ) {
685
+ return lookup .execute (object );
690
686
}
691
687
692
688
@ Specialization (guards = "eq(TP_DICT, key)" )
@@ -732,8 +728,8 @@ static Object doTpTraverse(PythonManagedClass object, @SuppressWarnings("unused"
732
728
@ Specialization (guards = "eq(TP_CALL, key)" )
733
729
@ SuppressWarnings ("unused" )
734
730
static Object doTpCall (PythonManagedClass object , PythonNativeWrapper nativeWrapper , String key ,
735
- @ Cached LookupNativeSlotNode lookup ) {
736
- return lookup .execute (object , TP_CALL );
731
+ @ Cached ( parameters = "TP_CALL" ) LookupNativeSlotNode lookup ) {
732
+ return lookup .execute (object );
737
733
}
738
734
739
735
@ Specialization (guards = "eq(TP_MRO, key)" )
0 commit comments