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 |
| 11 var GlobalMap = global.Map; | 11 var GlobalMap = global.Map; |
| 12 var GlobalSet = global.Set; | 12 var GlobalSet = global.Set; |
| 13 var IteratorPrototype = utils.ImportNow("IteratorPrototype"); | |
| 13 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 14 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 15 var MapIterator = utils.ImportNow("MapIterator"); | |
| 14 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 16 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 17 var SetIterator = utils.ImportNow("SetIterator"); | |
| 15 | 18 |
| 16 // ------------------------------------------------------------------- | 19 // ------------------------------------------------------------------- |
| 17 | 20 |
| 18 function SetIteratorConstructor(set, kind) { | 21 function SetIteratorConstructor(set, kind) { |
| 19 %SetIteratorInitialize(this, set, kind); | 22 %SetIteratorInitialize(this, set, kind); |
| 20 } | 23 } |
| 21 | 24 |
| 22 | 25 |
| 23 function SetIteratorNextJS() { | 26 function SetIteratorNextJS() { |
| 24 if (!IS_SET_ITERATOR(this)) { | 27 if (!IS_SET_ITERATOR(this)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 if (!IS_SET(this)) { | 61 if (!IS_SET(this)) { |
| 59 throw MakeTypeError(kIncompatibleMethodReceiver, | 62 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 60 'Set.prototype.values', this); | 63 'Set.prototype.values', this); |
| 61 } | 64 } |
| 62 return new SetIterator(this, ITERATOR_KIND_VALUES); | 65 return new SetIterator(this, ITERATOR_KIND_VALUES); |
| 63 } | 66 } |
| 64 | 67 |
| 65 // ------------------------------------------------------------------- | 68 // ------------------------------------------------------------------- |
| 66 | 69 |
| 67 %SetCode(SetIterator, SetIteratorConstructor); | 70 %SetCode(SetIterator, SetIteratorConstructor); |
| 68 %FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype}); | 71 %FunctionSetPrototype(SetIterator, {__proto__: IteratorPrototype}); |
|
Camillo Bruni
2015/10/16 08:34:01
Not sure if that would add value: since you create
| |
| 69 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); | 72 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); |
| 70 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ | 73 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ |
| 71 'next', SetIteratorNextJS | 74 'next', SetIteratorNextJS |
| 72 ]); | 75 ]); |
| 73 | 76 |
| 74 %AddNamedProperty(SetIterator.prototype, toStringTagSymbol, | 77 %AddNamedProperty(SetIterator.prototype, toStringTagSymbol, |
| 75 "Set Iterator", READ_ONLY | DONT_ENUM); | 78 "Set Iterator", READ_ONLY | DONT_ENUM); |
| 76 | 79 |
| 77 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ | 80 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ |
| 78 'entries', SetEntries, | 81 'entries', SetEntries, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 if (!IS_MAP(this)) { | 140 if (!IS_MAP(this)) { |
| 138 throw MakeTypeError(kIncompatibleMethodReceiver, | 141 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 139 'Map.prototype.values', this); | 142 'Map.prototype.values', this); |
| 140 } | 143 } |
| 141 return new MapIterator(this, ITERATOR_KIND_VALUES); | 144 return new MapIterator(this, ITERATOR_KIND_VALUES); |
| 142 } | 145 } |
| 143 | 146 |
| 144 // ------------------------------------------------------------------- | 147 // ------------------------------------------------------------------- |
| 145 | 148 |
| 146 %SetCode(MapIterator, MapIteratorConstructor); | 149 %SetCode(MapIterator, MapIteratorConstructor); |
| 147 %FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype}); | 150 %FunctionSetPrototype(MapIterator, {__proto__: IteratorPrototype}); |
|
Camillo Bruni
2015/10/16 08:34:00
ditto.
| |
| 148 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); | 151 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); |
| 149 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ | 152 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ |
| 150 'next', MapIteratorNextJS | 153 'next', MapIteratorNextJS |
| 151 ]); | 154 ]); |
| 152 | 155 |
| 153 %AddNamedProperty(MapIterator.prototype, toStringTagSymbol, | 156 %AddNamedProperty(MapIterator.prototype, toStringTagSymbol, |
| 154 "Map Iterator", READ_ONLY | DONT_ENUM); | 157 "Map Iterator", READ_ONLY | DONT_ENUM); |
| 155 | 158 |
| 156 | 159 |
| 157 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ | 160 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ |
| 158 'entries', MapEntries, | 161 'entries', MapEntries, |
| 159 'keys', MapKeys, | 162 'keys', MapKeys, |
| 160 'values', MapValues | 163 'values', MapValues |
| 161 ]); | 164 ]); |
| 162 | 165 |
| 163 %AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM); | 166 %AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM); |
| 164 | 167 |
| 165 // ------------------------------------------------------------------- | 168 // ------------------------------------------------------------------- |
| 166 // Exports | 169 // Exports |
| 167 | 170 |
| 168 utils.Export(function(to) { | 171 utils.Export(function(to) { |
| 169 to.MapEntries = MapEntries; | 172 to.MapEntries = MapEntries; |
| 170 to.MapIteratorNext = MapIteratorNextJS; | 173 to.MapIteratorNext = MapIteratorNextJS; |
| 171 to.SetIteratorNext = SetIteratorNextJS; | 174 to.SetIteratorNext = SetIteratorNextJS; |
| 172 to.SetValues = SetValues; | 175 to.SetValues = SetValues; |
| 173 }); | 176 }); |
| 174 | 177 |
| 175 }) | 178 }) |
| OLD | NEW |