OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } else { | 112 } else { |
113 NAMEConstructByArrayLike(this, arg1); | 113 NAMEConstructByArrayLike(this, arg1); |
114 } | 114 } |
115 } else { | 115 } else { |
116 throw MakeTypeError("constructor_not_function", ["NAME"]) | 116 throw MakeTypeError("constructor_not_function", ["NAME"]) |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 function NAME_GetBuffer() { | 120 function NAME_GetBuffer() { |
121 if (!(%_ClassOf(this) === 'NAME')) { | 121 if (!(%_ClassOf(this) === 'NAME')) { |
122 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.buffer", this); | 122 throw MakeTypeError('incompatible_method_receiver', |
| 123 ["NAME.buffer", this]); |
123 } | 124 } |
124 return %TypedArrayGetBuffer(this); | 125 return %TypedArrayGetBuffer(this); |
125 } | 126 } |
126 | 127 |
127 function NAME_GetByteLength() { | 128 function NAME_GetByteLength() { |
128 if (!(%_ClassOf(this) === 'NAME')) { | 129 if (!(%_ClassOf(this) === 'NAME')) { |
129 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteLength", this); | 130 throw MakeTypeError('incompatible_method_receiver', |
| 131 ["NAME.byteLength", this]); |
130 } | 132 } |
131 return %_ArrayBufferViewGetByteLength(this); | 133 return %_ArrayBufferViewGetByteLength(this); |
132 } | 134 } |
133 | 135 |
134 function NAME_GetByteOffset() { | 136 function NAME_GetByteOffset() { |
135 if (!(%_ClassOf(this) === 'NAME')) { | 137 if (!(%_ClassOf(this) === 'NAME')) { |
136 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteOffset", this); | 138 throw MakeTypeError('incompatible_method_receiver', |
| 139 ["NAME.byteOffset", this]); |
137 } | 140 } |
138 return %_ArrayBufferViewGetByteOffset(this); | 141 return %_ArrayBufferViewGetByteOffset(this); |
139 } | 142 } |
140 | 143 |
141 function NAME_GetLength() { | 144 function NAME_GetLength() { |
142 if (!(%_ClassOf(this) === 'NAME')) { | 145 if (!(%_ClassOf(this) === 'NAME')) { |
143 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.length", this); | 146 throw MakeTypeError('incompatible_method_receiver', |
| 147 ["NAME.length", this]); |
144 } | 148 } |
145 return %_TypedArrayGetLength(this); | 149 return %_TypedArrayGetLength(this); |
146 } | 150 } |
147 | 151 |
148 var $NAME = global.NAME; | 152 var $NAME = global.NAME; |
149 | 153 |
150 function NAMESubArray(begin, end) { | 154 function NAMESubArray(begin, end) { |
151 if (!(%_ClassOf(this) === 'NAME')) { | 155 if (!(%_ClassOf(this) === 'NAME')) { |
152 throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this); | 156 throw MakeTypeError('incompatible_method_receiver', |
| 157 ["NAME.subarray", this]); |
153 } | 158 } |
154 var beginInt = TO_INTEGER(begin); | 159 var beginInt = TO_INTEGER(begin); |
155 if (!IS_UNDEFINED(end)) { | 160 if (!IS_UNDEFINED(end)) { |
156 end = TO_INTEGER(end); | 161 end = TO_INTEGER(end); |
157 } | 162 } |
158 | 163 |
159 var srcLength = %_TypedArrayGetLength(this); | 164 var srcLength = %_TypedArrayGetLength(this); |
160 if (beginInt < 0) { | 165 if (beginInt < 0) { |
161 beginInt = $max(0, srcLength + beginInt); | 166 beginInt = $max(0, srcLength + beginInt); |
162 } else { | 167 } else { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 throw new MakeRangeError('invalid_data_view_length'); | 359 throw new MakeRangeError('invalid_data_view_length'); |
355 } | 360 } |
356 %_DataViewInitialize(this, buffer, offset, length); | 361 %_DataViewInitialize(this, buffer, offset, length); |
357 } else { | 362 } else { |
358 throw MakeTypeError('constructor_not_function', ["DataView"]); | 363 throw MakeTypeError('constructor_not_function', ["DataView"]); |
359 } | 364 } |
360 } | 365 } |
361 | 366 |
362 function DataViewGetBufferJS() { | 367 function DataViewGetBufferJS() { |
363 if (!IS_DATAVIEW(this)) { | 368 if (!IS_DATAVIEW(this)) { |
364 throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this); | 369 throw MakeTypeError('incompatible_method_receiver', |
| 370 ['DataView.buffer', this]); |
365 } | 371 } |
366 return %DataViewGetBuffer(this); | 372 return %DataViewGetBuffer(this); |
367 } | 373 } |
368 | 374 |
369 function DataViewGetByteOffset() { | 375 function DataViewGetByteOffset() { |
370 if (!IS_DATAVIEW(this)) { | 376 if (!IS_DATAVIEW(this)) { |
371 throw MakeTypeError(kIncompatibleMethodReceiver, | 377 throw MakeTypeError('incompatible_method_receiver', |
372 'DataView.byteOffset', this); | 378 ['DataView.byteOffset', this]); |
373 } | 379 } |
374 return %_ArrayBufferViewGetByteOffset(this); | 380 return %_ArrayBufferViewGetByteOffset(this); |
375 } | 381 } |
376 | 382 |
377 function DataViewGetByteLength() { | 383 function DataViewGetByteLength() { |
378 if (!IS_DATAVIEW(this)) { | 384 if (!IS_DATAVIEW(this)) { |
379 throw MakeTypeError(kIncompatibleMethodReceiver, | 385 throw MakeTypeError('incompatible_method_receiver', |
380 'DataView.byteLength', this); | 386 ['DataView.byteLength', this]); |
381 } | 387 } |
382 return %_ArrayBufferViewGetByteLength(this); | 388 return %_ArrayBufferViewGetByteLength(this); |
383 } | 389 } |
384 | 390 |
385 macro DATA_VIEW_TYPES(FUNCTION) | 391 macro DATA_VIEW_TYPES(FUNCTION) |
386 FUNCTION(Int8) | 392 FUNCTION(Int8) |
387 FUNCTION(Uint8) | 393 FUNCTION(Uint8) |
388 FUNCTION(Int16) | 394 FUNCTION(Int16) |
389 FUNCTION(Uint16) | 395 FUNCTION(Uint16) |
390 FUNCTION(Int32) | 396 FUNCTION(Int32) |
391 FUNCTION(Uint32) | 397 FUNCTION(Uint32) |
392 FUNCTION(Float32) | 398 FUNCTION(Float32) |
393 FUNCTION(Float64) | 399 FUNCTION(Float64) |
394 endmacro | 400 endmacro |
395 | 401 |
396 function ToPositiveDataViewOffset(offset) { | 402 function ToPositiveDataViewOffset(offset) { |
397 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); | 403 return ToPositiveInteger(offset, 'invalid_data_view_accessor_offset'); |
398 } | 404 } |
399 | 405 |
400 | 406 |
401 macro DATA_VIEW_GETTER_SETTER(TYPENAME) | 407 macro DATA_VIEW_GETTER_SETTER(TYPENAME) |
402 function DataViewGetTYPENAMEJS(offset, little_endian) { | 408 function DataViewGetTYPENAMEJS(offset, little_endian) { |
403 if (!IS_DATAVIEW(this)) { | 409 if (!IS_DATAVIEW(this)) { |
404 throw MakeTypeError(kIncompatibleMethodReceiver, | 410 throw MakeTypeError('incompatible_method_receiver', |
405 'DataView.getTYPENAME', this); | 411 ['DataView.getTYPENAME', this]); |
406 } | 412 } |
407 if (%_ArgumentsLength() < 1) { | 413 if (%_ArgumentsLength() < 1) { |
408 throw MakeTypeError('invalid_argument'); | 414 throw MakeTypeError('invalid_argument'); |
409 } | 415 } |
410 return %DataViewGetTYPENAME(this, | 416 return %DataViewGetTYPENAME(this, |
411 ToPositiveDataViewOffset(offset), | 417 ToPositiveDataViewOffset(offset), |
412 !!little_endian); | 418 !!little_endian); |
413 } | 419 } |
414 | 420 |
415 function DataViewSetTYPENAMEJS(offset, value, little_endian) { | 421 function DataViewSetTYPENAMEJS(offset, value, little_endian) { |
416 if (!IS_DATAVIEW(this)) { | 422 if (!IS_DATAVIEW(this)) { |
417 throw MakeTypeError(kIncompatibleMethodReceiver, | 423 throw MakeTypeError('incompatible_method_receiver', |
418 'DataView.setTYPENAME', this); | 424 ['DataView.setTYPENAME', this]); |
419 } | 425 } |
420 if (%_ArgumentsLength() < 2) { | 426 if (%_ArgumentsLength() < 2) { |
421 throw MakeTypeError('invalid_argument'); | 427 throw MakeTypeError('invalid_argument'); |
422 } | 428 } |
423 %DataViewSetTYPENAME(this, | 429 %DataViewSetTYPENAME(this, |
424 ToPositiveDataViewOffset(offset), | 430 ToPositiveDataViewOffset(offset), |
425 TO_NUMBER_INLINE(value), | 431 TO_NUMBER_INLINE(value), |
426 !!little_endian); | 432 !!little_endian); |
427 } | 433 } |
428 endmacro | 434 endmacro |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 "setUint32", DataViewSetUint32JS, | 468 "setUint32", DataViewSetUint32JS, |
463 | 469 |
464 "getFloat32", DataViewGetFloat32JS, | 470 "getFloat32", DataViewGetFloat32JS, |
465 "setFloat32", DataViewSetFloat32JS, | 471 "setFloat32", DataViewSetFloat32JS, |
466 | 472 |
467 "getFloat64", DataViewGetFloat64JS, | 473 "getFloat64", DataViewGetFloat64JS, |
468 "setFloat64", DataViewSetFloat64JS | 474 "setFloat64", DataViewSetFloat64JS |
469 ]); | 475 ]); |
470 | 476 |
471 })(); | 477 })(); |
OLD | NEW |