| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Analysis to determine how to generate code for `LookupMap`s. | 5 /// Analysis to determine how to generate code for `LookupMap`s. |
| 6 library compiler.src.js_backend.lookup_map_analysis; | 6 library compiler.src.js_backend.lookup_map_analysis; |
| 7 | 7 |
| 8 import '../common/registry.dart' show Registry; | 8 import '../common/registry.dart' show Registry; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../diagnostics/messages.dart' show MessageKind; | 10 import '../diagnostics/messages.dart' show MessageKind; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 version = new Version.parse(value.primitiveValue.slowToString()); | 167 version = new Version.parse(value.primitiveValue.slowToString()); |
| 168 } catch (e) {} | 168 } catch (e) {} |
| 169 | 169 |
| 170 if (version == null || !_validLookupMapVersionConstraint.allows(version)) { | 170 if (version == null || !_validLookupMapVersionConstraint.allows(version)) { |
| 171 backend.compiler.reportInfo(lookupMapVersionVariable, | 171 backend.compiler.reportInfo(lookupMapVersionVariable, |
| 172 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); | 172 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 ClassElement cls = lookupMapLibrary.findLocal('LookupMap'); | 176 ClassElement cls = lookupMapLibrary.findLocal('LookupMap'); |
| 177 cls.computeType(backend.compiler); | 177 cls.computeType(backend.resolution); |
| 178 entriesField = cls.lookupMember('_entries'); | 178 entriesField = cls.lookupMember('_entries'); |
| 179 keyField = cls.lookupMember('_key'); | 179 keyField = cls.lookupMember('_key'); |
| 180 valueField = cls.lookupMember('_value'); | 180 valueField = cls.lookupMember('_value'); |
| 181 // TODO(sigmund): Maybe inline nested maps to make the output code smaller? | 181 // TODO(sigmund): Maybe inline nested maps to make the output code smaller? |
| 182 typeLookupMapClass = cls; | 182 typeLookupMapClass = cls; |
| 183 } | 183 } |
| 184 | 184 |
| 185 /// Whether [constant] is an instance of a `LookupMap`. | 185 /// Whether [constant] is an instance of a `LookupMap`. |
| 186 bool isLookupMap(ConstantValue constant) => | 186 bool isLookupMap(ConstantValue constant) => |
| 187 _isEnabled && | 187 _isEnabled && |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 } else { | 431 } else { |
| 432 original.fields[analysis.entriesField] = | 432 original.fields[analysis.entriesField] = |
| 433 new ListConstantValue(listType, keyValuePairs); | 433 new ListConstantValue(listType, keyValuePairs); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 final _validLookupMapVersionConstraint = | 438 final _validLookupMapVersionConstraint = |
| 439 new VersionConstraint.parse('^0.0.1'); | 439 new VersionConstraint.parse('^0.0.1'); |
| OLD | NEW |