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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 var $ArrayBuffer = global.ArrayBuffer; | 30 var $ArrayBuffer = global.ArrayBuffer; |
31 | 31 |
32 // ------------------------------------------------------------------- | 32 // ------------------------------------------------------------------- |
33 | 33 |
34 function ArrayBufferConstructor(length) { // length = 1 | 34 function ArrayBufferConstructor(length) { // length = 1 |
35 if (%_IsConstructCall()) { | 35 if (%_IsConstructCall()) { |
36 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); | 36 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); |
37 %ArrayBufferInitialize(this, byteLength); | 37 %ArrayBufferInitialize(this, byteLength); |
38 } else { | 38 } else { |
39 return new $ArrayBuffer(length); | 39 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 function ArrayBufferGetByteLength() { | 43 function ArrayBufferGetByteLength() { |
44 if (!IS_ARRAYBUFFER(this)) { | 44 if (!IS_ARRAYBUFFER(this)) { |
45 throw MakeTypeError('incompatible_method_receiver', | 45 throw MakeTypeError('incompatible_method_receiver', |
46 ['ArrayBuffer.prototype.byteLength', this]); | 46 ['ArrayBuffer.prototype.byteLength', this]); |
47 } | 47 } |
48 return %ArrayBufferGetByteLength(this); | 48 return %ArrayBufferGetByteLength(this); |
49 } | 49 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength); | 94 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength); |
95 | 95 |
96 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( | 96 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( |
97 "slice", ArrayBufferSlice | 97 "slice", ArrayBufferSlice |
98 )); | 98 )); |
99 } | 99 } |
100 | 100 |
101 SetUpArrayBuffer(); | 101 SetUpArrayBuffer(); |
102 | 102 |
103 | 103 |
OLD | NEW |