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