6969import com .oracle .graal .python .builtins .objects .bytes .PByteArray ;
7070import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
7171import com .oracle .graal .python .builtins .objects .bytes .PIBytesLike ;
72- import com .oracle .graal .python .builtins .objects .common .SequenceNodes .LenNode ;
7372import com .oracle .graal .python .builtins .objects .common .SequenceNodes ;
73+ import com .oracle .graal .python .builtins .objects .common .SequenceNodes .LenNode ;
7474import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
7575import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .GetItemNode ;
7676import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .ToByteArrayNode ;
8585import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
8686import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
8787import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
88+ import com .oracle .graal .python .nodes .util .CastToIndexNode ;
8889import com .oracle .graal .python .runtime .PythonCore ;
8990import com .oracle .graal .python .runtime .exception .PException ;
9091import com .oracle .graal .python .runtime .exception .PythonErrorType ;
@@ -329,14 +330,10 @@ Object fstat(int fd,
329330 }
330331
331332 @ Specialization
332- Object fstatPInt (PInt fd ,
333+ Object fstatPInt (Object fd ,
334+ @ Cached ("createOverflow()" ) CastToIndexNode castToIntNode ,
333335 @ Cached ("create()" ) FstatNode recursive ) {
334- return recursive .executeWith (fd .intValue ());
335- }
336-
337- @ Fallback
338- Object doGeneric (Object o ) {
339- throw raise (TypeError , "an integer is required (got type %p)" , o );
336+ return recursive .executeWith (castToIntNode .execute (fd ));
340337 }
341338
342339 protected static StatNode createStatNode () {
@@ -775,9 +772,10 @@ Object writeStd(int fd, PByteArray data) {
775772 }
776773
777774 @ Specialization
778- Object writePInt (PInt fd , Object data ,
775+ Object writePInt (Object fd , Object data ,
776+ @ Cached ("createOverflow()" ) CastToIndexNode castToIntNode ,
779777 @ Cached ("create()" ) WriteNode recursive ) {
780- return recursive .executeWith (fd . intValue ( ), data );
778+ return recursive .executeWith (castToIntNode . execute ( fd ), data );
781779 }
782780
783781 private byte [] getByteArray (PIBytesLike pByteArray ) {
@@ -788,7 +786,7 @@ private byte[] getByteArray(PIBytesLike pByteArray) {
788786 return toByteArrayNode .execute (pByteArray .getSequenceStorage ());
789787 }
790788
791- protected WriteNode create () {
789+ public static WriteNode create () {
792790 return PosixModuleBuiltinsFactory .WriteNodeFactory .create (null );
793791 }
794792 }
0 commit comments