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 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
| 14 var ArrayIteratorCreateResultObject; |
14 var GlobalString = global.String; | 15 var GlobalString = global.String; |
15 | 16 var stringIteratorIteratedStringSymbol = |
16 var ArrayIteratorCreateResultObject; | 17 utils.GetPrivateSymbol("string_iterator_iterated_string_symbol"); |
| 18 var stringIteratorNextIndexSymbol = |
| 19 utils.GetPrivateSymbol("string_iterator_next_index_symbol"); |
17 | 20 |
18 utils.Import(function(from) { | 21 utils.Import(function(from) { |
19 ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject; | 22 ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject; |
20 }); | 23 }); |
21 | 24 |
22 // ------------------------------------------------------------------- | 25 // ------------------------------------------------------------------- |
23 | 26 |
24 var stringIteratorIteratedStringSymbol = | |
25 GLOBAL_PRIVATE("StringIterator#iteratedString"); | |
26 var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE("StringIterator#next"); | |
27 | |
28 | |
29 function StringIterator() {} | 27 function StringIterator() {} |
30 | 28 |
31 | 29 |
32 // 21.1.5.1 CreateStringIterator Abstract Operation | 30 // 21.1.5.1 CreateStringIterator Abstract Operation |
33 function CreateStringIterator(string) { | 31 function CreateStringIterator(string) { |
34 var s = TO_STRING_INLINE(string); | 32 var s = TO_STRING_INLINE(string); |
35 var iterator = new StringIterator; | 33 var iterator = new StringIterator; |
36 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); | 34 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); |
37 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); | 35 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); |
38 return iterator; | 36 return iterator; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 'next', StringIteratorNext | 92 'next', StringIteratorNext |
95 ]); | 93 ]); |
96 %AddNamedProperty(StringIterator.prototype, symbolToStringTag, | 94 %AddNamedProperty(StringIterator.prototype, symbolToStringTag, |
97 "String Iterator", READ_ONLY | DONT_ENUM); | 95 "String Iterator", READ_ONLY | DONT_ENUM); |
98 | 96 |
99 utils.SetFunctionName(StringPrototypeIterator, symbolIterator); | 97 utils.SetFunctionName(StringPrototypeIterator, symbolIterator); |
100 %AddNamedProperty(GlobalString.prototype, symbolIterator, | 98 %AddNamedProperty(GlobalString.prototype, symbolIterator, |
101 StringPrototypeIterator, DONT_ENUM); | 99 StringPrototypeIterator, DONT_ENUM); |
102 | 100 |
103 }) | 101 }) |
OLD | NEW |