Chromium Code Reviews| 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 8a3869e996cf39af054c6bac2e48aedb21f84197..0251300eac70a20bf881c03f07ceb04b78d7c5cd 100644 |
| --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| @@ -225,7 +225,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| return list; |
| } |
| - Block popBlock(int count) { |
| + Block popBlock(int count, Token beginToken) { |
|
ahe
2017/03/13 14:33:52
Should take an int, not a token.
jensj
2017/03/14 12:37:11
Fixed.
|
| List<dynamic /*Statement | List<Statement>*/ > statements = |
| popList(count) ?? <Statement>[]; |
| List<Statement> copy; |
| @@ -240,7 +240,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| copy.add(statement); |
| } |
| } |
| - return new Block(copy ?? statements); |
| + return new Block(copy ?? statements)..fileOffset = beginToken.charOffset; |
| } |
| Statement popStatementIfNotNull(Object value) { |
| @@ -356,7 +356,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| assert(count == 0); |
| push(NullValue.Block); |
| } else { |
| - Block block = popBlock(count); |
| + Block block = popBlock(count, beginToken); |
| exitLocalScope(); |
| push(block); |
| } |
| @@ -525,7 +525,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| if (arguments == null) { |
| push(new IncompletePropertyAccessor(this, beginToken.charOffset, name)); |
| } else { |
| - push(new SendAccessor(this, endToken.charOffset, name, arguments)); |
| + push(new SendAccessor(this, beginToken.charOffset, name, arguments)); |
| } |
| } else if (arguments == null) { |
| push(receiver); |
| @@ -871,7 +871,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void endExpressionFunctionBody(Token arrowToken, Token endToken) { |
| debugEvent("ExpressionFunctionBody"); |
| - endReturnStatement(true, arrowToken, endToken); |
| + endReturnStatement(true, arrowToken.next, endToken); |
| } |
| @override |
| @@ -969,7 +969,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void endBlock(int count, Token beginToken, Token endToken) { |
| debugEvent("Block"); |
| - Block block = popBlock(count); |
| + Block block = popBlock(count, beginToken); |
| exitLocalScope(); |
| push(block); |
| } |
| @@ -1064,7 +1064,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void endAwaitExpression(Token beginToken, Token endToken) { |
| debugEvent("AwaitExpression"); |
| - push(new AwaitExpression(popForValue())); |
| + push( |
| + new AwaitExpression(popForValue())..fileOffset = beginToken.charOffset); |
| } |
| @override |
| @@ -1299,8 +1300,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endFormalParameter( |
| - Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { |
| + void endFormalParameter(Token covariantKeyword, Token thisKeyword, |
| + Token nameToken, FormalParameterType kind) { |
| debugEvent("FormalParameter"); |
| // TODO(ahe): Need beginToken here. |
| int charOffset = thisKeyword?.charOffset; |
| @@ -1612,9 +1613,13 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| return throwNoSuchMethodError(target.name.name, arguments, charOffset); |
| } |
| if (target is Constructor) { |
| - return new ConstructorInvocation(target, arguments)..isConst = isConst; |
| + return new ConstructorInvocation(target, arguments) |
| + ..isConst = isConst |
| + ..fileOffset = charOffset; |
| } else { |
| - return new StaticInvocation(target, arguments)..isConst = isConst; |
| + return new StaticInvocation(target, arguments) |
| + ..isConst = isConst |
| + ..fileOffset = charOffset; |
| } |
| } |
| @@ -1683,13 +1688,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void handleNewExpression(Token token) { |
| debugEvent("NewExpression"); |
| + Token nameToken = token.next ?? token; |
|
ahe
2017/03/13 14:33:52
token.next can't be null.
jensj
2017/03/14 12:37:11
Acknowledged.
|
| Arguments arguments = pop(); |
| String name = pop(); |
| List<DartType> typeArguments = pop(); |
| var type = pop(); |
| if (arguments == null) { |
| - push(buildCompileTimeError("No arguments.", token.charOffset)); |
| + push(buildCompileTimeError("No arguments.", nameToken.charOffset)); |
| return; |
| } |
| @@ -1714,14 +1720,15 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| target = getRedirectionTarget(b.target); |
| if (target == null) { |
| push(buildCompileTimeError( |
| - "Cyclic definition of factory '${name}'.", token.charOffset)); |
| + "Cyclic definition of factory '${name}'.", nameToken.charOffset)); |
| return; |
| } |
| } |
| if (target is Constructor || |
| (target is Procedure && target.kind == ProcedureKind.Factory)) { |
| push(buildStaticInvocation(target, arguments, |
| - isConst: optional("const", token), charOffset: token.charOffset)); |
| + isConst: optional("const", token), |
| + charOffset: nameToken.charOffset)); |
| return; |
| } else { |
| errorName = debugName(type.name, name); |
| @@ -1730,7 +1737,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| errorName = debugName(getNodeName(type), name); |
| } |
| errorName ??= name; |
| - push(throwNoSuchMethodError(errorName, arguments, token.charOffset)); |
| + push(throwNoSuchMethodError(errorName, arguments, nameToken.charOffset)); |
| } |
| @override |
| @@ -1779,13 +1786,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endFunctionName(Token token) { |
| + void endFunctionName(Token beginToken, Token token) { |
| debugEvent("FunctionName"); |
| Identifier name = pop(); |
| VariableDeclaration variable = |
| new VariableDeclaration(name.name, isFinal: true); |
| push(new FunctionDeclaration( |
| - variable, new FunctionNode(new InvalidStatement()))); |
| + variable, new FunctionNode(new InvalidStatement())) |
| + ..fileOffset = beginToken.charOffset); |
| scope[variable.name] = new KernelVariableBuilder( |
| variable, member ?? classBuilder ?? library, uri); |
| enterLocalScope(); |
| @@ -1817,7 +1825,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endFunction(Token getOrSet, Token endToken) { |
| + void endFunction( |
| + Token getOrSet, Token formalParametersToken, Token endToken) { |
| debugEvent("Function"); |
| Statement body = popStatement(); |
| AsyncMarker asyncModifier = pop(); |
| @@ -1827,7 +1836,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| FormalParameters formals = pop(); |
| List<TypeParameter> typeParameters = pop(); |
| push(formals.addToFunction(new FunctionNode(body, |
| - typeParameters: typeParameters, asyncMarker: asyncModifier))); |
| + typeParameters: typeParameters, asyncMarker: asyncModifier) |
| + ..fileOffset = formalParametersToken.charOffset |
| + ..fileEndOffset = endToken.charOffset)); |
| } |
| @override |
| @@ -1845,7 +1856,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endUnnamedFunction(Token token) { |
| + void endUnnamedFunction(Token beginToken, Token token) { |
| debugEvent("UnnamedFunction"); |
| Statement body = popStatement(); |
| AsyncMarker asyncModifier = pop(); |
| @@ -1854,8 +1865,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| exitFunction(); |
| List<TypeParameter> typeParameters = pop(); |
| FunctionNode function = formals.addToFunction(new FunctionNode(body, |
| - typeParameters: typeParameters, asyncMarker: asyncModifier)); |
| - push(new FunctionExpression(function)); |
| + typeParameters: typeParameters, asyncMarker: asyncModifier) |
| + ..fileOffset = beginToken.charOffset |
| + ..fileEndOffset = token.charOffset); |
| + push(new FunctionExpression(function)..fileOffset = beginToken.charOffset); |
| } |
| @override |
| @@ -1981,7 +1994,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void endRethrowStatement(Token throwToken, Token endToken) { |
| debugEvent("RethrowStatement"); |
| - push(new ExpressionStatement(new Rethrow())); |
| + push(new ExpressionStatement( |
| + new Rethrow()..fileOffset = throwToken.charOffset)); |
| } |
| @override |
| @@ -2027,7 +2041,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { |
| debugEvent("YieldStatement"); |
| - push(new YieldStatement(popForValue(), isYieldStar: starToken != null)); |
| + push(new YieldStatement(popForValue(), isYieldStar: starToken != null) |
| + ..fileOffset = yieldToken.charOffset); |
| } |
| @override |
| @@ -2076,7 +2091,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| Token firstToken, |
| Token endToken) { |
| debugEvent("SwitchCase"); |
| - Block block = popBlock(statementCount); |
| + Block block = popBlock(statementCount, firstToken); |
| exitLocalScope(); |
| List<Label> labels = pop(); |
| List<Expression> expressions = pop(); |