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 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2855 push(labels); | 2855 push(labels); |
2856 } | 2856 } |
2857 | 2857 |
2858 @override | 2858 @override |
2859 void endSwitchStatement(Token switchKeyword, Token endToken) { | 2859 void endSwitchStatement(Token switchKeyword, Token endToken) { |
2860 debugEvent("SwitchStatement"); | 2860 debugEvent("SwitchStatement"); |
2861 // Do nothing. Handled by [endSwitchBlock]. | 2861 // Do nothing. Handled by [endSwitchBlock]. |
2862 } | 2862 } |
2863 | 2863 |
2864 @override | 2864 @override |
2865 void endSwitchBlock(int caseCount, Token beginToken, Token endToken) { | 2865 void endSwitchBlock( |
| 2866 int caseCount, Token beginToken, Token endToken, Token switchKeyword) { |
2866 debugEvent("SwitchBlock"); | 2867 debugEvent("SwitchBlock"); |
2867 List<SwitchCase> cases = | 2868 List<SwitchCase> cases = |
2868 new List<SwitchCase>.filled(caseCount, null, growable: true); | 2869 new List<SwitchCase>.filled(caseCount, null, growable: true); |
2869 for (int i = caseCount - 1; i >= 0; i--) { | 2870 for (int i = caseCount - 1; i >= 0; i--) { |
2870 List<Label> labels = pop(); | 2871 List<Label> labels = pop(); |
2871 SwitchCase current = cases[i] = pop(); | 2872 SwitchCase current = cases[i] = pop(); |
2872 for (Label label in labels) { | 2873 for (Label label in labels) { |
2873 JumpTarget target = switchScope.lookupLabel(label.name); | 2874 JumpTarget target = switchScope.lookupLabel(label.name); |
2874 if (target != null) { | 2875 if (target != null) { |
2875 target.resolveGotos(current); | 2876 target.resolveGotos(current); |
(...skipping 30 matching lines...) Expand all Loading... |
2906 lastNode is! ReturnStatement && | 2907 lastNode is! ReturnStatement && |
2907 lastNode is! Throw) { | 2908 lastNode is! Throw) { |
2908 block.addStatement( | 2909 block.addStatement( |
2909 new ExpressionStatement(buildFallThroughError(current.fileOffset))); | 2910 new ExpressionStatement(buildFallThroughError(current.fileOffset))); |
2910 } | 2911 } |
2911 } | 2912 } |
2912 JumpTarget target = exitBreakTarget(); | 2913 JumpTarget target = exitBreakTarget(); |
2913 exitSwitchScope(); | 2914 exitSwitchScope(); |
2914 exitLocalScope(); | 2915 exitLocalScope(); |
2915 Expression expression = popForValue(); | 2916 Expression expression = popForValue(); |
2916 Statement result = new KernelSwitchStatement(expression, cases); | 2917 Statement result = new KernelSwitchStatement(expression, cases) |
| 2918 ..fileOffset = switchKeyword.charOffset; |
2917 if (target.hasUsers) { | 2919 if (target.hasUsers) { |
2918 result = new KernelLabeledStatement(result); | 2920 result = new KernelLabeledStatement(result); |
2919 target.resolveBreaks(result); | 2921 target.resolveBreaks(result); |
2920 } | 2922 } |
2921 exitLoopOrSwitch(result); | 2923 exitLoopOrSwitch(result); |
2922 } | 2924 } |
2923 | 2925 |
2924 @override | 2926 @override |
2925 void handleCaseMatch(Token caseKeyword, Token colon) { | 2927 void handleCaseMatch(Token caseKeyword, Token colon) { |
2926 debugEvent("CaseMatch"); | 2928 debugEvent("CaseMatch"); |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3818 return AsyncMarker.Async; | 3820 return AsyncMarker.Async; |
3819 } else { | 3821 } else { |
3820 assert(identical(starToken.stringValue, "*")); | 3822 assert(identical(starToken.stringValue, "*")); |
3821 return AsyncMarker.AsyncStar; | 3823 return AsyncMarker.AsyncStar; |
3822 } | 3824 } |
3823 } else { | 3825 } else { |
3824 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3826 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3825 asyncToken.charOffset, null); | 3827 asyncToken.charOffset, null); |
3826 } | 3828 } |
3827 } | 3829 } |
OLD | NEW |