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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 var s = TO_STRING_INLINE(string); | 34 var s = TO_STRING_INLINE(string); |
35 var iterator = new StringIterator; | 35 var iterator = new StringIterator; |
36 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); | 36 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); |
37 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); | 37 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); |
38 return iterator; | 38 return iterator; |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 // 21.1.5.2.1 %StringIteratorPrototype%.next( ) | 42 // 21.1.5.2.1 %StringIteratorPrototype%.next( ) |
43 function StringIteratorNext() { | 43 function StringIteratorNext() { |
44 var iterator = TO_OBJECT(this); | 44 var iterator = this; |
45 | 45 |
46 if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) { | 46 if (!IS_SPEC_OBJECT(iterator) || |
| 47 !HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) { |
47 throw MakeTypeError(kIncompatibleMethodReceiver, | 48 throw MakeTypeError(kIncompatibleMethodReceiver, |
48 'String Iterator.prototype.next'); | 49 'String Iterator.prototype.next'); |
49 } | 50 } |
50 | 51 |
51 var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); | 52 var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); |
52 if (IS_UNDEFINED(s)) { | 53 if (IS_UNDEFINED(s)) { |
53 return ArrayIteratorCreateResultObject(UNDEFINED, true); | 54 return ArrayIteratorCreateResultObject(UNDEFINED, true); |
54 } | 55 } |
55 | 56 |
56 var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); | 57 var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 'next', StringIteratorNext | 95 'next', StringIteratorNext |
95 ]); | 96 ]); |
96 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, | 97 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, |
97 "String Iterator", READ_ONLY | DONT_ENUM); | 98 "String Iterator", READ_ONLY | DONT_ENUM); |
98 | 99 |
99 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); | 100 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); |
100 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, | 101 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, |
101 StringPrototypeIterator, DONT_ENUM); | 102 StringPrototypeIterator, DONT_ENUM); |
102 | 103 |
103 }) | 104 }) |
OLD | NEW |