| Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
|
| 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 e577fcd81e4bb35e3f079afc3fc836d8a5461b3d..d2021b60924b554a95ed791bbf14a7592f320faf 100644
|
| --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
|
| +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
|
| @@ -11,6 +11,8 @@ import '../parser/parser.dart' show FormalParameterType, optional;
|
|
|
| import '../parser/identifier_context.dart' show IdentifierContext;
|
|
|
| +import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory;
|
| +
|
| import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
|
| show KernelVariableDeclaration;
|
|
|
| @@ -88,6 +90,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| final TypeInferrer<Statement, Expression, KernelVariableDeclaration, Field>
|
| _typeInferrer;
|
|
|
| + final AstFactory astFactory;
|
| +
|
| Scope formalParameterScope;
|
|
|
| bool inInitializer = false;
|
| @@ -124,7 +128,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| this.classBuilder,
|
| this.isInstanceMember,
|
| this.uri,
|
| - this._typeInferrer)
|
| + this._typeInferrer,
|
| + this.astFactory)
|
| : enclosingScope = scope,
|
| library = library,
|
| isDartLibrary = library.uri.scheme == "dart",
|
| @@ -223,7 +228,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| copy.add(statement);
|
| }
|
| }
|
| - return new Block(copy ?? statements)..fileOffset = charOffset;
|
| + return astFactory.block(copy ?? statements, charOffset);
|
| }
|
|
|
| Statement popStatementIfNotNull(Object value) {
|
| @@ -435,7 +440,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| } else {
|
| internalError("Unhandled: ${builder.runtimeType}");
|
| }
|
| - _typeInferrer.inferBody(body, uri);
|
| + _typeInferrer?.inferBody(body, uri);
|
| builder.body = body;
|
| if (formals?.optional != null) {
|
| Iterator<FormalParameterBuilder> formalBuilders =
|
| @@ -920,8 +925,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| @override
|
| void handleLiteralInt(Token token) {
|
| debugEvent("LiteralInt");
|
| - push(
|
| - new IntLiteral(int.parse(token.lexeme))..fileOffset = token.charOffset);
|
| + push(astFactory.intLiteral(int.parse(token.lexeme), token.charOffset));
|
| }
|
|
|
| @override
|
| @@ -978,12 +982,12 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| bool isConst = (currentLocalVariableModifiers & constMask) != 0;
|
| bool isFinal = (currentLocalVariableModifiers & finalMask) != 0;
|
| assert(isConst == constantExpressionRequired);
|
| - push(new VariableDeclaration(identifier.name,
|
| + push(astFactory.variableDeclaration(identifier.name,
|
| initializer: initializer,
|
| - type: currentLocalVariableType ?? const DynamicType(),
|
| + type: currentLocalVariableType,
|
| isFinal: isFinal,
|
| - isConst: isConst)
|
| - ..fileEqualsOffset = equalsCharOffset);
|
| + isConst: isConst,
|
| + equalsCharOffset: equalsCharOffset));
|
| }
|
|
|
| @override
|
| @@ -1437,23 +1441,23 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| thisKeyword.charOffset);
|
| }
|
| type = field.target.type ?? const DynamicType();
|
| - variable = new VariableDeclaration(name.name,
|
| + variable = astFactory.variableDeclaration(name.name,
|
| type: type,
|
| initializer: name.initializer,
|
| isFinal: isFinal,
|
| - isConst: isConst)
|
| - ..fileOffset = name.fileOffset;
|
| + isConst: isConst,
|
| + charOffset: name.fileOffset);
|
| } else {
|
| addCompileTimeError(
|
| name.fileOffset, "'${name.name}' isn't a field in this class.");
|
| }
|
| }
|
| - variable ??= new VariableDeclaration(name.name,
|
| + variable ??= astFactory.variableDeclaration(name.name,
|
| type: type ?? const DynamicType(),
|
| initializer: name.initializer,
|
| isFinal: isFinal,
|
| - isConst: isConst)
|
| - ..fileOffset = name.fileOffset;
|
| + isConst: isConst,
|
| + charOffset: name.fileOffset);
|
| push(variable);
|
| }
|
|
|
| @@ -1912,7 +1916,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| debugEvent("FunctionName");
|
| Identifier name = pop();
|
| VariableDeclaration variable =
|
| - new VariableDeclaration(name.name, isFinal: true);
|
| + astFactory.variableDeclaration(name.name, isFinal: true);
|
| push(new FunctionDeclaration(
|
| variable, new FunctionNode(new InvalidStatement()))
|
| ..fileOffset = beginToken.charOffset);
|
|
|