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 GlobalString = global.String; | 14 var GlobalString = global.String; |
15 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 15 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
16 var stringIteratorIteratedStringSymbol = | 16 var stringIteratorIteratedStringSymbol = |
17 utils.ImportNow("string_iterator_iterated_string_symbol"); | 17 utils.ImportNow("string_iterator_iterated_string_symbol"); |
18 var stringIteratorNextIndexSymbol = | 18 var stringIteratorNextIndexSymbol = |
19 utils.ImportNow("string_iterator_next_index_symbol"); | 19 utils.ImportNow("string_iterator_next_index_symbol"); |
20 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 20 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
21 | 21 |
22 // ------------------------------------------------------------------- | 22 // ------------------------------------------------------------------- |
23 | 23 |
24 function StringIterator() {} | 24 function StringIterator() {} |
25 | 25 |
26 | 26 |
27 // 21.1.5.1 CreateStringIterator Abstract Operation | 27 // 21.1.5.1 CreateStringIterator Abstract Operation |
28 function CreateStringIterator(string) { | 28 function CreateStringIterator(string) { |
29 var s = TO_STRING_INLINE(string); | 29 var s = TO_STRING(string); |
30 var iterator = new StringIterator; | 30 var iterator = new StringIterator; |
31 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); | 31 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); |
32 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); | 32 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); |
33 return iterator; | 33 return iterator; |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) | 37 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) |
38 function StringIteratorNext() { | 38 function StringIteratorNext() { |
39 var iterator = this; | 39 var iterator = this; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 'next', StringIteratorNext | 87 'next', StringIteratorNext |
88 ]); | 88 ]); |
89 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, | 89 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, |
90 "String Iterator", READ_ONLY | DONT_ENUM); | 90 "String Iterator", READ_ONLY | DONT_ENUM); |
91 | 91 |
92 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); | 92 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); |
93 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, | 93 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, |
94 StringPrototypeIterator, DONT_ENUM); | 94 StringPrototypeIterator, DONT_ENUM); |
95 | 95 |
96 }) | 96 }) |
OLD | NEW |