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 13 matching lines...) Expand all Loading... | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 "use strict"; | 28 "use strict"; |
29 | 29 |
30 var $ArrayBuffer = global.ArrayBuffer; | 30 var $ArrayBuffer = global.ArrayBuffer; |
31 | 31 |
32 // ------------------------------------------------------------------- | 32 // ------------------------------------------------------------------- |
33 | 33 |
34 function ArrayBufferConstructor(byteLength) { // length = 1 | 34 function ArrayBufferConstructor(length) { // length = 1 |
35 if (%_IsConstructCall()) { | 35 if (%_IsConstructCall()) { |
36 var l = TO_POSITIVE_INTEGER(byteLength); | 36 var byteLength = IS_UNDEFINED(length) ? 0 : TO_INTEGER(length); |
rossberg
2013/06/24 12:36:03
Doesn't TO_INTEGER(undefined) yield 0 anyway?
| |
37 %ArrayBufferInitialize(this, l); | 37 if (byteLength < 0) |
38 throw MakeRangeError("invalid_array_buffer_length"); | |
39 %ArrayBufferInitialize(this, byteLength); | |
38 } else { | 40 } else { |
39 return new $ArrayBuffer(byteLength); | 41 return new $ArrayBuffer(length); |
40 } | 42 } |
41 } | 43 } |
42 | 44 |
43 function ArrayBufferGetByteLength() { | 45 function ArrayBufferGetByteLength() { |
44 if (!IS_ARRAYBUFFER(this)) { | 46 if (!IS_ARRAYBUFFER(this)) { |
45 throw MakeTypeError('incompatible_method_receiver', | 47 throw MakeTypeError('incompatible_method_receiver', |
46 ['ArrayBuffer.prototype.byteLength', this]); | 48 ['ArrayBuffer.prototype.byteLength', this]); |
47 } | 49 } |
48 return %ArrayBufferGetByteLength(this); | 50 return %ArrayBufferGetByteLength(this); |
49 } | 51 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength); | 93 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength); |
92 | 94 |
93 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( | 95 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( |
94 "slice", ArrayBufferSlice | 96 "slice", ArrayBufferSlice |
95 )); | 97 )); |
96 } | 98 } |
97 | 99 |
98 SetUpArrayBuffer(); | 100 SetUpArrayBuffer(); |
99 | 101 |
100 | 102 |
OLD | NEW |