36
36
import com .oracle .graal .python .builtins .CoreFunctions ;
37
37
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
38
38
import com .oracle .graal .python .builtins .PythonBuiltins ;
39
- import com .oracle .graal .python .builtins .objects .function .PKeyword ;
40
39
import com .oracle .graal .python .nodes .ErrorMessages ;
41
40
import com .oracle .graal .python .nodes .PRaiseNode ;
42
41
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
43
42
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
44
43
import com .oracle .graal .python .nodes .interop .PForeignToPTypeNode ;
45
- import com .oracle .graal .python .nodes .object .IsForeignObjectNode ;
46
44
import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
47
45
import com .oracle .graal .python .runtime .GilNode ;
48
46
import com .oracle .graal .python .runtime .IndirectCallData ;
51
49
import com .oracle .truffle .api .CompilerDirectives ;
52
50
import com .oracle .truffle .api .dsl .Bind ;
53
51
import com .oracle .truffle .api .dsl .Cached ;
54
- import com .oracle .truffle .api .dsl .Fallback ;
55
52
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
56
53
import com .oracle .truffle .api .dsl .NodeFactory ;
57
54
import com .oracle .truffle .api .dsl .Specialization ;
@@ -70,46 +67,14 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
70
67
return ForeignInstantiableBuiltinsFactory .getFactories ();
71
68
}
72
69
73
- @ Builtin (name = J___NEW__ , minNumOfPositionalArgs = 1 , takesVarArgs = true , takesVarKeywordArgs = true )
74
- @ GenerateNodeFactory
75
- abstract static class NewNode extends PythonBuiltinNode {
76
- @ Specialization (guards = {"isForeignObjectNode.execute(inliningTarget, callee)" , "!isNoValue(callee)" , "keywords.length == 0" }, limit = "1" )
77
- static Object doInteropCall (Object callee , Object [] arguments , @ SuppressWarnings ("unused" ) PKeyword [] keywords ,
78
- @ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
79
- @ SuppressWarnings ("unused" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
80
- @ CachedLibrary (limit = "3" ) InteropLibrary lib ,
81
- @ Cached PForeignToPTypeNode toPTypeNode ,
82
- @ Cached GilNode gil ,
83
- @ Cached PRaiseNode .Lazy raiseNode ) {
84
- gil .release (true );
85
- try {
86
- Object res = lib .instantiate (callee , arguments );
87
- return toPTypeNode .executeConvert (res );
88
- } catch (ArityException | UnsupportedTypeException e ) {
89
- throw raiseNode .get (inliningTarget ).raise (PythonErrorType .TypeError , ErrorMessages .INVALID_INSTANTIATION_OF_FOREIGN_OBJ );
90
- } catch (UnsupportedMessageException e ) {
91
- throw CompilerDirectives .shouldNotReachHere (e );
92
- } finally {
93
- gil .acquire ();
94
- }
95
- }
96
-
97
- @ Fallback
98
- @ SuppressWarnings ("unused" )
99
- static Object doGeneric (Object callee , Object arguments , Object keywords ,
100
- @ Cached PRaiseNode raiseNode ) {
101
- throw raiseNode .raise (PythonErrorType .TypeError , ErrorMessages .INVALID_INSTANTIATION_OF_FOREIGN_OBJ );
102
- }
103
- }
104
-
105
- @ Builtin (name = J___CALL__ , minNumOfPositionalArgs = 1 , takesVarArgs = true , takesVarKeywordArgs = true )
70
+ @ Builtin (name = J___NEW__ , minNumOfPositionalArgs = 1 , takesVarArgs = true )
71
+ @ Builtin (name = J___CALL__ , minNumOfPositionalArgs = 1 , takesVarArgs = true )
106
72
@ GenerateNodeFactory
107
73
public abstract static class CallNode extends PythonBuiltinNode {
108
- @ Specialization ( guards = { "isForeignObjectNode.execute(inliningTarget, callee)" , "!isNoValue(callee)" , "keywords.length == 0" }, limit = "1" )
109
- static Object doInteropCall (VirtualFrame frame , Object callee , Object [] arguments , @ SuppressWarnings ( "unused" ) PKeyword [] keywords ,
74
+ @ Specialization
75
+ static Object doInteropCall (VirtualFrame frame , Object callee , Object [] arguments ,
110
76
@ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
111
77
@ Cached ("createFor(this)" ) IndirectCallData indirectCallData ,
112
- @ SuppressWarnings ("unused" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
113
78
@ CachedLibrary (limit = "4" ) InteropLibrary lib ,
114
79
@ Cached PForeignToPTypeNode toPTypeNode ,
115
80
@ Cached GilNode gil ,
@@ -131,13 +96,6 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument
131
96
throw CompilerDirectives .shouldNotReachHere (e );
132
97
}
133
98
}
134
-
135
- @ Fallback
136
- @ SuppressWarnings ("unused" )
137
- static Object doGeneric (Object callee , Object arguments , Object keywords ,
138
- @ Cached PRaiseNode raiseNode ) {
139
- throw raiseNode .raise (PythonErrorType .TypeError , ErrorMessages .INVALID_INSTANTIATION_OF_FOREIGN_OBJ );
140
- }
141
99
}
142
100
143
101
}
0 commit comments