| 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; | 5 part of _js_helper; |
| 6 | 6 |
| 7 abstract class ConstantMap<K, V> implements Map<K, V> { | 7 abstract class ConstantMap<K, V> implements Map<K, V> { |
| 8 const ConstantMap._(); | 8 const ConstantMap._(); |
| 9 | 9 |
| 10 bool get isEmpty => length == 0; | 10 bool get isEmpty => length == 0; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 GeneralConstantMap(this._jsData) : super._(); | 107 GeneralConstantMap(this._jsData) : super._(); |
| 108 | 108 |
| 109 // [_jsData] holds a key-value pair list. | 109 // [_jsData] holds a key-value pair list. |
| 110 final _jsData; | 110 final _jsData; |
| 111 | 111 |
| 112 // We cannot create the backing map on creation since hashCode interceptors | 112 // We cannot create the backing map on creation since hashCode interceptors |
| 113 // have not been defined when constants are created. | 113 // have not been defined when constants are created. |
| 114 Map<K, V> _getMap() { | 114 Map<K, V> _getMap() { |
| 115 LinkedHashMap<K, V> backingMap = JS('LinkedHashMap|Null', r'#.$map', this); | 115 LinkedHashMap<K, V> backingMap = JS('LinkedHashMap|Null', r'#.$map', this); |
| 116 if (backingMap == null) { | 116 if (backingMap == null) { |
| 117 backingMap = new LinkedHashMap<K, V>(); | 117 backingMap = new JsLinkedHashMap<K, V>(); |
| 118 fillLiteralMap(_jsData, backingMap); | 118 fillLiteralMap(_jsData, backingMap); |
| 119 JS('', r'#.$map = #', this, backingMap); | 119 JS('', r'#.$map = #', this, backingMap); |
| 120 } | 120 } |
| 121 return backingMap; | 121 return backingMap; |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool containsValue(V needle) { | 124 bool containsValue(V needle) { |
| 125 return _getMap().containsValue(needle); | 125 return _getMap().containsValue(needle); |
| 126 } | 126 } |
| 127 | 127 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 Iterable<K> get keys { | 140 Iterable<K> get keys { |
| 141 return _getMap().keys; | 141 return _getMap().keys; |
| 142 } | 142 } |
| 143 | 143 |
| 144 Iterable<V> get values { | 144 Iterable<V> get values { |
| 145 return _getMap().values; | 145 return _getMap().values; |
| 146 } | 146 } |
| 147 | 147 |
| 148 int get length => _getMap().length; | 148 int get length => _getMap().length; |
| 149 } | 149 } |
| OLD | NEW |