Restore types to aid refactoring
Change-Id: Ib58e4cad0727f3b0556f21395bd0dddff3fc66de
Reviewed-on: https://dart-review.googlesource.com/73380
Reviewed-by: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 82fcfe8..20d6978 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -392,8 +392,8 @@
}
}
- void declareVariable(Object variable, Scope scope) {
- String name = forest.getVariableDeclarationName(variable);
+ void declareVariable(VariableDeclaration variable, Scope scope) {
+ String name = variable.name;
Declaration existing = scope.local[name];
if (existing != null) {
// This reports an error for duplicated declarations in the same scope:
@@ -407,7 +407,7 @@
return;
}
LocatedMessage context = scope.declare(
- forest.getVariableDeclarationName(variable),
+ variable.name,
new KernelVariableBuilder(
variable, member ?? classBuilder ?? library, uri),
uri);
@@ -438,7 +438,7 @@
@override
void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
debugEvent("Metadata");
- Object arguments = pop();
+ Arguments arguments = pop();
pushQualifiedReference(beginToken.next, periodBeforeName);
if (arguments != null) {
push(arguments);
@@ -531,7 +531,7 @@
}
}
pop(); // Type.
- List<Object> annotations = pop();
+ List<Expression> annotations = pop();
if (annotations != null) {
_typeInferrer.inferMetadata(this, annotations);
Field field = fields.first.target;
@@ -679,7 +679,7 @@
@override
void finishFunction(
- List<Object> annotations,
+ List<Expression> annotations,
FormalParameters<Expression, Statement, Arguments> formals,
AsyncMarker asyncModifier,
Statement body) {
@@ -1081,8 +1081,7 @@
@override
void endArguments(int count, Token beginToken, Token endToken) {
debugEvent("Arguments");
- List<Object> arguments =
- new List<Object>.filled(count, null, growable: true);
+ List<Object> arguments = new List<Object>(count);
popList(count, arguments);
int firstNamedArgumentIndex = arguments.length;
for (int i = 0; i < arguments.length; i++) {
@@ -1730,9 +1729,8 @@
String value = unescapeString(token.lexeme, token, this);
push(forest.literalString(value, token));
} else {
- Object count = 1 + interpolationCount * 2;
- List<Object> parts =
- popList(count, new List<Object>.filled(count, null, growable: true));
+ int count = 1 + interpolationCount * 2;
+ List<Object> parts = popList(count, new List<Object>(count));
Token first = parts.first;
Token last = parts.last;
Quote quote = analyzeQuote(first.lexeme);
@@ -2150,16 +2148,16 @@
int count, Token leftBracket, Token constKeyword, Token rightBracket) {
debugEvent("LiteralList");
List<Expression> expressions = popListForValue(count);
- Object typeArguments = pop();
+ List<DartType> typeArguments = pop();
DartType typeArgument;
if (typeArguments != null) {
- if (forest.getTypeCount(typeArguments) > 1) {
+ if (typeArguments.length > 1) {
addProblem(
fasta.messageListLiteralTooManyTypeArguments,
offsetForToken(leftBracket),
lengthOfSpan(leftBracket, leftBracket.endGroup));
} else {
- typeArgument = forest.getTypeAt(typeArguments, 0);
+ typeArgument = typeArguments.single;
if (library.loader.target.strongMode) {
typeArgument =
instantiateToBounds(typeArgument, coreTypes.objectClass);
@@ -2200,20 +2198,21 @@
void handleLiteralMap(
int count, Token leftBrace, Token constKeyword, Token rightBrace) {
debugEvent("LiteralMap");
- List<Object> entries = forest.mapEntryList(count);
+ List<MapEntry> entries =
+ new List<MapEntry>.filled(count, null, growable: true);
popList(count, entries);
- Object typeArguments = pop();
+ List<DartType> typeArguments = pop();
DartType keyType;
DartType valueType;
if (typeArguments != null) {
- if (forest.getTypeCount(typeArguments) != 2) {
+ if (typeArguments.length != 2) {
addProblem(
fasta.messageMapLiteralTypeArgumentMismatch,
offsetForToken(leftBrace),
lengthOfSpan(leftBrace, leftBrace.endGroup));
} else {
- keyType = forest.getTypeAt(typeArguments, 0);
- valueType = forest.getTypeAt(typeArguments, 1);
+ keyType = typeArguments[0];
+ valueType = typeArguments[1];
if (library.loader.target.strongMode) {
keyType = instantiateToBounds(keyType, coreTypes.objectClass);
valueType = instantiateToBounds(valueType, coreTypes.objectClass);
@@ -2305,7 +2304,7 @@
debugEvent("beginFunctionType");
}
- void enterFunctionTypeScope(List<Object> typeVariables) {
+ void enterFunctionTypeScope(List<KernelTypeVariableBuilder> typeVariables) {
debugEvent("enterFunctionTypeScope");
enterLocalScope(null,
scope.createNestedScope("function-type scope", isModifiable: true));
@@ -2520,7 +2519,7 @@
FormalParameterKind kind = optional("{", beginToken)
? FormalParameterKind.optionalNamed
: FormalParameterKind.optionalPositional;
- Object variables =
+ List<VariableDeclaration> variables =
new List<VariableDeclaration>.filled(count, null, growable: true);
popList(count, variables);
push(new OptionalFormals(kind, variables));
@@ -2634,19 +2633,18 @@
}
FormalParameters<Expression, Statement, Arguments> catchParameters =
popIfNotNull(catchKeyword);
- Object type = popIfNotNull(onKeyword);
- Object exception;
- Object stackTrace;
+ DartType type = popIfNotNull(onKeyword) ?? const DynamicType();
+ VariableDeclaration exception;
+ VariableDeclaration stackTrace;
if (catchParameters != null) {
int requiredCount = catchParameters.required.length;
if ((requiredCount == 1 || requiredCount == 2) &&
catchParameters.optional == null) {
exception = catchParameters.required[0];
- forest.setParameterType(exception, type);
+ exception.type = type;
if (requiredCount == 2) {
stackTrace = catchParameters.required[1];
- forest.setParameterType(
- stackTrace, coreTypes.stackTraceClass.rawType);
+ stackTrace.type = coreTypes.stackTraceClass.rawType;
}
} else {
// TODO(ahe): We're not storing this error in the AST.
@@ -2662,12 +2660,11 @@
var allCount = allFormals.length;
if (allCount >= 1) {
exception = allFormals[0];
- forest.setParameterType(exception, type);
+ exception.type = type;
}
if (allCount >= 2) {
stackTrace = allFormals[1];
- forest.setParameterType(
- stackTrace, coreTypes.stackTraceClass.rawType);
+ stackTrace.type = coreTypes.stackTraceClass.rawType;
}
}
}
@@ -2678,7 +2675,7 @@
@override
void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) {
Statement finallyBlock = popStatementIfNotNull(finallyKeyword);
- Object catches = popList(
+ List<Catch> catches = popList(
catchCount, new List<Catch>.filled(catchCount, null, growable: true));
Statement tryBlock = popStatement();
if (problemInTry == null) {
@@ -2976,7 +2973,7 @@
}
}
- List<Object> types = forest.argumentsTypeArguments(arguments);
+ List<DartType> types = forest.argumentsTypeArguments(arguments);
if (typeParameters.length != types.length) {
if (types.length == 0) {
// Expected `typeParameters.length` type arguments, but none given,
@@ -3308,7 +3305,7 @@
functionNestingLevel--;
inCatchBlock = pop();
switchScope = pop();
- List<Object> typeVariables = pop();
+ List<KernelTypeVariableBuilder> typeVariables = pop();
exitLocalScope();
push(typeVariables ?? NullValue.TypeVariables);
}
@@ -3322,7 +3319,7 @@
@override
void beginNamedFunctionExpression(Token token) {
debugEvent("beginNamedFunctionExpression");
- List<Object> typeVariables = pop();
+ List<KernelTypeVariableBuilder> typeVariables = pop();
// Create an additional scope in which the named function expression is
// declared.
enterLocalScope("named function");
@@ -3342,8 +3339,8 @@
exitLocalScope();
FormalParameters<Expression, Statement, Arguments> formals = pop();
Object declaration = pop();
- Object returnType = pop();
- Object hasImplicitReturnType = returnType == null;
+ DartType returnType = pop();
+ bool hasImplicitReturnType = returnType == null;
returnType ??= const DynamicType();
exitFunction();
List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop());
@@ -3557,20 +3554,20 @@
void handleLabel(Token token) {
debugEvent("Label");
Identifier identifier = pop();
- push(forest.label(deprecated_extractToken(identifier), token));
+ push(new Label(identifier.name, identifier.charOffset));
}
@override
void beginLabeledStatement(Token token, int labelCount) {
debugEvent("beginLabeledStatement");
- List<Object> labels =
- new List<Object>.filled(labelCount, null, growable: true);
+ List<Label> labels =
+ new List<Label>.filled(labelCount, null, growable: true);
popList(labelCount, labels);
enterLocalScope(null, scope.createNestedLabelScope());
LabelTarget target =
new LabelTarget(labels, member, functionNestingLevel, token.charOffset);
- for (Object label in labels) {
- scope.declareLabel(forest.getLabelName(label), target);
+ for (Label label in labels) {
+ scope.declareLabel(label.name, target);
}
push(target);
}
@@ -3695,14 +3692,13 @@
@override
void beginSwitchCase(int labelCount, int expressionCount, Token firstToken) {
debugEvent("beginSwitchCase");
- Object count = labelCount + expressionCount;
- List<Object> labelsAndExpressions =
- popList(count, new List<Object>.filled(count, null, growable: true));
- List<Object> labels = <Object>[];
+ int count = labelCount + expressionCount;
+ List<Object> labelsAndExpressions = popList(count, new List<Object>(count));
+ List<Label> labels = <Label>[];
List<Expression> expressions = <Expression>[];
if (labelsAndExpressions != null) {
for (Object labelOrExpression in labelsAndExpressions) {
- if (forest.isLabel(labelOrExpression)) {
+ if (labelOrExpression is Label) {
labels.add(labelOrExpression);
} else {
expressions.add(labelOrExpression);
@@ -3710,15 +3706,15 @@
}
}
assert(scope == switchScope);
- for (Object label in labels) {
- String labelName = forest.getLabelName(label);
+ for (Label label in labels) {
+ String labelName = label.name;
if (scope.hasLocalLabel(labelName)) {
// TODO(ahe): Should validate this is a goto target.
if (!scope.claimLabel(labelName)) {
addProblem(
fasta.templateDuplicateLabelInSwitchStatement
.withArguments(labelName),
- forest.getLabelOffset(label),
+ label.charOffset,
labelName.length);
}
} else {
@@ -3745,7 +3741,7 @@
// check this switch case to see if it falls through to the next case.
Statement block = popBlock(statementCount, firstToken, null);
exitLocalScope();
- List<Object> labels = pop();
+ List<Label> labels = pop();
List<Expression> expressions = pop();
List<int> expressionOffsets = <int>[];
for (Expression expression in expressions) {
@@ -3791,10 +3787,10 @@
List<SwitchCase> cases =
new List<SwitchCase>.filled(caseCount, null, growable: true);
for (int i = caseCount - 1; i >= 0; i--) {
- List<Object> labels = pop();
+ List<Label> labels = pop();
SwitchCase current = cases[i] = pop();
- for (Object label in labels) {
- JumpTarget target = switchScope.lookupLabel(forest.getLabelName(label));
+ for (Label label in labels) {
+ JumpTarget target = switchScope.lookupLabel(label.name);
if (target != null) {
target.resolveGotos(forest, current);
}
@@ -3952,7 +3948,11 @@
// See the code that resolves them below.
new ClassMemberParser(listener)
.parseTypeVariablesOpt(new Token.eof(-1)..next = token);
- enterFunctionTypeScope(listener.pop());
+ List<Object> typeVariables = listener.pop();
+ if (typeVariables != null) {
+ typeVariables = new List<KernelTypeVariableBuilder>.from(typeVariables);
+ }
+ enterFunctionTypeScope(typeVariables);
// The invocation of [enterFunctionTypeScope] above has put the type
// variables into the scope, and now the possibly unresolved types from
@@ -4058,7 +4058,7 @@
}
List<TypeParameter> typeVariableBuildersToKernel(
- List<Object> typeVariableBuilders) {
+ List<KernelTypeVariableBuilder> typeVariableBuilders) {
if (typeVariableBuilders == null) return null;
List<TypeParameter> typeParameters = new List<TypeParameter>.filled(
typeVariableBuilders.length, null,
@@ -4500,7 +4500,7 @@
@override
Expression wrapInDeferredCheck(
Expression expression, KernelPrefixBuilder prefix, int charOffset) {
- Object check = new VariableDeclaration.forValue(
+ VariableDeclaration check = new VariableDeclaration.forValue(
forest.checkLibraryIsLoaded(prefix.dependency))
..fileOffset = charOffset;
return new DeferredCheckJudgment(check, expression);
@@ -4601,24 +4601,24 @@
void resolveBreaks(Forest forest, Statement target) {
assert(isBreakTarget);
- for (Statement user in users) {
- forest.resolveBreak(target, user);
+ for (BreakStatement user in users) {
+ user.target = target;
}
users.clear();
}
void resolveContinues(Forest forest, Statement target) {
assert(isContinueTarget);
- for (Statement user in users) {
- forest.resolveContinue(target, user);
+ for (BreakStatement user in users) {
+ user.target = target;
}
users.clear();
}
- void resolveGotos(Forest forest, Object target) {
+ void resolveGotos(Forest forest, SwitchCase target) {
assert(isGotoTarget);
- for (Statement user in users) {
- forest.resolveContinueInSwitch(target, user);
+ for (ContinueSwitchStatement user in users) {
+ user.target = target;
}
users.clear();
}
@@ -4628,7 +4628,7 @@
}
class LabelTarget extends Declaration implements JumpTarget {
- final List<Object> labels;
+ final List<Label> labels;
@override
final MemberBuilder parent;
@@ -4684,7 +4684,7 @@
continueTarget.resolveContinues(forest, target);
}
- void resolveGotos(Forest forest, Object target) {
+ void resolveGotos(Forest forest, SwitchCase target) {
unsupported("resolveGotos", charOffset, fileUri);
}
@@ -4845,3 +4845,14 @@
asyncToken.charOffset, null);
}
}
+
+/// A data holder used to hold the information about a label that is pushed on
+/// the stack.
+class Label {
+ String name;
+ int charOffset;
+
+ Label(this.name, this.charOffset);
+
+ String toString() => "label($name)";
+}
diff --git a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
index 6e147a8..8461648 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart
@@ -11,16 +11,12 @@
Arguments,
AssertInitializer,
Block,
- BreakStatement,
Catch,
- ContinueSwitchStatement,
DartType,
- DynamicType,
EmptyStatement,
Expression,
ExpressionStatement,
InvalidExpression,
- LabeledStatement,
Let,
LibraryDependency,
MapEntry,
@@ -29,7 +25,6 @@
NamedExpression,
Procedure,
Statement,
- SwitchCase,
ThisExpression,
TreeNode,
VariableDeclaration,
@@ -263,20 +258,9 @@
}
@override
- List<MapEntry> mapEntryList(int length) {
- return new List<MapEntryJudgment>.filled(length, null, growable: true);
- }
-
- @override
int readOffset(TreeNode node) => node.fileOffset;
@override
- int getTypeCount(List typeArguments) => typeArguments.length;
-
- @override
- DartType getTypeAt(List typeArguments, int index) => typeArguments[index];
-
- @override
Expression loadLibrary(LibraryDependency dependency, Arguments arguments) {
return new LoadLibraryJudgment(dependency, arguments);
}
@@ -287,7 +271,7 @@
}
@override
- Expression asExpression(Expression expression, covariant type, Token token) {
+ Expression asExpression(Expression expression, DartType type, Token token) {
return new AsJudgment(
expression, typeInferenceTokensSaver?.asExpressionTokens(token), type)
..fileOffset = offsetForToken(token);
@@ -395,8 +379,6 @@
VariableDeclaration stackTraceParameter,
DartType stackTraceType,
Statement body) {
- exceptionType ??= const DynamicType();
- // TODO(brianwilkerson) Get the left and right parentheses and the comma.
return new CatchJudgment(
typeInferenceTokensSaver?.catchStatementTokens(
onKeyword, catchKeyword, null, null, null),
@@ -490,7 +472,7 @@
@override
Expression isExpression(
- Expression operand, isOperator, Token notOperator, covariant type) {
+ Expression operand, isOperator, Token notOperator, DartType type) {
int offset = offsetForToken(isOperator);
if (notOperator != null) {
return new IsNotJudgment(
@@ -507,11 +489,6 @@
}
@override
- Label label(Token identifier, Token colon) {
- return new Label(identifier.lexeme, identifier.charOffset);
- }
-
- @override
Statement labeledStatement(LabelTarget target, Statement statement) =>
statement;
@@ -653,17 +630,6 @@
}
@override
- String getLabelName(Label label) => label.name;
-
- @override
- int getLabelOffset(Label label) => label.charOffset;
-
- @override
- String getVariableDeclarationName(VariableDeclaration declaration) {
- return declaration.name;
- }
-
- @override
bool isBlock(Object node) => node is Block;
@override
@@ -695,36 +661,12 @@
statement is ExpressionStatement;
@override
- bool isLabel(covariant node) => node is Label;
-
- @override
bool isThisExpression(Object node) => node is ThisExpression;
@override
bool isVariablesDeclaration(Object node) => node is _VariablesDeclaration;
@override
- void resolveBreak(LabeledStatement target, BreakStatement user) {
- user.target = target;
- }
-
- @override
- void resolveContinue(LabeledStatement target, BreakStatement user) {
- user.target = target;
- }
-
- @override
- void resolveContinueInSwitch(
- SwitchCase target, ContinueSwitchStatement user) {
- user.target = target;
- }
-
- @override
- void setParameterType(VariableDeclaration parameter, DartType type) {
- parameter.type = type ?? const DynamicType();
- }
-
- @override
KernelVariableUseGenerator variableUseGenerator(
ExpressionGeneratorHelper helper,
Token token,
@@ -947,14 +889,3 @@
unsupported("transformChildren", fileOffset, uri);
}
}
-
-/// A data holder used to hold the information about a label that is pushed on
-/// the stack.
-class Label {
- String name;
- int charOffset;
-
- Label(this.name, this.charOffset);
-
- String toString() => "label($name)";
-}
diff --git a/pkg/front_end/lib/src/fasta/kernel/forest.dart b/pkg/front_end/lib/src/fasta/kernel/forest.dart
index 26da213..86f4e31 100644
--- a/pkg/front_end/lib/src/fasta/kernel/forest.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/forest.dart
@@ -4,15 +4,23 @@
library fasta.forest;
+import 'dart:core' hide MapEntry;
+
import 'package:kernel/ast.dart'
show
- Arguments, // TODO(ahe): Remove this import.
+ Arguments,
+ Catch,
DartType,
Expression,
+ LibraryDependency,
+ MapEntry,
Member,
Name,
+ NamedExpression,
Procedure,
- Statement;
+ Statement,
+ TreeNode,
+ VariableDeclaration;
import 'body_builder.dart' show LabelTarget;
@@ -51,17 +59,17 @@
const Forest();
Arguments arguments(List<Expression> positional, Token location,
- {covariant List types, covariant List named});
+ {List<DartType> types, List<NamedExpression> named});
Arguments argumentsEmpty(Token location);
- List argumentsNamed(Arguments arguments);
+ List<Object> argumentsNamed(Arguments arguments);
List<Expression> argumentsPositional(Arguments arguments);
List argumentsTypeArguments(Arguments arguments);
- void argumentsSetTypeArguments(Arguments arguments, covariant List types);
+ void argumentsSetTypeArguments(Arguments arguments, List<DartType> types);
Expression asLiteralString(Expression value);
@@ -113,11 +121,11 @@
Expression literalMap(
Token constKeyword,
bool isConst,
- covariant keyType,
- covariant valueType,
+ DartType keyType,
+ DartType valueType,
Object typeArguments,
Token leftBracket,
- covariant List entries,
+ List<MapEntry> entries,
Token rightBracket);
/// Return a representation of a null literal at the given [location].
@@ -138,7 +146,7 @@
/// [Operator]. The [value] is the string value of the symbol.
Expression literalSymbolSingluar(String value, Token hash, Object component);
- Expression literalType(covariant type, Token location);
+ Expression literalType(DartType type, Token location);
/// Return a representation of a key/value pair in a literal map. The [key] is
/// the representation of the expression used to compute the key. The [colon]
@@ -146,26 +154,13 @@
/// is the representation of the expression used to compute the value.
Object mapEntry(Expression key, Token colon, Expression value);
- /// Return a list that can hold [length] representations of map entries, as
- /// returned from [mapEntry].
- List mapEntryList(int length);
+ int readOffset(TreeNode node);
- int readOffset(covariant node);
+ Expression loadLibrary(LibraryDependency dependency, Arguments arguments);
- /// Given a representation of a list of [typeArguments], return the number of
- /// type arguments in the list.
- int getTypeCount(covariant typeArguments);
+ Expression checkLibraryIsLoaded(LibraryDependency dependency);
- /// Given a representation of a list of [typeArguments], return the type
- /// associated with the argument at the given [index].
- DartType getTypeAt(covariant typeArguments, int index);
-
- Expression loadLibrary(covariant dependency, Arguments arguments);
-
- Expression checkLibraryIsLoaded(covariant dependency);
-
- Expression asExpression(
- Expression expression, covariant type, Token location);
+ Expression asExpression(Expression expression, DartType type, Token location);
/// Return a representation of an assert that appears in a constructor's
/// initializer list.
@@ -190,11 +185,11 @@
/// Return a representation of a catch clause.
Object catchClause(
Token onKeyword,
- covariant exceptionType,
+ DartType exceptionType,
Token catchKeyword,
- covariant exceptionParameter,
- covariant stackTraceParameter,
- covariant stackTraceType,
+ VariableDeclaration exceptionParameter,
+ VariableDeclaration stackTraceParameter,
+ DartType stackTraceType,
Statement body);
/// Return a representation of a conditional expression. The [condition] is
@@ -211,7 +206,7 @@
/// Return a representation of a do statement.
Statement doStatement(Token doKeyword, Statement body, Token whileKeyword,
- covariant Expression condition, Token semicolon);
+ Expression condition, Token semicolon);
/// Return a representation of an expression statement composed from the
/// [expression] and [semicolon].
@@ -225,8 +220,8 @@
Statement forStatement(
Token forKeyword,
Token leftParenthesis,
- covariant variableList,
- covariant initializers,
+ List<VariableDeclaration> variableList,
+ List<Expression> initializers,
Token leftSeparator,
Expression condition,
Statement conditionStatement,
@@ -235,7 +230,7 @@
Statement body);
/// Return a representation of an `if` statement.
- Statement ifStatement(Token ifKeyword, covariant Expression condition,
+ Statement ifStatement(Token ifKeyword, Expression condition,
Statement thenStatement, Token elseKeyword, Statement elseStatement);
/// Return a representation of an `is` expression. The [operand] is the
@@ -243,11 +238,7 @@
/// The [notOperator] is either the `!` or `null` if the test is not negated.
/// The [type] is a representation of the type that is the right operand.
Expression isExpression(
- Expression operand, Token isOperator, Token notOperator, covariant type);
-
- /// Return a representation of the label consisting of the given [identifer]
- /// followed by the given [colon].
- Object label(Token identifier, Token colon);
+ Expression operand, Token isOperator, Token notOperator, DartType type);
/// Return a representation of a [statement] that has one or more labels (from
/// the [target]) associated with it.
@@ -297,11 +288,12 @@
/// might be provided, in which case it could be returned instead of the
/// representation of the try statement.
Statement tryStatement(Token tryKeyword, Statement body,
- covariant catchClauses, Token finallyKeyword, Statement finallyBlock);
+ List<Catch> catchClauses, Token finallyKeyword, Statement finallyBlock);
- Statement variablesDeclaration(covariant List declarations, Uri uri);
+ Statement variablesDeclaration(
+ List<VariableDeclaration> declarations, Uri uri);
- Object variablesDeclarationExtractDeclarations(
+ List<VariableDeclaration> variablesDeclarationExtractDeclarations(
covariant Statement variablesDeclaration);
Statement wrapVariables(Statement statement);
@@ -309,7 +301,7 @@
/// Return a representation of a while statement introduced by the
/// [whileKeyword] and consisting of the given [condition] and [body].
Statement whileStatement(
- Token whileKeyword, covariant Expression condition, Statement body);
+ Token whileKeyword, Expression condition, Statement body);
/// Return a representation of a yield statement consisting of the
/// [yieldKeyword], [star], [expression], and [semicolon]. The [star] is null
@@ -320,15 +312,6 @@
/// Return the expression from the given expression [statement].
Expression getExpressionFromExpressionStatement(Statement statement);
- /// Return the name of the given [label].
- String getLabelName(covariant label);
-
- /// Return the offset of the given [label].
- int getLabelOffset(covariant label);
-
- /// Return the name of the given variable [declaration].
- String getVariableDeclarationName(covariant declaration);
-
bool isBlock(Object node);
/// Return `true` if the given [statement] is the representation of an empty
@@ -341,31 +324,12 @@
/// expression statement.
bool isExpressionStatement(Statement statement);
- /// Return `true` if the given [node] is a label.
- bool isLabel(covariant node);
-
bool isThisExpression(Object node);
bool isVariablesDeclaration(Object node);
- /// Record that the [user] (a break statement) is associated with the [target]
- /// statement.
- void resolveBreak(covariant Statement target, covariant Statement user);
-
- /// Record that the [user] (a continue statement) is associated with the
- /// [target] statement.
- void resolveContinue(covariant Statement target, covariant Statement user);
-
- /// Record that the [user] (a continue statement inside a switch case) is
- /// associated with the [target] statement.
- void resolveContinueInSwitch(
- covariant Object target, covariant Statement user);
-
- /// Set the type of the [parameter] to the given [type].
- void setParameterType(covariant parameter, covariant type);
-
Generator variableUseGenerator(ExpressionGeneratorHelper helper,
- Token location, covariant variable, DartType promotedType);
+ Token location, VariableDeclaration variable, DartType promotedType);
Generator propertyAccessGenerator(
ExpressionGeneratorHelper helper,
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 1e07bc1..5629444 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
@@ -39,6 +39,7 @@
LibraryPart,
ListLiteral,
Location,
+ MapEntry,
Member,
MethodInvocation,
Name,
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 c5e1b74..ce99bf3 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
@@ -1881,12 +1881,12 @@
MapLiteralTokens tokens;
DartType inferredType;
- List<MapEntryJudgment> get judgments => entries;
+ List<MapEntry> get judgments => entries;
final DartType _declaredKeyType;
final DartType _declaredValueType;
- MapLiteralJudgment(this.tokens, List<MapEntryJudgment> judgments,
+ MapLiteralJudgment(this.tokens, List<MapEntry> judgments,
{DartType keyType, DartType valueType, bool isConst: false})
: _declaredKeyType = keyType,
_declaredValueType = valueType,
@@ -1924,9 +1924,9 @@
inferredValueType = _declaredValueType ?? const DynamicType();
}
List<ExpressionJudgment> cachedKeyJudgments =
- judgments.map((j) => j.keyJudgment).toList();
+ judgments.map((j) => (j as MapEntryJudgment).keyJudgment).toList();
List<ExpressionJudgment> cachedValueJudgments =
- judgments.map((j) => j.valueJudgment).toList();
+ judgments.map((j) => (j as MapEntryJudgment).valueJudgment).toList();
if (inferenceNeeded || typeChecksNeeded) {
for (MapEntryJudgment judgment in judgments) {
judgment.infer(inferrer, inferredKeyType, inferredValueType);
diff --git a/pkg/front_end/lib/src/fasta/source/stack_listener.dart b/pkg/front_end/lib/src/fasta/source/stack_listener.dart
index bc7beda..cd41814 100644
--- a/pkg/front_end/lib/src/fasta/source/stack_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/stack_listener.dart
@@ -76,7 +76,7 @@
// TODO(ahe): This doesn't belong here. Only implemented by body_builder.dart
// and ast_builder.dart.
- void finishFunction(List annotations, covariant formals,
+ void finishFunction(covariant List<Object> annotations, covariant formals,
AsyncMarker asyncModifier, covariant body) {
return unsupported("finishFunction", -1, uri);
}