Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| index 849100a1c5cdf19c83674b42dcf77f815740d6b4..fd77898bd1b63fdbb164f733e8f850a20b300485 100644 |
| --- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| +++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
| @@ -313,6 +313,10 @@ class AstBuilder extends ScopeListener { |
| debugEvent("InitializedIdentifier"); |
| AstNode node = pop(); |
| VariableDeclaration variable; |
| + // TODO(paulberry,ahe): This seems kludgy. It would be preferable if we |
| + // could respond to a "handleNoVariableInitializer" event by converting a |
| + // SimpleIdentifier into a VariableDeclaration, and then when this code was |
| + // reached, node would always be a VariableDeclaration. |
|
ahe
2017/02/20 09:04:20
Good idea. I've filed issue https://github.com/dar
Paul Berry
2017/02/20 15:01:36
Thanks for doing that! Now that the new event is
|
| if (node is VariableDeclaration) { |
| variable = node; |
| } else if (node is SimpleIdentifier) { |
| @@ -626,6 +630,8 @@ class AstBuilder extends ScopeListener { |
| } |
| void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { |
| + // TODO(paulberry): set up scopes properly to resolve parameters and type |
| + // variables. |
| debugEvent("TopLevelMethod"); |
| FunctionBody body = _endFunctionBody(); |
| FormalParameterList parameters = pop(); |
| @@ -932,6 +938,48 @@ class AstBuilder extends ScopeListener { |
| toAnalyzerToken(ofKeyword), uri, name, toAnalyzerToken(semicolon))); |
| accumulateIdentifierComponents = false; |
| } |
| + |
| + void endUnnamedFunction(Token token) { |
| + // TODO(paulberry): set up scopes properly to resolve parameters and type |
| + // variables. |
|
ahe
2017/02/20 09:04:20
This is a bit tricky when it comes to handling ini
Paul Berry
2017/02/20 15:01:36
Good point. I've updated the TODO comment to make
|
| + debugEvent("UnnamedFunction"); |
| + var body = _endFunctionBody(); |
| + FormalParameterList parameters = pop(); |
| + TypeParameterList typeParameters = pop(); |
| + push(ast.functionExpression(typeParameters, parameters, body)); |
| + } |
| + |
| + @override |
| + void handleNoFieldInitializer(Token token) { |
| + debugEvent("NoFieldInitializer"); |
| + SimpleIdentifier name = pop(); |
| + push(ast.variableDeclaration(name, null, null)); |
| + } |
| + |
| + void endFieldInitializer(Token assignment) { |
| + debugEvent("FieldInitializer"); |
| + Expression initializer = pop(); |
| + SimpleIdentifier name = pop(); |
| + push(ast.variableDeclaration( |
| + name, toAnalyzerToken(assignment), initializer)); |
| + } |
| + |
| + void endTopLevelFields(int count, Token beginToken, Token endToken) { |
| + debugEvent("TopLevelFields"); |
| + List<VariableDeclaration> variables = popList(count); |
| + TypeAnnotation type = pop(); |
| + // TODO(paulberry,ahe): the parser needs to pass the var/const/final keyword |
|
ahe
2017/02/20 09:04:20
Those should be available in beginToken. Another o
Paul Berry
2017/02/20 15:01:36
Oh, ok. I misread the parser code and thought "be
|
| + // to the listener. |
| + var keyword = null; // TODO(paulberry) |
| + var variableList = ast.variableDeclarationList( |
| + null, null, toAnalyzerToken(keyword), type, variables); |
| + var modifiers = pop(); |
| + assert(modifiers == null); // TODO(paulberry) |
| + List<Annotation> metadata = pop(); |
| + Comment comment = null; // TODO(paulberry) |
| + push(ast.topLevelVariableDeclaration( |
| + comment, metadata, variableList, toAnalyzerToken(endToken))); |
| + } |
| } |
| /// Data structure placed on the stack to represent a class body. |