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

Side by Side Diff: test/codegen/expect/collection/collection.js

Issue 962083002: support the JS builtin (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 | « test/codegen/expect/async/async.js ('k') | test/codegen/expect/convert/convert.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var collection; 1 var collection;
2 (function(collection) { 2 (function(collection) {
3 'use strict'; 3 'use strict';
4 let _HashMap$ = dart.generic(function(K, V) { 4 let _HashMap$ = dart.generic(function(K, V) {
5 class _HashMap extends dart.Object { 5 class _HashMap extends dart.Object {
6 _HashMap() { 6 _HashMap() {
7 this._length = 0; 7 this._length = 0;
8 this._strings = null; 8 this._strings = null;
9 this._nums = null; 9 this._nums = null;
10 this._rest = null; 10 this._rest = null;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } else { 61 } else {
62 return this._get(key); 62 return this._get(key);
63 } 63 }
64 } 64 }
65 _get(key) { 65 _get(key) {
66 let rest = this._rest; 66 let rest = this._rest;
67 if (rest === null) 67 if (rest === null)
68 return dart.as(null, V); 68 return dart.as(null, V);
69 let bucket = this._getBucket(rest, key); 69 let bucket = this._getBucket(rest, key);
70 let index = this._findBucketIndex(bucket, key); 70 let index = this._findBucketIndex(bucket, key);
71 return dart.as(index < 0 ? null : _foreign_helper.JS('var', '#[#]', buck et, index + 1), V); 71 return dart.as(index < 0 ? null : bucket[index + 1], V);
72 } 72 }
73 set(key, value) { 73 set(key, value) {
74 if (_isStringKey(key)) { 74 if (_isStringKey(key)) {
75 let strings = this._strings; 75 let strings = this._strings;
76 if (strings === null) 76 if (strings === null)
77 this._strings = strings = _newHashTable(); 77 this._strings = strings = _newHashTable();
78 this._addHashTableEntry(strings, key, value); 78 this._addHashTableEntry(strings, key, value);
79 } else if (_isNumericKey(key)) { 79 } else if (_isNumericKey(key)) {
80 let nums = this._nums; 80 let nums = this._nums;
81 if (nums === null) 81 if (nums === null)
82 this._nums = nums = _newHashTable(); 82 this._nums = nums = _newHashTable();
83 this._addHashTableEntry(nums, key, value); 83 this._addHashTableEntry(nums, key, value);
84 } else { 84 } else {
85 this._set(key, value); 85 this._set(key, value);
86 } 86 }
87 } 87 }
88 _set(key, value) { 88 _set(key, value) {
89 let rest = this._rest; 89 let rest = this._rest;
90 if (rest === null) 90 if (rest === null)
91 this._rest = rest = _newHashTable(); 91 this._rest = rest = _newHashTable();
92 let hash = this._computeHashCode(key); 92 let hash = this._computeHashCode(key);
93 let bucket = _foreign_helper.JS('var', '#[#]', rest, hash); 93 let bucket = rest[hash];
94 if (bucket === null) { 94 if (bucket === null) {
95 _setTableEntry(rest, hash, _foreign_helper.JS('var', '[#, #]', key, va lue)); 95 _setTableEntry(rest, hash, [key, value]);
96 this._length++; 96 this._length++;
97 this._keys = null; 97 this._keys = null;
98 } else { 98 } else {
99 let index = this._findBucketIndex(bucket, key); 99 let index = this._findBucketIndex(bucket, key);
100 if (index >= 0) { 100 if (index >= 0) {
101 _foreign_helper.JS('void', '#[#] = #', bucket, index + 1, value); 101 bucket[index + 1] = value;
102 } else { 102 } else {
103 _foreign_helper.JS('void', '#.push(#, #)', bucket, key, value); 103 bucket.push(key, value);
104 this._length++; 104 this._length++;
105 this._keys = null; 105 this._keys = null;
106 } 106 }
107 } 107 }
108 } 108 }
109 putIfAbsent(key, ifAbsent) { 109 putIfAbsent(key, ifAbsent) {
110 if (this.containsKey(key)) 110 if (this.containsKey(key))
111 return this.get(key); 111 return this.get(key);
112 let value = ifAbsent(); 112 let value = ifAbsent();
113 this.set(key, value); 113 this.set(key, value);
(...skipping 11 matching lines...) Expand all
125 _remove(key) { 125 _remove(key) {
126 let rest = this._rest; 126 let rest = this._rest;
127 if (rest === null) 127 if (rest === null)
128 return dart.as(null, V); 128 return dart.as(null, V);
129 let bucket = this._getBucket(rest, key); 129 let bucket = this._getBucket(rest, key);
130 let index = this._findBucketIndex(bucket, key); 130 let index = this._findBucketIndex(bucket, key);
131 if (index < 0) 131 if (index < 0)
132 return dart.as(null, V); 132 return dart.as(null, V);
133 this._length--; 133 this._length--;
134 this._keys = null; 134 this._keys = null;
135 return dart.as(_foreign_helper.JS('var', '#.splice(#, 2)[1]', bucket, in dex), V); 135 return dart.as(bucket.splice(index, 2)[1], V);
136 } 136 }
137 clear() { 137 clear() {
138 if (this._length > 0) { 138 if (this._length > 0) {
139 this._strings = this._nums = this._rest = this._keys = null; 139 this._strings = this._nums = this._rest = this._keys = null;
140 this._length = 0; 140 this._length = 0;
141 } 141 }
142 } 142 }
143 forEach(action) { 143 forEach(action) {
144 let keys = this._computeKeys(); 144 let keys = this._computeKeys();
145 for (let i = 0, length = keys.length; i < length; i++) { 145 for (let i = 0, length = keys.length; i < length; i++) {
146 let key = _foreign_helper.JS('var', '#[#]', keys, i); 146 let key = keys[i];
147 action(dart.as(key, K), this.get(key)); 147 action(dart.as(key, K), this.get(key));
148 if (_foreign_helper.JS('bool', '# !== #', keys, this._keys)) { 148 if (keys !== this._keys) {
149 throw new core.ConcurrentModificationError(this); 149 throw new core.ConcurrentModificationError(this);
150 } 150 }
151 } 151 }
152 } 152 }
153 _computeKeys() { 153 _computeKeys() {
154 if (this._keys !== null) 154 if (this._keys !== null)
155 return this._keys; 155 return this._keys;
156 let result = new core.List(this._length); 156 let result = new core.List(this._length);
157 let index = 0; 157 let index = 0;
158 let strings = this._strings; 158 let strings = this._strings;
159 if (strings !== null) { 159 if (strings !== null) {
160 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', strings); 160 let names = Object.getOwnPropertyNames(strings);
161 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 161 let entries = names.length;
162 for (let i = 0; i < entries; i++) { 162 for (let i = 0; i < entries; i++) {
163 let key = dart.as(_foreign_helper.JS('String', '#[#]', names, i), co re.String); 163 let key = names[i];
164 _foreign_helper.JS('void', '#[#] = #', result, index, key); 164 result[index] = key;
165 index++; 165 index++;
166 } 166 }
167 } 167 }
168 let nums = this._nums; 168 let nums = this._nums;
169 if (nums !== null) { 169 if (nums !== null) {
170 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', nums); 170 let names = Object.getOwnPropertyNames(nums);
171 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 171 let entries = names.length;
172 for (let i = 0; i < entries; i++) { 172 for (let i = 0; i < entries; i++) {
173 let key = dart.as(_foreign_helper.JS('num', '+#[#]', names, i), core .num); 173 let key = +names[i];
174 _foreign_helper.JS('void', '#[#] = #', result, index, key); 174 result[index] = key;
175 index++; 175 index++;
176 } 176 }
177 } 177 }
178 let rest = this._rest; 178 let rest = this._rest;
179 if (rest !== null) { 179 if (rest !== null) {
180 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', rest); 180 let names = Object.getOwnPropertyNames(rest);
181 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 181 let entries = names.length;
182 for (let i = 0; i < entries; i++) { 182 for (let i = 0; i < entries; i++) {
183 let key = _foreign_helper.JS('String', '#[#]', names, i); 183 let key = names[i];
184 let bucket = _foreign_helper.JS('var', '#[#]', rest, key); 184 let bucket = rest[key];
185 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core.int); 185 let length = bucket.length;
186 for (let i = 0; i < length; i = 2) { 186 for (let i = 0; i < length; i = 2) {
187 let key = _foreign_helper.JS('var', '#[#]', bucket, i); 187 let key = bucket[i];
188 _foreign_helper.JS('void', '#[#] = #', result, index, key); 188 result[index] = key;
189 index++; 189 index++;
190 } 190 }
191 } 191 }
192 } 192 }
193 dart.assert(index === this._length); 193 dart.assert(index === this._length);
194 return this._keys = result; 194 return this._keys = result;
195 } 195 }
196 _addHashTableEntry(table, key, value) { 196 _addHashTableEntry(table, key, value) {
197 if (!dart.notNull(_hasTableEntry(table, key))) { 197 if (!dart.notNull(_hasTableEntry(table, key))) {
198 this._length++; 198 this._length++;
199 this._keys = null; 199 this._keys = null;
200 } 200 }
201 _setTableEntry(table, key, value); 201 _setTableEntry(table, key, value);
202 } 202 }
203 _removeHashTableEntry(table, key) { 203 _removeHashTableEntry(table, key) {
204 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, k ey))) { 204 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, k ey))) {
205 let value = dart.as(_getTableEntry(table, key), V); 205 let value = dart.as(_getTableEntry(table, key), V);
206 _deleteTableEntry(table, key); 206 _deleteTableEntry(table, key);
207 this._length--; 207 this._length--;
208 this._keys = null; 208 this._keys = null;
209 return value; 209 return value;
210 } else { 210 } else {
211 return dart.as(null, V); 211 return dart.as(null, V);
212 } 212 }
213 } 213 }
214 static _isStringKey(key) { 214 static _isStringKey(key) {
215 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k ey, '__proto__')); 215 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k ey, '__proto__'));
216 } 216 }
217 static _isNumericKey(key) { 217 static _isNumericKey(key) {
218 return core.bool['&&'](dart.is(key, core.num), _foreign_helper.JS('bool' , '(# & 0x3ffffff) === #', key, key)); 218 return dart.notNull(dart.is(key, core.num)) && dart.notNull((key & 0x3ff ffff) === key);
219 } 219 }
220 _computeHashCode(key) { 220 _computeHashCode(key) {
221 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', dart.dload(key , 'hashCode')), core.int); 221 return dart.dload(key, 'hashCode') & 0x3ffffff;
222 } 222 }
223 static _hasTableEntry(table, key) { 223 static _hasTableEntry(table, key) {
224 let entry = _foreign_helper.JS('var', '#[#]', table, key); 224 let entry = table[key];
225 return entry !== null; 225 return entry !== null;
226 } 226 }
227 static _getTableEntry(table, key) { 227 static _getTableEntry(table, key) {
228 let entry = _foreign_helper.JS('var', '#[#]', table, key); 228 let entry = table[key];
229 return _foreign_helper.JS('bool', '# === #', entry, table) ? null : entr y; 229 return entry === table ? null : entry;
230 } 230 }
231 static _setTableEntry(table, key, value) { 231 static _setTableEntry(table, key, value) {
232 if (value === null) { 232 if (value === null) {
233 _foreign_helper.JS('void', '#[#] = #', table, key, table); 233 table[key] = table;
234 } else { 234 } else {
235 _foreign_helper.JS('void', '#[#] = #', table, key, value); 235 table[key] = value;
236 } 236 }
237 } 237 }
238 static _deleteTableEntry(table, key) { 238 static _deleteTableEntry(table, key) {
239 _foreign_helper.JS('void', 'delete #[#]', table, key); 239 delete table[key];
240 } 240 }
241 _getBucket(table, key) { 241 _getBucket(table, key) {
242 let hash = this._computeHashCode(key); 242 let hash = this._computeHashCode(key);
243 return dart.as(_foreign_helper.JS('var', '#[#]', table, hash), core.List ); 243 return dart.as(table[hash], core.List);
244 } 244 }
245 _findBucketIndex(bucket, key) { 245 _findBucketIndex(bucket, key) {
246 if (bucket === null) 246 if (bucket === null)
247 return -1; 247 return -1;
248 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 248 let length = bucket.length;
249 for (let i = 0; i < length; i = 2) { 249 for (let i = 0; i < length; i = 2) {
250 if (dart.equals(_foreign_helper.JS('var', '#[#]', bucket, i), key)) 250 if (dart.equals(bucket[i], key))
251 return i; 251 return i;
252 } 252 }
253 return -1; 253 return -1;
254 } 254 }
255 static _newHashTable() { 255 static _newHashTable() {
256 let table = _foreign_helper.JS('var', 'Object.create(null)'); 256 let table = Object.create(null);
257 let temporaryKey = '<non-identifier-key>'; 257 let temporaryKey = '<non-identifier-key>';
258 _setTableEntry(table, temporaryKey, table); 258 _setTableEntry(table, temporaryKey, table);
259 _deleteTableEntry(table, temporaryKey); 259 _deleteTableEntry(table, temporaryKey);
260 return table; 260 return table;
261 } 261 }
262 } 262 }
263 return _HashMap; 263 return _HashMap;
264 }); 264 });
265 let _HashMap = _HashMap$(dynamic, dynamic); 265 let _HashMap = _HashMap$(dynamic, dynamic);
266 let _IdentityHashMap$ = dart.generic(function(K, V) { 266 let _IdentityHashMap$ = dart.generic(function(K, V) {
267 class _IdentityHashMap extends _HashMap$(K, V) { 267 class _IdentityHashMap extends _HashMap$(K, V) {
268 _computeHashCode(key) { 268 _computeHashCode(key) {
269 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', core.identityH ashCode(key)), core.int); 269 return core.identityHashCode(key) & 0x3ffffff;
270 } 270 }
271 _findBucketIndex(bucket, key) { 271 _findBucketIndex(bucket, key) {
272 if (bucket === null) 272 if (bucket === null)
273 return -1; 273 return -1;
274 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 274 let length = bucket.length;
275 for (let i = 0; i < length; i = 2) { 275 for (let i = 0; i < length; i = 2) {
276 if (core.identical(_foreign_helper.JS('var', '#[#]', bucket, i), key)) 276 if (core.identical(bucket[i], key))
277 return i; 277 return i;
278 } 278 }
279 return -1; 279 return -1;
280 } 280 }
281 } 281 }
282 return _IdentityHashMap; 282 return _IdentityHashMap;
283 }); 283 });
284 let _IdentityHashMap = _IdentityHashMap$(dynamic, dynamic); 284 let _IdentityHashMap = _IdentityHashMap$(dynamic, dynamic);
285 let _CustomHashMap$ = dart.generic(function(K, V) { 285 let _CustomHashMap$ = dart.generic(function(K, V) {
286 class _CustomHashMap extends _HashMap$(K, V) { 286 class _CustomHashMap extends _HashMap$(K, V) {
(...skipping 15 matching lines...) Expand all
302 if (!dart.notNull(this._validKey(key))) 302 if (!dart.notNull(this._validKey(key)))
303 return false; 303 return false;
304 return super._containsKey(key); 304 return super._containsKey(key);
305 } 305 }
306 remove(key) { 306 remove(key) {
307 if (!dart.notNull(this._validKey(key))) 307 if (!dart.notNull(this._validKey(key)))
308 return dart.as(null, V); 308 return dart.as(null, V);
309 return super._remove(key); 309 return super._remove(key);
310 } 310 }
311 _computeHashCode(key) { 311 _computeHashCode(key) {
312 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', this._hashCode (dart.as(key, K))), core.int); 312 return this._hashCode(dart.as(key, K)) & 0x3ffffff;
313 } 313 }
314 _findBucketIndex(bucket, key) { 314 _findBucketIndex(bucket, key) {
315 if (bucket === null) 315 if (bucket === null)
316 return -1; 316 return -1;
317 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 317 let length = bucket.length;
318 for (let i = 0; i < length; i = 2) { 318 for (let i = 0; i < length; i = 2) {
319 if (this._equals(dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), K), dart.as(key, K))) 319 if (this._equals(dart.as(bucket[i], K), dart.as(key, K)))
320 return i; 320 return i;
321 } 321 }
322 return -1; 322 return -1;
323 } 323 }
324 toString() { 324 toString() {
325 return Maps.mapToString(this); 325 return Maps.mapToString(this);
326 } 326 }
327 } 327 }
328 return _CustomHashMap; 328 return _CustomHashMap;
329 }); 329 });
(...skipping 11 matching lines...) Expand all
341 return dart.equals(dart.dload(this._map, '_length'), 0); 341 return dart.equals(dart.dload(this._map, '_length'), 0);
342 } 342 }
343 get iterator() { 343 get iterator() {
344 return new HashMapKeyIterator(this._map, dart.as(dart.dinvoke(this._map, '_computeKeys'), core.List)); 344 return new HashMapKeyIterator(this._map, dart.as(dart.dinvoke(this._map, '_computeKeys'), core.List));
345 } 345 }
346 contains(element) { 346 contains(element) {
347 return dart.as(dart.dinvoke(this._map, 'containsKey', element), core.boo l); 347 return dart.as(dart.dinvoke(this._map, 'containsKey', element), core.boo l);
348 } 348 }
349 forEach(f) { 349 forEach(f) {
350 let keys = dart.as(dart.dinvoke(this._map, '_computeKeys'), core.List); 350 let keys = dart.as(dart.dinvoke(this._map, '_computeKeys'), core.List);
351 for (let i = 0, length = dart.as(_foreign_helper.JS('int', '#.length', k eys), core.int); i < length; i++) { 351 for (let i = 0, length = keys.length; i < length; i++) {
352 f(dart.as(_foreign_helper.JS('var', '#[#]', keys, i), E)); 352 f(dart.as(keys[i], E));
353 if (_foreign_helper.JS('bool', '# !== #', keys, dart.dload(this._map, '_keys'))) { 353 if (keys !== dart.dload(this._map, '_keys')) {
354 throw new core.ConcurrentModificationError(this._map); 354 throw new core.ConcurrentModificationError(this._map);
355 } 355 }
356 } 356 }
357 } 357 }
358 } 358 }
359 return HashMapKeyIterable; 359 return HashMapKeyIterable;
360 }); 360 });
361 let HashMapKeyIterable = HashMapKeyIterable$(dynamic); 361 let HashMapKeyIterable = HashMapKeyIterable$(dynamic);
362 let HashMapKeyIterator$ = dart.generic(function(E) { 362 let HashMapKeyIterator$ = dart.generic(function(E) {
363 class HashMapKeyIterator extends dart.Object { 363 class HashMapKeyIterator extends dart.Object {
364 HashMapKeyIterator(_map, _keys) { 364 HashMapKeyIterator(_map, _keys) {
365 this._map = _map; 365 this._map = _map;
366 this._keys = _keys; 366 this._keys = _keys;
367 this._offset = 0; 367 this._offset = 0;
368 this._current = dart.as(null, E); 368 this._current = dart.as(null, E);
369 } 369 }
370 get current() { 370 get current() {
371 return this._current; 371 return this._current;
372 } 372 }
373 moveNext() { 373 moveNext() {
374 let keys = this._keys; 374 let keys = this._keys;
375 let offset = this._offset; 375 let offset = this._offset;
376 if (_foreign_helper.JS('bool', '# !== #', keys, dart.dload(this._map, '_ keys'))) { 376 if (keys !== dart.dload(this._map, '_keys')) {
377 throw new core.ConcurrentModificationError(this._map); 377 throw new core.ConcurrentModificationError(this._map);
378 } else if (offset['>='](_foreign_helper.JS('int', '#.length', keys))) { 378 } else if (offset >= keys.length) {
379 this._current = dart.as(null, E); 379 this._current = dart.as(null, E);
380 return false; 380 return false;
381 } else { 381 } else {
382 this._current = dart.as(_foreign_helper.JS('var', '#[#]', keys, offset ), E); 382 this._current = dart.as(keys[offset], E);
383 this._offset = dart.as(_foreign_helper.JS('int', '#', offset + 1), cor e.int); 383 this._offset = offset + 1;
384 return true; 384 return true;
385 } 385 }
386 } 386 }
387 } 387 }
388 return HashMapKeyIterator; 388 return HashMapKeyIterator;
389 }); 389 });
390 let HashMapKeyIterator = HashMapKeyIterator$(dynamic); 390 let HashMapKeyIterator = HashMapKeyIterator$(dynamic);
391 let _LinkedHashMap$ = dart.generic(function(K, V) { 391 let _LinkedHashMap$ = dart.generic(function(K, V) {
392 class _LinkedHashMap extends dart.Object { 392 class _LinkedHashMap extends dart.Object {
393 _LinkedHashMap() { 393 _LinkedHashMap() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 464 }
465 } 465 }
466 _get(key) { 466 _get(key) {
467 let rest = this._rest; 467 let rest = this._rest;
468 if (rest === null) 468 if (rest === null)
469 return dart.as(null, V); 469 return dart.as(null, V);
470 let bucket = this._getBucket(rest, key); 470 let bucket = this._getBucket(rest, key);
471 let index = this._findBucketIndex(bucket, key); 471 let index = this._findBucketIndex(bucket, key);
472 if (index < 0) 472 if (index < 0)
473 return dart.as(null, V); 473 return dart.as(null, V);
474 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, index), Lin kedHashMapCell); 474 let cell = dart.as(bucket[index], LinkedHashMapCell);
475 return dart.as(cell._value, V); 475 return dart.as(cell._value, V);
476 } 476 }
477 set(key, value) { 477 set(key, value) {
478 if (_isStringKey(key)) { 478 if (_isStringKey(key)) {
479 let strings = this._strings; 479 let strings = this._strings;
480 if (strings === null) 480 if (strings === null)
481 this._strings = strings = _newHashTable(); 481 this._strings = strings = _newHashTable();
482 this._addHashTableEntry(strings, key, value); 482 this._addHashTableEntry(strings, key, value);
483 } else if (_isNumericKey(key)) { 483 } else if (_isNumericKey(key)) {
484 let nums = this._nums; 484 let nums = this._nums;
485 if (nums === null) 485 if (nums === null)
486 this._nums = nums = _newHashTable(); 486 this._nums = nums = _newHashTable();
487 this._addHashTableEntry(nums, key, value); 487 this._addHashTableEntry(nums, key, value);
488 } else { 488 } else {
489 this._set(key, value); 489 this._set(key, value);
490 } 490 }
491 } 491 }
492 _set(key, value) { 492 _set(key, value) {
493 let rest = this._rest; 493 let rest = this._rest;
494 if (rest === null) 494 if (rest === null)
495 this._rest = rest = _newHashTable(); 495 this._rest = rest = _newHashTable();
496 let hash = this._computeHashCode(key); 496 let hash = this._computeHashCode(key);
497 let bucket = _foreign_helper.JS('var', '#[#]', rest, hash); 497 let bucket = rest[hash];
498 if (bucket === null) { 498 if (bucket === null) {
499 let cell = this._newLinkedCell(key, value); 499 let cell = this._newLinkedCell(key, value);
500 _setTableEntry(rest, hash, _foreign_helper.JS('var', '[#]', cell)); 500 _setTableEntry(rest, hash, [cell]);
501 } else { 501 } else {
502 let index = this._findBucketIndex(bucket, key); 502 let index = this._findBucketIndex(bucket, key);
503 if (index >= 0) { 503 if (index >= 0) {
504 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, index), LinkedHashMapCell); 504 let cell = dart.as(bucket[index], LinkedHashMapCell);
505 cell._value = value; 505 cell._value = value;
506 } else { 506 } else {
507 let cell = this._newLinkedCell(key, value); 507 let cell = this._newLinkedCell(key, value);
508 _foreign_helper.JS('void', '#.push(#)', bucket, cell); 508 bucket.push(cell);
509 } 509 }
510 } 510 }
511 } 511 }
512 putIfAbsent(key, ifAbsent) { 512 putIfAbsent(key, ifAbsent) {
513 if (this.containsKey(key)) 513 if (this.containsKey(key))
514 return this.get(key); 514 return this.get(key);
515 let value = ifAbsent(); 515 let value = ifAbsent();
516 this.set(key, value); 516 this.set(key, value);
517 return value; 517 return value;
518 } 518 }
519 remove(key) { 519 remove(key) {
520 if (_isStringKey(key)) { 520 if (_isStringKey(key)) {
521 return this._removeHashTableEntry(this._strings, key); 521 return this._removeHashTableEntry(this._strings, key);
522 } else if (_isNumericKey(key)) { 522 } else if (_isNumericKey(key)) {
523 return this._removeHashTableEntry(this._nums, key); 523 return this._removeHashTableEntry(this._nums, key);
524 } else { 524 } else {
525 return this._remove(key); 525 return this._remove(key);
526 } 526 }
527 } 527 }
528 _remove(key) { 528 _remove(key) {
529 let rest = this._rest; 529 let rest = this._rest;
530 if (rest === null) 530 if (rest === null)
531 return dart.as(null, V); 531 return dart.as(null, V);
532 let bucket = this._getBucket(rest, key); 532 let bucket = this._getBucket(rest, key);
533 let index = this._findBucketIndex(bucket, key); 533 let index = this._findBucketIndex(bucket, key);
534 if (index < 0) 534 if (index < 0)
535 return dart.as(null, V); 535 return dart.as(null, V);
536 let cell = dart.as(_foreign_helper.JS('var', '#.splice(#, 1)[0]', bucket , index), LinkedHashMapCell); 536 let cell = dart.as(bucket.splice(index, 1)[0], LinkedHashMapCell);
537 this._unlinkCell(cell); 537 this._unlinkCell(cell);
538 return dart.as(cell._value, V); 538 return dart.as(cell._value, V);
539 } 539 }
540 clear() { 540 clear() {
541 if (this._length > 0) { 541 if (this._length > 0) {
542 this._strings = this._nums = this._rest = this._first = this._last = n ull; 542 this._strings = this._nums = this._rest = this._first = this._last = n ull;
543 this._length = 0; 543 this._length = 0;
544 this._modified(); 544 this._modified();
545 } 545 }
546 } 546 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } else { 604 } else {
605 next._previous = previous; 605 next._previous = previous;
606 } 606 }
607 this._length--; 607 this._length--;
608 this._modified(); 608 this._modified();
609 } 609 }
610 static _isStringKey(key) { 610 static _isStringKey(key) {
611 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k ey, '__proto__')); 611 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k ey, '__proto__'));
612 } 612 }
613 static _isNumericKey(key) { 613 static _isNumericKey(key) {
614 return core.bool['&&'](dart.is(key, core.num), _foreign_helper.JS('bool' , '(# & 0x3ffffff) === #', key, key)); 614 return dart.notNull(dart.is(key, core.num)) && dart.notNull((key & 0x3ff ffff) === key);
615 } 615 }
616 _computeHashCode(key) { 616 _computeHashCode(key) {
617 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', dart.dload(key , 'hashCode')), core.int); 617 return dart.dload(key, 'hashCode') & 0x3ffffff;
618 } 618 }
619 static _getTableEntry(table, key) { 619 static _getTableEntry(table, key) {
620 return _foreign_helper.JS('var', '#[#]', table, key); 620 return table[key];
621 } 621 }
622 static _setTableEntry(table, key, value) { 622 static _setTableEntry(table, key, value) {
623 dart.assert(value !== null); 623 dart.assert(value !== null);
624 _foreign_helper.JS('void', '#[#] = #', table, key, value); 624 table[key] = value;
625 } 625 }
626 static _deleteTableEntry(table, key) { 626 static _deleteTableEntry(table, key) {
627 _foreign_helper.JS('void', 'delete #[#]', table, key); 627 delete table[key];
628 } 628 }
629 _getBucket(table, key) { 629 _getBucket(table, key) {
630 let hash = this._computeHashCode(key); 630 let hash = this._computeHashCode(key);
631 return dart.as(_foreign_helper.JS('var', '#[#]', table, hash), core.List ); 631 return dart.as(table[hash], core.List);
632 } 632 }
633 _findBucketIndex(bucket, key) { 633 _findBucketIndex(bucket, key) {
634 if (bucket === null) 634 if (bucket === null)
635 return -1; 635 return -1;
636 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 636 let length = bucket.length;
637 for (let i = 0; i < length; i++) { 637 for (let i = 0; i < length; i++) {
638 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashMapCell); 638 let cell = dart.as(bucket[i], LinkedHashMapCell);
639 if (dart.equals(cell._key, key)) 639 if (dart.equals(cell._key, key))
640 return i; 640 return i;
641 } 641 }
642 return -1; 642 return -1;
643 } 643 }
644 static _newHashTable() { 644 static _newHashTable() {
645 let table = _foreign_helper.JS('var', 'Object.create(null)'); 645 let table = Object.create(null);
646 let temporaryKey = '<non-identifier-key>'; 646 let temporaryKey = '<non-identifier-key>';
647 _setTableEntry(table, temporaryKey, table); 647 _setTableEntry(table, temporaryKey, table);
648 _deleteTableEntry(table, temporaryKey); 648 _deleteTableEntry(table, temporaryKey);
649 return table; 649 return table;
650 } 650 }
651 toString() { 651 toString() {
652 return Maps.mapToString(this); 652 return Maps.mapToString(this);
653 } 653 }
654 } 654 }
655 return _LinkedHashMap; 655 return _LinkedHashMap;
656 }); 656 });
657 let _LinkedHashMap = _LinkedHashMap$(dynamic, dynamic); 657 let _LinkedHashMap = _LinkedHashMap$(dynamic, dynamic);
658 let _LinkedIdentityHashMap$ = dart.generic(function(K, V) { 658 let _LinkedIdentityHashMap$ = dart.generic(function(K, V) {
659 class _LinkedIdentityHashMap extends _LinkedHashMap$(K, V) { 659 class _LinkedIdentityHashMap extends _LinkedHashMap$(K, V) {
660 _computeHashCode(key) { 660 _computeHashCode(key) {
661 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', core.identityH ashCode(key)), core.int); 661 return core.identityHashCode(key) & 0x3ffffff;
662 } 662 }
663 _findBucketIndex(bucket, key) { 663 _findBucketIndex(bucket, key) {
664 if (bucket === null) 664 if (bucket === null)
665 return -1; 665 return -1;
666 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 666 let length = bucket.length;
667 for (let i = 0; i < length; i++) { 667 for (let i = 0; i < length; i++) {
668 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashMapCell); 668 let cell = dart.as(bucket[i], LinkedHashMapCell);
669 if (core.identical(cell._key, key)) 669 if (core.identical(cell._key, key))
670 return i; 670 return i;
671 } 671 }
672 return -1; 672 return -1;
673 } 673 }
674 } 674 }
675 return _LinkedIdentityHashMap; 675 return _LinkedIdentityHashMap;
676 }); 676 });
677 let _LinkedIdentityHashMap = _LinkedIdentityHashMap$(dynamic, dynamic); 677 let _LinkedIdentityHashMap = _LinkedIdentityHashMap$(dynamic, dynamic);
678 let _LinkedCustomHashMap$ = dart.generic(function(K, V) { 678 let _LinkedCustomHashMap$ = dart.generic(function(K, V) {
(...skipping 16 matching lines...) Expand all
695 if (!dart.notNull(this._validKey(key))) 695 if (!dart.notNull(this._validKey(key)))
696 return false; 696 return false;
697 return super._containsKey(key); 697 return super._containsKey(key);
698 } 698 }
699 remove(key) { 699 remove(key) {
700 if (!dart.notNull(this._validKey(key))) 700 if (!dart.notNull(this._validKey(key)))
701 return dart.as(null, V); 701 return dart.as(null, V);
702 return super._remove(key); 702 return super._remove(key);
703 } 703 }
704 _computeHashCode(key) { 704 _computeHashCode(key) {
705 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', this._hashCode (dart.as(key, K))), core.int); 705 return this._hashCode(dart.as(key, K)) & 0x3ffffff;
706 } 706 }
707 _findBucketIndex(bucket, key) { 707 _findBucketIndex(bucket, key) {
708 if (bucket === null) 708 if (bucket === null)
709 return -1; 709 return -1;
710 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 710 let length = bucket.length;
711 for (let i = 0; i < length; i++) { 711 for (let i = 0; i < length; i++) {
712 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashMapCell); 712 let cell = dart.as(bucket[i], LinkedHashMapCell);
713 if (this._equals(dart.as(cell._key, K), dart.as(key, K))) 713 if (this._equals(dart.as(cell._key, K), dart.as(key, K)))
714 return i; 714 return i;
715 } 715 }
716 return -1; 716 return -1;
717 } 717 }
718 } 718 }
719 return _LinkedCustomHashMap; 719 return _LinkedCustomHashMap;
720 }); 720 });
721 let _LinkedCustomHashMap = _LinkedCustomHashMap$(dynamic, dynamic); 721 let _LinkedCustomHashMap = _LinkedCustomHashMap$(dynamic, dynamic);
722 class LinkedHashMapCell extends dart.Object { 722 class LinkedHashMapCell extends dart.Object {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 return this._addHashTableEntry(nums, element); 860 return this._addHashTableEntry(nums, element);
861 } else { 861 } else {
862 return this._add(element); 862 return this._add(element);
863 } 863 }
864 } 864 }
865 _add(element) { 865 _add(element) {
866 let rest = this._rest; 866 let rest = this._rest;
867 if (rest === null) 867 if (rest === null)
868 this._rest = rest = _newHashTable(); 868 this._rest = rest = _newHashTable();
869 let hash = this._computeHashCode(element); 869 let hash = this._computeHashCode(element);
870 let bucket = _foreign_helper.JS('var', '#[#]', rest, hash); 870 let bucket = rest[hash];
871 if (bucket === null) { 871 if (bucket === null) {
872 _setTableEntry(rest, hash, _foreign_helper.JS('var', '[#]', element)); 872 _setTableEntry(rest, hash, [element]);
873 } else { 873 } else {
874 let index = this._findBucketIndex(bucket, element); 874 let index = this._findBucketIndex(bucket, element);
875 if (index >= 0) 875 if (index >= 0)
876 return false; 876 return false;
877 _foreign_helper.JS('void', '#.push(#)', bucket, element); 877 bucket.push(element);
878 } 878 }
879 this._length++; 879 this._length++;
880 this._elements = null; 880 this._elements = null;
881 return true; 881 return true;
882 } 882 }
883 addAll(objects) { 883 addAll(objects) {
884 for (let each of objects) { 884 for (let each of objects) {
885 this.add(each); 885 this.add(each);
886 } 886 }
887 } 887 }
888 remove(object) { 888 remove(object) {
889 if (_isStringElement(object)) { 889 if (_isStringElement(object)) {
890 return this._removeHashTableEntry(this._strings, object); 890 return this._removeHashTableEntry(this._strings, object);
891 } else if (_isNumericElement(object)) { 891 } else if (_isNumericElement(object)) {
892 return this._removeHashTableEntry(this._nums, object); 892 return this._removeHashTableEntry(this._nums, object);
893 } else { 893 } else {
894 return this._remove(object); 894 return this._remove(object);
895 } 895 }
896 } 896 }
897 _remove(object) { 897 _remove(object) {
898 let rest = this._rest; 898 let rest = this._rest;
899 if (rest === null) 899 if (rest === null)
900 return false; 900 return false;
901 let bucket = this._getBucket(rest, object); 901 let bucket = this._getBucket(rest, object);
902 let index = this._findBucketIndex(bucket, object); 902 let index = this._findBucketIndex(bucket, object);
903 if (index < 0) 903 if (index < 0)
904 return false; 904 return false;
905 this._length--; 905 this._length--;
906 this._elements = null; 906 this._elements = null;
907 _foreign_helper.JS('void', '#.splice(#, 1)', bucket, index); 907 bucket.splice(index, 1);
908 return true; 908 return true;
909 } 909 }
910 clear() { 910 clear() {
911 if (this._length > 0) { 911 if (this._length > 0) {
912 this._strings = this._nums = this._rest = this._elements = null; 912 this._strings = this._nums = this._rest = this._elements = null;
913 this._length = 0; 913 this._length = 0;
914 } 914 }
915 } 915 }
916 _computeElements() { 916 _computeElements() {
917 if (this._elements !== null) 917 if (this._elements !== null)
918 return this._elements; 918 return this._elements;
919 let result = new core.List(this._length); 919 let result = new core.List(this._length);
920 let index = 0; 920 let index = 0;
921 let strings = this._strings; 921 let strings = this._strings;
922 if (strings !== null) { 922 if (strings !== null) {
923 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', strings); 923 let names = Object.getOwnPropertyNames(strings);
924 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 924 let entries = names.length;
925 for (let i = 0; i < entries; i++) { 925 for (let i = 0; i < entries; i++) {
926 let element = dart.as(_foreign_helper.JS('String', '#[#]', names, i) , core.String); 926 let element = names[i];
927 _foreign_helper.JS('void', '#[#] = #', result, index, element); 927 result[index] = element;
928 index++; 928 index++;
929 } 929 }
930 } 930 }
931 let nums = this._nums; 931 let nums = this._nums;
932 if (nums !== null) { 932 if (nums !== null) {
933 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', nums); 933 let names = Object.getOwnPropertyNames(nums);
934 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 934 let entries = names.length;
935 for (let i = 0; i < entries; i++) { 935 for (let i = 0; i < entries; i++) {
936 let element = dart.as(_foreign_helper.JS('num', '+#[#]', names, i), core.num); 936 let element = +names[i];
937 _foreign_helper.JS('void', '#[#] = #', result, index, element); 937 result[index] = element;
938 index++; 938 index++;
939 } 939 }
940 } 940 }
941 let rest = this._rest; 941 let rest = this._rest;
942 if (rest !== null) { 942 if (rest !== null) {
943 let names = _foreign_helper.JS('var', 'Object.getOwnPropertyNames(#)', rest); 943 let names = Object.getOwnPropertyNames(rest);
944 let entries = dart.as(_foreign_helper.JS('int', '#.length', names), co re.int); 944 let entries = names.length;
945 for (let i = 0; i < entries; i++) { 945 for (let i = 0; i < entries; i++) {
946 let entry = _foreign_helper.JS('String', '#[#]', names, i); 946 let entry = names[i];
947 let bucket = _foreign_helper.JS('var', '#[#]', rest, entry); 947 let bucket = rest[entry];
948 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core.int); 948 let length = bucket.length;
949 for (let i = 0; i < length; i++) { 949 for (let i = 0; i < length; i++) {
950 _foreign_helper.JS('void', '#[#] = #[#]', result, index, bucket, i ); 950 result[index] = bucket[i];
951 index++; 951 index++;
952 } 952 }
953 } 953 }
954 } 954 }
955 dart.assert(index === this._length); 955 dart.assert(index === this._length);
956 return this._elements = result; 956 return this._elements = result;
957 } 957 }
958 _addHashTableEntry(table, element) { 958 _addHashTableEntry(table, element) {
959 if (_hasTableEntry(table, element)) 959 if (_hasTableEntry(table, element))
960 return false; 960 return false;
961 _setTableEntry(table, element, 0); 961 _setTableEntry(table, element, 0);
962 this._length++; 962 this._length++;
963 this._elements = null; 963 this._elements = null;
964 return true; 964 return true;
965 } 965 }
966 _removeHashTableEntry(table, element) { 966 _removeHashTableEntry(table, element) {
967 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, e lement))) { 967 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, e lement))) {
968 _deleteTableEntry(table, element); 968 _deleteTableEntry(table, element);
969 this._length--; 969 this._length--;
970 this._elements = null; 970 this._elements = null;
971 return true; 971 return true;
972 } else { 972 } else {
973 return false; 973 return false;
974 } 974 }
975 } 975 }
976 static _isStringElement(element) { 976 static _isStringElement(element) {
977 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa ls(element, '__proto__')); 977 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa ls(element, '__proto__'));
978 } 978 }
979 static _isNumericElement(element) { 979 static _isNumericElement(element) {
980 return core.bool['&&'](dart.is(element, core.num), _foreign_helper.JS('b ool', '(# & 0x3ffffff) === #', element, element)); 980 return dart.notNull(dart.is(element, core.num)) && dart.notNull((element & 0x3ffffff) === element);
981 } 981 }
982 _computeHashCode(element) { 982 _computeHashCode(element) {
983 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', dart.dload(ele ment, 'hashCode')), core.int); 983 return dart.dload(element, 'hashCode') & 0x3ffffff;
984 } 984 }
985 static _hasTableEntry(table, key) { 985 static _hasTableEntry(table, key) {
986 let entry = _foreign_helper.JS('var', '#[#]', table, key); 986 let entry = table[key];
987 return entry !== null; 987 return entry !== null;
988 } 988 }
989 static _setTableEntry(table, key, value) { 989 static _setTableEntry(table, key, value) {
990 dart.assert(value !== null); 990 dart.assert(value !== null);
991 _foreign_helper.JS('void', '#[#] = #', table, key, value); 991 table[key] = value;
992 } 992 }
993 static _deleteTableEntry(table, key) { 993 static _deleteTableEntry(table, key) {
994 _foreign_helper.JS('void', 'delete #[#]', table, key); 994 delete table[key];
995 } 995 }
996 _getBucket(table, element) { 996 _getBucket(table, element) {
997 let hash = this._computeHashCode(element); 997 let hash = this._computeHashCode(element);
998 return dart.as(_foreign_helper.JS('var', '#[#]', table, hash), core.List ); 998 return dart.as(table[hash], core.List);
999 } 999 }
1000 _findBucketIndex(bucket, element) { 1000 _findBucketIndex(bucket, element) {
1001 if (bucket === null) 1001 if (bucket === null)
1002 return -1; 1002 return -1;
1003 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1003 let length = bucket.length;
1004 for (let i = 0; i < length; i++) { 1004 for (let i = 0; i < length; i++) {
1005 if (dart.equals(_foreign_helper.JS('var', '#[#]', bucket, i), element) ) 1005 if (dart.equals(bucket[i], element))
1006 return i; 1006 return i;
1007 } 1007 }
1008 return -1; 1008 return -1;
1009 } 1009 }
1010 static _newHashTable() { 1010 static _newHashTable() {
1011 let table = _foreign_helper.JS('var', 'Object.create(null)'); 1011 let table = Object.create(null);
1012 let temporaryKey = '<non-identifier-key>'; 1012 let temporaryKey = '<non-identifier-key>';
1013 _setTableEntry(table, temporaryKey, table); 1013 _setTableEntry(table, temporaryKey, table);
1014 _deleteTableEntry(table, temporaryKey); 1014 _deleteTableEntry(table, temporaryKey);
1015 return table; 1015 return table;
1016 } 1016 }
1017 } 1017 }
1018 return _HashSet; 1018 return _HashSet;
1019 }); 1019 });
1020 let _HashSet = _HashSet$(dynamic); 1020 let _HashSet = _HashSet$(dynamic);
1021 let _IdentityHashSet$ = dart.generic(function(E) { 1021 let _IdentityHashSet$ = dart.generic(function(E) {
1022 class _IdentityHashSet extends _HashSet$(E) { 1022 class _IdentityHashSet extends _HashSet$(E) {
1023 _newSet() { 1023 _newSet() {
1024 return new _IdentityHashSet(); 1024 return new _IdentityHashSet();
1025 } 1025 }
1026 _computeHashCode(key) { 1026 _computeHashCode(key) {
1027 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', core.identityH ashCode(key)), core.int); 1027 return core.identityHashCode(key) & 0x3ffffff;
1028 } 1028 }
1029 _findBucketIndex(bucket, element) { 1029 _findBucketIndex(bucket, element) {
1030 if (bucket === null) 1030 if (bucket === null)
1031 return -1; 1031 return -1;
1032 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1032 let length = bucket.length;
1033 for (let i = 0; i < length; i++) { 1033 for (let i = 0; i < length; i++) {
1034 if (core.identical(_foreign_helper.JS('var', '#[#]', bucket, i), eleme nt)) 1034 if (core.identical(bucket[i], element))
1035 return i; 1035 return i;
1036 } 1036 }
1037 return -1; 1037 return -1;
1038 } 1038 }
1039 } 1039 }
1040 return _IdentityHashSet; 1040 return _IdentityHashSet;
1041 }); 1041 });
1042 let _IdentityHashSet = _IdentityHashSet$(dynamic); 1042 let _IdentityHashSet = _IdentityHashSet$(dynamic);
1043 let _CustomHashSet$ = dart.generic(function(E) { 1043 let _CustomHashSet$ = dart.generic(function(E) {
1044 class _CustomHashSet extends _HashSet$(E) { 1044 class _CustomHashSet extends _HashSet$(E) {
1045 _CustomHashSet(_equality, _hasher, validKey) { 1045 _CustomHashSet(_equality, _hasher, validKey) {
1046 this._equality = _equality; 1046 this._equality = _equality;
1047 this._hasher = _hasher; 1047 this._hasher = _hasher;
1048 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x , E), _Predicate); 1048 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x , E), _Predicate);
1049 super._HashSet(); 1049 super._HashSet();
1050 } 1050 }
1051 _newSet() { 1051 _newSet() {
1052 return new _CustomHashSet(this._equality, this._hasher, this._validKey); 1052 return new _CustomHashSet(this._equality, this._hasher, this._validKey);
1053 } 1053 }
1054 _findBucketIndex(bucket, element) { 1054 _findBucketIndex(bucket, element) {
1055 if (bucket === null) 1055 if (bucket === null)
1056 return -1; 1056 return -1;
1057 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1057 let length = bucket.length;
1058 for (let i = 0; i < length; i++) { 1058 for (let i = 0; i < length; i++) {
1059 if (this._equality(dart.as(_foreign_helper.JS('var', '#[#]', bucket, i ), E), dart.as(element, E))) 1059 if (this._equality(dart.as(bucket[i], E), dart.as(element, E)))
1060 return i; 1060 return i;
1061 } 1061 }
1062 return -1; 1062 return -1;
1063 } 1063 }
1064 _computeHashCode(element) { 1064 _computeHashCode(element) {
1065 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', this._hasher(d art.as(element, E))), core.int); 1065 return this._hasher(dart.as(element, E)) & 0x3ffffff;
1066 } 1066 }
1067 add(object) { 1067 add(object) {
1068 return super._add(object); 1068 return super._add(object);
1069 } 1069 }
1070 contains(object) { 1070 contains(object) {
1071 if (!dart.notNull(this._validKey(object))) 1071 if (!dart.notNull(this._validKey(object)))
1072 return false; 1072 return false;
1073 return super._contains(object); 1073 return super._contains(object);
1074 } 1074 }
1075 lookup(object) { 1075 lookup(object) {
(...skipping 17 matching lines...) Expand all
1093 this._elements = _elements; 1093 this._elements = _elements;
1094 this._offset = 0; 1094 this._offset = 0;
1095 this._current = dart.as(null, E); 1095 this._current = dart.as(null, E);
1096 } 1096 }
1097 get current() { 1097 get current() {
1098 return this._current; 1098 return this._current;
1099 } 1099 }
1100 moveNext() { 1100 moveNext() {
1101 let elements = this._elements; 1101 let elements = this._elements;
1102 let offset = this._offset; 1102 let offset = this._offset;
1103 if (_foreign_helper.JS('bool', '# !== #', elements, dart.dload(this._set , '_elements'))) { 1103 if (elements !== dart.dload(this._set, '_elements')) {
1104 throw new core.ConcurrentModificationError(this._set); 1104 throw new core.ConcurrentModificationError(this._set);
1105 } else if (offset['>='](_foreign_helper.JS('int', '#.length', elements)) ) { 1105 } else if (offset >= elements.length) {
1106 this._current = dart.as(null, E); 1106 this._current = dart.as(null, E);
1107 return false; 1107 return false;
1108 } else { 1108 } else {
1109 this._current = dart.as(_foreign_helper.JS('var', '#[#]', elements, of fset), E); 1109 this._current = dart.as(elements[offset], E);
1110 this._offset = dart.as(_foreign_helper.JS('int', '#', offset + 1), cor e.int); 1110 this._offset = offset + 1;
1111 return true; 1111 return true;
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 return HashSetIterator; 1115 return HashSetIterator;
1116 }); 1116 });
1117 let HashSetIterator = HashSetIterator$(dynamic); 1117 let HashSetIterator = HashSetIterator$(dynamic);
1118 let _LinkedHashSet$ = dart.generic(function(E) { 1118 let _LinkedHashSet$ = dart.generic(function(E) {
1119 class _LinkedHashSet extends _HashSetBase$(E) { 1119 class _LinkedHashSet extends _HashSetBase$(E) {
1120 _LinkedHashSet() { 1120 _LinkedHashSet() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return this._addHashTableEntry(nums, element); 1220 return this._addHashTableEntry(nums, element);
1221 } else { 1221 } else {
1222 return this._add(element); 1222 return this._add(element);
1223 } 1223 }
1224 } 1224 }
1225 _add(element) { 1225 _add(element) {
1226 let rest = this._rest; 1226 let rest = this._rest;
1227 if (rest === null) 1227 if (rest === null)
1228 this._rest = rest = _newHashTable(); 1228 this._rest = rest = _newHashTable();
1229 let hash = this._computeHashCode(element); 1229 let hash = this._computeHashCode(element);
1230 let bucket = _foreign_helper.JS('var', '#[#]', rest, hash); 1230 let bucket = rest[hash];
1231 if (bucket === null) { 1231 if (bucket === null) {
1232 let cell = this._newLinkedCell(element); 1232 let cell = this._newLinkedCell(element);
1233 _setTableEntry(rest, hash, _foreign_helper.JS('var', '[#]', cell)); 1233 _setTableEntry(rest, hash, [cell]);
1234 } else { 1234 } else {
1235 let index = this._findBucketIndex(bucket, element); 1235 let index = this._findBucketIndex(bucket, element);
1236 if (index >= 0) 1236 if (index >= 0)
1237 return false; 1237 return false;
1238 let cell = this._newLinkedCell(element); 1238 let cell = this._newLinkedCell(element);
1239 _foreign_helper.JS('void', '#.push(#)', bucket, cell); 1239 bucket.push(cell);
1240 } 1240 }
1241 return true; 1241 return true;
1242 } 1242 }
1243 remove(object) { 1243 remove(object) {
1244 if (_isStringElement(object)) { 1244 if (_isStringElement(object)) {
1245 return this._removeHashTableEntry(this._strings, object); 1245 return this._removeHashTableEntry(this._strings, object);
1246 } else if (_isNumericElement(object)) { 1246 } else if (_isNumericElement(object)) {
1247 return this._removeHashTableEntry(this._nums, object); 1247 return this._removeHashTableEntry(this._nums, object);
1248 } else { 1248 } else {
1249 return this._remove(object); 1249 return this._remove(object);
1250 } 1250 }
1251 } 1251 }
1252 _remove(object) { 1252 _remove(object) {
1253 let rest = this._rest; 1253 let rest = this._rest;
1254 if (rest === null) 1254 if (rest === null)
1255 return false; 1255 return false;
1256 let bucket = this._getBucket(rest, object); 1256 let bucket = this._getBucket(rest, object);
1257 let index = this._findBucketIndex(bucket, object); 1257 let index = this._findBucketIndex(bucket, object);
1258 if (index < 0) 1258 if (index < 0)
1259 return false; 1259 return false;
1260 let cell = dart.as(_foreign_helper.JS('var', '#.splice(#, 1)[0]', bucket , index), LinkedHashSetCell); 1260 let cell = dart.as(bucket.splice(index, 1)[0], LinkedHashSetCell);
1261 this._unlinkCell(cell); 1261 this._unlinkCell(cell);
1262 return true; 1262 return true;
1263 } 1263 }
1264 removeWhere(test) { 1264 removeWhere(test) {
1265 this._filterWhere(test, true); 1265 this._filterWhere(test, true);
1266 } 1266 }
1267 retainWhere(test) { 1267 retainWhere(test) {
1268 this._filterWhere(test, false); 1268 this._filterWhere(test, false);
1269 } 1269 }
1270 _filterWhere(test, removeMatching) { 1270 _filterWhere(test, removeMatching) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 } else { 1337 } else {
1338 next._previous = previous; 1338 next._previous = previous;
1339 } 1339 }
1340 this._length--; 1340 this._length--;
1341 this._modified(); 1341 this._modified();
1342 } 1342 }
1343 static _isStringElement(element) { 1343 static _isStringElement(element) {
1344 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa ls(element, '__proto__')); 1344 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa ls(element, '__proto__'));
1345 } 1345 }
1346 static _isNumericElement(element) { 1346 static _isNumericElement(element) {
1347 return core.bool['&&'](dart.is(element, core.num), _foreign_helper.JS('b ool', '(# & 0x3ffffff) === #', element, element)); 1347 return dart.notNull(dart.is(element, core.num)) && dart.notNull((element & 0x3ffffff) === element);
1348 } 1348 }
1349 _computeHashCode(element) { 1349 _computeHashCode(element) {
1350 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', dart.dload(ele ment, 'hashCode')), core.int); 1350 return dart.dload(element, 'hashCode') & 0x3ffffff;
1351 } 1351 }
1352 static _getTableEntry(table, key) { 1352 static _getTableEntry(table, key) {
1353 return _foreign_helper.JS('var', '#[#]', table, key); 1353 return table[key];
1354 } 1354 }
1355 static _setTableEntry(table, key, value) { 1355 static _setTableEntry(table, key, value) {
1356 dart.assert(value !== null); 1356 dart.assert(value !== null);
1357 _foreign_helper.JS('void', '#[#] = #', table, key, value); 1357 table[key] = value;
1358 } 1358 }
1359 static _deleteTableEntry(table, key) { 1359 static _deleteTableEntry(table, key) {
1360 _foreign_helper.JS('void', 'delete #[#]', table, key); 1360 delete table[key];
1361 } 1361 }
1362 _getBucket(table, element) { 1362 _getBucket(table, element) {
1363 let hash = this._computeHashCode(element); 1363 let hash = this._computeHashCode(element);
1364 return dart.as(_foreign_helper.JS('var', '#[#]', table, hash), core.List ); 1364 return dart.as(table[hash], core.List);
1365 } 1365 }
1366 _findBucketIndex(bucket, element) { 1366 _findBucketIndex(bucket, element) {
1367 if (bucket === null) 1367 if (bucket === null)
1368 return -1; 1368 return -1;
1369 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1369 let length = bucket.length;
1370 for (let i = 0; i < length; i++) { 1370 for (let i = 0; i < length; i++) {
1371 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashSetCell); 1371 let cell = dart.as(bucket[i], LinkedHashSetCell);
1372 if (dart.equals(cell._element, element)) 1372 if (dart.equals(cell._element, element))
1373 return i; 1373 return i;
1374 } 1374 }
1375 return -1; 1375 return -1;
1376 } 1376 }
1377 static _newHashTable() { 1377 static _newHashTable() {
1378 let table = _foreign_helper.JS('var', 'Object.create(null)'); 1378 let table = Object.create(null);
1379 let temporaryKey = '<non-identifier-key>'; 1379 let temporaryKey = '<non-identifier-key>';
1380 _setTableEntry(table, temporaryKey, table); 1380 _setTableEntry(table, temporaryKey, table);
1381 _deleteTableEntry(table, temporaryKey); 1381 _deleteTableEntry(table, temporaryKey);
1382 return table; 1382 return table;
1383 } 1383 }
1384 } 1384 }
1385 return _LinkedHashSet; 1385 return _LinkedHashSet;
1386 }); 1386 });
1387 let _LinkedHashSet = _LinkedHashSet$(dynamic); 1387 let _LinkedHashSet = _LinkedHashSet$(dynamic);
1388 let _LinkedIdentityHashSet$ = dart.generic(function(E) { 1388 let _LinkedIdentityHashSet$ = dart.generic(function(E) {
1389 class _LinkedIdentityHashSet extends _LinkedHashSet$(E) { 1389 class _LinkedIdentityHashSet extends _LinkedHashSet$(E) {
1390 _newSet() { 1390 _newSet() {
1391 return new _LinkedIdentityHashSet(); 1391 return new _LinkedIdentityHashSet();
1392 } 1392 }
1393 _computeHashCode(key) { 1393 _computeHashCode(key) {
1394 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', core.identityH ashCode(key)), core.int); 1394 return core.identityHashCode(key) & 0x3ffffff;
1395 } 1395 }
1396 _findBucketIndex(bucket, element) { 1396 _findBucketIndex(bucket, element) {
1397 if (bucket === null) 1397 if (bucket === null)
1398 return -1; 1398 return -1;
1399 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1399 let length = bucket.length;
1400 for (let i = 0; i < length; i++) { 1400 for (let i = 0; i < length; i++) {
1401 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashSetCell); 1401 let cell = dart.as(bucket[i], LinkedHashSetCell);
1402 if (core.identical(cell._element, element)) 1402 if (core.identical(cell._element, element))
1403 return i; 1403 return i;
1404 } 1404 }
1405 return -1; 1405 return -1;
1406 } 1406 }
1407 } 1407 }
1408 return _LinkedIdentityHashSet; 1408 return _LinkedIdentityHashSet;
1409 }); 1409 });
1410 let _LinkedIdentityHashSet = _LinkedIdentityHashSet$(dynamic); 1410 let _LinkedIdentityHashSet = _LinkedIdentityHashSet$(dynamic);
1411 let _LinkedCustomHashSet$ = dart.generic(function(E) { 1411 let _LinkedCustomHashSet$ = dart.generic(function(E) {
1412 class _LinkedCustomHashSet extends _LinkedHashSet$(E) { 1412 class _LinkedCustomHashSet extends _LinkedHashSet$(E) {
1413 _LinkedCustomHashSet(_equality, _hasher, validKey) { 1413 _LinkedCustomHashSet(_equality, _hasher, validKey) {
1414 this._equality = _equality; 1414 this._equality = _equality;
1415 this._hasher = _hasher; 1415 this._hasher = _hasher;
1416 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x , E), _Predicate); 1416 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x , E), _Predicate);
1417 super._LinkedHashSet(); 1417 super._LinkedHashSet();
1418 } 1418 }
1419 _newSet() { 1419 _newSet() {
1420 return new _LinkedCustomHashSet(this._equality, this._hasher, this._vali dKey); 1420 return new _LinkedCustomHashSet(this._equality, this._hasher, this._vali dKey);
1421 } 1421 }
1422 _findBucketIndex(bucket, element) { 1422 _findBucketIndex(bucket, element) {
1423 if (bucket === null) 1423 if (bucket === null)
1424 return -1; 1424 return -1;
1425 let length = dart.as(_foreign_helper.JS('int', '#.length', bucket), core .int); 1425 let length = bucket.length;
1426 for (let i = 0; i < length; i++) { 1426 for (let i = 0; i < length; i++) {
1427 let cell = dart.as(_foreign_helper.JS('var', '#[#]', bucket, i), Linke dHashSetCell); 1427 let cell = dart.as(bucket[i], LinkedHashSetCell);
1428 if (this._equality(dart.as(cell._element, E), dart.as(element, E))) 1428 if (this._equality(dart.as(cell._element, E), dart.as(element, E)))
1429 return i; 1429 return i;
1430 } 1430 }
1431 return -1; 1431 return -1;
1432 } 1432 }
1433 _computeHashCode(element) { 1433 _computeHashCode(element) {
1434 return dart.as(_foreign_helper.JS('int', '# & 0x3ffffff', this._hasher(d art.as(element, E))), core.int); 1434 return this._hasher(dart.as(element, E)) & 0x3ffffff;
1435 } 1435 }
1436 add(element) { 1436 add(element) {
1437 return super._add(element); 1437 return super._add(element);
1438 } 1438 }
1439 contains(object) { 1439 contains(object) {
1440 if (!dart.notNull(this._validKey(object))) 1440 if (!dart.notNull(this._validKey(object)))
1441 return false; 1441 return false;
1442 return super._contains(object); 1442 return super._contains(object);
1443 } 1443 }
1444 lookup(object) { 1444 lookup(object) {
(...skipping 3342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4787 collection.ListQueue$ = ListQueue$; 4787 collection.ListQueue$ = ListQueue$;
4788 collection.SetMixin = SetMixin; 4788 collection.SetMixin = SetMixin;
4789 collection.SetMixin$ = SetMixin$; 4789 collection.SetMixin$ = SetMixin$;
4790 collection.SetBase = SetBase; 4790 collection.SetBase = SetBase;
4791 collection.SetBase$ = SetBase$; 4791 collection.SetBase$ = SetBase$;
4792 collection.SplayTreeMap = SplayTreeMap; 4792 collection.SplayTreeMap = SplayTreeMap;
4793 collection.SplayTreeMap$ = SplayTreeMap$; 4793 collection.SplayTreeMap$ = SplayTreeMap$;
4794 collection.SplayTreeSet = SplayTreeSet; 4794 collection.SplayTreeSet = SplayTreeSet;
4795 collection.SplayTreeSet$ = SplayTreeSet$; 4795 collection.SplayTreeSet$ = SplayTreeSet$;
4796 })(collection || (collection = {})); 4796 })(collection || (collection = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/async/async.js ('k') | test/codegen/expect/convert/convert.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698