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 283adcb7163dd835a9dd638aa8b8a32a58c0ea3d..0c6996914ff6e315f1f432d1ccbf497730df3b30 100644 |
| --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| @@ -2412,20 +2412,26 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void beginFunction(Token token) { |
| - debugEvent("beginFunction"); |
| + void beginFunctionDeclaration(Token token) { |
| + debugEvent("beginNamedFunctionExpression"); |
| enterFunction(); |
| } |
| @override |
| - void beginUnnamedFunction(Token token) { |
| - debugEvent("beginUnnamedFunction"); |
| + void beginNamedFunctionExpression(Token token) { |
| + debugEvent("beginNamedFunctionExpression"); |
| enterFunction(); |
| } |
| @override |
| - void endFunction(Token getOrSet, Token endToken) { |
| - debugEvent("Function"); |
| + void beginFunctionExpression(Token token) { |
| + debugEvent("beginFunctionExpression"); |
| + enterFunction(); |
| + } |
| + |
| + @override |
| + void endNamedFunctionExpression(Token endToken) { |
| + debugEvent("NamedFunctionExpression"); |
| Statement body = popStatement(); |
| AsyncMarker asyncModifier = pop(); |
| if (functionNestingLevel != 0) { |
| @@ -2433,16 +2439,39 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| FormalParameters formals = pop(); |
| List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); |
| - push(formals.addToFunction(new FunctionNode(body, |
| - typeParameters: typeParameters, asyncMarker: asyncModifier) |
| - ..fileOffset = formals.charOffset |
| - ..fileEndOffset = endToken.charOffset)); |
| + |
| + exitLocalScope(); |
| + KernelFunctionDeclaration declaration = pop(); |
| + VariableDeclaration variable = declaration.variable; |
| + var returnType = pop(); |
| + returnType ??= const DynamicType(); |
| + pop(); // Modifiers. |
| + exitFunction(); |
| + |
| + variable.initializer = new KernelFunctionExpression(formals.addToFunction( |
| + new FunctionNode(body, |
| + typeParameters: typeParameters, asyncMarker: asyncModifier) |
| + ..fileOffset = formals.charOffset |
| + ..fileEndOffset = endToken.charOffset)) |
| + ..parent = variable |
| + ..fileOffset = formals.charOffset; |
| + push(new Let(variable, new VariableGet(variable))); |
| } |
| @override |
| - void endFunctionDeclaration(Token token) { |
| + void endFunctionDeclaration(Token endToken) { |
| debugEvent("FunctionDeclaration"); |
| - FunctionNode function = pop(); |
| + Statement body = popStatement(); |
| + AsyncMarker asyncModifier = pop(); |
| + if (functionNestingLevel != 0) { |
| + exitLocalScope(); |
| + } |
| + FormalParameters formals = pop(); |
| + List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); |
| + FunctionNode function = formals.addToFunction(new FunctionNode(body, |
| + typeParameters: typeParameters, asyncMarker: asyncModifier) |
| + ..fileOffset = formals.charOffset |
| + ..fileEndOffset = endToken.charOffset); |
| exitLocalScope(); |
| var declaration = pop(); |
| var returnType = pop(); |
| @@ -2469,8 +2498,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endUnnamedFunction(Token beginToken, Token token) { |
| - debugEvent("UnnamedFunction"); |
| + void endFunctionExpression(Token beginToken, Token token) { |
|
danrubel
2017/07/06 15:43:34
rename token to endToken? Or is it tokenAfterExpre
ahe
2017/07/06 19:54:18
Now that I think about it, I think I've been rathe
danrubel
2017/07/06 19:58:42
Naming the current token 'token' sounds good to me
Paul Berry
2017/07/06 20:06:57
Not a blocking issue, just food for thought: I hav
ahe
2017/07/06 20:58:53
That's actually what I do for type variables. And
|
| + debugEvent("FunctionExpression"); |
| Statement body = popStatement(); |
| AsyncMarker asyncModifier = pop(); |
| exitLocalScope(); |