| 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 '../elements/resolution_types.dart'; | 8 import '../elements/resolution_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // TODO(johnniwinther): Remove this factory constructor when `null` is never | 26 // TODO(johnniwinther): Remove this factory constructor when `null` is never |
| 27 // passed as an element result. | 27 // passed as an element result. |
| 28 factory ResolutionResult.forElement(Element element) { | 28 factory ResolutionResult.forElement(Element element) { |
| 29 return element != null ? new ElementResult(element) : const NoneResult(); | 29 return element != null ? new ElementResult(element) : const NoneResult(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 ResultKind get kind; | 32 ResultKind get kind; |
| 33 Node get node => null; | 33 Node get node => null; |
| 34 Element get element => null; | 34 Element get element => null; |
| 35 DartType get type => null; | 35 ResolutionDartType get type => null; |
| 36 ConstantExpression get constant => null; | 36 ConstantExpression get constant => null; |
| 37 bool get isConstant => false; | 37 bool get isConstant => false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 /// The prefix of top level or member access, like `prefix.member`, | 40 /// The prefix of top level or member access, like `prefix.member`, |
| 41 /// `prefix.Class.member` or `Class.member`. | 41 /// `prefix.Class.member` or `Class.member`. |
| 42 class PrefixResult extends ResolutionResult { | 42 class PrefixResult extends ResolutionResult { |
| 43 final PrefixElement prefix; | 43 final PrefixElement prefix; |
| 44 final ClassElement cls; | 44 final ClassElement cls; |
| 45 | 45 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 | 60 |
| 61 ResultKind get kind => ResultKind.ELEMENT; | 61 ResultKind get kind => ResultKind.ELEMENT; |
| 62 | 62 |
| 63 ElementResult(this.element) { | 63 ElementResult(this.element) { |
| 64 assert(element != null); | 64 assert(element != null); |
| 65 } | 65 } |
| 66 | 66 |
| 67 String toString() => 'ElementResult($element)'; | 67 String toString() => 'ElementResult($element)'; |
| 68 } | 68 } |
| 69 | 69 |
| 70 /// The result for the resolution of a node that points to an [DartType]. | 70 /// The result for the resolution of a node that points to an |
| 71 /// [ResolutionDartType]. |
| 71 class TypeResult extends ResolutionResult { | 72 class TypeResult extends ResolutionResult { |
| 72 final DartType type; | 73 final ResolutionDartType type; |
| 73 | 74 |
| 74 TypeResult(this.type) { | 75 TypeResult(this.type) { |
| 75 assert(type != null); | 76 assert(type != null); |
| 76 } | 77 } |
| 77 | 78 |
| 78 ResultKind get kind => ResultKind.TYPE; | 79 ResultKind get kind => ResultKind.TYPE; |
| 79 | 80 |
| 80 Element get element => type.element; | 81 Element get element => type.element; |
| 81 | 82 |
| 82 String toString() => 'TypeResult($type)'; | 83 String toString() => 'TypeResult($type)'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 126 |
| 126 /// Returns the list of [ConstantExpression]s for each of the arguments. If | 127 /// Returns the list of [ConstantExpression]s for each of the arguments. If |
| 127 /// [isValidAsConstant] is `false`, `null` is returned. | 128 /// [isValidAsConstant] is `false`, `null` is returned. |
| 128 List<ConstantExpression> get constantArguments { | 129 List<ConstantExpression> get constantArguments { |
| 129 if (!isValidAsConstant) return null; | 130 if (!isValidAsConstant) return null; |
| 130 return argumentResults.map((ResolutionResult result) { | 131 return argumentResults.map((ResolutionResult result) { |
| 131 return result.constant; | 132 return result.constant; |
| 132 }).toList(); | 133 }).toList(); |
| 133 } | 134 } |
| 134 } | 135 } |
| OLD | NEW |