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.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
9 | 9 |
10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 forKeyword.charOffset, uri); | 1501 forKeyword.charOffset, uri); |
1502 } | 1502 } |
1503 exitLocalScope(); | 1503 exitLocalScope(); |
1504 JumpTarget continueTarget = exitContinueTarget(); | 1504 JumpTarget continueTarget = exitContinueTarget(); |
1505 JumpTarget breakTarget = exitBreakTarget(); | 1505 JumpTarget breakTarget = exitBreakTarget(); |
1506 if (continueTarget.hasUsers) { | 1506 if (continueTarget.hasUsers) { |
1507 body = new KernelLabeledStatement(body); | 1507 body = new KernelLabeledStatement(body); |
1508 continueTarget.resolveContinues(body); | 1508 continueTarget.resolveContinues(body); |
1509 } | 1509 } |
1510 Statement result = | 1510 Statement result = |
1511 new KernelForStatement(variables, condition, updates, body); | 1511 new KernelForStatement(variables, condition, updates, body) |
| 1512 ..fileOffset = forKeyword.charOffset; |
1512 if (begin != null) { | 1513 if (begin != null) { |
1513 result = new KernelBlock(<Statement>[begin, result]); | 1514 result = new KernelBlock(<Statement>[begin, result]); |
1514 } | 1515 } |
1515 if (breakTarget.hasUsers) { | 1516 if (breakTarget.hasUsers) { |
1516 result = new KernelLabeledStatement(result); | 1517 result = new KernelLabeledStatement(result); |
1517 breakTarget.resolveBreaks(result); | 1518 breakTarget.resolveBreaks(result); |
1518 } | 1519 } |
1519 exitLoopOrSwitch(result); | 1520 exitLoopOrSwitch(result); |
1520 } | 1521 } |
1521 | 1522 |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 Token doKeyword, Token whileKeyword, Token endToken) { | 2550 Token doKeyword, Token whileKeyword, Token endToken) { |
2550 debugEvent("DoWhileStatement"); | 2551 debugEvent("DoWhileStatement"); |
2551 Expression condition = popForValue(); | 2552 Expression condition = popForValue(); |
2552 Statement body = popStatement(); | 2553 Statement body = popStatement(); |
2553 JumpTarget continueTarget = exitContinueTarget(); | 2554 JumpTarget continueTarget = exitContinueTarget(); |
2554 JumpTarget breakTarget = exitBreakTarget(); | 2555 JumpTarget breakTarget = exitBreakTarget(); |
2555 if (continueTarget.hasUsers) { | 2556 if (continueTarget.hasUsers) { |
2556 body = new KernelLabeledStatement(body); | 2557 body = new KernelLabeledStatement(body); |
2557 continueTarget.resolveContinues(body); | 2558 continueTarget.resolveContinues(body); |
2558 } | 2559 } |
2559 Statement result = new KernelDoStatement(body, condition); | 2560 Statement result = new KernelDoStatement(body, condition) |
| 2561 ..fileOffset = doKeyword.charOffset; |
2560 if (breakTarget.hasUsers) { | 2562 if (breakTarget.hasUsers) { |
2561 result = new KernelLabeledStatement(result); | 2563 result = new KernelLabeledStatement(result); |
2562 breakTarget.resolveBreaks(result); | 2564 breakTarget.resolveBreaks(result); |
2563 } | 2565 } |
2564 exitLoopOrSwitch(result); | 2566 exitLoopOrSwitch(result); |
2565 } | 2567 } |
2566 | 2568 |
2567 @override | 2569 @override |
2568 void beginForInExpression(Token token) { | 2570 void beginForInExpression(Token token) { |
2569 enterLocalScope(scope.parent); | 2571 enterLocalScope(scope.parent); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2617 .buildAssignment(new VariableGet(variable), voidContext: true))), | 2619 .buildAssignment(new VariableGet(variable), voidContext: true))), |
2618 body); | 2620 body); |
2619 } else { | 2621 } else { |
2620 variable = new VariableDeclaration.forValue( | 2622 variable = new VariableDeclaration.forValue( |
2621 deprecated_buildCompileTimeError("Expected lvalue, but got ${lvalue}", | 2623 deprecated_buildCompileTimeError("Expected lvalue, but got ${lvalue}", |
2622 forToken.next.next.charOffset)); | 2624 forToken.next.next.charOffset)); |
2623 } | 2625 } |
2624 Statement result = new KernelForInStatement( | 2626 Statement result = new KernelForInStatement( |
2625 variable, expression, body, declaresVariable, | 2627 variable, expression, body, declaresVariable, |
2626 isAsync: awaitToken != null) | 2628 isAsync: awaitToken != null) |
2627 ..fileOffset = body.fileOffset; | 2629 ..fileOffset = forToken.charOffset |
| 2630 ..bodyOffset = body.fileOffset; |
2628 if (breakTarget.hasUsers) { | 2631 if (breakTarget.hasUsers) { |
2629 result = new KernelLabeledStatement(result); | 2632 result = new KernelLabeledStatement(result); |
2630 breakTarget.resolveBreaks(result); | 2633 breakTarget.resolveBreaks(result); |
2631 } | 2634 } |
2632 exitLoopOrSwitch(result); | 2635 exitLoopOrSwitch(result); |
2633 } | 2636 } |
2634 | 2637 |
2635 @override | 2638 @override |
2636 void handleLabel(Token token) { | 2639 void handleLabel(Token token) { |
2637 debugEvent("Label"); | 2640 debugEvent("Label"); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2696 void endWhileStatement(Token whileKeyword, Token endToken) { | 2699 void endWhileStatement(Token whileKeyword, Token endToken) { |
2697 debugEvent("WhileStatement"); | 2700 debugEvent("WhileStatement"); |
2698 Statement body = popStatement(); | 2701 Statement body = popStatement(); |
2699 Expression condition = popForValue(); | 2702 Expression condition = popForValue(); |
2700 JumpTarget continueTarget = exitContinueTarget(); | 2703 JumpTarget continueTarget = exitContinueTarget(); |
2701 JumpTarget breakTarget = exitBreakTarget(); | 2704 JumpTarget breakTarget = exitBreakTarget(); |
2702 if (continueTarget.hasUsers) { | 2705 if (continueTarget.hasUsers) { |
2703 body = new KernelLabeledStatement(body); | 2706 body = new KernelLabeledStatement(body); |
2704 continueTarget.resolveContinues(body); | 2707 continueTarget.resolveContinues(body); |
2705 } | 2708 } |
2706 Statement result = new KernelWhileStatement(condition, body); | 2709 Statement result = new KernelWhileStatement(condition, body) |
| 2710 ..fileOffset = whileKeyword.charOffset; |
2707 if (breakTarget.hasUsers) { | 2711 if (breakTarget.hasUsers) { |
2708 result = new KernelLabeledStatement(result); | 2712 result = new KernelLabeledStatement(result); |
2709 breakTarget.resolveBreaks(result); | 2713 breakTarget.resolveBreaks(result); |
2710 } | 2714 } |
2711 exitLoopOrSwitch(result); | 2715 exitLoopOrSwitch(result); |
2712 } | 2716 } |
2713 | 2717 |
2714 @override | 2718 @override |
2715 void handleEmptyStatement(Token token) { | 2719 void handleEmptyStatement(Token token) { |
2716 debugEvent("EmptyStatement"); | 2720 debugEvent("EmptyStatement"); |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3802 return AsyncMarker.Async; | 3806 return AsyncMarker.Async; |
3803 } else { | 3807 } else { |
3804 assert(identical(starToken.stringValue, "*")); | 3808 assert(identical(starToken.stringValue, "*")); |
3805 return AsyncMarker.AsyncStar; | 3809 return AsyncMarker.AsyncStar; |
3806 } | 3810 } |
3807 } else { | 3811 } else { |
3808 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3812 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3809 asyncToken.charOffset, null); | 3813 asyncToken.charOffset, null); |
3810 } | 3814 } |
3811 } | 3815 } |
OLD | NEW |