45
45
import static com .oracle .graal .python .nodes .ErrorMessages .BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P ;
46
46
import static com .oracle .graal .python .nodes .ErrorMessages .LIST_INDEX_OUT_OF_RANGE ;
47
47
import static com .oracle .graal .python .nodes .ErrorMessages .NATIVE_S_SUBTYPES_NOT_IMPLEMENTED ;
48
+
48
49
import java .util .Arrays ;
49
50
import java .util .List ;
51
+
50
52
import com .oracle .graal .python .builtins .Builtin ;
51
53
import com .oracle .graal .python .builtins .CoreFunctions ;
52
54
import com .oracle .graal .python .builtins .Python3Core ;
85
87
import com .oracle .graal .python .runtime .exception .PException ;
86
88
import com .oracle .graal .python .util .PythonUtils ;
87
89
import com .oracle .truffle .api .dsl .Cached ;
90
+ import com .oracle .truffle .api .dsl .Fallback ;
88
91
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
89
92
import com .oracle .truffle .api .dsl .ImportStatic ;
90
93
import com .oracle .truffle .api .dsl .NodeFactory ;
@@ -514,7 +517,7 @@ protected boolean isListSubtype(VirtualFrame frame, Object obj, GetClassNode get
514
517
abstract static class PyListInsertNode extends PythonTernaryBuiltinNode {
515
518
516
519
@ Specialization
517
- Object append (VirtualFrame frame , PList list , int i , Object item ,
520
+ Object insert (VirtualFrame frame , PList list , Object i , Object item ,
518
521
@ Cached ListInsertNode insertNode ,
519
522
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
520
523
try {
@@ -526,18 +529,17 @@ Object append(VirtualFrame frame, PList list, int i, Object item,
526
529
}
527
530
}
528
531
529
- @ Specialization (guards = {"!isList(obj)" , "isListSubtype(frame, obj, getClassNode, isSubtypeNode)" })
530
- public Object asTupleNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object obj , @ SuppressWarnings ("unused" ) int i , @ SuppressWarnings ("unused" ) Object item ,
532
+ @ Specialization (guards = {"!isList(obj)" , "isListSubtype(frame, obj, getClassNode, isSubtypeNode)" }, limit = "1" )
533
+ public Object insertNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object obj , @ SuppressWarnings ("unused" ) long i , @ SuppressWarnings ("unused" ) Object item ,
531
534
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
532
535
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
533
536
@ Cached PRaiseNativeNode raiseNativeNode ) {
534
537
return raiseNativeNode .raiseInt (frame , -1 , PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "list" );
535
538
}
536
539
537
- @ Specialization (guards = {"!isList(obj)" , "!isListSubtype(frame, obj, getClassNode, isSubtypeNode)" })
538
- public Object asTuple (VirtualFrame frame , Object obj , @ SuppressWarnings ("unused" ) int i , @ SuppressWarnings ("unused" ) Object item ,
539
- @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
540
- @ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
540
+ @ Fallback
541
+ @ SuppressWarnings ("unused" )
542
+ public Object error (VirtualFrame frame , Object obj , Object i , Object item ,
541
543
@ Cached StrNode strNode ,
542
544
@ Cached PRaiseNativeNode raiseNativeNode ) {
543
545
return raiseNativeNode .raiseInt (frame , -1 , SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , obj ), obj );
0 commit comments