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 14 matching lines...) Expand all Loading... |
25 MakeTypeError = from.MakeTypeError; | 25 MakeTypeError = from.MakeTypeError; |
26 }); | 26 }); |
27 | 27 |
28 // ------------------------------------------------------------------- | 28 // ------------------------------------------------------------------- |
29 | 29 |
30 function StringIterator() {} | 30 function StringIterator() {} |
31 | 31 |
32 | 32 |
33 // 21.1.5.1 CreateStringIterator Abstract Operation | 33 // 21.1.5.1 CreateStringIterator Abstract Operation |
34 function CreateStringIterator(string) { | 34 function CreateStringIterator(string) { |
| 35 CHECK_OBJECT_COERCIBLE(string, 'String.prototype[Symbol.iterator]'); |
35 var s = TO_STRING(string); | 36 var s = TO_STRING(string); |
36 var iterator = new StringIterator; | 37 var iterator = new StringIterator; |
37 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); | 38 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); |
38 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); | 39 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); |
39 return iterator; | 40 return iterator; |
40 } | 41 } |
41 | 42 |
42 | 43 |
43 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) | 44 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) |
44 function StringIteratorNext() { | 45 function StringIteratorNext() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 'next', StringIteratorNext | 94 'next', StringIteratorNext |
94 ]); | 95 ]); |
95 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, | 96 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, |
96 "String Iterator", READ_ONLY | DONT_ENUM); | 97 "String Iterator", READ_ONLY | DONT_ENUM); |
97 | 98 |
98 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); | 99 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); |
99 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, | 100 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, |
100 StringPrototypeIterator, DONT_ENUM); | 101 StringPrototypeIterator, DONT_ENUM); |
101 | 102 |
102 }) | 103 }) |
OLD | NEW |