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 var $mapEntries; | 5 var $mapEntries; |
6 var $mapIteratorNext; | 6 var $mapIteratorNext; |
7 var $setIteratorNext; | 7 var $setIteratorNext; |
8 var $setValues; | 8 var $setValues; |
9 | 9 |
10 (function(global, utils) { | 10 (function(global, utils) { |
11 | 11 |
12 "use strict"; | 12 "use strict"; |
13 | 13 |
14 %CheckIsBootstrapping(); | 14 %CheckIsBootstrapping(); |
15 | 15 |
16 var GlobalMap = global.Map; | 16 var GlobalMap = global.Map; |
17 var GlobalSet = global.Set; | 17 var GlobalSet = global.Set; |
| 18 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 19 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
18 | 20 |
19 // ------------------------------------------------------------------- | 21 // ------------------------------------------------------------------- |
20 | 22 |
21 function SetIteratorConstructor(set, kind) { | 23 function SetIteratorConstructor(set, kind) { |
22 %SetIteratorInitialize(this, set, kind); | 24 %SetIteratorInitialize(this, set, kind); |
23 } | 25 } |
24 | 26 |
25 | 27 |
26 function SetIteratorNextJS() { | 28 function SetIteratorNextJS() { |
27 if (!IS_SET_ITERATOR(this)) { | 29 if (!IS_SET_ITERATOR(this)) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 69 |
68 // ------------------------------------------------------------------- | 70 // ------------------------------------------------------------------- |
69 | 71 |
70 %SetCode(SetIterator, SetIteratorConstructor); | 72 %SetCode(SetIterator, SetIteratorConstructor); |
71 %FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype}); | 73 %FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype}); |
72 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); | 74 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); |
73 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ | 75 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ |
74 'next', SetIteratorNextJS | 76 'next', SetIteratorNextJS |
75 ]); | 77 ]); |
76 | 78 |
77 %AddNamedProperty(SetIterator.prototype, symbolToStringTag, | 79 %AddNamedProperty(SetIterator.prototype, toStringTagSymbol, |
78 "Set Iterator", READ_ONLY | DONT_ENUM); | 80 "Set Iterator", READ_ONLY | DONT_ENUM); |
79 | 81 |
80 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ | 82 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ |
81 'entries', SetEntries, | 83 'entries', SetEntries, |
82 'keys', SetValues, | 84 'keys', SetValues, |
83 'values', SetValues | 85 'values', SetValues |
84 ]); | 86 ]); |
85 | 87 |
86 %AddNamedProperty(GlobalSet.prototype, symbolIterator, SetValues, DONT_ENUM); | 88 %AddNamedProperty(GlobalSet.prototype, iteratorSymbol, SetValues, DONT_ENUM); |
87 | 89 |
88 $setIteratorNext = SetIteratorNextJS; | 90 $setIteratorNext = SetIteratorNextJS; |
89 $setValues = SetValues; | 91 $setValues = SetValues; |
90 | 92 |
91 // ------------------------------------------------------------------- | 93 // ------------------------------------------------------------------- |
92 | 94 |
93 function MapIteratorConstructor(map, kind) { | 95 function MapIteratorConstructor(map, kind) { |
94 %MapIteratorInitialize(this, map, kind); | 96 %MapIteratorInitialize(this, map, kind); |
95 } | 97 } |
96 | 98 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 151 |
150 // ------------------------------------------------------------------- | 152 // ------------------------------------------------------------------- |
151 | 153 |
152 %SetCode(MapIterator, MapIteratorConstructor); | 154 %SetCode(MapIterator, MapIteratorConstructor); |
153 %FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype}); | 155 %FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype}); |
154 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); | 156 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); |
155 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ | 157 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ |
156 'next', MapIteratorNextJS | 158 'next', MapIteratorNextJS |
157 ]); | 159 ]); |
158 | 160 |
159 %AddNamedProperty(MapIterator.prototype, symbolToStringTag, | 161 %AddNamedProperty(MapIterator.prototype, toStringTagSymbol, |
160 "Map Iterator", READ_ONLY | DONT_ENUM); | 162 "Map Iterator", READ_ONLY | DONT_ENUM); |
161 | 163 |
162 | 164 |
163 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ | 165 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ |
164 'entries', MapEntries, | 166 'entries', MapEntries, |
165 'keys', MapKeys, | 167 'keys', MapKeys, |
166 'values', MapValues | 168 'values', MapValues |
167 ]); | 169 ]); |
168 | 170 |
169 %AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM); | 171 %AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM); |
170 | 172 |
171 $mapEntries = MapEntries; | 173 $mapEntries = MapEntries; |
172 $mapIteratorNext = MapIteratorNextJS; | 174 $mapIteratorNext = MapIteratorNextJS; |
173 | 175 |
174 }) | 176 }) |
OLD | NEW |