67
67
import java .util .logging .Level ;
68
68
69
69
import com .oracle .graal .python .PythonLanguage ;
70
+ import com .oracle .graal .python .annotations .ArgumentClinic ;
70
71
import com .oracle .graal .python .builtins .Builtin ;
71
72
import com .oracle .graal .python .builtins .CoreFunctions ;
72
73
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
91
92
import com .oracle .graal .python .builtins .modules .ExternalFunctionNodes .SetAttrFuncRootNode ;
92
93
import com .oracle .graal .python .builtins .modules .PythonCextBuiltinsFactory .CheckInquiryResultNodeGen ;
93
94
import com .oracle .graal .python .builtins .modules .PythonCextBuiltinsFactory .CheckIterNextResultNodeGen ;
94
- import com .oracle .graal .python .builtins .modules .PythonCextBuiltinsFactory .CreateFunctionNodeFactory ;
95
95
import com .oracle .graal .python .builtins .modules .PythonCextBuiltinsFactory .DefaultCheckFunctionResultNodeGen ;
96
96
import com .oracle .graal .python .builtins .objects .PNone ;
97
97
import com .oracle .graal .python .builtins .objects .PythonAbstractObject ;
233
233
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
234
234
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
235
235
import com .oracle .graal .python .nodes .function .builtins .PythonQuaternaryBuiltinNode ;
236
+ import com .oracle .graal .python .nodes .function .builtins .PythonQuaternaryClinicBuiltinNode ;
236
237
import com .oracle .graal .python .nodes .function .builtins .PythonTernaryBuiltinNode ;
237
238
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
238
239
import com .oracle .graal .python .nodes .function .builtins .PythonVarargsBuiltinNode ;
240
+ import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
239
241
import com .oracle .graal .python .nodes .object .GetClassNode ;
240
- import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
241
242
import com .oracle .graal .python .nodes .truffle .PythonTypes ;
242
243
import com .oracle .graal .python .nodes .util .CannotCastException ;
243
244
import com .oracle .graal .python .nodes .util .CastToByteNode ;
@@ -412,7 +413,6 @@ Object run(Object obj,
412
413
413
414
@ Builtin (name = "PyTruffle_Type" , minNumOfPositionalArgs = 1 )
414
415
@ GenerateNodeFactory
415
- @ TypeSystemReference (PythonArithmeticTypes .class )
416
416
abstract static class PyTruffle_Type extends NativeBuiltin {
417
417
418
418
private static final String [] LOOKUP_MODULES = new String []{
@@ -423,7 +423,8 @@ abstract static class PyTruffle_Type extends NativeBuiltin {
423
423
424
424
@ Specialization
425
425
@ TruffleBoundary
426
- Object doI (String typeName ) {
426
+ Object doI (Object typeNameObject ) {
427
+ String typeName = CastToJavaStringNode .getUncached ().execute (typeNameObject );
427
428
PythonCore core = getCore ();
428
429
for (PythonBuiltinClassType type : PythonBuiltinClassType .VALUES ) {
429
430
if (type .getName ().equals (typeName )) {
@@ -499,7 +500,6 @@ protected static SequenceStorageNodes.SetItemNode createSetItem() {
499
500
500
501
@ Builtin (name = "CreateBuiltinMethod" , minNumOfPositionalArgs = 2 )
501
502
@ GenerateNodeFactory
502
- @ TypeSystemReference (PythonArithmeticTypes .class )
503
503
abstract static class CreateBuiltinMethodNode extends PythonBuiltinNode {
504
504
@ Specialization
505
505
@ TruffleBoundary
@@ -508,10 +508,14 @@ Object runWithoutCWrapper(PBuiltinFunction descriptor, Object self) {
508
508
}
509
509
}
510
510
511
- @ Builtin (name = "CreateFunction" , minNumOfPositionalArgs = 2 , maxNumOfPositionalArgs = 4 )
511
+ @ Builtin (name = "CreateFunction" , minNumOfPositionalArgs = 2 , parameterNames = {"name" , "callable" , "wrapper" , "type" })
512
+ @ ArgumentClinic (name = "name" , conversion = ArgumentClinic .ClinicConversion .String )
512
513
@ GenerateNodeFactory
513
- @ TypeSystemReference (PythonArithmeticTypes .class )
514
- abstract static class CreateFunctionNode extends PythonBuiltinNode {
514
+ abstract static class CreateFunctionNode extends PythonQuaternaryClinicBuiltinNode {
515
+ @ Override
516
+ protected ArgumentClinicProvider getArgumentClinic () {
517
+ return PythonCextBuiltinsClinicProviders .CreateFunctionNodeClinicProviderGen .INSTANCE ;
518
+ }
515
519
516
520
abstract Object execute (String name , Object callable , Object wrapper , Object type );
517
521
@@ -612,11 +616,6 @@ static boolean isNativeWrapper(Object obj) {
612
616
static boolean isDecoratedManagedFunction (Object obj ) {
613
617
return obj instanceof PyCFunctionDecorator && CApiGuards .isNativeWrapper (((PyCFunctionDecorator ) obj ).getNativeFunction ());
614
618
}
615
-
616
- public static CreateFunctionNode create () {
617
- return CreateFunctionNodeFactory .create (null );
618
- }
619
-
620
619
}
621
620
622
621
@ Builtin (name = "PyErr_Restore" , minNumOfPositionalArgs = 3 )
@@ -1419,24 +1418,25 @@ private String decodeUTF32(byte[] data, int size, String errors, int byteorder)
1419
1418
1420
1419
@ Builtin (name = "PyTruffle_Unicode_AsWideChar" , minNumOfPositionalArgs = 4 )
1421
1420
@ GenerateNodeFactory
1422
- @ TypeSystemReference (PythonArithmeticTypes .class )
1423
1421
abstract static class PyTruffle_Unicode_AsWideChar extends NativeUnicodeBuiltin {
1424
1422
@ Child private UnicodeAsWideCharNode asWideCharNode ;
1425
1423
1426
1424
@ Specialization
1427
- Object doUnicode (VirtualFrame frame , String s , long elementSize , @ SuppressWarnings ("unused" ) PNone elements , Object errorMarker ) {
1428
- return doUnicode (frame , s , elementSize , -1 , errorMarker );
1425
+ Object doUnicode (VirtualFrame frame , Object s , long elementSize , @ SuppressWarnings ("unused" ) PNone elements , Object errorMarker ,
1426
+ @ Shared ("castStr" ) @ Cached CastToJavaStringNode castStr ) {
1427
+ return doUnicode (frame , s , elementSize , -1 , errorMarker , castStr );
1429
1428
}
1430
1429
1431
1430
@ Specialization
1432
- Object doUnicode (VirtualFrame frame , String s , long elementSize , long elements , Object errorMarker ) {
1431
+ Object doUnicode (VirtualFrame frame , Object s , long elementSize , long elements , Object errorMarker ,
1432
+ @ Shared ("castStr" ) @ Cached CastToJavaStringNode castStr ) {
1433
1433
try {
1434
1434
if (asWideCharNode == null ) {
1435
1435
CompilerDirectives .transferToInterpreterAndInvalidate ();
1436
1436
asWideCharNode = insert (UnicodeAsWideCharNodeGen .create ());
1437
1437
}
1438
1438
1439
- PBytes wchars = asWideCharNode .executeLittleEndian (s , elementSize , elements );
1439
+ PBytes wchars = asWideCharNode .executeLittleEndian (castStr . execute ( s ) , elementSize , elements );
1440
1440
if (wchars != null ) {
1441
1441
return wchars ;
1442
1442
} else {
@@ -1449,18 +1449,20 @@ Object doUnicode(VirtualFrame frame, String s, long elementSize, long elements,
1449
1449
}
1450
1450
1451
1451
@ Specialization
1452
- Object doUnicode (VirtualFrame frame , String s , PInt elementSize , @ SuppressWarnings ("unused" ) PNone elements , Object errorMarker ) {
1452
+ Object doUnicode (VirtualFrame frame , String s , PInt elementSize , @ SuppressWarnings ("unused" ) PNone elements , Object errorMarker ,
1453
+ @ Shared ("castStr" ) @ Cached CastToJavaStringNode castStr ) {
1453
1454
try {
1454
- return doUnicode (frame , s , elementSize .longValueExact (), -1 , errorMarker );
1455
+ return doUnicode (frame , s , elementSize .longValueExact (), -1 , errorMarker , castStr );
1455
1456
} catch (OverflowException e ) {
1456
1457
return raiseNative (frame , errorMarker , PythonErrorType .ValueError , ErrorMessages .INVALID_PARAMS );
1457
1458
}
1458
1459
}
1459
1460
1460
1461
@ Specialization
1461
- Object doUnicode (VirtualFrame frame , String s , PInt elementSize , PInt elements , Object errorMarker ) {
1462
+ Object doUnicode (VirtualFrame frame , String s , PInt elementSize , PInt elements , Object errorMarker ,
1463
+ @ Shared ("castStr" ) @ Cached CastToJavaStringNode castStr ) {
1462
1464
try {
1463
- return doUnicode (frame , s , elementSize .longValueExact (), elements .longValueExact (), errorMarker );
1465
+ return doUnicode (frame , s , elementSize .longValueExact (), elements .longValueExact (), errorMarker , castStr );
1464
1466
} catch (OverflowException e ) {
1465
1467
return raiseNative (frame , errorMarker , PythonErrorType .ValueError , ErrorMessages .INVALID_PARAMS );
1466
1468
}
0 commit comments