Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: src/collection-iterator.js

Issue 1095573002: Revert of Migrate error messages, part 2. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/collection.js ('k') | src/execution.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "use strict"; 5 "use strict";
6 6
7 7
8 // This file relies on the fact that the following declaration has been made 8 // This file relies on the fact that the following declaration has been made
9 // in runtime.js: 9 // in runtime.js:
10 // var $Set = global.Set; 10 // var $Set = global.Set;
11 // var $Map = global.Map; 11 // var $Map = global.Map;
12 12
13 13
14 function SetIteratorConstructor(set, kind) { 14 function SetIteratorConstructor(set, kind) {
15 %SetIteratorInitialize(this, set, kind); 15 %SetIteratorInitialize(this, set, kind);
16 } 16 }
17 17
18 18
19 function SetIteratorNextJS() { 19 function SetIteratorNextJS() {
20 if (!IS_SET_ITERATOR(this)) { 20 if (!IS_SET_ITERATOR(this)) {
21 throw MakeTypeError(kIncompatibleMethodReceiver, 21 throw MakeTypeError('incompatible_method_receiver',
22 'Set Iterator.prototype.next', this); 22 ['Set Iterator.prototype.next', this]);
23 } 23 }
24 24
25 var value_array = [UNDEFINED, UNDEFINED]; 25 var value_array = [UNDEFINED, UNDEFINED];
26 var entry = {value: value_array, done: false}; 26 var entry = {value: value_array, done: false};
27 switch (%SetIteratorNext(this, value_array)) { 27 switch (%SetIteratorNext(this, value_array)) {
28 case 0: 28 case 0:
29 entry.value = UNDEFINED; 29 entry.value = UNDEFINED;
30 entry.done = true; 30 entry.done = true;
31 break; 31 break;
32 case ITERATOR_KIND_VALUES: 32 case ITERATOR_KIND_VALUES:
33 entry.value = value_array[0]; 33 entry.value = value_array[0];
34 break; 34 break;
35 case ITERATOR_KIND_ENTRIES: 35 case ITERATOR_KIND_ENTRIES:
36 value_array[1] = value_array[0]; 36 value_array[1] = value_array[0];
37 break; 37 break;
38 } 38 }
39 39
40 return entry; 40 return entry;
41 } 41 }
42 42
43 43
44 function SetIteratorSymbolIterator() { 44 function SetIteratorSymbolIterator() {
45 return this; 45 return this;
46 } 46 }
47 47
48 48
49 function SetEntries() { 49 function SetEntries() {
50 if (!IS_SET(this)) { 50 if (!IS_SET(this)) {
51 throw MakeTypeError(kIncompatibleMethodReceiver, 51 throw MakeTypeError('incompatible_method_receiver',
52 'Set.prototype.entries', this); 52 ['Set.prototype.entries', this]);
53 } 53 }
54 return new SetIterator(this, ITERATOR_KIND_ENTRIES); 54 return new SetIterator(this, ITERATOR_KIND_ENTRIES);
55 } 55 }
56 56
57 57
58 function SetValues() { 58 function SetValues() {
59 if (!IS_SET(this)) { 59 if (!IS_SET(this)) {
60 throw MakeTypeError(kIncompatibleMethodReceiver, 60 throw MakeTypeError('incompatible_method_receiver',
61 'Set.prototype.values', this); 61 ['Set.prototype.values', this]);
62 } 62 }
63 return new SetIterator(this, ITERATOR_KIND_VALUES); 63 return new SetIterator(this, ITERATOR_KIND_VALUES);
64 } 64 }
65 65
66 66
67 function SetUpSetIterator() { 67 function SetUpSetIterator() {
68 %CheckIsBootstrapping(); 68 %CheckIsBootstrapping();
69 69
70 %SetCode(SetIterator, SetIteratorConstructor); 70 %SetCode(SetIterator, SetIteratorConstructor);
71 %FunctionSetPrototype(SetIterator, new $Object()); 71 %FunctionSetPrototype(SetIterator, new $Object());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 107
108 function MapIteratorSymbolIterator() { 108 function MapIteratorSymbolIterator() {
109 return this; 109 return this;
110 } 110 }
111 111
112 112
113 function MapIteratorNextJS() { 113 function MapIteratorNextJS() {
114 if (!IS_MAP_ITERATOR(this)) { 114 if (!IS_MAP_ITERATOR(this)) {
115 throw MakeTypeError(kIncompatibleMethodReceiver, 115 throw MakeTypeError('incompatible_method_receiver',
116 'Map Iterator.prototype.next', this); 116 ['Map Iterator.prototype.next', this]);
117 } 117 }
118 118
119 var value_array = [UNDEFINED, UNDEFINED]; 119 var value_array = [UNDEFINED, UNDEFINED];
120 var entry = {value: value_array, done: false}; 120 var entry = {value: value_array, done: false};
121 switch (%MapIteratorNext(this, value_array)) { 121 switch (%MapIteratorNext(this, value_array)) {
122 case 0: 122 case 0:
123 entry.value = UNDEFINED; 123 entry.value = UNDEFINED;
124 entry.done = true; 124 entry.done = true;
125 break; 125 break;
126 case ITERATOR_KIND_KEYS: 126 case ITERATOR_KIND_KEYS:
127 entry.value = value_array[0]; 127 entry.value = value_array[0];
128 break; 128 break;
129 case ITERATOR_KIND_VALUES: 129 case ITERATOR_KIND_VALUES:
130 entry.value = value_array[1]; 130 entry.value = value_array[1];
131 break; 131 break;
132 // ITERATOR_KIND_ENTRIES does not need any processing. 132 // ITERATOR_KIND_ENTRIES does not need any processing.
133 } 133 }
134 134
135 return entry; 135 return entry;
136 } 136 }
137 137
138 138
139 function MapEntries() { 139 function MapEntries() {
140 if (!IS_MAP(this)) { 140 if (!IS_MAP(this)) {
141 throw MakeTypeError(kIncompatibleMethodReceiver, 141 throw MakeTypeError('incompatible_method_receiver',
142 'Map.prototype.entries', this); 142 ['Map.prototype.entries', this]);
143 } 143 }
144 return new MapIterator(this, ITERATOR_KIND_ENTRIES); 144 return new MapIterator(this, ITERATOR_KIND_ENTRIES);
145 } 145 }
146 146
147 147
148 function MapKeys() { 148 function MapKeys() {
149 if (!IS_MAP(this)) { 149 if (!IS_MAP(this)) {
150 throw MakeTypeError(kIncompatibleMethodReceiver, 150 throw MakeTypeError('incompatible_method_receiver',
151 'Map.prototype.keys', this); 151 ['Map.prototype.keys', this]);
152 } 152 }
153 return new MapIterator(this, ITERATOR_KIND_KEYS); 153 return new MapIterator(this, ITERATOR_KIND_KEYS);
154 } 154 }
155 155
156 156
157 function MapValues() { 157 function MapValues() {
158 if (!IS_MAP(this)) { 158 if (!IS_MAP(this)) {
159 throw MakeTypeError(kIncompatibleMethodReceiver, 159 throw MakeTypeError('incompatible_method_receiver',
160 'Map.prototype.values', this); 160 ['Map.prototype.values', this]);
161 } 161 }
162 return new MapIterator(this, ITERATOR_KIND_VALUES); 162 return new MapIterator(this, ITERATOR_KIND_VALUES);
163 } 163 }
164 164
165 165
166 function SetUpMapIterator() { 166 function SetUpMapIterator() {
167 %CheckIsBootstrapping(); 167 %CheckIsBootstrapping();
168 168
169 %SetCode(MapIterator, MapIteratorConstructor); 169 %SetCode(MapIterator, MapIteratorConstructor);
170 %FunctionSetPrototype(MapIterator, new $Object()); 170 %FunctionSetPrototype(MapIterator, new $Object());
(...skipping 18 matching lines...) Expand all
189 InstallFunctions($Map.prototype, DONT_ENUM, [ 189 InstallFunctions($Map.prototype, DONT_ENUM, [
190 'entries', MapEntries, 190 'entries', MapEntries,
191 'keys', MapKeys, 191 'keys', MapKeys,
192 'values', MapValues 192 'values', MapValues
193 ]); 193 ]);
194 194
195 %AddNamedProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM); 195 %AddNamedProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
196 } 196 }
197 197
198 ExtendMapPrototype(); 198 ExtendMapPrototype();
OLDNEW
« no previous file with comments | « src/collection.js ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698