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 IteratorPrototype = utils.ImportNow("IteratorPrototype"); |
15 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 16 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
16 var stringIteratorIteratedStringSymbol = | 17 var stringIteratorIteratedStringSymbol = |
17 utils.ImportNow("string_iterator_iterated_string_symbol"); | 18 utils.ImportNow("string_iterator_iterated_string_symbol"); |
18 var stringIteratorNextIndexSymbol = | 19 var stringIteratorNextIndexSymbol = |
19 utils.ImportNow("string_iterator_next_index_symbol"); | 20 utils.ImportNow("string_iterator_next_index_symbol"); |
20 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 21 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
21 | 22 |
22 // ------------------------------------------------------------------- | 23 // ------------------------------------------------------------------- |
23 | 24 |
24 function StringIterator() {} | 25 function StringIterator() {} |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 | 75 |
75 | 76 |
76 // 21.1.3.27 String.prototype [ @@iterator ]( ) | 77 // 21.1.3.27 String.prototype [ @@iterator ]( ) |
77 function StringPrototypeIterator() { | 78 function StringPrototypeIterator() { |
78 return CreateStringIterator(this); | 79 return CreateStringIterator(this); |
79 } | 80 } |
80 | 81 |
81 //------------------------------------------------------------------- | 82 //------------------------------------------------------------------- |
82 | 83 |
83 %FunctionSetPrototype(StringIterator, {__proto__: $iteratorPrototype}); | 84 %FunctionSetPrototype(StringIterator, {__proto__: IteratorPrototype}); |
84 %FunctionSetInstanceClassName(StringIterator, 'String Iterator'); | 85 %FunctionSetInstanceClassName(StringIterator, 'String Iterator'); |
85 | 86 |
86 utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [ | 87 utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [ |
87 'next', StringIteratorNext | 88 'next', StringIteratorNext |
88 ]); | 89 ]); |
89 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, | 90 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, |
90 "String Iterator", READ_ONLY | DONT_ENUM); | 91 "String Iterator", READ_ONLY | DONT_ENUM); |
91 | 92 |
92 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); | 93 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); |
93 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, | 94 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, |
94 StringPrototypeIterator, DONT_ENUM); | 95 StringPrototypeIterator, DONT_ENUM); |
95 | 96 |
96 }) | 97 }) |
OLD | NEW |