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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 // ES6 Draft 15.13.5.5.3 | 51 // ES6 Draft 15.13.5.5.3 |
52 function ArrayBufferSlice(start, end) { | 52 function ArrayBufferSlice(start, end) { |
53 if (!IS_ARRAYBUFFER(this)) { | 53 if (!IS_ARRAYBUFFER(this)) { |
54 throw MakeTypeError('incompatible_method_receiver', | 54 throw MakeTypeError('incompatible_method_receiver', |
55 ['ArrayBuffer.prototype.slice', this]); | 55 ['ArrayBuffer.prototype.slice', this]); |
56 } | 56 } |
57 | 57 |
58 var relativeStart = TO_INTEGER(start); | 58 var relativeStart = TO_INTEGER(start); |
59 if (!IS_UNDEFINED(end)) { | |
60 end = TO_INTEGER(end); | |
61 } | |
62 var first; | 59 var first; |
63 var byte_length = %ArrayBufferGetByteLength(this); | 60 var byte_length = %ArrayBufferGetByteLength(this); |
64 if (relativeStart < 0) { | 61 if (relativeStart < 0) { |
65 first = MathMax(byte_length + relativeStart, 0); | 62 first = MathMax(byte_length + relativeStart, 0); |
66 } else { | 63 } else { |
67 first = MathMin(relativeStart, byte_length); | 64 first = MathMin(relativeStart, byte_length); |
68 } | 65 } |
69 var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; | 66 var relativeEnd = IS_UNDEFINED(end) ? byte_length : TO_INTEGER(end); |
70 var fin; | 67 var fin; |
71 if (relativeEnd < 0) { | 68 if (relativeEnd < 0) { |
72 fin = MathMax(byte_length + relativeEnd, 0); | 69 fin = MathMax(byte_length + relativeEnd, 0); |
73 } else { | 70 } else { |
74 fin = MathMin(relativeEnd, byte_length); | 71 fin = MathMin(relativeEnd, byte_length); |
75 } | 72 } |
76 | 73 |
77 if (fin < first) { | 74 if (fin < first) { |
78 fin = first; | 75 fin = first; |
79 } | 76 } |
(...skipping 24 matching lines...) Expand all Loading... |
104 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( | 101 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( |
105 "isView", ArrayBufferIsView | 102 "isView", ArrayBufferIsView |
106 )); | 103 )); |
107 | 104 |
108 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( | 105 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( |
109 "slice", ArrayBufferSlice | 106 "slice", ArrayBufferSlice |
110 )); | 107 )); |
111 } | 108 } |
112 | 109 |
113 SetUpArrayBuffer(); | 110 SetUpArrayBuffer(); |
OLD | NEW |