OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 19 matching lines...) Expand all Loading... | |
30 // This file relies on the fact that the following declaration has been made | 30 // This file relies on the fact that the following declaration has been made |
31 // in runtime.js: | 31 // in runtime.js: |
32 // var $Array = global.Array; | 32 // var $Array = global.Array; |
33 | 33 |
34 | 34 |
35 | 35 |
36 // --------------- Typed Arrays --------------------- | 36 // --------------- Typed Arrays --------------------- |
37 | 37 |
38 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { | 38 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { |
39 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 39 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
40 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_POSITIVE_INTEGER(byteOffset); | 40 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_INTEGER(byteOffset); |
rossberg
2013/06/24 12:36:03
Same here
| |
41 if (offset < 0) { | |
42 throw MakeRangeError("invalid_typed_array_length"); | |
43 } | |
41 | 44 |
42 if (offset % elementSize !== 0) { | 45 if (offset % elementSize !== 0) { |
43 throw MakeRangeError("invalid_typed_array_alignment", | 46 throw MakeRangeError("invalid_typed_array_alignment", |
44 "start offset", name, elementSize); | 47 "start offset", name, elementSize); |
45 } | 48 } |
46 var bufferByteLength = %ArrayBufferGetByteLength(buffer); | 49 var bufferByteLength = %ArrayBufferGetByteLength(buffer); |
47 if (offset > bufferByteLength) { | 50 if (offset > bufferByteLength) { |
48 throw MakeRangeError("invalid_typed_array_offset"); | 51 throw MakeRangeError("invalid_typed_array_offset"); |
49 } | 52 } |
50 | 53 |
51 var newByteLength; | 54 var newByteLength; |
52 var newLength; | 55 var newLength; |
53 if (IS_UNDEFINED(length)) { | 56 if (IS_UNDEFINED(length)) { |
54 if (bufferByteLength % elementSize !== 0) { | 57 if (bufferByteLength % elementSize !== 0) { |
55 throw MakeRangeError("invalid_typed_array_alignment", | 58 throw MakeRangeError("invalid_typed_array_alignment", |
56 "byte length", name, elementSize); | 59 "byte length", name, elementSize); |
57 } | 60 } |
58 newByteLength = bufferByteLength - offset; | 61 newByteLength = bufferByteLength - offset; |
59 newLength = newByteLength / elementSize; | 62 newLength = newByteLength / elementSize; |
60 } else { | 63 } else { |
61 var newLength = TO_POSITIVE_INTEGER(length); | 64 var newLength = TO_INTEGER(length); |
65 if (newLength < 0) { | |
66 throw MakeRangeError("invalid_typed_array_length"); | |
67 } | |
62 newByteLength = newLength * elementSize; | 68 newByteLength = newLength * elementSize; |
63 } | 69 } |
64 if (offset + newByteLength > bufferByteLength) { | 70 if (offset + newByteLength > bufferByteLength) { |
65 throw MakeRangeError("invalid_typed_array_length"); | 71 throw MakeRangeError("invalid_typed_array_length"); |
66 } | 72 } |
67 %TypedArrayInitialize(obj, arrayId, buffer, offset, newByteLength); | 73 %TypedArrayInitialize(obj, arrayId, buffer, offset, newByteLength); |
68 } | 74 } |
69 | 75 |
70 function ConstructByLength(obj, length) { | 76 function ConstructByLength(obj, length) { |
71 var l = IS_UNDEFINED(length) ? 0 : TO_POSITIVE_INTEGER(length); | 77 var l = TO_INTEGER(length); |
78 if (l < 0) { | |
79 throw MakeRangeError("invalid_typed_array_length"); | |
80 } | |
72 var byteLength = l * elementSize; | 81 var byteLength = l * elementSize; |
73 var buffer = new global.ArrayBuffer(byteLength); | 82 var buffer = new global.ArrayBuffer(byteLength); |
74 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); | 83 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); |
75 } | 84 } |
76 | 85 |
77 function ConstructByArrayLike(obj, arrayLike) { | 86 function ConstructByArrayLike(obj, arrayLike) { |
78 var length = arrayLike.length; | 87 var length = arrayLike.length; |
79 var l = IS_UNDEFINED(length) ? 0 : TO_POSITIVE_INTEGER(length); | 88 var l = TO_INTEGER(length); |
89 if (l < 0) { | |
90 throw MakeRangeError("invalid_typed_array_length"); | |
91 } | |
80 var byteLength = l * elementSize; | 92 var byteLength = l * elementSize; |
81 var buffer = new $ArrayBuffer(byteLength); | 93 var buffer = new $ArrayBuffer(byteLength); |
82 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); | 94 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); |
83 for (var i = 0; i < l; i++) { | 95 for (var i = 0; i < l; i++) { |
84 obj[i] = arrayLike[i]; | 96 obj[i] = arrayLike[i]; |
85 } | 97 } |
86 } | 98 } |
87 | 99 |
88 return function (arg1, arg2, arg3) { | 100 return function (arg1, arg2, arg3) { |
89 if (%_IsConstructCall()) { | 101 if (%_IsConstructCall()) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 endInt = beginInt; | 150 endInt = beginInt; |
139 } | 151 } |
140 var newLength = endInt - beginInt; | 152 var newLength = endInt - beginInt; |
141 var beginByteOffset = | 153 var beginByteOffset = |
142 %TypedArrayGetByteOffset(this) + beginInt * elementSize; | 154 %TypedArrayGetByteOffset(this) + beginInt * elementSize; |
143 return new constructor(%TypedArrayGetBuffer(this), | 155 return new constructor(%TypedArrayGetBuffer(this), |
144 beginByteOffset, newLength); | 156 beginByteOffset, newLength); |
145 } | 157 } |
146 } | 158 } |
147 | 159 |
148 function TypedArraySet(obj, offset) { | 160 function TypedArraySet(obj, offset) { |
rossberg
2013/06/24 12:36:03
and here
| |
149 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_POSITIVE_INTEGER(offset); | 161 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); |
162 if (intOffset < 0) { | |
163 throw MakeTypeError("typed_array_set_negative_offset"); | |
164 } | |
150 if (%TypedArraySetFastCases(this, obj, intOffset)) | 165 if (%TypedArraySetFastCases(this, obj, intOffset)) |
151 return; | 166 return; |
152 | 167 |
153 var l = obj.length; | 168 var l = obj.length; |
154 if (IS_UNDEFINED(l)) { | 169 if (IS_UNDEFINED(l)) { |
155 throw MakeTypeError("invalid_argument"); | 170 throw MakeTypeError("invalid_argument"); |
156 } | 171 } |
157 if (intOffset + l > this.length) { | 172 if (intOffset + l > this.length) { |
158 throw MakeRangeError("typed_array_set_source_too_large"); | 173 throw MakeRangeError("typed_array_set_source_too_large"); |
159 } | 174 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 // --------------------------- DataView ----------------------------- | 217 // --------------------------- DataView ----------------------------- |
203 | 218 |
204 var $DataView = global.DataView; | 219 var $DataView = global.DataView; |
205 | 220 |
206 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 | 221 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 |
207 if (%_IsConstructCall()) { | 222 if (%_IsConstructCall()) { |
208 if (!IS_ARRAYBUFFER(buffer)) { | 223 if (!IS_ARRAYBUFFER(buffer)) { |
209 throw MakeTypeError('data_view_not_array_buffer', []); | 224 throw MakeTypeError('data_view_not_array_buffer', []); |
210 } | 225 } |
211 var bufferByteLength = %ArrayBufferGetByteLength(buffer); | 226 var bufferByteLength = %ArrayBufferGetByteLength(buffer); |
212 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_POSITIVE_INTEGER(byteOffset); | 227 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_INTEGER(byteOffset); |
rossberg
2013/06/24 12:36:03
and here
| |
213 if (offset > bufferByteLength) { | 228 if (offset < 0 || offset > bufferByteLength) { |
214 throw MakeRangeError('invalid_data_view_offset', []); | 229 throw MakeRangeError('invalid_data_view_offset', []); |
215 } | 230 } |
216 var length = IS_UNDEFINED(byteLength) ? | 231 var length = IS_UNDEFINED(byteLength) ? |
217 bufferByteLength - offset : TO_POSITIVE_INTEGER(byteLength); | 232 bufferByteLength - offset : TO_INTEGER(byteLength); |
218 if (offset + length > bufferByteLength) { | 233 if (length < 0 || offset + length > bufferByteLength) { |
219 throw new MakeRangeError('invalid_data_view_length'); | 234 throw new MakeRangeError('invalid_data_view_length'); |
220 } | 235 } |
221 %DataViewInitialize(this, buffer, offset, length); | 236 %DataViewInitialize(this, buffer, offset, length); |
222 } else { | 237 } else { |
223 return new $DataView(buffer, byteOffset, byteLength) | 238 return new $DataView(buffer, byteOffset, byteLength) |
224 } | 239 } |
225 } | 240 } |
226 | 241 |
227 function DataViewGetBuffer() { | 242 function DataViewGetBuffer() { |
228 if (!IS_DATAVIEW(this)) { | 243 if (!IS_DATAVIEW(this)) { |
(...skipping 17 matching lines...) Expand all Loading... | |
246 ['DataView.byteLength', this]); | 261 ['DataView.byteLength', this]); |
247 } | 262 } |
248 return %DataViewGetByteLength(this); | 263 return %DataViewGetByteLength(this); |
249 } | 264 } |
250 | 265 |
251 function DataViewGetInt8(offset, little_endian) { | 266 function DataViewGetInt8(offset, little_endian) { |
252 if (!IS_DATAVIEW(this)) { | 267 if (!IS_DATAVIEW(this)) { |
253 throw MakeTypeError('incompatible_method_reciever', | 268 throw MakeTypeError('incompatible_method_reciever', |
254 ['DataView.getInt8', this]); | 269 ['DataView.getInt8', this]); |
255 } | 270 } |
256 return %DataViewGetInt8(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 271 offset = TO_INTEGER(offset); |
272 if (offset < 0) { | |
273 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
274 } | |
275 return %DataViewGetInt8(this, offset, !!little_endian); | |
257 } | 276 } |
258 | 277 |
259 function DataViewSetInt8(offset, value, little_endian) { | 278 function DataViewSetInt8(offset, value, little_endian) { |
260 if (!IS_DATAVIEW(this)) { | 279 if (!IS_DATAVIEW(this)) { |
261 throw MakeTypeError('incompatible_method_reciever', | 280 throw MakeTypeError('incompatible_method_reciever', |
262 ['DataView.setInt8', this]); | 281 ['DataView.setInt8', this]); |
263 } | 282 } |
283 offset = TO_INTEGER(offset); | |
284 if (offset < 0) { | |
285 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
286 } | |
264 %DataViewSetInt8(this, | 287 %DataViewSetInt8(this, |
265 TO_POSITIVE_INTEGER(offset), | 288 offset, |
266 TO_NUMBER_INLINE(value), | 289 TO_NUMBER_INLINE(value), |
267 !!little_endian); | 290 !!little_endian); |
268 } | 291 } |
269 | 292 |
270 function DataViewGetUint8(offset, little_endian) { | 293 function DataViewGetUint8(offset, little_endian) { |
271 if (!IS_DATAVIEW(this)) { | 294 if (!IS_DATAVIEW(this)) { |
272 throw MakeTypeError('incompatible_method_reciever', | 295 throw MakeTypeError('incompatible_method_reciever', |
273 ['DataView.getUint8', this]); | 296 ['DataView.getUint8', this]); |
274 } | 297 } |
275 return %DataViewGetUint8(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 298 offset = TO_INTEGER(offset); |
299 if (offset < 0) { | |
300 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
301 } | |
302 return %DataViewGetUint8(this, offset, !!little_endian); | |
276 } | 303 } |
277 | 304 |
278 function DataViewSetUint8(offset, value, little_endian) { | 305 function DataViewSetUint8(offset, value, little_endian) { |
279 if (!IS_DATAVIEW(this)) { | 306 if (!IS_DATAVIEW(this)) { |
280 throw MakeTypeError('incompatible_method_reciever', | 307 throw MakeTypeError('incompatible_method_reciever', |
281 ['DataView.setUint8', this]); | 308 ['DataView.setUint8', this]); |
282 } | 309 } |
310 offset = TO_INTEGER(offset); | |
311 if (offset < 0) { | |
312 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
313 } | |
283 %DataViewSetUint8(this, | 314 %DataViewSetUint8(this, |
284 TO_POSITIVE_INTEGER(offset), | 315 offset, |
285 TO_NUMBER_INLINE(value), | 316 TO_NUMBER_INLINE(value), |
286 !!little_endian); | 317 !!little_endian); |
287 } | 318 } |
288 | 319 |
289 function DataViewGetInt16(offset, little_endian) { | 320 function DataViewGetInt16(offset, little_endian) { |
290 if (!IS_DATAVIEW(this)) { | 321 if (!IS_DATAVIEW(this)) { |
291 throw MakeTypeError('incompatible_method_reciever', | 322 throw MakeTypeError('incompatible_method_reciever', |
292 ['DataView.getInt16', this]); | 323 ['DataView.getInt16', this]); |
293 } | 324 } |
294 return %DataViewGetInt16(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 325 offset = TO_INTEGER(offset); |
326 if (offset < 0) { | |
327 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
328 } | |
329 return %DataViewGetInt16(this, offset, !!little_endian); | |
295 } | 330 } |
296 | 331 |
297 function DataViewSetInt16(offset, value, little_endian) { | 332 function DataViewSetInt16(offset, value, little_endian) { |
298 if (!IS_DATAVIEW(this)) { | 333 if (!IS_DATAVIEW(this)) { |
299 throw MakeTypeError('incompatible_method_reciever', | 334 throw MakeTypeError('incompatible_method_reciever', |
300 ['DataView.setInt16', this]); | 335 ['DataView.setInt16', this]); |
301 } | 336 } |
337 offset = TO_INTEGER(offset); | |
338 if (offset < 0) { | |
339 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
340 } | |
302 %DataViewSetInt16(this, | 341 %DataViewSetInt16(this, |
303 TO_POSITIVE_INTEGER(offset), | 342 offset, |
304 TO_NUMBER_INLINE(value), | 343 TO_NUMBER_INLINE(value), |
305 !!little_endian); | 344 !!little_endian); |
306 } | 345 } |
307 | 346 |
308 function DataViewGetUint16(offset, little_endian) { | 347 function DataViewGetUint16(offset, little_endian) { |
309 if (!IS_DATAVIEW(this)) { | 348 if (!IS_DATAVIEW(this)) { |
310 throw MakeTypeError('incompatible_method_reciever', | 349 throw MakeTypeError('incompatible_method_reciever', |
311 ['DataView.getUint16', this]); | 350 ['DataView.getUint16', this]); |
312 } | 351 } |
313 return %DataViewGetUint16(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 352 offset = TO_INTEGER(offset); |
353 if (offset < 0) { | |
354 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
355 } | |
356 return %DataViewGetUint16(this, offset, !!little_endian); | |
314 } | 357 } |
315 | 358 |
316 function DataViewSetUint16(offset, value, little_endian) { | 359 function DataViewSetUint16(offset, value, little_endian) { |
317 if (!IS_DATAVIEW(this)) { | 360 if (!IS_DATAVIEW(this)) { |
318 throw MakeTypeError('incompatible_method_reciever', | 361 throw MakeTypeError('incompatible_method_reciever', |
319 ['DataView.setUint16', this]); | 362 ['DataView.setUint16', this]); |
320 } | 363 } |
364 offset = TO_INTEGER(offset); | |
365 if (offset < 0) { | |
366 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
367 } | |
321 %DataViewSetUint16(this, | 368 %DataViewSetUint16(this, |
322 TO_POSITIVE_INTEGER(offset), | 369 offset, |
323 TO_NUMBER_INLINE(value), | 370 TO_NUMBER_INLINE(value), |
324 !!little_endian); | 371 !!little_endian); |
325 } | 372 } |
326 | 373 |
327 function DataViewGetInt32(offset, little_endian) { | 374 function DataViewGetInt32(offset, little_endian) { |
328 if (!IS_DATAVIEW(this)) { | 375 if (!IS_DATAVIEW(this)) { |
329 throw MakeTypeError('incompatible_method_reciever', | 376 throw MakeTypeError('incompatible_method_reciever', |
330 ['DataView.getInt32', this]); | 377 ['DataView.getInt32', this]); |
331 } | 378 } |
332 return %DataViewGetInt32(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 379 offset = TO_INTEGER(offset); |
380 if (offset < 0) { | |
381 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
382 } | |
383 return %DataViewGetInt32(this, offset, !!little_endian); | |
333 } | 384 } |
334 | 385 |
335 function DataViewSetInt32(offset, value, little_endian) { | 386 function DataViewSetInt32(offset, value, little_endian) { |
336 if (!IS_DATAVIEW(this)) { | 387 if (!IS_DATAVIEW(this)) { |
337 throw MakeTypeError('incompatible_method_reciever', | 388 throw MakeTypeError('incompatible_method_reciever', |
338 ['DataView.setInt32', this]); | 389 ['DataView.setInt32', this]); |
339 } | 390 } |
391 offset = TO_INTEGER(offset); | |
392 if (offset < 0) { | |
393 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
394 } | |
340 %DataViewSetInt32(this, | 395 %DataViewSetInt32(this, |
341 TO_POSITIVE_INTEGER(offset), | 396 offset, |
342 TO_NUMBER_INLINE(value), | 397 TO_NUMBER_INLINE(value), |
343 !!little_endian); | 398 !!little_endian); |
344 } | 399 } |
345 | 400 |
346 function DataViewGetUint32(offset, little_endian) { | 401 function DataViewGetUint32(offset, little_endian) { |
347 if (!IS_DATAVIEW(this)) { | 402 if (!IS_DATAVIEW(this)) { |
348 throw MakeTypeError('incompatible_method_reciever', | 403 throw MakeTypeError('incompatible_method_reciever', |
349 ['DataView.getUint32', this]); | 404 ['DataView.getUint32', this]); |
350 } | 405 } |
351 return %DataViewGetUint32(this, TO_POSITIVE_INTEGER(offset), !!little_endian); | 406 offset = TO_INTEGER(offset); |
407 if (offset < 0) { | |
408 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
409 } | |
410 return %DataViewGetUint32(this, offset, !!little_endian); | |
352 } | 411 } |
353 | 412 |
354 function DataViewSetUint32(offset, value, little_endian) { | 413 function DataViewSetUint32(offset, value, little_endian) { |
355 if (!IS_DATAVIEW(this)) { | 414 if (!IS_DATAVIEW(this)) { |
356 throw MakeTypeError('incompatible_method_reciever', | 415 throw MakeTypeError('incompatible_method_reciever', |
357 ['DataView.setUint32', this]); | 416 ['DataView.setUint32', this]); |
358 } | 417 } |
418 offset = TO_INTEGER(offset); | |
419 if (offset < 0) { | |
420 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
421 } | |
359 %DataViewSetUint32(this, | 422 %DataViewSetUint32(this, |
360 TO_POSITIVE_INTEGER(offset), | 423 offset, |
361 TO_NUMBER_INLINE(value), | 424 TO_NUMBER_INLINE(value), |
362 !!little_endian); | 425 !!little_endian); |
363 } | 426 } |
364 | 427 |
365 function DataViewGetFloat32(offset, little_endian) { | 428 function DataViewGetFloat32(offset, little_endian) { |
366 if (!IS_DATAVIEW(this)) { | 429 if (!IS_DATAVIEW(this)) { |
367 throw MakeTypeError('incompatible_method_reciever', | 430 throw MakeTypeError('incompatible_method_reciever', |
368 ['DataView.getFloat32', this]); | 431 ['DataView.getFloat32', this]); |
369 } | 432 } |
370 return %DataViewGetFloat32(this, TO_POSITIVE_INTEGER(offset), !!little_endian) ; | 433 offset = TO_INTEGER(offset); |
434 if (offset < 0) { | |
435 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
436 } | |
437 return %DataViewGetFloat32(this, offset, !!little_endian); | |
371 } | 438 } |
372 | 439 |
373 function DataViewSetFloat32(offset, value, little_endian) { | 440 function DataViewSetFloat32(offset, value, little_endian) { |
374 if (!IS_DATAVIEW(this)) { | 441 if (!IS_DATAVIEW(this)) { |
375 throw MakeTypeError('incompatible_method_reciever', | 442 throw MakeTypeError('incompatible_method_reciever', |
376 ['DataView.setFloat32', this]); | 443 ['DataView.setFloat32', this]); |
377 } | 444 } |
445 offset = TO_INTEGER(offset); | |
446 if (offset < 0) { | |
447 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
448 } | |
378 %DataViewSetFloat32(this, | 449 %DataViewSetFloat32(this, |
379 TO_POSITIVE_INTEGER(offset), | 450 offset, |
380 TO_NUMBER_INLINE(value), | 451 TO_NUMBER_INLINE(value), |
381 !!little_endian); | 452 !!little_endian); |
382 } | 453 } |
383 | 454 |
384 function DataViewGetFloat64(offset, little_endian) { | 455 function DataViewGetFloat64(offset, little_endian) { |
385 if (!IS_DATAVIEW(this)) { | 456 if (!IS_DATAVIEW(this)) { |
386 throw MakeTypeError('incompatible_method_reciever', | 457 throw MakeTypeError('incompatible_method_reciever', |
387 ['DataView.getFloat64', this]); | 458 ['DataView.getFloat64', this]); |
388 } | 459 } |
389 return %DataViewGetFloat64(this, TO_POSITIVE_INTEGER(offset), !!little_endian) ; | 460 offset = TO_INTEGER(offset); |
461 if (offset < 0) { | |
462 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
463 } | |
464 return %DataViewGetFloat64(this, offset, !!little_endian); | |
390 } | 465 } |
391 | 466 |
392 function DataViewSetFloat64(offset, value, little_endian) { | 467 function DataViewSetFloat64(offset, value, little_endian) { |
393 if (!IS_DATAVIEW(this)) { | 468 if (!IS_DATAVIEW(this)) { |
394 throw MakeTypeError('incompatible_method_reciever', | 469 throw MakeTypeError('incompatible_method_reciever', |
395 ['DataView.setFloat64', this]); | 470 ['DataView.setFloat64', this]); |
396 } | 471 } |
472 offset = TO_INTEGER(offset); | |
473 if (offset < 0) { | |
474 throw MakeRangeError("invalid_data_view_accessor_offset"); | |
475 } | |
397 %DataViewSetFloat64(this, | 476 %DataViewSetFloat64(this, |
398 TO_POSITIVE_INTEGER(offset), | 477 offset, |
399 TO_NUMBER_INLINE(value), | 478 TO_NUMBER_INLINE(value), |
400 !!little_endian); | 479 !!little_endian); |
401 } | 480 } |
402 | 481 |
403 function SetupDataView() { | 482 function SetupDataView() { |
404 %CheckIsBootstrapping(); | 483 %CheckIsBootstrapping(); |
405 | 484 |
406 // Setup the DataView constructor. | 485 // Setup the DataView constructor. |
407 %SetCode($DataView, DataViewConstructor); | 486 %SetCode($DataView, DataViewConstructor); |
408 %FunctionSetPrototype($DataView, new $Object); | 487 %FunctionSetPrototype($DataView, new $Object); |
(...skipping 26 matching lines...) Expand all Loading... | |
435 | 514 |
436 "getFloat32", DataViewGetFloat32, | 515 "getFloat32", DataViewGetFloat32, |
437 "setFloat32", DataViewSetFloat32, | 516 "setFloat32", DataViewSetFloat32, |
438 | 517 |
439 "getFloat64", DataViewGetFloat64, | 518 "getFloat64", DataViewGetFloat64, |
440 "setFloat64", DataViewSetFloat64 | 519 "setFloat64", DataViewSetFloat64 |
441 )); | 520 )); |
442 } | 521 } |
443 | 522 |
444 SetupDataView(); | 523 SetupDataView(); |
OLD | NEW |