Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: pkg/compiler/lib/src/resolution/resolution_result.dart

Issue 1218793002: Compute constant constructors in resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/resolution/resolution_result.dart
diff --git a/pkg/compiler/lib/src/resolution/resolution_result.dart b/pkg/compiler/lib/src/resolution/resolution_result.dart
index 5426fe3f3de8c3af834007d4e70cbf1f51ddf341..ba2b74cdd58c5eb91f5034e791bcf2787ef7e485 100644
--- a/pkg/compiler/lib/src/resolution/resolution_result.dart
+++ b/pkg/compiler/lib/src/resolution/resolution_result.dart
@@ -23,6 +23,7 @@ abstract class ResolutionResult {
}
ResultKind get kind;
+ Node get node => null;
Element get element => null;
DartType get type => null;
ConstantExpression get constant => null;
@@ -64,11 +65,16 @@ class AssertResult extends ResolutionResult {
String toString() => 'AssertResult()';
}
+/// The result for resolving a constant expression.
class ConstantResult extends ResolutionResult {
final Node node;
final ConstantExpression constant;
+ final Element element;
- ConstantResult(this.node, this.constant);
+ /// Creates a result for the [constant] expression. [node] is provided for
+ /// error reporting on the constant and [element] is provided if the
+ /// expression additionally serves an [Element] like [ElementResult].
+ ConstantResult(this.node, this.constant, {this.element});
bool get isConstant => true;
@@ -83,4 +89,31 @@ class NoneResult extends ResolutionResult {
ResultKind get kind => ResultKind.NONE;
String toString() => 'NoneResult()';
+}
+
+/// The result of resolving a list of arguments.
+class ArgumentsResult {
+ /// The call structure of the arguments.
+ final CallStructure callStructure;
+
+ /// The resolutions results for each argument.
+ final List<ResolutionResult> argumentResults;
+
+ /// `true` if the arguments are valid as arguments to a constructed constant
+ /// expression.
+ final bool isValidAsConstant;
+
+ ArgumentsResult(
+ this.callStructure,
+ this.argumentResults,
+ {this.isValidAsConstant});
+
+ /// Returns the list of [ConstantExpression]s for each of the arguments. If
+ /// [isValidAsConstant] is `false`, `null` is returned.
+ List<ConstantExpression> get constantArguments {
+ if (!isValidAsConstant) return null;
+ return argumentResults.map((ResolutionResult result) {
+ return result.constant;
+ }).toList();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698