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

Side by Side Diff: lib/runtime/dart/collection.js

Issue 1169473003: fixes #43, remove => workaround (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 | « lib/runtime/dart/async.js ('k') | lib/runtime/dart/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 = dart.defineLibrary(collection, {}); 1 var collection = dart.defineLibrary(collection, {});
2 var _internal = dart.lazyImport(_internal); 2 var _internal = dart.lazyImport(_internal);
3 var core = dart.import(core); 3 var core = dart.import(core);
4 var _js_helper = dart.lazyImport(_js_helper); 4 var _js_helper = dart.lazyImport(_js_helper);
5 var math = dart.lazyImport(math); 5 var math = dart.lazyImport(math);
6 (function(exports, _internal, core, _js_helper, math) { 6 (function(exports, _internal, core, _js_helper, math) {
7 'use strict'; 7 'use strict';
8 let _source = Symbol('_source'); 8 let _source = Symbol('_source');
9 let UnmodifiableListView$ = dart.generic(function(E) { 9 let UnmodifiableListView$ = dart.generic(function(E) {
10 class UnmodifiableListView extends _internal.UnmodifiableListBase$(E) { 10 class UnmodifiableListView extends _internal.UnmodifiableListBase$(E) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 result.remove(element); 185 result.remove(element);
186 } 186 }
187 return result; 187 return result;
188 } 188 }
189 [core.$toList](opts) { 189 [core.$toList](opts) {
190 let growable = opts && 'growable' in opts ? opts.growable : true; 190 let growable = opts && 'growable' in opts ? opts.growable : true;
191 let result = growable ? (() => { 191 let result = growable ? (() => {
192 let _ = core.List$(E).new(); 192 let _ = core.List$(E).new();
193 _[core.$length] = this[core.$length]; 193 _[core.$length] = this[core.$length];
194 return _; 194 return _;
195 }).bind(this)() : core.List$(E).new(this[core.$length]); 195 })() : core.List$(E).new(this[core.$length]);
196 let i = 0; 196 let i = 0;
197 for (let element of this) 197 for (let element of this)
198 result[core.$set]((() => { 198 result[core.$set]((() => {
199 let x = i; 199 let x = i;
200 i = dart.notNull(x) + 1; 200 i = dart.notNull(x) + 1;
201 return x; 201 return x;
202 })(), element); 202 })(), element);
203 return result; 203 return result;
204 } 204 }
205 [core.$map](f) { 205 [core.$map](f) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (other[core.$contains](element)) 444 if (other[core.$contains](element))
445 result.add(element); 445 result.add(element);
446 } 446 }
447 return result; 447 return result;
448 } 448 }
449 [core.$toSet]() { 449 [core.$toSet]() {
450 return (() => { 450 return (() => {
451 let _ = this[_newSet](); 451 let _ = this[_newSet]();
452 _.addAll(this); 452 _.addAll(this);
453 return _; 453 return _;
454 }).bind(this)(); 454 })();
455 } 455 }
456 } 456 }
457 dart.setSignature(_HashSetBase, { 457 dart.setSignature(_HashSetBase, {
458 methods: () => ({ 458 methods: () => ({
459 difference: [core.Set$(E), [core.Set$(core.Object)]], 459 difference: [core.Set$(E), [core.Set$(core.Object)]],
460 intersection: [core.Set$(E), [core.Set$(core.Object)]], 460 intersection: [core.Set$(E), [core.Set$(core.Object)]],
461 [core.$toSet]: [core.Set$(E), []] 461 [core.$toSet]: [core.Set$(E), []]
462 }) 462 })
463 }); 463 });
464 return _HashSetBase; 464 return _HashSetBase;
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 addFirst(entry) { 1331 addFirst(entry) {
1332 dart.as(entry, E); 1332 dart.as(entry, E);
1333 this[_insertAfter](this, entry); 1333 this[_insertAfter](this, entry);
1334 } 1334 }
1335 add(entry) { 1335 add(entry) {
1336 dart.as(entry, E); 1336 dart.as(entry, E);
1337 this[_insertAfter](this[_previous], entry); 1337 this[_insertAfter](this[_previous], entry);
1338 } 1338 }
1339 addAll(entries) { 1339 addAll(entries) {
1340 dart.as(entries, core.Iterable$(E)); 1340 dart.as(entries, core.Iterable$(E));
1341 entries[core.$forEach](dart.fn((entry => this[_insertAfter](this[_previo us], dart.as(entry, E))).bind(this), dart.void, [core.Object])); 1341 entries[core.$forEach](dart.fn(entry => this[_insertAfter](this[_previou s], dart.as(entry, E)), dart.void, [core.Object]));
1342 } 1342 }
1343 remove(entry) { 1343 remove(entry) {
1344 dart.as(entry, E); 1344 dart.as(entry, E);
1345 if (!dart.equals(entry[_list], this)) 1345 if (!dart.equals(entry[_list], this))
1346 return false; 1346 return false;
1347 this[_unlink](entry); 1347 this[_unlink](entry);
1348 return true; 1348 return true;
1349 } 1349 }
1350 get [core.$iterator]() { 1350 get [core.$iterator]() {
1351 return new (_LinkedListIterator$(E))(this); 1351 return new (_LinkedListIterator$(E))(this);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 result.add(this[core.$get](i)); 1740 result.add(this[core.$get](i));
1741 } 1741 }
1742 return result; 1742 return result;
1743 } 1743 }
1744 [core.$add](element) { 1744 [core.$add](element) {
1745 dart.as(element, E); 1745 dart.as(element, E);
1746 this[core.$set]((() => { 1746 this[core.$set]((() => {
1747 let x = this[core.$length]; 1747 let x = this[core.$length];
1748 this[core.$length] = dart.notNull(x) + 1; 1748 this[core.$length] = dart.notNull(x) + 1;
1749 return x; 1749 return x;
1750 }).bind(this)(), element); 1750 })(), element);
1751 } 1751 }
1752 [core.$addAll](iterable) { 1752 [core.$addAll](iterable) {
1753 dart.as(iterable, core.Iterable$(E)); 1753 dart.as(iterable, core.Iterable$(E));
1754 for (let element of iterable) { 1754 for (let element of iterable) {
1755 this[core.$set]((() => { 1755 this[core.$set]((() => {
1756 let x = this[core.$length]; 1756 let x = this[core.$length];
1757 this[core.$length] = dart.notNull(x) + 1; 1757 this[core.$length] = dart.notNull(x) + 1;
1758 return x; 1758 return x;
1759 }).bind(this)(), element); 1759 })(), element);
1760 } 1760 }
1761 } 1761 }
1762 [core.$remove](element) { 1762 [core.$remove](element) {
1763 for (let i = 0; dart.notNull(i) < dart.notNull(this[core.$length]); i = dart.notNull(i) + 1) { 1763 for (let i = 0; dart.notNull(i) < dart.notNull(this[core.$length]); i = dart.notNull(i) + 1) {
1764 if (dart.equals(this[core.$get](i), element)) { 1764 if (dart.equals(this[core.$get](i), element)) {
1765 this[core.$setRange](i, dart.notNull(this[core.$length]) - 1, this, dart.notNull(i) + 1); 1765 this[core.$setRange](i, dart.notNull(this[core.$length]) - 1, this, dart.notNull(i) + 1);
1766 this[core.$length] = dart.notNull(this[core.$length]) - 1; 1766 this[core.$length] = dart.notNull(this[core.$length]) - 1;
1767 return true; 1767 return true;
1768 } 1768 }
1769 } 1769 }
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3409 } 3409 }
3410 if (splayCount != this[_splayCount]) { 3410 if (splayCount != this[_splayCount]) {
3411 comp = this[_splay](key); 3411 comp = this[_splay](key);
3412 dart.assert(comp != 0); 3412 dart.assert(comp != 0);
3413 } 3413 }
3414 this[_addNewRoot](new (_SplayTreeMapNode$(K, core.Object))(key, value), comp); 3414 this[_addNewRoot](new (_SplayTreeMapNode$(K, core.Object))(key, value), comp);
3415 return value; 3415 return value;
3416 } 3416 }
3417 addAll(other) { 3417 addAll(other) {
3418 dart.as(other, core.Map$(K, V)); 3418 dart.as(other, core.Map$(K, V));
3419 other.forEach(dart.fn(((key, value) => { 3419 other.forEach(dart.fn((key, value) => {
3420 dart.as(key, K); 3420 dart.as(key, K);
3421 dart.as(value, V); 3421 dart.as(value, V);
3422 this.set(key, value); 3422 this.set(key, value);
3423 }).bind(this), core.Object, [K, V])); 3423 }, core.Object, [K, V]));
3424 } 3424 }
3425 get isEmpty() { 3425 get isEmpty() {
3426 return this[_root] == null; 3426 return this[_root] == null;
3427 } 3427 }
3428 get isNotEmpty() { 3428 get isNotEmpty() {
3429 return !dart.notNull(this.isEmpty); 3429 return !dart.notNull(this.isEmpty);
3430 } 3430 }
3431 forEach(f) { 3431 forEach(f) {
3432 dart.as(f, dart.functionType(dart.void, [K, V])); 3432 dart.as(f, dart.functionType(dart.void, [K, V]));
3433 let nodes = new (_SplayTreeNodeIterator$(K))(this); 3433 let nodes = new (_SplayTreeNodeIterator$(K))(this);
3434 while (nodes.moveNext()) { 3434 while (nodes.moveNext()) {
3435 let node = dart.as(nodes.current, _SplayTreeMapNode$(K, V)); 3435 let node = dart.as(nodes.current, _SplayTreeMapNode$(K, V));
3436 f(node.key, node.value); 3436 f(node.key, node.value);
3437 } 3437 }
3438 } 3438 }
3439 get length() { 3439 get length() {
3440 return this[_count]; 3440 return this[_count];
3441 } 3441 }
3442 clear() { 3442 clear() {
3443 this[_clear](); 3443 this[_clear]();
3444 } 3444 }
3445 containsKey(key) { 3445 containsKey(key) {
3446 return dart.notNull(this[_validKey](key)) && this[_splay](dart.as(key, K )) == 0; 3446 return dart.notNull(this[_validKey](key)) && this[_splay](dart.as(key, K )) == 0;
3447 } 3447 }
3448 containsValue(value) { 3448 containsValue(value) {
3449 let found = false; 3449 let found = false;
3450 let initialSplayCount = this[_splayCount]; 3450 let initialSplayCount = this[_splayCount];
3451 let visit = (node => { 3451 let visit = node => {
3452 while (node != null) { 3452 while (node != null) {
3453 if (dart.equals(node.value, value)) 3453 if (dart.equals(node.value, value))
3454 return true; 3454 return true;
3455 if (initialSplayCount != this[_splayCount]) { 3455 if (initialSplayCount != this[_splayCount]) {
3456 throw new core.ConcurrentModificationError(this); 3456 throw new core.ConcurrentModificationError(this);
3457 } 3457 }
3458 if (dart.notNull(node.right != null) && dart.notNull(visit(dart.as(n ode.right, _SplayTreeMapNode)))) 3458 if (dart.notNull(node.right != null) && dart.notNull(visit(dart.as(n ode.right, _SplayTreeMapNode))))
3459 return true; 3459 return true;
3460 node = dart.as(node.left, _SplayTreeMapNode); 3460 node = dart.as(node.left, _SplayTreeMapNode);
3461 } 3461 }
3462 return false; 3462 return false;
3463 }).bind(this); 3463 };
3464 dart.fn(visit, core.bool, [_SplayTreeMapNode]); 3464 dart.fn(visit, core.bool, [_SplayTreeMapNode]);
3465 return visit(dart.as(this[_root], _SplayTreeMapNode)); 3465 return visit(dart.as(this[_root], _SplayTreeMapNode));
3466 } 3466 }
3467 get keys() { 3467 get keys() {
3468 return new (_SplayTreeKeyIterable$(K))(this); 3468 return new (_SplayTreeKeyIterable$(K))(this);
3469 } 3469 }
3470 get values() { 3470 get values() {
3471 return new (_SplayTreeValueIterable$(K, V))(this); 3471 return new (_SplayTreeValueIterable$(K, V))(this);
3472 } 3472 }
3473 toString() { 3473 toString() {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3959 get isEmpty() { 3959 get isEmpty() {
3960 return this[_length] == 0; 3960 return this[_length] == 0;
3961 } 3961 }
3962 get isNotEmpty() { 3962 get isNotEmpty() {
3963 return !dart.notNull(this.isEmpty); 3963 return !dart.notNull(this.isEmpty);
3964 } 3964 }
3965 get keys() { 3965 get keys() {
3966 return new (HashMapKeyIterable$(K))(this); 3966 return new (HashMapKeyIterable$(K))(this);
3967 } 3967 }
3968 get values() { 3968 get values() {
3969 return _internal.MappedIterable$(K, V).new(this.keys, dart.fn((each => t his.get(each)).bind(this), V, [core.Object])); 3969 return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => th is.get(each), V, [core.Object]));
3970 } 3970 }
3971 containsKey(key) { 3971 containsKey(key) {
3972 if (_HashMap$()._isStringKey(key)) { 3972 if (_HashMap$()._isStringKey(key)) {
3973 let strings = this[_strings]; 3973 let strings = this[_strings];
3974 return strings == null ? false : _HashMap$()._hasTableEntry(strings, k ey); 3974 return strings == null ? false : _HashMap$()._hasTableEntry(strings, k ey);
3975 } else if (_HashMap$()._isNumericKey(key)) { 3975 } else if (_HashMap$()._isNumericKey(key)) {
3976 let nums = this[_nums]; 3976 let nums = this[_nums];
3977 return nums == null ? false : _HashMap$()._hasTableEntry(nums, key); 3977 return nums == null ? false : _HashMap$()._hasTableEntry(nums, key);
3978 } else { 3978 } else {
3979 return this[_containsKey](key); 3979 return this[_containsKey](key);
3980 } 3980 }
3981 } 3981 }
3982 [_containsKey](key) { 3982 [_containsKey](key) {
3983 let rest = this[_rest]; 3983 let rest = this[_rest];
3984 if (rest == null) 3984 if (rest == null)
3985 return false; 3985 return false;
3986 let bucket = this[_getBucket](rest, key); 3986 let bucket = this[_getBucket](rest, key);
3987 return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0; 3987 return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0;
3988 } 3988 }
3989 containsValue(value) { 3989 containsValue(value) {
3990 return this[_computeKeys]()[core.$any](dart.fn((each => dart.equals(this .get(each), value)).bind(this), core.bool, [core.Object])); 3990 return this[_computeKeys]()[core.$any](dart.fn(each => dart.equals(this. get(each), value), core.bool, [core.Object]));
3991 } 3991 }
3992 addAll(other) { 3992 addAll(other) {
3993 dart.as(other, core.Map$(K, V)); 3993 dart.as(other, core.Map$(K, V));
3994 other.forEach(dart.fn(((key, value) => { 3994 other.forEach(dart.fn((key, value) => {
3995 dart.as(key, K); 3995 dart.as(key, K);
3996 dart.as(value, V); 3996 dart.as(value, V);
3997 this.set(key, value); 3997 this.set(key, value);
3998 }).bind(this), core.Object, [K, V])); 3998 }, core.Object, [K, V]));
3999 } 3999 }
4000 get(key) { 4000 get(key) {
4001 if (_HashMap$()._isStringKey(key)) { 4001 if (_HashMap$()._isStringKey(key)) {
4002 let strings = this[_strings]; 4002 let strings = this[_strings];
4003 return strings == null ? null : dart.as(_HashMap$()._getTableEntry(str ings, key), V); 4003 return strings == null ? null : dart.as(_HashMap$()._getTableEntry(str ings, key), V);
4004 } else if (_HashMap$()._isNumericKey(key)) { 4004 } else if (_HashMap$()._isNumericKey(key)) {
4005 let nums = this[_nums]; 4005 let nums = this[_nums];
4006 return nums == null ? null : dart.as(_HashMap$()._getTableEntry(nums, key), V); 4006 return nums == null ? null : dart.as(_HashMap$()._getTableEntry(nums, key), V);
4007 } else { 4007 } else {
4008 return this[_get](key); 4008 return this[_get](key);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 get isEmpty() { 4428 get isEmpty() {
4429 return this[_length] == 0; 4429 return this[_length] == 0;
4430 } 4430 }
4431 get isNotEmpty() { 4431 get isNotEmpty() {
4432 return !dart.notNull(this.isEmpty); 4432 return !dart.notNull(this.isEmpty);
4433 } 4433 }
4434 get keys() { 4434 get keys() {
4435 return new (LinkedHashMapKeyIterable$(K))(this); 4435 return new (LinkedHashMapKeyIterable$(K))(this);
4436 } 4436 }
4437 get values() { 4437 get values() {
4438 return _internal.MappedIterable$(K, V).new(this.keys, dart.fn((each => t his.get(each)).bind(this), V, [core.Object])); 4438 return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => th is.get(each), V, [core.Object]));
4439 } 4439 }
4440 containsKey(key) { 4440 containsKey(key) {
4441 if (_LinkedHashMap$()._isStringKey(key)) { 4441 if (_LinkedHashMap$()._isStringKey(key)) {
4442 let strings = this[_strings]; 4442 let strings = this[_strings];
4443 if (strings == null) 4443 if (strings == null)
4444 return false; 4444 return false;
4445 let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), Lin kedHashMapCell); 4445 let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), Lin kedHashMapCell);
4446 return cell != null; 4446 return cell != null;
4447 } else if (_LinkedHashMap$()._isNumericKey(key)) { 4447 } else if (_LinkedHashMap$()._isNumericKey(key)) {
4448 let nums = this[_nums]; 4448 let nums = this[_nums];
4449 if (nums == null) 4449 if (nums == null)
4450 return false; 4450 return false;
4451 let cell = dart.as(_LinkedHashMap$()._getTableEntry(nums, key), Linked HashMapCell); 4451 let cell = dart.as(_LinkedHashMap$()._getTableEntry(nums, key), Linked HashMapCell);
4452 return cell != null; 4452 return cell != null;
4453 } else { 4453 } else {
4454 return this[_containsKey](key); 4454 return this[_containsKey](key);
4455 } 4455 }
4456 } 4456 }
4457 [_containsKey](key) { 4457 [_containsKey](key) {
4458 let rest = this[_rest]; 4458 let rest = this[_rest];
4459 if (rest == null) 4459 if (rest == null)
4460 return false; 4460 return false;
4461 let bucket = this[_getBucket](rest, key); 4461 let bucket = this[_getBucket](rest, key);
4462 return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0; 4462 return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0;
4463 } 4463 }
4464 containsValue(value) { 4464 containsValue(value) {
4465 return this.keys[core.$any](dart.fn((each => dart.equals(this.get(each), value)).bind(this), core.bool, [core.Object])); 4465 return this.keys[core.$any](dart.fn(each => dart.equals(this.get(each), value), core.bool, [core.Object]));
4466 } 4466 }
4467 addAll(other) { 4467 addAll(other) {
4468 dart.as(other, core.Map$(K, V)); 4468 dart.as(other, core.Map$(K, V));
4469 other.forEach(dart.fn(((key, value) => { 4469 other.forEach(dart.fn((key, value) => {
4470 dart.as(key, K); 4470 dart.as(key, K);
4471 dart.as(value, V); 4471 dart.as(value, V);
4472 this.set(key, value); 4472 this.set(key, value);
4473 }).bind(this), core.Object, [K, V])); 4473 }, core.Object, [K, V]));
4474 } 4474 }
4475 get(key) { 4475 get(key) {
4476 if (_LinkedHashMap$()._isStringKey(key)) { 4476 if (_LinkedHashMap$()._isStringKey(key)) {
4477 let strings = this[_strings]; 4477 let strings = this[_strings];
4478 if (strings == null) 4478 if (strings == null)
4479 return null; 4479 return null;
4480 let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), Lin kedHashMapCell); 4480 let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), Lin kedHashMapCell);
4481 return cell == null ? null : dart.as(cell[_value], V); 4481 return cell == null ? null : dart.as(cell[_value], V);
4482 } else if (_LinkedHashMap$()._isNumericKey(key)) { 4482 } else if (_LinkedHashMap$()._isNumericKey(key)) {
4483 let nums = this[_nums]; 4483 let nums = this[_nums];
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
5792 exports.LinkedHashMapKeyIterable$ = LinkedHashMapKeyIterable$; 5792 exports.LinkedHashMapKeyIterable$ = LinkedHashMapKeyIterable$;
5793 exports.LinkedHashMapKeyIterable = LinkedHashMapKeyIterable; 5793 exports.LinkedHashMapKeyIterable = LinkedHashMapKeyIterable;
5794 exports.LinkedHashMapKeyIterator$ = LinkedHashMapKeyIterator$; 5794 exports.LinkedHashMapKeyIterator$ = LinkedHashMapKeyIterator$;
5795 exports.LinkedHashMapKeyIterator = LinkedHashMapKeyIterator; 5795 exports.LinkedHashMapKeyIterator = LinkedHashMapKeyIterator;
5796 exports.HashSetIterator$ = HashSetIterator$; 5796 exports.HashSetIterator$ = HashSetIterator$;
5797 exports.HashSetIterator = HashSetIterator; 5797 exports.HashSetIterator = HashSetIterator;
5798 exports.LinkedHashSetCell = LinkedHashSetCell; 5798 exports.LinkedHashSetCell = LinkedHashSetCell;
5799 exports.LinkedHashSetIterator$ = LinkedHashSetIterator$; 5799 exports.LinkedHashSetIterator$ = LinkedHashSetIterator$;
5800 exports.LinkedHashSetIterator = LinkedHashSetIterator; 5800 exports.LinkedHashSetIterator = LinkedHashSetIterator;
5801 })(collection, _internal, core, _js_helper, math); 5801 })(collection, _internal, core, _js_helper, math);
OLDNEW
« no previous file with comments | « lib/runtime/dart/async.js ('k') | lib/runtime/dart/convert.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698