| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 internalError("unhandled identifier: ${node.runtimeType}"); | 413 internalError("unhandled identifier: ${node.runtimeType}"); |
| 414 } | 414 } |
| 415 push(variable); | 415 push(variable); |
| 416 scope[variable.name.name] = variable.name.staticElement = | 416 scope[variable.name.name] = variable.name.staticElement = |
| 417 new AnalyzerLocalVariableElemment(variable); | 417 new AnalyzerLocalVariableElemment(variable); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void endVariablesDeclaration(int count, Token endToken) { | 420 void endVariablesDeclaration(int count, Token endToken) { |
| 421 debugEvent("VariablesDeclaration"); | 421 debugEvent("VariablesDeclaration"); |
| 422 List<VariableDeclaration> variables = popList(count); | 422 List<VariableDeclaration> variables = popList(count); |
| 423 TypeName type = pop(); | 423 TypeAnnotation type = pop(); |
| 424 pop(); // TODO(paulberry): Modifiers. | 424 pop(); // TODO(paulberry): Modifiers. |
| 425 push(ast.variableDeclarationStatement( | 425 push(ast.variableDeclarationStatement( |
| 426 ast.variableDeclarationList(null, null, null, type, variables), | 426 ast.variableDeclarationList(null, null, null, type, variables), |
| 427 toAnalyzerToken(endToken))); | 427 toAnalyzerToken(endToken))); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void handleAssignmentExpression(Token token) { | 430 void handleAssignmentExpression(Token token) { |
| 431 debugEvent("AssignmentExpression"); | 431 debugEvent("AssignmentExpression"); |
| 432 Expression rhs = pop(); | 432 Expression rhs = pop(); |
| 433 Expression lhs = pop(); | 433 Expression lhs = pop(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 549 |
| 550 void handleAsOperator(Token operator, Token endToken) { | 550 void handleAsOperator(Token operator, Token endToken) { |
| 551 debugEvent("AsOperator"); | 551 debugEvent("AsOperator"); |
| 552 TypeAnnotation type = pop(); | 552 TypeAnnotation type = pop(); |
| 553 Expression expression = pop(); | 553 Expression expression = pop(); |
| 554 push(ast.asExpression(expression, toAnalyzerToken(operator), type)); | 554 push(ast.asExpression(expression, toAnalyzerToken(operator), type)); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void handleIsOperator(Token operator, Token not, Token endToken) { | 557 void handleIsOperator(Token operator, Token not, Token endToken) { |
| 558 debugEvent("IsOperator"); | 558 debugEvent("IsOperator"); |
| 559 TypeName type = pop(); | 559 TypeAnnotation type = pop(); |
| 560 Expression expression = pop(); | 560 Expression expression = pop(); |
| 561 push(ast.isExpression( | 561 push(ast.isExpression( |
| 562 expression, toAnalyzerToken(operator), toAnalyzerToken(not), type)); | 562 expression, toAnalyzerToken(operator), toAnalyzerToken(not), type)); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void handleConditionalExpression(Token question, Token colon) { | 565 void handleConditionalExpression(Token question, Token colon) { |
| 566 debugEvent("ConditionalExpression"); | 566 debugEvent("ConditionalExpression"); |
| 567 Expression elseExpression = pop(); | 567 Expression elseExpression = pop(); |
| 568 Expression thenExpression = pop(); | 568 Expression thenExpression = pop(); |
| 569 Expression condition = pop(); | 569 Expression condition = pop(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 } | 665 } |
| 666 | 666 |
| 667 @override | 667 @override |
| 668 void endFunctionTypedFormalParameter( | 668 void endFunctionTypedFormalParameter( |
| 669 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { | 669 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { |
| 670 debugEvent("FunctionTypedFormalParameter"); | 670 debugEvent("FunctionTypedFormalParameter"); |
| 671 | 671 |
| 672 FormalParameterList formalParameters = pop(); | 672 FormalParameterList formalParameters = pop(); |
| 673 TypeParameterList typeParameters = pop(); | 673 TypeParameterList typeParameters = pop(); |
| 674 SimpleIdentifier name = pop(); | 674 SimpleIdentifier name = pop(); |
| 675 TypeName returnType = pop(); | 675 TypeAnnotation returnType = pop(); |
| 676 | 676 |
| 677 { | 677 { |
| 678 _Modifiers modifiers = pop(); | 678 _Modifiers modifiers = pop(); |
| 679 if (modifiers != null) { | 679 if (modifiers != null) { |
| 680 // TODO(scheglov): Report error. | 680 // TODO(scheglov): Report error. |
| 681 internalError('Unexpected modifier. Report an error.'); | 681 internalError('Unexpected modifier. Report an error.'); |
| 682 } | 682 } |
| 683 } | 683 } |
| 684 | 684 |
| 685 pop(); // TODO(paulberry): Metadata. | 685 pop(); // TODO(paulberry): Metadata. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 toAnalyzerToken(endToken))); | 734 toAnalyzerToken(endToken))); |
| 735 } | 735 } |
| 736 | 736 |
| 737 void handleCatchBlock(Token onKeyword, Token catchKeyword) { | 737 void handleCatchBlock(Token onKeyword, Token catchKeyword) { |
| 738 debugEvent("CatchBlock"); | 738 debugEvent("CatchBlock"); |
| 739 Block body = pop(); | 739 Block body = pop(); |
| 740 FormalParameterList catchParameters = popIfNotNull(catchKeyword); | 740 FormalParameterList catchParameters = popIfNotNull(catchKeyword); |
| 741 if (catchKeyword != null) { | 741 if (catchKeyword != null) { |
| 742 exitLocalScope(); | 742 exitLocalScope(); |
| 743 } | 743 } |
| 744 TypeName type = popIfNotNull(onKeyword); | 744 TypeAnnotation type = popIfNotNull(onKeyword); |
| 745 SimpleIdentifier exception; | 745 SimpleIdentifier exception; |
| 746 SimpleIdentifier stackTrace; | 746 SimpleIdentifier stackTrace; |
| 747 if (catchParameters != null) { | 747 if (catchParameters != null) { |
| 748 if (catchParameters.length > 0) { | 748 if (catchParameters.length > 0) { |
| 749 exception = catchParameters.parameters[0].identifier; | 749 exception = catchParameters.parameters[0].identifier; |
| 750 } | 750 } |
| 751 if (catchParameters.length > 1) { | 751 if (catchParameters.length > 1) { |
| 752 stackTrace = catchParameters.parameters[1].identifier; | 752 stackTrace = catchParameters.parameters[1].identifier; |
| 753 } | 753 } |
| 754 } | 754 } |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 } else if (identical('static', s)) { | 1503 } else if (identical('static', s)) { |
| 1504 staticKeyword = token; | 1504 staticKeyword = token; |
| 1505 } else if (identical('var', s)) { | 1505 } else if (identical('var', s)) { |
| 1506 finalConstOrVarKeyword = token; | 1506 finalConstOrVarKeyword = token; |
| 1507 } else { | 1507 } else { |
| 1508 internalError('Unhandled modifier: $s'); | 1508 internalError('Unhandled modifier: $s'); |
| 1509 } | 1509 } |
| 1510 } | 1510 } |
| 1511 } | 1511 } |
| 1512 } | 1512 } |
| OLD | NEW |