| 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, shared, exports) { | 10 (function(global, shared, exports) { |
| 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 GlobalObject = global.Object; | |
| 18 var GlobalSet = global.Set; | 17 var GlobalSet = global.Set; |
| 19 | 18 |
| 20 // ------------------------------------------------------------------- | 19 // ------------------------------------------------------------------- |
| 21 | 20 |
| 22 function SetIteratorConstructor(set, kind) { | 21 function SetIteratorConstructor(set, kind) { |
| 23 %SetIteratorInitialize(this, set, kind); | 22 %SetIteratorInitialize(this, set, kind); |
| 24 } | 23 } |
| 25 | 24 |
| 26 | 25 |
| 27 function SetIteratorNextJS() { | 26 function SetIteratorNextJS() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 42 break; | 41 break; |
| 43 case ITERATOR_KIND_ENTRIES: | 42 case ITERATOR_KIND_ENTRIES: |
| 44 value_array[1] = value_array[0]; | 43 value_array[1] = value_array[0]; |
| 45 break; | 44 break; |
| 46 } | 45 } |
| 47 | 46 |
| 48 return entry; | 47 return entry; |
| 49 } | 48 } |
| 50 | 49 |
| 51 | 50 |
| 52 function SetIteratorSymbolIterator() { | |
| 53 return this; | |
| 54 } | |
| 55 | |
| 56 | |
| 57 function SetEntries() { | 51 function SetEntries() { |
| 58 if (!IS_SET(this)) { | 52 if (!IS_SET(this)) { |
| 59 throw MakeTypeError(kIncompatibleMethodReceiver, | 53 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 60 'Set.prototype.entries', this); | 54 'Set.prototype.entries', this); |
| 61 } | 55 } |
| 62 return new SetIterator(this, ITERATOR_KIND_ENTRIES); | 56 return new SetIterator(this, ITERATOR_KIND_ENTRIES); |
| 63 } | 57 } |
| 64 | 58 |
| 65 | 59 |
| 66 function SetValues() { | 60 function SetValues() { |
| 67 if (!IS_SET(this)) { | 61 if (!IS_SET(this)) { |
| 68 throw MakeTypeError(kIncompatibleMethodReceiver, | 62 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 69 'Set.prototype.values', this); | 63 'Set.prototype.values', this); |
| 70 } | 64 } |
| 71 return new SetIterator(this, ITERATOR_KIND_VALUES); | 65 return new SetIterator(this, ITERATOR_KIND_VALUES); |
| 72 } | 66 } |
| 73 | 67 |
| 74 // ------------------------------------------------------------------- | 68 // ------------------------------------------------------------------- |
| 75 | 69 |
| 76 %SetCode(SetIterator, SetIteratorConstructor); | 70 %SetCode(SetIterator, SetIteratorConstructor); |
| 77 %FunctionSetPrototype(SetIterator, new GlobalObject()); | 71 %FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype}); |
| 78 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); | 72 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); |
| 79 $installFunctions(SetIterator.prototype, DONT_ENUM, [ | 73 $installFunctions(SetIterator.prototype, DONT_ENUM, [ |
| 80 'next', SetIteratorNextJS | 74 'next', SetIteratorNextJS |
| 81 ]); | 75 ]); |
| 82 | 76 |
| 83 $setFunctionName(SetIteratorSymbolIterator, symbolIterator); | |
| 84 %AddNamedProperty(SetIterator.prototype, symbolIterator, | |
| 85 SetIteratorSymbolIterator, DONT_ENUM); | |
| 86 %AddNamedProperty(SetIterator.prototype, symbolToStringTag, | 77 %AddNamedProperty(SetIterator.prototype, symbolToStringTag, |
| 87 "Set Iterator", READ_ONLY | DONT_ENUM); | 78 "Set Iterator", READ_ONLY | DONT_ENUM); |
| 88 | 79 |
| 89 $installFunctions(GlobalSet.prototype, DONT_ENUM, [ | 80 $installFunctions(GlobalSet.prototype, DONT_ENUM, [ |
| 90 'entries', SetEntries, | 81 'entries', SetEntries, |
| 91 'keys', SetValues, | 82 'keys', SetValues, |
| 92 'values', SetValues | 83 'values', SetValues |
| 93 ]); | 84 ]); |
| 94 | 85 |
| 95 %AddNamedProperty(GlobalSet.prototype, symbolIterator, SetValues, DONT_ENUM); | 86 %AddNamedProperty(GlobalSet.prototype, symbolIterator, SetValues, DONT_ENUM); |
| 96 | 87 |
| 97 $setIteratorNext = SetIteratorNextJS; | 88 $setIteratorNext = SetIteratorNextJS; |
| 98 $setValues = SetValues; | 89 $setValues = SetValues; |
| 99 | 90 |
| 100 // ------------------------------------------------------------------- | 91 // ------------------------------------------------------------------- |
| 101 | 92 |
| 102 function MapIteratorConstructor(map, kind) { | 93 function MapIteratorConstructor(map, kind) { |
| 103 %MapIteratorInitialize(this, map, kind); | 94 %MapIteratorInitialize(this, map, kind); |
| 104 } | 95 } |
| 105 | 96 |
| 106 | 97 |
| 107 function MapIteratorSymbolIterator() { | |
| 108 return this; | |
| 109 } | |
| 110 | |
| 111 | |
| 112 function MapIteratorNextJS() { | 98 function MapIteratorNextJS() { |
| 113 if (!IS_MAP_ITERATOR(this)) { | 99 if (!IS_MAP_ITERATOR(this)) { |
| 114 throw MakeTypeError(kIncompatibleMethodReceiver, | 100 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 115 'Map Iterator.prototype.next', this); | 101 'Map Iterator.prototype.next', this); |
| 116 } | 102 } |
| 117 | 103 |
| 118 var value_array = [UNDEFINED, UNDEFINED]; | 104 var value_array = [UNDEFINED, UNDEFINED]; |
| 119 var entry = {value: value_array, done: false}; | 105 var entry = {value: value_array, done: false}; |
| 120 switch (%MapIteratorNext(this, value_array)) { | 106 switch (%MapIteratorNext(this, value_array)) { |
| 121 case 0: | 107 case 0: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (!IS_MAP(this)) { | 143 if (!IS_MAP(this)) { |
| 158 throw MakeTypeError(kIncompatibleMethodReceiver, | 144 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 159 'Map.prototype.values', this); | 145 'Map.prototype.values', this); |
| 160 } | 146 } |
| 161 return new MapIterator(this, ITERATOR_KIND_VALUES); | 147 return new MapIterator(this, ITERATOR_KIND_VALUES); |
| 162 } | 148 } |
| 163 | 149 |
| 164 // ------------------------------------------------------------------- | 150 // ------------------------------------------------------------------- |
| 165 | 151 |
| 166 %SetCode(MapIterator, MapIteratorConstructor); | 152 %SetCode(MapIterator, MapIteratorConstructor); |
| 167 %FunctionSetPrototype(MapIterator, new GlobalObject()); | 153 %FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype}); |
| 168 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); | 154 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); |
| 169 $installFunctions(MapIterator.prototype, DONT_ENUM, [ | 155 $installFunctions(MapIterator.prototype, DONT_ENUM, [ |
| 170 'next', MapIteratorNextJS | 156 'next', MapIteratorNextJS |
| 171 ]); | 157 ]); |
| 172 | 158 |
| 173 $setFunctionName(MapIteratorSymbolIterator, symbolIterator); | |
| 174 %AddNamedProperty(MapIterator.prototype, symbolIterator, | |
| 175 MapIteratorSymbolIterator, DONT_ENUM); | |
| 176 %AddNamedProperty(MapIterator.prototype, symbolToStringTag, | 159 %AddNamedProperty(MapIterator.prototype, symbolToStringTag, |
| 177 "Map Iterator", READ_ONLY | DONT_ENUM); | 160 "Map Iterator", READ_ONLY | DONT_ENUM); |
| 178 | 161 |
| 179 | 162 |
| 180 $installFunctions(GlobalMap.prototype, DONT_ENUM, [ | 163 $installFunctions(GlobalMap.prototype, DONT_ENUM, [ |
| 181 'entries', MapEntries, | 164 'entries', MapEntries, |
| 182 'keys', MapKeys, | 165 'keys', MapKeys, |
| 183 'values', MapValues | 166 'values', MapValues |
| 184 ]); | 167 ]); |
| 185 | 168 |
| 186 %AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM); | 169 %AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM); |
| 187 | 170 |
| 188 $mapEntries = MapEntries; | 171 $mapEntries = MapEntries; |
| 189 $mapIteratorNext = MapIteratorNextJS; | 172 $mapIteratorNext = MapIteratorNextJS; |
| 190 | 173 |
| 191 }) | 174 }) |
| OLD | NEW |