| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 7 |
| 8 // This file relies on the fact that the following declaration has been made | 8 // This file relies on the fact that the following declaration has been made |
| 9 // in runtime.js: | 9 // in runtime.js: |
| 10 // var $String = global.String; | 10 // var $String = global.String; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // 21.1.5.2.2 %StringIteratorPrototype%[@@iterator] | 31 // 21.1.5.2.2 %StringIteratorPrototype%[@@iterator] |
| 32 function StringIteratorIterator() { | 32 function StringIteratorIterator() { |
| 33 return this; | 33 return this; |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 // 21.1.5.2.1 %StringIteratorPrototype%.next( ) | 37 // 21.1.5.2.1 %StringIteratorPrototype%.next( ) |
| 38 function StringIteratorNext() { | 38 function StringIteratorNext() { |
| 39 var iterator = ToObject(this); | 39 var iterator = ToObject(this); |
| 40 | 40 |
| 41 if (!HAS_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) { | 41 if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) { |
| 42 throw MakeTypeError('incompatible_method_receiver', | 42 throw MakeTypeError('incompatible_method_receiver', |
| 43 ['String Iterator.prototype.next']); | 43 ['String Iterator.prototype.next']); |
| 44 } | 44 } |
| 45 | 45 |
| 46 var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); | 46 var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); |
| 47 if (IS_UNDEFINED(s)) { | 47 if (IS_UNDEFINED(s)) { |
| 48 return CreateIteratorResultObject(UNDEFINED, true); | 48 return CreateIteratorResultObject(UNDEFINED, true); |
| 49 } | 49 } |
| 50 | 50 |
| 51 var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); | 51 var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); |
| 52 var length = TO_UINT32(s.length); | 52 var length = TO_UINT32(s.length); |
| 53 | 53 |
| 54 if (position >= length) { | 54 if (position >= length) { |
| 55 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED); | 55 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, |
| 56 UNDEFINED); |
| 56 return CreateIteratorResultObject(UNDEFINED, true); | 57 return CreateIteratorResultObject(UNDEFINED, true); |
| 57 } | 58 } |
| 58 | 59 |
| 59 var first = %_StringCharCodeAt(s, position); | 60 var first = %_StringCharCodeAt(s, position); |
| 60 var resultString = %_StringCharFromCode(first); | 61 var resultString = %_StringCharFromCode(first); |
| 61 position++; | 62 position++; |
| 62 | 63 |
| 63 if (first >= 0xD800 && first <= 0xDBFF && position < length) { | 64 if (first >= 0xD800 && first <= 0xDBFF && position < length) { |
| 64 var second = %_StringCharCodeAt(s, position); | 65 var second = %_StringCharCodeAt(s, position); |
| 65 if (second >= 0xDC00 && second <= 0xDFFF) { | 66 if (second >= 0xDC00 && second <= 0xDFFF) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 98 |
| 98 | 99 |
| 99 function ExtendStringPrototypeWithIterator() { | 100 function ExtendStringPrototypeWithIterator() { |
| 100 %CheckIsBootstrapping(); | 101 %CheckIsBootstrapping(); |
| 101 | 102 |
| 102 %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]'); | 103 %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]'); |
| 103 %AddNamedProperty($String.prototype, symbolIterator, | 104 %AddNamedProperty($String.prototype, symbolIterator, |
| 104 StringPrototypeIterator, DONT_ENUM); | 105 StringPrototypeIterator, DONT_ENUM); |
| 105 } | 106 } |
| 106 ExtendStringPrototypeWithIterator(); | 107 ExtendStringPrototypeWithIterator(); |
| OLD | NEW |