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) { |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 function SetIteratorNextJS() { | 28 function SetIteratorNextJS() { |
29 if (!IS_SET_ITERATOR(this)) { | 29 if (!IS_SET_ITERATOR(this)) { |
30 throw MakeTypeError(kIncompatibleMethodReceiver, | 30 throw MakeTypeError(kIncompatibleMethodReceiver, |
31 'Set Iterator.prototype.next', this); | 31 'Set Iterator.prototype.next', this); |
32 } | 32 } |
33 | 33 |
34 var value_array = [UNDEFINED, UNDEFINED]; | 34 var value_array = [UNDEFINED, UNDEFINED]; |
35 var entry = {value: value_array, done: false}; | 35 var result = %_CreateIterResultObject(value_array, false); |
36 switch (%SetIteratorNext(this, value_array)) { | 36 switch (%SetIteratorNext(this, value_array)) { |
37 case 0: | 37 case 0: |
38 entry.value = UNDEFINED; | 38 result.value = UNDEFINED; |
39 entry.done = true; | 39 result.done = true; |
40 break; | 40 break; |
41 case ITERATOR_KIND_VALUES: | 41 case ITERATOR_KIND_VALUES: |
42 entry.value = value_array[0]; | 42 result.value = value_array[0]; |
43 break; | 43 break; |
44 case ITERATOR_KIND_ENTRIES: | 44 case ITERATOR_KIND_ENTRIES: |
45 value_array[1] = value_array[0]; | 45 value_array[1] = value_array[0]; |
46 break; | 46 break; |
47 } | 47 } |
48 | 48 |
49 return entry; | 49 return result; |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 function SetEntries() { | 53 function SetEntries() { |
54 if (!IS_SET(this)) { | 54 if (!IS_SET(this)) { |
55 throw MakeTypeError(kIncompatibleMethodReceiver, | 55 throw MakeTypeError(kIncompatibleMethodReceiver, |
56 'Set.prototype.entries', this); | 56 'Set.prototype.entries', this); |
57 } | 57 } |
58 return new SetIterator(this, ITERATOR_KIND_ENTRIES); | 58 return new SetIterator(this, ITERATOR_KIND_ENTRIES); |
59 } | 59 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 function MapIteratorNextJS() { | 100 function MapIteratorNextJS() { |
101 if (!IS_MAP_ITERATOR(this)) { | 101 if (!IS_MAP_ITERATOR(this)) { |
102 throw MakeTypeError(kIncompatibleMethodReceiver, | 102 throw MakeTypeError(kIncompatibleMethodReceiver, |
103 'Map Iterator.prototype.next', this); | 103 'Map Iterator.prototype.next', this); |
104 } | 104 } |
105 | 105 |
106 var value_array = [UNDEFINED, UNDEFINED]; | 106 var value_array = [UNDEFINED, UNDEFINED]; |
107 var entry = {value: value_array, done: false}; | 107 var result = %_CreateIterResultObject(value_array, false); |
108 switch (%MapIteratorNext(this, value_array)) { | 108 switch (%MapIteratorNext(this, value_array)) { |
109 case 0: | 109 case 0: |
110 entry.value = UNDEFINED; | 110 result.value = UNDEFINED; |
111 entry.done = true; | 111 result.done = true; |
112 break; | 112 break; |
113 case ITERATOR_KIND_KEYS: | 113 case ITERATOR_KIND_KEYS: |
114 entry.value = value_array[0]; | 114 result.value = value_array[0]; |
115 break; | 115 break; |
116 case ITERATOR_KIND_VALUES: | 116 case ITERATOR_KIND_VALUES: |
117 entry.value = value_array[1]; | 117 result.value = value_array[1]; |
118 break; | 118 break; |
119 // ITERATOR_KIND_ENTRIES does not need any processing. | 119 // ITERATOR_KIND_ENTRIES does not need any processing. |
120 } | 120 } |
121 | 121 |
122 return entry; | 122 return result; |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 function MapEntries() { | 126 function MapEntries() { |
127 if (!IS_MAP(this)) { | 127 if (!IS_MAP(this)) { |
128 throw MakeTypeError(kIncompatibleMethodReceiver, | 128 throw MakeTypeError(kIncompatibleMethodReceiver, |
129 'Map.prototype.entries', this); | 129 'Map.prototype.entries', this); |
130 } | 130 } |
131 return new MapIterator(this, ITERATOR_KIND_ENTRIES); | 131 return new MapIterator(this, ITERATOR_KIND_ENTRIES); |
132 } | 132 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 'keys', MapKeys, | 167 'keys', MapKeys, |
168 'values', MapValues | 168 'values', MapValues |
169 ]); | 169 ]); |
170 | 170 |
171 %AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM); | 171 %AddNamedProperty(GlobalMap.prototype, iteratorSymbol, MapEntries, DONT_ENUM); |
172 | 172 |
173 $mapEntries = MapEntries; | 173 $mapEntries = MapEntries; |
174 $mapIteratorNext = MapIteratorNextJS; | 174 $mapIteratorNext = MapIteratorNextJS; |
175 | 175 |
176 }) | 176 }) |
OLD | NEW |