| 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 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
| 12 // Imports | 12 // Imports |
| 13 | 13 |
| 14 var GlobalMap = global.Map; | 14 var GlobalMap = global.Map; |
| 15 var GlobalSet = global.Set; | 15 var GlobalSet = global.Set; |
| 16 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 16 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 17 var MakeTypeError; | |
| 18 var MapIterator = utils.ImportNow("MapIterator"); | 17 var MapIterator = utils.ImportNow("MapIterator"); |
| 19 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 18 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 20 var SetIterator = utils.ImportNow("SetIterator"); | 19 var SetIterator = utils.ImportNow("SetIterator"); |
| 21 | 20 |
| 22 utils.Import(function(from) { | |
| 23 MakeTypeError = from.MakeTypeError; | |
| 24 }); | |
| 25 | |
| 26 // ------------------------------------------------------------------- | 21 // ------------------------------------------------------------------- |
| 27 | 22 |
| 28 function SetIteratorConstructor(set, kind) { | 23 function SetIteratorConstructor(set, kind) { |
| 29 %SetIteratorInitialize(this, set, kind); | 24 %SetIteratorInitialize(this, set, kind); |
| 30 } | 25 } |
| 31 | 26 |
| 32 | 27 |
| 33 function SetIteratorNextJS() { | 28 function SetIteratorNextJS() { |
| 34 if (!IS_SET_ITERATOR(this)) { | 29 if (!IS_SET_ITERATOR(this)) { |
| 35 throw MakeTypeError(kIncompatibleMethodReceiver, | 30 throw %make_type_error(kIncompatibleMethodReceiver, |
| 36 'Set Iterator.prototype.next', this); | 31 'Set Iterator.prototype.next', this); |
| 37 } | 32 } |
| 38 | 33 |
| 39 var value_array = [UNDEFINED, UNDEFINED]; | 34 var value_array = [UNDEFINED, UNDEFINED]; |
| 40 var result = %_CreateIterResultObject(value_array, false); | 35 var result = %_CreateIterResultObject(value_array, false); |
| 41 switch (%SetIteratorNext(this, value_array)) { | 36 switch (%SetIteratorNext(this, value_array)) { |
| 42 case 0: | 37 case 0: |
| 43 result.value = UNDEFINED; | 38 result.value = UNDEFINED; |
| 44 result.done = true; | 39 result.done = true; |
| 45 break; | 40 break; |
| 46 case ITERATOR_KIND_VALUES: | 41 case ITERATOR_KIND_VALUES: |
| 47 result.value = value_array[0]; | 42 result.value = value_array[0]; |
| 48 break; | 43 break; |
| 49 case ITERATOR_KIND_ENTRIES: | 44 case ITERATOR_KIND_ENTRIES: |
| 50 value_array[1] = value_array[0]; | 45 value_array[1] = value_array[0]; |
| 51 break; | 46 break; |
| 52 } | 47 } |
| 53 | 48 |
| 54 return result; | 49 return result; |
| 55 } | 50 } |
| 56 | 51 |
| 57 | 52 |
| 58 function SetEntries() { | 53 function SetEntries() { |
| 59 if (!IS_SET(this)) { | 54 if (!IS_SET(this)) { |
| 60 throw MakeTypeError(kIncompatibleMethodReceiver, | 55 throw %make_type_error(kIncompatibleMethodReceiver, |
| 61 'Set.prototype.entries', this); | 56 'Set.prototype.entries', this); |
| 62 } | 57 } |
| 63 return new SetIterator(this, ITERATOR_KIND_ENTRIES); | 58 return new SetIterator(this, ITERATOR_KIND_ENTRIES); |
| 64 } | 59 } |
| 65 | 60 |
| 66 | 61 |
| 67 function SetValues() { | 62 function SetValues() { |
| 68 if (!IS_SET(this)) { | 63 if (!IS_SET(this)) { |
| 69 throw MakeTypeError(kIncompatibleMethodReceiver, | 64 throw %make_type_error(kIncompatibleMethodReceiver, |
| 70 'Set.prototype.values', this); | 65 'Set.prototype.values', this); |
| 71 } | 66 } |
| 72 return new SetIterator(this, ITERATOR_KIND_VALUES); | 67 return new SetIterator(this, ITERATOR_KIND_VALUES); |
| 73 } | 68 } |
| 74 | 69 |
| 75 // ------------------------------------------------------------------- | 70 // ------------------------------------------------------------------- |
| 76 | 71 |
| 77 %SetCode(SetIterator, SetIteratorConstructor); | 72 %SetCode(SetIterator, SetIteratorConstructor); |
| 78 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); | 73 %FunctionSetInstanceClassName(SetIterator, 'Set Iterator'); |
| 79 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ | 74 utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 | 88 |
| 94 // ------------------------------------------------------------------- | 89 // ------------------------------------------------------------------- |
| 95 | 90 |
| 96 function MapIteratorConstructor(map, kind) { | 91 function MapIteratorConstructor(map, kind) { |
| 97 %MapIteratorInitialize(this, map, kind); | 92 %MapIteratorInitialize(this, map, kind); |
| 98 } | 93 } |
| 99 | 94 |
| 100 | 95 |
| 101 function MapIteratorNextJS() { | 96 function MapIteratorNextJS() { |
| 102 if (!IS_MAP_ITERATOR(this)) { | 97 if (!IS_MAP_ITERATOR(this)) { |
| 103 throw MakeTypeError(kIncompatibleMethodReceiver, | 98 throw %make_type_error(kIncompatibleMethodReceiver, |
| 104 'Map Iterator.prototype.next', this); | 99 'Map Iterator.prototype.next', this); |
| 105 } | 100 } |
| 106 | 101 |
| 107 var value_array = [UNDEFINED, UNDEFINED]; | 102 var value_array = [UNDEFINED, UNDEFINED]; |
| 108 var result = %_CreateIterResultObject(value_array, false); | 103 var result = %_CreateIterResultObject(value_array, false); |
| 109 switch (%MapIteratorNext(this, value_array)) { | 104 switch (%MapIteratorNext(this, value_array)) { |
| 110 case 0: | 105 case 0: |
| 111 result.value = UNDEFINED; | 106 result.value = UNDEFINED; |
| 112 result.done = true; | 107 result.done = true; |
| 113 break; | 108 break; |
| 114 case ITERATOR_KIND_KEYS: | 109 case ITERATOR_KIND_KEYS: |
| 115 result.value = value_array[0]; | 110 result.value = value_array[0]; |
| 116 break; | 111 break; |
| 117 case ITERATOR_KIND_VALUES: | 112 case ITERATOR_KIND_VALUES: |
| 118 result.value = value_array[1]; | 113 result.value = value_array[1]; |
| 119 break; | 114 break; |
| 120 // ITERATOR_KIND_ENTRIES does not need any processing. | 115 // ITERATOR_KIND_ENTRIES does not need any processing. |
| 121 } | 116 } |
| 122 | 117 |
| 123 return result; | 118 return result; |
| 124 } | 119 } |
| 125 | 120 |
| 126 | 121 |
| 127 function MapEntries() { | 122 function MapEntries() { |
| 128 if (!IS_MAP(this)) { | 123 if (!IS_MAP(this)) { |
| 129 throw MakeTypeError(kIncompatibleMethodReceiver, | 124 throw %make_type_error(kIncompatibleMethodReceiver, |
| 130 'Map.prototype.entries', this); | 125 'Map.prototype.entries', this); |
| 131 } | 126 } |
| 132 return new MapIterator(this, ITERATOR_KIND_ENTRIES); | 127 return new MapIterator(this, ITERATOR_KIND_ENTRIES); |
| 133 } | 128 } |
| 134 | 129 |
| 135 | 130 |
| 136 function MapKeys() { | 131 function MapKeys() { |
| 137 if (!IS_MAP(this)) { | 132 if (!IS_MAP(this)) { |
| 138 throw MakeTypeError(kIncompatibleMethodReceiver, | 133 throw %make_type_error(kIncompatibleMethodReceiver, |
| 139 'Map.prototype.keys', this); | 134 'Map.prototype.keys', this); |
| 140 } | 135 } |
| 141 return new MapIterator(this, ITERATOR_KIND_KEYS); | 136 return new MapIterator(this, ITERATOR_KIND_KEYS); |
| 142 } | 137 } |
| 143 | 138 |
| 144 | 139 |
| 145 function MapValues() { | 140 function MapValues() { |
| 146 if (!IS_MAP(this)) { | 141 if (!IS_MAP(this)) { |
| 147 throw MakeTypeError(kIncompatibleMethodReceiver, | 142 throw %make_type_error(kIncompatibleMethodReceiver, |
| 148 'Map.prototype.values', this); | 143 'Map.prototype.values', this); |
| 149 } | 144 } |
| 150 return new MapIterator(this, ITERATOR_KIND_VALUES); | 145 return new MapIterator(this, ITERATOR_KIND_VALUES); |
| 151 } | 146 } |
| 152 | 147 |
| 153 // ------------------------------------------------------------------- | 148 // ------------------------------------------------------------------- |
| 154 | 149 |
| 155 %SetCode(MapIterator, MapIteratorConstructor); | 150 %SetCode(MapIterator, MapIteratorConstructor); |
| 156 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); | 151 %FunctionSetInstanceClassName(MapIterator, 'Map Iterator'); |
| 157 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ | 152 utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 174 // Exports | 169 // Exports |
| 175 | 170 |
| 176 utils.Export(function(to) { | 171 utils.Export(function(to) { |
| 177 to.MapEntries = MapEntries; | 172 to.MapEntries = MapEntries; |
| 178 to.MapIteratorNext = MapIteratorNextJS; | 173 to.MapIteratorNext = MapIteratorNextJS; |
| 179 to.SetIteratorNext = SetIteratorNextJS; | 174 to.SetIteratorNext = SetIteratorNextJS; |
| 180 to.SetValues = SetValues; | 175 to.SetValues = SetValues; |
| 181 }); | 176 }); |
| 182 | 177 |
| 183 }) | 178 }) |
| OLD | NEW |