59
59
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PyUnicodeData ;
60
60
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PyUnicodeState ;
61
61
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PythonClassInitNativeWrapper ;
62
+ import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PythonClassNativeWrapper ;
62
63
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PythonNativeWrapper ;
63
64
import com .oracle .graal .python .builtins .objects .cext .NativeWrappers .PythonObjectNativeWrapper ;
64
65
import com .oracle .graal .python .builtins .objects .cext .PythonObjectNativeWrapperMRFactory .PAsPointerNodeGen ;
@@ -856,7 +857,7 @@ abstract static class ToNativeNode extends Node {
856
857
857
858
Object access (PythonClassInitNativeWrapper obj ) {
858
859
if (!pIsPointerNode .execute (obj )) {
859
- obj .setNativePointer (getToPyObjectNode ().getHandleForObject (getMaterializeDelegateNode ().execute (obj ), 0 ));
860
+ obj .setNativePointer (getToPyObjectNode ().getHandleForObject (getMaterializeDelegateNode ().execute (obj )));
860
861
}
861
862
return obj ;
862
863
}
@@ -999,7 +1000,7 @@ abstract static class PToNativeNode extends PNodeWithContext {
999
1000
@ Specialization
1000
1001
PythonNativeWrapper doInitClass (PythonClassInitNativeWrapper obj ) {
1001
1002
if (!pIsPointerNode .execute (obj )) {
1002
- obj .setNativePointer (getToPyObjectNode ().getHandleForObject (getMaterializeDelegateNode ().execute (obj ), 0 ));
1003
+ obj .setNativePointer (getToPyObjectNode ().getHandleForObject (getMaterializeDelegateNode ().execute (obj )));
1003
1004
}
1004
1005
return obj ;
1005
1006
}
@@ -1050,34 +1051,18 @@ abstract static class ToPyObjectNode extends CExtBaseNode {
1050
1051
@ CompilationFinal private TruffleObject PyNoneHandle ;
1051
1052
@ Child private PCallNativeNode callNativeUnary ;
1052
1053
@ Child private PCallNativeNode callNativeBinary ;
1053
- @ Child private GetClassNode getClassNode ;
1054
1054
@ Child private CExtNodes .ToSulongNode toSulongNode ;
1055
1055
1056
- public abstract Object execute (Object value );
1056
+ public abstract Object execute (PythonNativeWrapper wrapper , Object value );
1057
1057
1058
- @ Specialization
1059
- Object runNativeClass (PythonNativeClass object ) {
1060
- return object .object ;
1061
- }
1062
-
1063
- @ Specialization
1064
- Object runNativeObject (PythonNativeObject object ) {
1065
- return object .object ;
1066
- }
1067
-
1068
- @ Specialization (guards = "isManagedPythonClass(object)" )
1069
- Object runClass (PythonClass object ) {
1070
- return callUnaryIntoCapi (getPyObjectHandle_ForJavaType (), getToSulongNode ().execute (object ));
1058
+ @ Specialization (guards = "isManagedPythonClass(wrapper)" )
1059
+ Object doClass (PythonClassNativeWrapper wrapper , PythonClass object ) {
1060
+ return callUnaryIntoCapi (getPyObjectHandle_ForJavaType (), wrapper );
1071
1061
}
1072
1062
1073
1063
@ Fallback
1074
- Object runObject (Object object ) {
1075
- PythonClass clazz = getClassNode ().execute (object );
1076
- return callBinaryIntoCapi (getPyObjectHandle_ForJavaObject (), getToSulongNode ().execute (object ), clazz .getFlags ());
1077
- }
1078
-
1079
- Object getHandleForObject (Object object , long flags ) {
1080
- return callBinaryIntoCapi (getPyObjectHandle_ForJavaObject (), object , flags );
1064
+ Object doObject (PythonNativeWrapper wrapper , Object object ) {
1065
+ return callUnaryIntoCapi (getPyObjectHandle_ForJavaObject (), wrapper );
1081
1066
}
1082
1067
1083
1068
private TruffleObject getPyObjectHandle_ForJavaType () {
@@ -1096,8 +1081,9 @@ private TruffleObject getPyObjectHandle_ForJavaObject() {
1096
1081
return PyObjectHandle_FromJavaObject ;
1097
1082
}
1098
1083
1099
- protected boolean isManagedPythonClass (PythonAbstractObject klass ) {
1100
- return klass instanceof PythonClass && !(klass instanceof PythonNativeClass );
1084
+ protected static boolean isManagedPythonClass (PythonClassNativeWrapper wrapper ) {
1085
+ assert wrapper .getDelegate () instanceof PythonClass ;
1086
+ return !(wrapper .getDelegate () instanceof PythonNativeClass );
1101
1087
}
1102
1088
1103
1089
private Object callUnaryIntoCapi (TruffleObject fun , Object arg ) {
@@ -1108,22 +1094,6 @@ private Object callUnaryIntoCapi(TruffleObject fun, Object arg) {
1108
1094
return callNativeUnary .execute (fun , new Object []{arg });
1109
1095
}
1110
1096
1111
- private Object callBinaryIntoCapi (TruffleObject fun , Object arg0 , Object arg1 ) {
1112
- if (callNativeBinary == null ) {
1113
- CompilerDirectives .transferToInterpreterAndInvalidate ();
1114
- callNativeBinary = insert (PCallNativeNode .create ());
1115
- }
1116
- return callNativeBinary .execute (fun , new Object []{arg0 , arg1 });
1117
- }
1118
-
1119
- private GetClassNode getClassNode () {
1120
- if (getClassNode == null ) {
1121
- CompilerDirectives .transferToInterpreterAndInvalidate ();
1122
- getClassNode = insert (GetClassNode .create ());
1123
- }
1124
- return getClassNode ;
1125
- }
1126
-
1127
1097
private CExtNodes .ToSulongNode getToSulongNode () {
1128
1098
if (toSulongNode == null ) {
1129
1099
CompilerDirectives .transferToInterpreterAndInvalidate ();
0 commit comments