| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; | 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; | 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; |
| 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; | 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 void endFieldInitializer(Token assignment) { | 1412 void endFieldInitializer(Token assignment) { |
| 1413 debugEvent("FieldInitializer"); | 1413 debugEvent("FieldInitializer"); |
| 1414 Expression initializer = pop(); | 1414 Expression initializer = pop(); |
| 1415 SimpleIdentifier name = pop(); | 1415 SimpleIdentifier name = pop(); |
| 1416 push(ast.variableDeclaration( | 1416 push(ast.variableDeclaration( |
| 1417 name, toAnalyzerToken(assignment), initializer)); | 1417 name, toAnalyzerToken(assignment), initializer)); |
| 1418 } | 1418 } |
| 1419 | 1419 |
| 1420 @override |
| 1421 void endFunction(Token getOrSet, Token endToken) { |
| 1422 debugEvent("Function"); |
| 1423 FunctionBody body = pop(); |
| 1424 pop(); // constructor initializers |
| 1425 FormalParameterList parameters = pop(); |
| 1426 TypeParameterList typeParameters = pop(); |
| 1427 // TODO(scheglov) It is an error if "getOrSet" is not null. |
| 1428 push(ast.functionExpression(typeParameters, parameters, body)); |
| 1429 } |
| 1430 |
| 1431 @override |
| 1432 void endFunctionDeclaration(Token token) { |
| 1433 debugEvent("FunctionDeclaration"); |
| 1434 FunctionExpression functionExpression = pop(); |
| 1435 SimpleIdentifier name = pop(); |
| 1436 TypeAnnotation returnType = pop(); |
| 1437 pop(); // modifiers |
| 1438 push(ast.functionDeclarationStatement(ast.functionDeclaration( |
| 1439 null, null, null, returnType, null, name, functionExpression))); |
| 1440 } |
| 1441 |
| 1442 @override |
| 1443 void endFunctionName(Token beginToken, Token token) { |
| 1444 debugEvent("FunctionName"); |
| 1445 } |
| 1446 |
| 1420 void endTopLevelFields(int count, Token beginToken, Token endToken) { | 1447 void endTopLevelFields(int count, Token beginToken, Token endToken) { |
| 1421 debugEvent("TopLevelFields"); | 1448 debugEvent("TopLevelFields"); |
| 1422 List<VariableDeclaration> variables = popList(count); | 1449 List<VariableDeclaration> variables = popList(count); |
| 1423 TypeAnnotation type = pop(); | 1450 TypeAnnotation type = pop(); |
| 1424 _Modifiers modifiers = pop(); | 1451 _Modifiers modifiers = pop(); |
| 1425 Token keyword = modifiers?.finalConstOrVarKeyword; | 1452 Token keyword = modifiers?.finalConstOrVarKeyword; |
| 1426 var variableList = ast.variableDeclarationList( | 1453 var variableList = ast.variableDeclarationList( |
| 1427 null, null, toAnalyzerToken(keyword), type, variables); | 1454 null, null, toAnalyzerToken(keyword), type, variables); |
| 1428 List<Annotation> metadata = pop(); | 1455 List<Annotation> metadata = pop(); |
| 1429 Comment comment = pop(); | 1456 Comment comment = pop(); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 } else if (identical('static', s)) { | 1842 } else if (identical('static', s)) { |
| 1816 staticKeyword = token; | 1843 staticKeyword = token; |
| 1817 } else if (identical('var', s)) { | 1844 } else if (identical('var', s)) { |
| 1818 finalConstOrVarKeyword = token; | 1845 finalConstOrVarKeyword = token; |
| 1819 } else { | 1846 } else { |
| 1820 internalError('Unhandled modifier: $s'); | 1847 internalError('Unhandled modifier: $s'); |
| 1821 } | 1848 } |
| 1822 } | 1849 } |
| 1823 } | 1850 } |
| 1824 } | 1851 } |
| OLD | NEW |