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

Side by Side Diff: frog/leg/lib/constant_map.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/leg/lib/clock.dart ('k') | frog/leg/lib/core.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This class has no constructor. This is on purpose since the instantiation
6 // is shortcut by the compiler.
7 class ConstantMap<V> implements Map<String, V> {
8 final int length;
9 // A constant map is backed by a JavaScript object.
10 final _jsObject;
11 final List<String> _keys;
12
13 bool containsValue(V needle) {
14 return getValues().some((V value) => value == needle);
15 }
16
17 bool containsKey(String key) {
18 if (key == '__proto__') return false;
19 return jsHasOwnProperty(_jsObject, key);
20 }
21
22 V operator [](String key) {
23 if (!containsKey(key)) return null;
24 return jsPropertyAccess(_jsObject, key);
25 }
26
27 void forEach(void f(String key, V value)) {
28 _keys.forEach((String key) => f(key, this[key]));
29 }
30
31 Collection<String> getKeys() => _keys;
32
33 Collection<V> getValues() {
34 List<V> result = <V>[];
35 _keys.forEach((String key) => result.add(this[key]));
36 return result;
37 }
38
39 bool isEmpty() => length == 0;
40
41 String toString() => Maps.mapToString(this);
42
43 _throwImmutable() {
44 throw const IllegalAccessException();
45 }
46 void operator []=(String key, V val) => _throwImmutable();
47 V putIfAbsent(String key, V ifAbsent()) => _throwImmutable();
48 V remove(String key) => _throwImmutable();
49 void clear() => _throwImmutable();
50 }
OLDNEW
« no previous file with comments | « frog/leg/lib/clock.dart ('k') | frog/leg/lib/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698