69
69
import com .oracle .graal .python .builtins .objects .bytes .PByteArray ;
70
70
import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
71
71
import com .oracle .graal .python .builtins .objects .bytes .PIBytesLike ;
72
- import com .oracle .graal .python .builtins .objects .common .SequenceNodes .LenNode ;
73
72
import com .oracle .graal .python .builtins .objects .common .SequenceNodes ;
73
+ import com .oracle .graal .python .builtins .objects .common .SequenceNodes .LenNode ;
74
74
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
75
75
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .GetItemNode ;
76
76
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .ToByteArrayNode ;
85
85
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
86
86
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
87
87
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
88
+ import com .oracle .graal .python .nodes .util .CastToIndexNode ;
88
89
import com .oracle .graal .python .runtime .PythonCore ;
89
90
import com .oracle .graal .python .runtime .exception .PException ;
90
91
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
@@ -329,14 +330,10 @@ Object fstat(int fd,
329
330
}
330
331
331
332
@ Specialization
332
- Object fstatPInt (PInt fd ,
333
+ Object fstatPInt (Object fd ,
334
+ @ Cached ("createOverflow()" ) CastToIndexNode castToIntNode ,
333
335
@ 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 ));
340
337
}
341
338
342
339
protected static StatNode createStatNode () {
@@ -775,9 +772,10 @@ Object writeStd(int fd, PByteArray data) {
775
772
}
776
773
777
774
@ Specialization
778
- Object writePInt (PInt fd , Object data ,
775
+ Object writePInt (Object fd , Object data ,
776
+ @ Cached ("createOverflow()" ) CastToIndexNode castToIntNode ,
779
777
@ Cached ("create()" ) WriteNode recursive ) {
780
- return recursive .executeWith (fd . intValue ( ), data );
778
+ return recursive .executeWith (castToIntNode . execute ( fd ), data );
781
779
}
782
780
783
781
private byte [] getByteArray (PIBytesLike pByteArray ) {
@@ -788,7 +786,7 @@ private byte[] getByteArray(PIBytesLike pByteArray) {
788
786
return toByteArrayNode .execute (pByteArray .getSequenceStorage ());
789
787
}
790
788
791
- protected WriteNode create () {
789
+ public static WriteNode create () {
792
790
return PosixModuleBuiltinsFactory .WriteNodeFactory .create (null );
793
791
}
794
792
}
0 commit comments