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