3636import com .oracle .graal .python .builtins .CoreFunctions ;
3737import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
3838import com .oracle .graal .python .builtins .PythonBuiltins ;
39- import com .oracle .graal .python .builtins .objects .function .PKeyword ;
4039import com .oracle .graal .python .nodes .ErrorMessages ;
4140import com .oracle .graal .python .nodes .PRaiseNode ;
4241import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
4342import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
4443import com .oracle .graal .python .nodes .interop .PForeignToPTypeNode ;
45- import com .oracle .graal .python .nodes .object .IsForeignObjectNode ;
4644import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
4745import com .oracle .graal .python .runtime .GilNode ;
4846import com .oracle .graal .python .runtime .IndirectCallData ;
5149import com .oracle .truffle .api .CompilerDirectives ;
5250import com .oracle .truffle .api .dsl .Bind ;
5351import com .oracle .truffle .api .dsl .Cached ;
54- import com .oracle .truffle .api .dsl .Fallback ;
5552import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
5653import com .oracle .truffle .api .dsl .NodeFactory ;
5754import com .oracle .truffle .api .dsl .Specialization ;
@@ -70,46 +67,14 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
7067 return ForeignInstantiableBuiltinsFactory .getFactories ();
7168 }
7269
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 )
10672 @ GenerateNodeFactory
10773 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 ,
11076 @ SuppressWarnings ("unused" ) @ Bind ("this" ) Node inliningTarget ,
11177 @ Cached ("createFor(this)" ) IndirectCallData indirectCallData ,
112- @ SuppressWarnings ("unused" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
11378 @ CachedLibrary (limit = "4" ) InteropLibrary lib ,
11479 @ Cached PForeignToPTypeNode toPTypeNode ,
11580 @ Cached GilNode gil ,
@@ -131,13 +96,6 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument
13196 throw CompilerDirectives .shouldNotReachHere (e );
13297 }
13398 }
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- }
14199 }
142100
143101}
0 commit comments