| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 228 } |
| 229 | 229 |
| 230 void doPropertyGet(Token token) {} | 230 void doPropertyGet(Token token) {} |
| 231 | 231 |
| 232 void endExpressionStatement(Token token) { | 232 void endExpressionStatement(Token token) { |
| 233 debugEvent("ExpressionStatement"); | 233 debugEvent("ExpressionStatement"); |
| 234 push(ast.expressionStatement(pop(), toAnalyzerToken(token))); | 234 push(ast.expressionStatement(pop(), toAnalyzerToken(token))); |
| 235 } | 235 } |
| 236 | 236 |
| 237 @override | 237 @override |
| 238 void endEmptyFunctionBody(Token semicolon) { | 238 void handleEmptyFunctionBody(Token semicolon) { |
| 239 debugEvent("EmptyFunctionBody"); | 239 debugEvent("EmptyFunctionBody"); |
| 240 // TODO(scheglov) Change the parser to not produce these modifiers. | 240 // TODO(scheglov) Change the parser to not produce these modifiers. |
| 241 pop(); // star | 241 pop(); // star |
| 242 pop(); // async | 242 pop(); // async |
| 243 push(ast.emptyFunctionBody(toAnalyzerToken(semicolon))); | 243 push(ast.emptyFunctionBody(toAnalyzerToken(semicolon))); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void endFunctionBody(int count, Token beginToken, Token endToken) { | 246 void endBlockFunctionBody(int count, Token beginToken, Token endToken) { |
| 247 debugEvent("FunctionBody"); | 247 debugEvent("BlockFunctionBody"); |
| 248 List statements = popList(count); | 248 List statements = popList(count); |
| 249 if (beginToken != null) { | 249 if (beginToken != null) { |
| 250 exitLocalScope(); | 250 exitLocalScope(); |
| 251 } | 251 } |
| 252 Block block = ast.block( | 252 Block block = ast.block( |
| 253 toAnalyzerToken(beginToken), statements, toAnalyzerToken(endToken)); | 253 toAnalyzerToken(beginToken), statements, toAnalyzerToken(endToken)); |
| 254 analyzer.Token star = pop(); | 254 analyzer.Token star = pop(); |
| 255 analyzer.Token asyncKeyword = pop(); | 255 analyzer.Token asyncKeyword = pop(); |
| 256 push(ast.blockFunctionBody(asyncKeyword, star, block)); | 256 push(ast.blockFunctionBody(asyncKeyword, star, block)); |
| 257 } | 257 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 internalError( | 340 internalError( |
| 341 "Unhandled property access: ${identifierOrInvoke.runtimeType}"); | 341 "Unhandled property access: ${identifierOrInvoke.runtimeType}"); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 void handleLiteralInt(Token token) { | 345 void handleLiteralInt(Token token) { |
| 346 debugEvent("LiteralInt"); | 346 debugEvent("LiteralInt"); |
| 347 push(ast.integerLiteral(toAnalyzerToken(token), int.parse(token.lexeme))); | 347 push(ast.integerLiteral(toAnalyzerToken(token), int.parse(token.lexeme))); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void endExpressionFunctionBody(Token arrowToken, Token endToken) { | 350 void handleExpressionFunctionBody(Token arrowToken, Token endToken) { |
| 351 debugEvent("ExpressionFunctionBody"); | 351 debugEvent("ExpressionFunctionBody"); |
| 352 Expression expression = pop(); | 352 Expression expression = pop(); |
| 353 analyzer.Token star = pop(); | 353 analyzer.Token star = pop(); |
| 354 analyzer.Token asyncKeyword = pop(); | 354 analyzer.Token asyncKeyword = pop(); |
| 355 assert(star == null); | 355 assert(star == null); |
| 356 push(ast.expressionFunctionBody(asyncKeyword, toAnalyzerToken(arrowToken), | 356 push(ast.expressionFunctionBody(asyncKeyword, toAnalyzerToken(arrowToken), |
| 357 expression, toAnalyzerToken(endToken))); | 357 expression, toAnalyzerToken(endToken))); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void endReturnStatement( | 360 void endReturnStatement( |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 } else if (identical('static', s)) { | 1604 } else if (identical('static', s)) { |
| 1605 staticKeyword = token; | 1605 staticKeyword = token; |
| 1606 } else if (identical('var', s)) { | 1606 } else if (identical('var', s)) { |
| 1607 finalConstOrVarKeyword = token; | 1607 finalConstOrVarKeyword = token; |
| 1608 } else { | 1608 } else { |
| 1609 internalError('Unhandled modifier: $s'); | 1609 internalError('Unhandled modifier: $s'); |
| 1610 } | 1610 } |
| 1611 } | 1611 } |
| 1612 } | 1612 } |
| 1613 } | 1613 } |
| OLD | NEW |