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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 var $ArrayBuffer = global.ArrayBuffer; | 7 var $ArrayBuffer = global.ArrayBuffer; |
8 | 8 |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 ['ArrayBuffer.prototype.slice', this]); | 32 ['ArrayBuffer.prototype.slice', this]); |
33 } | 33 } |
34 | 34 |
35 var relativeStart = TO_INTEGER(start); | 35 var relativeStart = TO_INTEGER(start); |
36 if (!IS_UNDEFINED(end)) { | 36 if (!IS_UNDEFINED(end)) { |
37 end = TO_INTEGER(end); | 37 end = TO_INTEGER(end); |
38 } | 38 } |
39 var first; | 39 var first; |
40 var byte_length = %_ArrayBufferGetByteLength(this); | 40 var byte_length = %_ArrayBufferGetByteLength(this); |
41 if (relativeStart < 0) { | 41 if (relativeStart < 0) { |
42 first = MathMax(byte_length + relativeStart, 0); | 42 first = $max(byte_length + relativeStart, 0); |
43 } else { | 43 } else { |
44 first = MathMin(relativeStart, byte_length); | 44 first = $min(relativeStart, byte_length); |
45 } | 45 } |
46 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; | 46 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; |
47 var fin; | 47 var fin; |
48 if (relativeEnd < 0) { | 48 if (relativeEnd < 0) { |
49 fin = MathMax(byte_length + relativeEnd, 0); | 49 fin = $max(byte_length + relativeEnd, 0); |
50 } else { | 50 } else { |
51 fin = MathMin(relativeEnd, byte_length); | 51 fin = $min(relativeEnd, byte_length); |
52 } | 52 } |
53 | 53 |
54 if (fin < first) { | 54 if (fin < first) { |
55 fin = first; | 55 fin = first; |
56 } | 56 } |
57 var newLen = fin - first; | 57 var newLen = fin - first; |
58 // TODO(dslomov): implement inheritance | 58 // TODO(dslomov): implement inheritance |
59 var result = new $ArrayBuffer(newLen); | 59 var result = new $ArrayBuffer(newLen); |
60 | 60 |
61 %ArrayBufferSliceImpl(this, result, first); | 61 %ArrayBufferSliceImpl(this, result, first); |
(...skipping 23 matching lines...) Expand all Loading... |
85 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( | 85 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( |
86 "isView", ArrayBufferIsViewJS | 86 "isView", ArrayBufferIsViewJS |
87 )); | 87 )); |
88 | 88 |
89 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( | 89 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( |
90 "slice", ArrayBufferSlice | 90 "slice", ArrayBufferSlice |
91 )); | 91 )); |
92 } | 92 } |
93 | 93 |
94 SetUpArrayBuffer(); | 94 SetUpArrayBuffer(); |
OLD | NEW |