@@ -69,7 +69,7 @@ public Value execute(Value... args) {
69
69
}
70
70
return process (file , "r" );
71
71
} catch (IOException ioe ) {
72
- return new NumberValue (- 1 ) ;
72
+ return NumberValue . MINUS_ONE ;
73
73
}
74
74
}
75
75
@@ -101,7 +101,7 @@ private static abstract class FileFunction implements Function {
101
101
@ Override
102
102
public Value execute (Value ... args ) {
103
103
if (args .length < 1 ) throw new ArgumentsMismatchException ("File descriptor expected" );
104
- final int key = ( int ) args [0 ].asNumber ();
104
+ final int key = args [0 ].asInt ();
105
105
try {
106
106
return execute (files .get (key ), args );
107
107
} catch (IOException ioe ) {
@@ -115,7 +115,7 @@ public Value execute(Value... args) {
115
115
private static class readBoolean extends FileFunction {
116
116
@ Override
117
117
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
118
- return new NumberValue (fileInfo .dis .readBoolean () ? 1 : 0 );
118
+ return NumberValue . fromBoolean (fileInfo .dis .readBoolean ());
119
119
}
120
120
}
121
121
@@ -132,8 +132,8 @@ protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
132
132
final ArrayValue array = (ArrayValue ) args [1 ];
133
133
int offset = 0 , length = array .size ();
134
134
if (args .length > 3 ) {
135
- offset = ( int ) args [2 ].asNumber ();
136
- length = ( int ) args [3 ].asNumber ();
135
+ offset = args [2 ].asInt ();
136
+ length = args [3 ].asInt ();
137
137
}
138
138
139
139
final byte [] buffer = new byte [length ];
@@ -170,7 +170,7 @@ protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
170
170
private static class readChar extends FileFunction {
171
171
@ Override
172
172
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
173
- return new NumberValue (fileInfo .dis .readChar ());
173
+ return new NumberValue (( short ) fileInfo .dis .readChar ());
174
174
}
175
175
}
176
176
@@ -239,15 +239,15 @@ protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
239
239
private static class writeBoolean extends FileFunction {
240
240
@ Override
241
241
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
242
- fileInfo .dos .writeBoolean (args [1 ].asNumber () != 0 );
242
+ fileInfo .dos .writeBoolean (args [1 ].asInt () != 0 );
243
243
return NumberValue .ONE ;
244
244
}
245
245
}
246
246
247
247
private static class writeByte extends FileFunction {
248
248
@ Override
249
249
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
250
- fileInfo .dos .writeByte ((byte ) args [1 ].asNumber ());
250
+ fileInfo .dos .writeByte ((byte ) args [1 ].asInt ());
251
251
return NumberValue .ONE ;
252
252
}
253
253
}
@@ -256,7 +256,7 @@ private static class writeChar extends FileFunction {
256
256
@ Override
257
257
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
258
258
final char ch = (args [1 ].type () == Types .NUMBER )
259
- ? ((char ) args [1 ].asNumber ())
259
+ ? ((char ) args [1 ].asInt ())
260
260
: args [1 ].asString ().charAt (0 );
261
261
fileInfo .dos .writeChar (ch );
262
262
return NumberValue .ONE ;
@@ -266,15 +266,15 @@ protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
266
266
private static class writeShort extends FileFunction {
267
267
@ Override
268
268
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
269
- fileInfo .dos .writeShort ((short ) args [1 ].asNumber ());
269
+ fileInfo .dos .writeShort ((short ) args [1 ].asInt ());
270
270
return NumberValue .ONE ;
271
271
}
272
272
}
273
273
274
274
private static class writeInt extends FileFunction {
275
275
@ Override
276
276
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
277
- fileInfo .dos .writeInt (( int ) args [1 ].asNumber ());
277
+ fileInfo .dos .writeInt (args [1 ].asInt ());
278
278
return NumberValue .ONE ;
279
279
}
280
280
}
0 commit comments