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

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

Issue 1316723003: implement null aware ops, fixes #249 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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 dart_library.library('dart/collection', null, /* Imports */[ 1 dart_library.library('dart/collection', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core' 3 'dart/core'
4 ], /* Lazy imports */[ 4 ], /* Lazy imports */[
5 'dart/_internal', 5 'dart/_internal',
6 'dart/_js_helper', 6 'dart/_js_helper',
7 'dart/math' 7 'dart/math'
8 ], function(exports, dart, core, _internal, _js_helper, math) { 8 ], function(exports, dart, core, _internal, _js_helper, math) {
9 'use strict'; 9 'use strict';
10 let dartx = dart.dartx; 10 let dartx = dart.dartx;
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 class MapBase extends dart.mixin(core.Object, MapMixin$(K, V)) {} 2283 class MapBase extends dart.mixin(core.Object, MapMixin$(K, V)) {}
2284 return MapBase; 2284 return MapBase;
2285 }); 2285 });
2286 let MapBase = MapBase$(); 2286 let MapBase = MapBase$();
2287 let _UnmodifiableMapMixin$ = dart.generic(function(K, V) { 2287 let _UnmodifiableMapMixin$ = dart.generic(function(K, V) {
2288 class _UnmodifiableMapMixin extends core.Object { 2288 class _UnmodifiableMapMixin extends core.Object {
2289 set(key, value) { 2289 set(key, value) {
2290 dart.as(key, K); 2290 dart.as(key, K);
2291 dart.as(value, V); 2291 dart.as(value, V);
2292 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map")); 2292 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map"));
2293 return value;
2293 } 2294 }
2294 addAll(other) { 2295 addAll(other) {
2295 dart.as(other, core.Map$(K, V)); 2296 dart.as(other, core.Map$(K, V));
2296 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map")); 2297 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map"));
2297 } 2298 }
2298 clear() { 2299 clear() {
2299 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map")); 2300 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map"));
2300 } 2301 }
2301 remove(key) { 2302 remove(key) {
2302 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map")); 2303 dart.throw(new core.UnsupportedError("Cannot modify unmodifiable map"));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 MapView(map) { 2408 MapView(map) {
2408 this[_map] = map; 2409 this[_map] = map;
2409 } 2410 }
2410 get(key) { 2411 get(key) {
2411 return this[_map].get(key); 2412 return this[_map].get(key);
2412 } 2413 }
2413 set(key, value) { 2414 set(key, value) {
2414 dart.as(key, K); 2415 dart.as(key, K);
2415 dart.as(value, V); 2416 dart.as(value, V);
2416 this[_map].set(key, value); 2417 this[_map].set(key, value);
2418 return value;
2417 } 2419 }
2418 addAll(other) { 2420 addAll(other) {
2419 dart.as(other, core.Map$(K, V)); 2421 dart.as(other, core.Map$(K, V));
2420 this[_map].addAll(other); 2422 this[_map].addAll(other);
2421 } 2423 }
2422 clear() { 2424 clear() {
2423 this[_map].clear(); 2425 this[_map].clear();
2424 } 2426 }
2425 putIfAbsent(key, ifAbsent) { 2427 putIfAbsent(key, ifAbsent) {
2426 dart.as(key, K); 2428 dart.as(key, K);
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 dart.setSignature(_SplayTreeMapNode, { 3319 dart.setSignature(_SplayTreeMapNode, {
3318 constructors: () => ({_SplayTreeMapNode: [_SplayTreeMapNode$(K, V), [K, V] ]}) 3320 constructors: () => ({_SplayTreeMapNode: [_SplayTreeMapNode$(K, V), [K, V] ]})
3319 }); 3321 });
3320 return _SplayTreeMapNode; 3322 return _SplayTreeMapNode;
3321 }); 3323 });
3322 let _SplayTreeMapNode = _SplayTreeMapNode$(); 3324 let _SplayTreeMapNode = _SplayTreeMapNode$();
3323 let _dummy = Symbol('_dummy'); 3325 let _dummy = Symbol('_dummy');
3324 let _root = Symbol('_root'); 3326 let _root = Symbol('_root');
3325 let _count = Symbol('_count'); 3327 let _count = Symbol('_count');
3326 let _splayCount = Symbol('_splayCount'); 3328 let _splayCount = Symbol('_splayCount');
3329 let _compare = Symbol('_compare');
3327 let _splay = Symbol('_splay'); 3330 let _splay = Symbol('_splay');
3328 let _compare = Symbol('_compare');
3329 let _splayMin = Symbol('_splayMin'); 3331 let _splayMin = Symbol('_splayMin');
3330 let _splayMax = Symbol('_splayMax'); 3332 let _splayMax = Symbol('_splayMax');
3331 let _addNewRoot = Symbol('_addNewRoot'); 3333 let _addNewRoot = Symbol('_addNewRoot');
3332 let _first = Symbol('_first'); 3334 let _first = Symbol('_first');
3333 let _last = Symbol('_last'); 3335 let _last = Symbol('_last');
3334 let _clear = Symbol('_clear'); 3336 let _clear = Symbol('_clear');
3335 let _SplayTree$ = dart.generic(function(K) { 3337 let _SplayTree$ = dart.generic(function(K) {
3336 class _SplayTree extends core.Object { 3338 class _SplayTree extends core.Object {
3337 _SplayTree() { 3339 _SplayTree() {
3338 this[_dummy] = new (_SplayTreeNode$(K))(null); 3340 this[_dummy] = new (_SplayTreeNode$(K))(null);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 } 3556 }
3555 remove(key) { 3557 remove(key) {
3556 if (!dart.notNull(this[_validKey](key))) 3558 if (!dart.notNull(this[_validKey](key)))
3557 return null; 3559 return null;
3558 let mapRoot = dart.as(this[_remove](dart.as(key, K)), _SplayTreeMapNode) ; 3560 let mapRoot = dart.as(this[_remove](dart.as(key, K)), _SplayTreeMapNode) ;
3559 if (mapRoot != null) 3561 if (mapRoot != null)
3560 return dart.as(mapRoot.value, V); 3562 return dart.as(mapRoot.value, V);
3561 return null; 3563 return null;
3562 } 3564 }
3563 set(key, value) { 3565 set(key, value) {
3564 dart.as(key, K); 3566 ((() => {
3565 dart.as(value, V); 3567 dart.as(key, K);
3566 if (key == null) 3568 dart.as(value, V);
3567 dart.throw(new core.ArgumentError(key)); 3569 if (key == null)
3568 let comp = this[_splay](key); 3570 dart.throw(new core.ArgumentError(key));
3569 if (comp == 0) { 3571 let comp = this[_splay](key);
3570 let mapRoot = dart.as(this[_root], _SplayTreeMapNode); 3572 if (comp == 0) {
3571 mapRoot.value = value; 3573 let mapRoot = dart.as(this[_root], _SplayTreeMapNode);
3572 return; 3574 mapRoot.value = value;
3573 } 3575 return;
3574 this[_addNewRoot](new (_SplayTreeMapNode$(K, dart.dynamic))(key, value), comp); 3576 }
3577 this[_addNewRoot](new (_SplayTreeMapNode$(K, dart.dynamic))(key, value ), comp);
3578 }).bind(this))();
3579 return value;
3575 } 3580 }
3576 putIfAbsent(key, ifAbsent) { 3581 putIfAbsent(key, ifAbsent) {
3577 dart.as(key, K); 3582 dart.as(key, K);
3578 dart.as(ifAbsent, dart.functionType(V, [])); 3583 dart.as(ifAbsent, dart.functionType(V, []));
3579 if (key == null) 3584 if (key == null)
3580 dart.throw(new core.ArgumentError(key)); 3585 dart.throw(new core.ArgumentError(key));
3581 let comp = this[_splay](key); 3586 let comp = this[_splay](key);
3582 if (comp == 0) { 3587 if (comp == 0) {
3583 let mapRoot = dart.as(this[_root], _SplayTreeMapNode); 3588 let mapRoot = dart.as(this[_root], _SplayTreeMapNode);
3584 return dart.as(mapRoot.value, V); 3589 return dart.as(mapRoot.value, V);
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 this[_strings] = strings = _HashMap$()._newHashTable(); 4225 this[_strings] = strings = _HashMap$()._newHashTable();
4221 this[_addHashTableEntry](strings, key, value); 4226 this[_addHashTableEntry](strings, key, value);
4222 } else if (dart.notNull(_HashMap$()._isNumericKey(key))) { 4227 } else if (dart.notNull(_HashMap$()._isNumericKey(key))) {
4223 let nums = this[_nums]; 4228 let nums = this[_nums];
4224 if (nums == null) 4229 if (nums == null)
4225 this[_nums] = nums = _HashMap$()._newHashTable(); 4230 this[_nums] = nums = _HashMap$()._newHashTable();
4226 this[_addHashTableEntry](nums, key, value); 4231 this[_addHashTableEntry](nums, key, value);
4227 } else { 4232 } else {
4228 this[_set](key, value); 4233 this[_set](key, value);
4229 } 4234 }
4235 return value;
4230 } 4236 }
4231 [_set](key, value) { 4237 [_set](key, value) {
4232 dart.as(key, K); 4238 dart.as(key, K);
4233 dart.as(value, V); 4239 dart.as(value, V);
4234 let rest = this[_rest]; 4240 let rest = this[_rest];
4235 if (rest == null) 4241 if (rest == null)
4236 this[_rest] = rest = _HashMap$()._newHashTable(); 4242 this[_rest] = rest = _HashMap$()._newHashTable();
4237 let hash = this[_computeHashCode](key); 4243 let hash = this[_computeHashCode](key);
4238 let bucket = rest[hash]; 4244 let bucket = rest[hash];
4239 if (bucket == null) { 4245 if (bucket == null) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4482 } 4488 }
4483 get(key) { 4489 get(key) {
4484 if (!dart.notNull(this[_validKey](key))) 4490 if (!dart.notNull(this[_validKey](key)))
4485 return null; 4491 return null;
4486 return super[_get](key); 4492 return super[_get](key);
4487 } 4493 }
4488 set(key, value) { 4494 set(key, value) {
4489 dart.as(key, K); 4495 dart.as(key, K);
4490 dart.as(value, V); 4496 dart.as(value, V);
4491 super[_set](key, value); 4497 super[_set](key, value);
4498 return value;
4492 } 4499 }
4493 containsKey(key) { 4500 containsKey(key) {
4494 if (!dart.notNull(this[_validKey](key))) 4501 if (!dart.notNull(this[_validKey](key)))
4495 return false; 4502 return false;
4496 return super[_containsKey](key); 4503 return super[_containsKey](key);
4497 } 4504 }
4498 remove(key) { 4505 remove(key) {
4499 if (!dart.notNull(this[_validKey](key))) 4506 if (!dart.notNull(this[_validKey](key)))
4500 return null; 4507 return null;
4501 return super[_remove](key); 4508 return super[_remove](key);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4711 this[_strings] = strings = _LinkedHashMap$()._newHashTable(); 4718 this[_strings] = strings = _LinkedHashMap$()._newHashTable();
4712 this[_addHashTableEntry](strings, key, value); 4719 this[_addHashTableEntry](strings, key, value);
4713 } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) { 4720 } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) {
4714 let nums = this[_nums]; 4721 let nums = this[_nums];
4715 if (nums == null) 4722 if (nums == null)
4716 this[_nums] = nums = _LinkedHashMap$()._newHashTable(); 4723 this[_nums] = nums = _LinkedHashMap$()._newHashTable();
4717 this[_addHashTableEntry](nums, key, value); 4724 this[_addHashTableEntry](nums, key, value);
4718 } else { 4725 } else {
4719 this[_set](key, value); 4726 this[_set](key, value);
4720 } 4727 }
4728 return value;
4721 } 4729 }
4722 [_set](key, value) { 4730 [_set](key, value) {
4723 dart.as(key, K); 4731 dart.as(key, K);
4724 dart.as(value, V); 4732 dart.as(value, V);
4725 let rest = this[_rest]; 4733 let rest = this[_rest];
4726 if (rest == null) 4734 if (rest == null)
4727 this[_rest] = rest = _LinkedHashMap$()._newHashTable(); 4735 this[_rest] = rest = _LinkedHashMap$()._newHashTable();
4728 let hash = this[_computeHashCode](key); 4736 let hash = this[_computeHashCode](key);
4729 let bucket = rest[hash]; 4737 let bucket = rest[hash];
4730 if (bucket == null) { 4738 if (bucket == null) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
4963 } 4971 }
4964 get(key) { 4972 get(key) {
4965 if (!dart.notNull(this[_validKey](key))) 4973 if (!dart.notNull(this[_validKey](key)))
4966 return null; 4974 return null;
4967 return super[_get](key); 4975 return super[_get](key);
4968 } 4976 }
4969 set(key, value) { 4977 set(key, value) {
4970 dart.as(key, K); 4978 dart.as(key, K);
4971 dart.as(value, V); 4979 dart.as(value, V);
4972 super[_set](key, value); 4980 super[_set](key, value);
4981 return value;
4973 } 4982 }
4974 containsKey(key) { 4983 containsKey(key) {
4975 if (!dart.notNull(this[_validKey](key))) 4984 if (!dart.notNull(this[_validKey](key)))
4976 return false; 4985 return false;
4977 return super[_containsKey](key); 4986 return super[_containsKey](key);
4978 } 4987 }
4979 remove(key) { 4988 remove(key) {
4980 if (!dart.notNull(this[_validKey](key))) 4989 if (!dart.notNull(this[_validKey](key)))
4981 return null; 4990 return null;
4982 return super[_remove](key); 4991 return super[_remove](key);
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
6020 exports.LinkedHashMapKeyIterable$ = LinkedHashMapKeyIterable$; 6029 exports.LinkedHashMapKeyIterable$ = LinkedHashMapKeyIterable$;
6021 exports.LinkedHashMapKeyIterable = LinkedHashMapKeyIterable; 6030 exports.LinkedHashMapKeyIterable = LinkedHashMapKeyIterable;
6022 exports.LinkedHashMapKeyIterator$ = LinkedHashMapKeyIterator$; 6031 exports.LinkedHashMapKeyIterator$ = LinkedHashMapKeyIterator$;
6023 exports.LinkedHashMapKeyIterator = LinkedHashMapKeyIterator; 6032 exports.LinkedHashMapKeyIterator = LinkedHashMapKeyIterator;
6024 exports.HashSetIterator$ = HashSetIterator$; 6033 exports.HashSetIterator$ = HashSetIterator$;
6025 exports.HashSetIterator = HashSetIterator; 6034 exports.HashSetIterator = HashSetIterator;
6026 exports.LinkedHashSetCell = LinkedHashSetCell; 6035 exports.LinkedHashSetCell = LinkedHashSetCell;
6027 exports.LinkedHashSetIterator$ = LinkedHashSetIterator$; 6036 exports.LinkedHashSetIterator$ = LinkedHashSetIterator$;
6028 exports.LinkedHashSetIterator = LinkedHashSetIterator; 6037 exports.LinkedHashSetIterator = LinkedHashSetIterator;
6029 }); 6038 });
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