OLD | NEW |
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 part of js_helper; | |
6 | |
7 // This class has no constructor. This is on purpose since the instantiation | 5 // This class has no constructor. This is on purpose since the instantiation |
8 // is shortcut by the compiler. | 6 // is shortcut by the compiler. |
9 class ConstantMap<V> implements Map<String, V> { | 7 class ConstantMap<V> implements Map<String, V> { |
10 final int length; | 8 final int length; |
11 // A constant map is backed by a JavaScript object. | 9 // A constant map is backed by a JavaScript object. |
12 final _jsObject; | 10 final _jsObject; |
13 final List<String> _keys; | 11 final List<String> _keys; |
14 | 12 |
15 bool containsValue(V needle) { | 13 bool containsValue(V needle) { |
16 return getValues().some((V value) => value == needle); | 14 return getValues().some((V value) => value == needle); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 bool containsKey(String key) { | 57 bool containsKey(String key) { |
60 if (key == '__proto__') return true; | 58 if (key == '__proto__') return true; |
61 return super.containsKey(key); | 59 return super.containsKey(key); |
62 } | 60 } |
63 | 61 |
64 V operator [](String key) { | 62 V operator [](String key) { |
65 if (key == '__proto__') return _protoValue; | 63 if (key == '__proto__') return _protoValue; |
66 return super[key]; | 64 return super[key]; |
67 } | 65 } |
68 } | 66 } |
OLD | NEW |