| 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() { | 10 (function() { |
| 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; | 17 var GlobalObject = global.Object; |
| 18 var GlobalSet = global.Set; | 18 var GlobalSet = global.Set; |
| 19 | 19 |
| 20 // ------------------------------------------------------------------- | 20 // ------------------------------------------------------------------- |
| 21 | 21 |
| 22 function SetIteratorConstructor(set, kind) { | 22 function SetIteratorConstructor(set, kind) { |
| 23 %SetIteratorInitialize(this, set, kind); | 23 %SetIteratorInitialize(this, set, kind); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 function SetIteratorNextJS() { | 27 function SetIteratorNextJS() { |
| 28 if (!IS_SET_ITERATOR(this)) { | 28 if (!IS_SET_ITERATOR(this)) { |
| 29 throw MakeTypeError('incompatible_method_receiver', | 29 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 30 ['Set Iterator.prototype.next', this]); | 30 'Set Iterator.prototype.next', this); |
| 31 } | 31 } |
| 32 | 32 |
| 33 var value_array = [UNDEFINED, UNDEFINED]; | 33 var value_array = [UNDEFINED, UNDEFINED]; |
| 34 var entry = {value: value_array, done: false}; | 34 var entry = {value: value_array, done: false}; |
| 35 switch (%SetIteratorNext(this, value_array)) { | 35 switch (%SetIteratorNext(this, value_array)) { |
| 36 case 0: | 36 case 0: |
| 37 entry.value = UNDEFINED; | 37 entry.value = UNDEFINED; |
| 38 entry.done = true; | 38 entry.done = true; |
| 39 break; | 39 break; |
| 40 case ITERATOR_KIND_VALUES: | 40 case ITERATOR_KIND_VALUES: |
| 41 entry.value = value_array[0]; | 41 entry.value = value_array[0]; |
| 42 break; | 42 break; |
| 43 case ITERATOR_KIND_ENTRIES: | 43 case ITERATOR_KIND_ENTRIES: |
| 44 value_array[1] = value_array[0]; | 44 value_array[1] = value_array[0]; |
| 45 break; | 45 break; |
| 46 } | 46 } |
| 47 | 47 |
| 48 return entry; | 48 return entry; |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 function SetIteratorSymbolIterator() { | 52 function SetIteratorSymbolIterator() { |
| 53 return this; | 53 return this; |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 function SetEntries() { | 57 function SetEntries() { |
| 58 if (!IS_SET(this)) { | 58 if (!IS_SET(this)) { |
| 59 throw MakeTypeError('incompatible_method_receiver', | 59 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 60 ['Set.prototype.entries', this]); | 60 'Set.prototype.entries', this); |
| 61 } | 61 } |
| 62 return new SetIterator(this, ITERATOR_KIND_ENTRIES); | 62 return new SetIterator(this, ITERATOR_KIND_ENTRIES); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 function SetValues() { | 66 function SetValues() { |
| 67 if (!IS_SET(this)) { | 67 if (!IS_SET(this)) { |
| 68 throw MakeTypeError('incompatible_method_receiver', | 68 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 69 ['Set.prototype.values', this]); | 69 'Set.prototype.values', this); |
| 70 } | 70 } |
| 71 return new SetIterator(this, ITERATOR_KIND_VALUES); | 71 return new SetIterator(this, ITERATOR_KIND_VALUES); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // ------------------------------------------------------------------- | 74 // ------------------------------------------------------------------- |
| 75 | 75 |
| 76 %SetCode(SetIterator, SetIteratorConstructor); | 76 %SetCode(SetIterator, SetIteratorConstructor); |
| 77 %FunctionSetPrototype(SetIterator, new GlobalObject()); | 77 %FunctionSetPrototype(SetIterator, new GlobalObject()); |
| 78 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); | 78 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); |
| 79 InstallFunctions(SetIterator.prototype, DONT_ENUM, [ | 79 InstallFunctions(SetIterator.prototype, DONT_ENUM, [ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 | 106 |
| 107 function MapIteratorSymbolIterator() { | 107 function MapIteratorSymbolIterator() { |
| 108 return this; | 108 return this; |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 function MapIteratorNextJS() { | 112 function MapIteratorNextJS() { |
| 113 if (!IS_MAP_ITERATOR(this)) { | 113 if (!IS_MAP_ITERATOR(this)) { |
| 114 throw MakeTypeError('incompatible_method_receiver', | 114 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 115 ['Map Iterator.prototype.next', this]); | 115 'Map Iterator.prototype.next', this); |
| 116 } | 116 } |
| 117 | 117 |
| 118 var value_array = [UNDEFINED, UNDEFINED]; | 118 var value_array = [UNDEFINED, UNDEFINED]; |
| 119 var entry = {value: value_array, done: false}; | 119 var entry = {value: value_array, done: false}; |
| 120 switch (%MapIteratorNext(this, value_array)) { | 120 switch (%MapIteratorNext(this, value_array)) { |
| 121 case 0: | 121 case 0: |
| 122 entry.value = UNDEFINED; | 122 entry.value = UNDEFINED; |
| 123 entry.done = true; | 123 entry.done = true; |
| 124 break; | 124 break; |
| 125 case ITERATOR_KIND_KEYS: | 125 case ITERATOR_KIND_KEYS: |
| 126 entry.value = value_array[0]; | 126 entry.value = value_array[0]; |
| 127 break; | 127 break; |
| 128 case ITERATOR_KIND_VALUES: | 128 case ITERATOR_KIND_VALUES: |
| 129 entry.value = value_array[1]; | 129 entry.value = value_array[1]; |
| 130 break; | 130 break; |
| 131 // ITERATOR_KIND_ENTRIES does not need any processing. | 131 // ITERATOR_KIND_ENTRIES does not need any processing. |
| 132 } | 132 } |
| 133 | 133 |
| 134 return entry; | 134 return entry; |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 function MapEntries() { | 138 function MapEntries() { |
| 139 if (!IS_MAP(this)) { | 139 if (!IS_MAP(this)) { |
| 140 throw MakeTypeError('incompatible_method_receiver', | 140 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 141 ['Map.prototype.entries', this]); | 141 'Map.prototype.entries', this); |
| 142 } | 142 } |
| 143 return new MapIterator(this, ITERATOR_KIND_ENTRIES); | 143 return new MapIterator(this, ITERATOR_KIND_ENTRIES); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 function MapKeys() { | 147 function MapKeys() { |
| 148 if (!IS_MAP(this)) { | 148 if (!IS_MAP(this)) { |
| 149 throw MakeTypeError('incompatible_method_receiver', | 149 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 150 ['Map.prototype.keys', this]); | 150 'Map.prototype.keys', this); |
| 151 } | 151 } |
| 152 return new MapIterator(this, ITERATOR_KIND_KEYS); | 152 return new MapIterator(this, ITERATOR_KIND_KEYS); |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 function MapValues() { | 156 function MapValues() { |
| 157 if (!IS_MAP(this)) { | 157 if (!IS_MAP(this)) { |
| 158 throw MakeTypeError('incompatible_method_receiver', | 158 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 159 ['Map.prototype.values', this]); | 159 'Map.prototype.values', this); |
| 160 } | 160 } |
| 161 return new MapIterator(this, ITERATOR_KIND_VALUES); | 161 return new MapIterator(this, ITERATOR_KIND_VALUES); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // ------------------------------------------------------------------- | 164 // ------------------------------------------------------------------- |
| 165 | 165 |
| 166 %SetCode(MapIterator, MapIteratorConstructor); | 166 %SetCode(MapIterator, MapIteratorConstructor); |
| 167 %FunctionSetPrototype(MapIterator, new GlobalObject()); | 167 %FunctionSetPrototype(MapIterator, new GlobalObject()); |
| 168 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); | 168 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); |
| 169 InstallFunctions(MapIterator.prototype, DONT_ENUM, [ | 169 InstallFunctions(MapIterator.prototype, DONT_ENUM, [ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 182 'keys', MapKeys, | 182 'keys', MapKeys, |
| 183 'values', MapValues | 183 'values', MapValues |
| 184 ]); | 184 ]); |
| 185 | 185 |
| 186 %AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM); | 186 %AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM); |
| 187 | 187 |
| 188 $mapEntries = MapEntries; | 188 $mapEntries = MapEntries; |
| 189 $mapIteratorNext = MapIteratorNextJS; | 189 $mapIteratorNext = MapIteratorNextJS; |
| 190 | 190 |
| 191 })(); | 191 })(); |
| OLD | NEW |