| 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'; | 8 import 'package:pub_semver/pub_semver.dart'; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (value == null) { | 139 if (value == null) { |
| 140 reporter.reportHintMessage(lookupMapVersionVariable, | 140 reporter.reportHintMessage(lookupMapVersionVariable, |
| 141 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); | 141 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); |
| 142 return const LookupMapAnalysis._(); | 142 return const LookupMapAnalysis._(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // TODO(sigmund): add proper version resolution using the pub_semver package | 145 // TODO(sigmund): add proper version resolution using the pub_semver package |
| 146 // when we introduce the next version. | 146 // when we introduce the next version. |
| 147 Version version; | 147 Version version; |
| 148 try { | 148 try { |
| 149 version = new Version.parse(value.primitiveValue.slowToString()); | 149 version = new Version.parse(value.primitiveValue); |
| 150 } catch (e) {} | 150 } catch (e) {} |
| 151 | 151 |
| 152 if (version == null || !_validLookupMapVersionConstraint.allows(version)) { | 152 if (version == null || !_validLookupMapVersionConstraint.allows(version)) { |
| 153 reporter.reportHintMessage(lookupMapVersionVariable, | 153 reporter.reportHintMessage(lookupMapVersionVariable, |
| 154 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); | 154 MessageKind.UNRECOGNIZED_VERSION_OF_LOOKUP_MAP); |
| 155 return const LookupMapAnalysis._(); | 155 return const LookupMapAnalysis._(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 ClassEntity typeLookupMapClass = | 158 ClassEntity typeLookupMapClass = |
| 159 elementEnvironment.lookupClass(analysis.lookupMapLibrary, 'LookupMap'); | 159 elementEnvironment.lookupClass(analysis.lookupMapLibrary, 'LookupMap'); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 original.fields[analysis._valueField] = keyValuePairs[1]; | 497 original.fields[analysis._valueField] = keyValuePairs[1]; |
| 498 } | 498 } |
| 499 } else { | 499 } else { |
| 500 original.fields[analysis._entriesField] = | 500 original.fields[analysis._entriesField] = |
| 501 new ListConstantValue(listType, keyValuePairs); | 501 new ListConstantValue(listType, keyValuePairs); |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); | 506 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); |
| OLD | NEW |