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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/mirrors/util.dart

Issue 119913002: Align source mirrors with runtime mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + small fix. Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library util; 5 library dart2js.mirrors.util;
6
7 import 'dart:collection' show Maps;
6 8
7 /** 9 /**
8 * An abstract map implementation. This class can be used as a superclass for 10 * An abstract map implementation. This class can be used as a superclass for
9 * implementing maps, requiring only the further implementation of the 11 * implementing maps, requiring only the further implementation of the
10 * [:operator []:], [:forEach:] and [:length:] methods to provide a fully 12 * [:operator []:], [:forEach:] and [:length:] methods to provide a fully
11 * implemented immutable map. 13 * implemented immutable map.
12 */ 14 */
13 abstract class AbstractMap<K, V> implements Map<K, V> { 15 abstract class AbstractMap<K, V> implements Map<K, V> {
14 AbstractMap(); 16 AbstractMap();
15 17
16 AbstractMap.from(Map<K, V> other) { 18 AbstractMap.from(Map<K, V> other) {
17 other.forEach((k,v) => this[k] = v); 19 other.forEach((k,v) => this[k] = v);
18 } 20 }
19 21
20 void operator []=(K key, value) { 22 void operator []=(K key, value) {
21 throw new UnsupportedError('[]= is not supported'); 23 throw new UnsupportedError('[]= is not supported');
22 } 24 }
23 25
24 void clear() { 26 void clear() {
25 throw new UnsupportedError('clear() is not supported'); 27 throw new UnsupportedError('clear() is not supported');
26 } 28 }
27 29
28 void addAll(Map<K, V> other) { 30 void addAll(Map<K, V> other) {
29 throw new UnsupportedError('addAll() is not supported'); 31 throw new UnsupportedError('addAll() is not supported');
30 } 32 }
31 33
32 bool containsKey(K key) { 34 bool containsKey(K key) {
33 var found = false; 35 var found = false;
34 forEach((k,_) { 36 forEach((k,_) {
35 if (k == key) { 37 if (k == key) {
36 found = true; 38 found = true;
37 } 39 }
(...skipping 30 matching lines...) Expand all
68 V value = this[key]; 70 V value = this[key];
69 this[key] = ifAbsent(); 71 this[key] = ifAbsent();
70 return value; 72 return value;
71 } 73 }
72 return null; 74 return null;
73 } 75 }
74 76
75 V remove(K key) { 77 V remove(K key) {
76 throw new UnsupportedError('V remove(K key) is not supported'); 78 throw new UnsupportedError('V remove(K key) is not supported');
77 } 79 }
80
81 String toString() => Maps.mapToString(this);
78 } 82 }
79 83
80 /** 84 /**
81 * [ImmutableMapWrapper] wraps a (mutable) map as an immutable map where all 85 * [ImmutableMapWrapper] wraps a (mutable) map as an immutable map where all
82 * mutating operations throw [UnsupportedError] upon invocation. 86 * mutating operations throw [UnsupportedError] upon invocation.
83 */ 87 */
84 class ImmutableMapWrapper<K, V> extends AbstractMap<K, V> { 88 class ImmutableMapWrapper<K, V> extends AbstractMap<K, V> {
85 final Map<K, V> _map; 89 final Map<K, V> _map;
86 90
87 ImmutableMapWrapper(this._map); 91 ImmutableMapWrapper(this._map);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 173
170 void forEach(void f(K key, Vout value)) { 174 void forEach(void f(K key, Vout value)) {
171 _map.forEach((K k, Vin v) { 175 _map.forEach((K k, Vin v) {
172 var value = _filter(v); 176 var value = _filter(v);
173 if (value != null) { 177 if (value != null) {
174 f(k, value); 178 f(k, value);
175 } 179 }
176 }); 180 });
177 } 181 }
178 } 182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698