File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 37
37
import static com .oracle .graal .python .nodes .SpecialMethodNames .__GE__ ;
38
38
import static com .oracle .graal .python .nodes .SpecialMethodNames .__GT__ ;
39
39
import static com .oracle .graal .python .nodes .SpecialMethodNames .__ITER__ ;
40
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__INDEX__ ;
40
41
import static com .oracle .graal .python .nodes .SpecialMethodNames .__LEN__ ;
41
42
import static com .oracle .graal .python .nodes .SpecialMethodNames .__LE__ ;
42
43
import static com .oracle .graal .python .nodes .SpecialMethodNames .__LT__ ;
@@ -906,4 +907,22 @@ protected Object doIt(TruffleObject object,
906
907
}
907
908
}
908
909
}
910
+
911
+ @ Builtin (name = __INDEX__ , fixedNumOfArguments = 1 )
912
+ @ GenerateNodeFactory
913
+ abstract static class IndexNode extends UnboxNode {
914
+ @ Specialization (guards = "isForeignObject(object)" )
915
+ protected Object doIt (TruffleObject object ,
916
+ @ Cached ("IS_BOXED.createNode()" ) Node isBoxedNode ,
917
+ @ Cached ("UNBOX.createNode()" ) Node unboxNode ) {
918
+ if (ForeignAccess .sendIsBoxed (isBoxedNode , object )) {
919
+ try {
920
+ return ForeignAccess .sendUnbox (unboxNode , object );
921
+ } catch (UnsupportedMessageException e ) {
922
+ throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the UNBOX message" );
923
+ }
924
+ }
925
+ throw raiseIndexError ();
926
+ }
927
+ }
909
928
}
You can’t perform that action at this time.
0 commit comments