| 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; |
| 11 import '../constants/values.dart' show | 11 import '../constants/values.dart' show |
| 12 ConstantValue, | 12 ConstantValue, |
| 13 ConstructedConstantValue, | 13 ConstructedConstantValue, |
| 14 ListConstantValue, | 14 ListConstantValue, |
| 15 NullConstantValue, | 15 NullConstantValue, |
| 16 StringConstantValue, |
| 16 TypeConstantValue; | 17 TypeConstantValue; |
| 17 import '../dart_types.dart' show DartType; | 18 import '../dart_types.dart' show DartType; |
| 18 import '../elements/elements.dart' show | 19 import '../elements/elements.dart' show |
| 19 ClassElement, | 20 ClassElement, |
| 20 Element, | 21 Element, |
| 21 Elements, | 22 Elements, |
| 22 FieldElement, | 23 FieldElement, |
| 23 FunctionElement, | 24 FunctionElement, |
| 24 FunctionSignature, | 25 FunctionSignature, |
| 25 LibraryElement, | 26 LibraryElement, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 145 } |
| 145 | 146 |
| 146 /// Checks if the version of lookup_map is valid, and if so, enable this | 147 /// Checks if the version of lookup_map is valid, and if so, enable this |
| 147 /// analysis during codegen. | 148 /// analysis during codegen. |
| 148 void onCodegenStart() { | 149 void onCodegenStart() { |
| 149 _inCodegen = true; | 150 _inCodegen = true; |
| 150 if (lookupMapVersionVariable == null) return; | 151 if (lookupMapVersionVariable == null) return; |
| 151 | 152 |
| 152 // At this point, the lookupMapVersionVariable should be resolved and it's | 153 // At this point, the lookupMapVersionVariable should be resolved and it's |
| 153 // constant value should be available. | 154 // constant value should be available. |
| 154 ConstantValue value = | 155 StringConstantValue value = |
| 155 backend.constants.getConstantValueForVariable(lookupMapVersionVariable); | 156 backend.constants.getConstantValueForVariable(lookupMapVersionVariable); |
| 156 if (value == null) { | 157 if (value == null) { |
| 157 backend.compiler.reportInfo(lookupMapVersionVariable, | 158 backend.compiler.reportInfo(lookupMapVersionVariable, |
| 158 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); | 159 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); |
| 159 return; | 160 return; |
| 160 } | 161 } |
| 161 | 162 |
| 162 // TODO(sigmund): add proper version resolution using the pub_semver package | 163 // TODO(sigmund): add proper version resolution using the pub_semver package |
| 163 // when we introduce the next version. | 164 // when we introduce the next version. |
| 164 String version = value.primitiveValue.slowToString(); | 165 String version = value.primitiveValue.slowToString(); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 if (keyValuePairs.length == 2) { | 423 if (keyValuePairs.length == 2) { |
| 423 original.fields[analysis.keyField] = keyValuePairs[0]; | 424 original.fields[analysis.keyField] = keyValuePairs[0]; |
| 424 original.fields[analysis.valueField] = keyValuePairs[1]; | 425 original.fields[analysis.valueField] = keyValuePairs[1]; |
| 425 } | 426 } |
| 426 } else { | 427 } else { |
| 427 original.fields[analysis.entriesField] = | 428 original.fields[analysis.entriesField] = |
| 428 new ListConstantValue(listType, keyValuePairs); | 429 new ListConstantValue(listType, keyValuePairs); |
| 429 } | 430 } |
| 430 } | 431 } |
| 431 } | 432 } |
| OLD | NEW |