| 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 library dart2js.resolution.result; | 5 library dart2js.resolution.result; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| 11 import '../universe/call_structure.dart' show | 11 import '../universe/call_structure.dart' show CallStructure; |
| 12 CallStructure; | |
| 13 | 12 |
| 14 enum ResultKind { | 13 enum ResultKind { NONE, ELEMENT, TYPE, ASSERT, CONSTANT, PREFIX, } |
| 15 NONE, | |
| 16 ELEMENT, | |
| 17 TYPE, | |
| 18 ASSERT, | |
| 19 CONSTANT, | |
| 20 PREFIX, | |
| 21 } | |
| 22 | 14 |
| 23 /// The result of resolving a node. | 15 /// The result of resolving a node. |
| 24 abstract class ResolutionResult { | 16 abstract class ResolutionResult { |
| 25 const ResolutionResult(); | 17 const ResolutionResult(); |
| 26 | 18 |
| 27 // TODO(johnniwinther): Remove this factory constructor when `null` is never | 19 // TODO(johnniwinther): Remove this factory constructor when `null` is never |
| 28 // passed as an element result. | 20 // passed as an element result. |
| 29 factory ResolutionResult.forElement(Element element) { | 21 factory ResolutionResult.forElement(Element element) { |
| 30 return element != null ? new ElementResult(element) : const NoneResult(); | 22 return element != null ? new ElementResult(element) : const NoneResult(); |
| 31 } | 23 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 /// The call structure of the arguments. | 106 /// The call structure of the arguments. |
| 115 final CallStructure callStructure; | 107 final CallStructure callStructure; |
| 116 | 108 |
| 117 /// The resolutions results for each argument. | 109 /// The resolutions results for each argument. |
| 118 final List<ResolutionResult> argumentResults; | 110 final List<ResolutionResult> argumentResults; |
| 119 | 111 |
| 120 /// `true` if the arguments are valid as arguments to a constructed constant | 112 /// `true` if the arguments are valid as arguments to a constructed constant |
| 121 /// expression. | 113 /// expression. |
| 122 final bool isValidAsConstant; | 114 final bool isValidAsConstant; |
| 123 | 115 |
| 124 ArgumentsResult( | 116 ArgumentsResult(this.callStructure, this.argumentResults, |
| 125 this.callStructure, | |
| 126 this.argumentResults, | |
| 127 {this.isValidAsConstant}); | 117 {this.isValidAsConstant}); |
| 128 | 118 |
| 129 /// Returns the list of [ConstantExpression]s for each of the arguments. If | 119 /// Returns the list of [ConstantExpression]s for each of the arguments. If |
| 130 /// [isValidAsConstant] is `false`, `null` is returned. | 120 /// [isValidAsConstant] is `false`, `null` is returned. |
| 131 List<ConstantExpression> get constantArguments { | 121 List<ConstantExpression> get constantArguments { |
| 132 if (!isValidAsConstant) return null; | 122 if (!isValidAsConstant) return null; |
| 133 return argumentResults.map((ResolutionResult result) { | 123 return argumentResults.map((ResolutionResult result) { |
| 134 return result.constant; | 124 return result.constant; |
| 135 }).toList(); | 125 }).toList(); |
| 136 } | 126 } |
| 137 } | 127 } |
| OLD | NEW |