| 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 'package:pub_semver/pub_semver.dart'; |
| 9 |
| 8 import '../common.dart'; | 10 import '../common.dart'; |
| 9 import '../common/registry.dart' show Registry; | 11 import '../common/registry.dart' show Registry; |
| 10 import '../compiler.dart' show Compiler; | 12 import '../compiler.dart' show Compiler; |
| 11 import '../constants/values.dart' | 13 import '../constants/values.dart' |
| 12 show | 14 show |
| 13 ConstantValue, | 15 ConstantValue, |
| 14 ConstructedConstantValue, | 16 ConstructedConstantValue, |
| 15 ListConstantValue, | 17 ListConstantValue, |
| 16 NullConstantValue, | 18 NullConstantValue, |
| 17 StringConstantValue, | 19 StringConstantValue, |
| 18 TypeConstantValue; | 20 TypeConstantValue; |
| 19 import '../dart_types.dart' show DartType; | 21 import '../dart_types.dart' show DartType; |
| 22 import '../dart_types.dart' show InterfaceType; |
| 20 import '../elements/elements.dart' | 23 import '../elements/elements.dart' |
| 21 show | 24 show ClassElement, FieldElement, LibraryElement, VariableElement; |
| 22 ClassElement, | |
| 23 Element, | |
| 24 Elements, | |
| 25 FieldElement, | |
| 26 FunctionElement, | |
| 27 FunctionSignature, | |
| 28 LibraryElement, | |
| 29 VariableElement; | |
| 30 import 'js_backend.dart' show JavaScriptBackend; | 25 import 'js_backend.dart' show JavaScriptBackend; |
| 31 import '../dart_types.dart' show DynamicType, InterfaceType; | |
| 32 import 'package:pub_semver/pub_semver.dart'; | |
| 33 | 26 |
| 34 /// An analysis and optimization to remove unused entries from a `LookupMap`. | 27 /// An analysis and optimization to remove unused entries from a `LookupMap`. |
| 35 /// | 28 /// |
| 36 /// `LookupMaps` are defined in `package:lookup_map/lookup_map.dart`. They are | 29 /// `LookupMaps` are defined in `package:lookup_map/lookup_map.dart`. They are |
| 37 /// simple maps that contain constant expressions as keys, and that only support | 30 /// simple maps that contain constant expressions as keys, and that only support |
| 38 /// the lookup operation. | 31 /// the lookup operation. |
| 39 /// | 32 /// |
| 40 /// This analysis and optimization will tree-shake the contents of the maps by | 33 /// This analysis and optimization will tree-shake the contents of the maps by |
| 41 /// looking at the program and finding which keys are clearly unused. Not all | 34 /// looking at the program and finding which keys are clearly unused. Not all |
| 42 /// constants can be approximated statically, so this optimization is limited to | 35 /// constants can be approximated statically, so this optimization is limited to |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 original.fields[analysis.valueField] = keyValuePairs[1]; | 429 original.fields[analysis.valueField] = keyValuePairs[1]; |
| 437 } | 430 } |
| 438 } else { | 431 } else { |
| 439 original.fields[analysis.entriesField] = | 432 original.fields[analysis.entriesField] = |
| 440 new ListConstantValue(listType, keyValuePairs); | 433 new ListConstantValue(listType, keyValuePairs); |
| 441 } | 434 } |
| 442 } | 435 } |
| 443 } | 436 } |
| 444 | 437 |
| 445 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); | 438 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); |
| OLD | NEW |