Chromium Code Reviews| 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 if (IS_NULL_OR_UNDEFINED(string)) { | |
|
adamk
2016/03/09 23:31:58
There's a macro for this:
CHECK_OBJECT_COERCIBLE(
Dan Ehrenberg
2016/03/09 23:53:59
Awesome, applied
| |
| 36 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 37 'String.prototype[Symbol.iterator]'); | |
| 38 } | |
| 35 var s = TO_STRING(string); | 39 var s = TO_STRING(string); |
| 36 var iterator = new StringIterator; | 40 var iterator = new StringIterator; |
| 37 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); | 41 SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s); |
| 38 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); | 42 SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0); |
| 39 return iterator; | 43 return iterator; |
| 40 } | 44 } |
| 41 | 45 |
| 42 | 46 |
| 43 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) | 47 // ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( ) |
| 44 function StringIteratorNext() { | 48 function StringIteratorNext() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 'next', StringIteratorNext | 97 'next', StringIteratorNext |
| 94 ]); | 98 ]); |
| 95 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, | 99 %AddNamedProperty(StringIterator.prototype, toStringTagSymbol, |
| 96 "String Iterator", READ_ONLY | DONT_ENUM); | 100 "String Iterator", READ_ONLY | DONT_ENUM); |
| 97 | 101 |
| 98 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); | 102 utils.SetFunctionName(StringPrototypeIterator, iteratorSymbol); |
| 99 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, | 103 %AddNamedProperty(GlobalString.prototype, iteratorSymbol, |
| 100 StringPrototypeIterator, DONT_ENUM); | 104 StringPrototypeIterator, DONT_ENUM); |
| 101 | 105 |
| 102 }) | 106 }) |
| OLD | NEW |