Convert ShadowIfStatement to IfJudgment.
R=brianwilkerson@google.com, paulberry@google.com
Change-Id: I6ba48a2f73e5e5f0b72a6f2a92d46244c23d8249
Reviewed-on: https://dart-review.googlesource.com/61119
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
index ebb58a9..d32d6fe 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
@@ -88,7 +88,7 @@
NullJudgment,
ShadowExpressionStatement,
ShadowForStatement,
- ShadowIfStatement,
+ IfJudgment,
ShadowListLiteral,
ShadowLogicalExpression,
ShadowMapLiteral,
@@ -405,7 +405,7 @@
@override
Statement ifStatement(Token ifKeyword, Expression condition,
Statement thenStatement, Token elseKeyword, Statement elseStatement) {
- return new ShadowIfStatement(condition, thenStatement, elseStatement)
+ return new IfJudgment(condition, thenStatement, elseStatement)
..fileOffset = ifKeyword.charOffset;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart
index c8bd55a6..7efa8f3 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart
@@ -79,7 +79,7 @@
ShadowFunctionDeclaration,
ShadowFunctionExpression,
ShadowIfNullExpression,
- ShadowIfStatement,
+ IfJudgment,
ShadowIllegalAssignment,
ShadowIndexAssign,
ShadowInvalidInitializer,
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
index 52f89f1..9741b4d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
@@ -1328,22 +1328,31 @@
}
/// Concrete shadow object representing an if statement in kernel form.
-class ShadowIfStatement extends IfStatement implements StatementJudgment {
- ShadowIfStatement(Expression condition, Statement then, Statement otherwise)
+class IfJudgment extends IfStatement implements StatementJudgment {
+ IfJudgment(Expression condition, Statement then, Statement otherwise)
: super(condition, then, otherwise);
+ ExpressionJudgment get conditionJudgment => condition;
+
+ StatementJudgment get thenJudgment => then;
+
+ StatementJudgment get otherwiseJudgment => otherwise;
+
@override
void infer<Expression, Statement, Initializer, Type>(
ShadowTypeInferrer inferrer,
Factory<Expression, Statement, Initializer, Type> factory) {
inferrer.listener.ifStatementEnter(fileOffset);
+ var conditionJudgment = this.conditionJudgment;
var expectedType = inferrer.coreTypes.boolClass.rawType;
- var conditionType = inferrer.inferExpression(
- factory, condition, expectedType, !inferrer.isTopLevel);
- inferrer.ensureAssignable(
- expectedType, conditionType, condition, condition.fileOffset);
- inferrer.inferStatement(factory, then);
- if (otherwise != null) inferrer.inferStatement(factory, otherwise);
+ inferrer.inferExpression(
+ factory, conditionJudgment, expectedType, !inferrer.isTopLevel);
+ inferrer.ensureAssignable(expectedType, conditionJudgment.inferredType,
+ condition, condition.fileOffset);
+ inferrer.inferStatement(factory, thenJudgment);
+ if (otherwiseJudgment != null) {
+ inferrer.inferStatement(factory, otherwiseJudgment);
+ }
inferrer.listener.ifStatementExit(fileOffset);
}
}