Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2750013002: [kernel] Debugging of switch statement (Closed)
Patch Set: Take #2: Update switch case to include list of positions Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 '../parser/parser.dart' show FormalParameterType, optional; 7 import '../parser/parser.dart' show FormalParameterType, optional;
8 8
9 import '../parser/error_kind.dart' show ErrorKind; 9 import '../parser/error_kind.dart' show ErrorKind;
10 10
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 void handleStringPart(Token token) { 804 void handleStringPart(Token token) {
805 debugEvent("StringPart"); 805 debugEvent("StringPart");
806 push(token); 806 push(token);
807 } 807 }
808 808
809 @override 809 @override
810 void endLiteralString(int interpolationCount, Token endToken) { 810 void endLiteralString(int interpolationCount, Token endToken) {
811 debugEvent("endLiteralString"); 811 debugEvent("endLiteralString");
812 if (interpolationCount == 0) { 812 if (interpolationCount == 0) {
813 Token token = pop(); 813 Token token = pop();
814 push(new StringLiteral(unescapeString(token.lexeme))); 814 push(new StringLiteral(unescapeString(token.lexeme))
815 ..fileOffset = token.charOffset);
815 } else { 816 } else {
816 List parts = popList(1 + interpolationCount * 2); 817 List parts = popList(1 + interpolationCount * 2);
817 Token first = parts.first; 818 Token first = parts.first;
818 Token last = parts.last; 819 Token last = parts.last;
819 Quote quote = analyzeQuote(first.lexeme); 820 Quote quote = analyzeQuote(first.lexeme);
820 List<Expression> expressions = <Expression>[]; 821 List<Expression> expressions = <Expression>[];
821 expressions 822 expressions
822 .add(new StringLiteral(unescapeFirstStringPart(first.lexeme, quote))); 823 .add(new StringLiteral(unescapeFirstStringPart(first.lexeme, quote)));
823 for (int i = 1; i < parts.length - 1; i++) { 824 for (int i = 1; i < parts.length - 1; i++) {
824 var part = parts[i]; 825 var part = parts[i];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 expressions.add(part); 859 expressions.add(part);
859 } 860 }
860 } 861 }
861 } 862 }
862 push(new StringConcatenation(expressions ?? parts)); 863 push(new StringConcatenation(expressions ?? parts));
863 } 864 }
864 865
865 @override 866 @override
866 void handleLiteralInt(Token token) { 867 void handleLiteralInt(Token token) {
867 debugEvent("LiteralInt"); 868 debugEvent("LiteralInt");
868 push(new IntLiteral(int.parse(token.lexeme))); 869 push(
870 new IntLiteral(int.parse(token.lexeme))..fileOffset = token.charOffset);
869 } 871 }
870 872
871 @override 873 @override
872 void handleEmptyFunctionBody(Token semicolon) { 874 void handleEmptyFunctionBody(Token semicolon) {
873 debugEvent("ExpressionFunctionBody"); 875 debugEvent("ExpressionFunctionBody");
874 endBlockFunctionBody(0, null, semicolon); 876 endBlockFunctionBody(0, null, semicolon);
875 } 877 }
876 878
877 @override 879 @override
878 void handleExpressionFunctionBody(Token arrowToken, Token endToken) { 880 void handleExpressionFunctionBody(Token arrowToken, Token endToken) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 push(new ListLiteral(expressions, 1099 push(new ListLiteral(expressions,
1098 typeArgument: typeArgument, isConst: constKeyword != null) 1100 typeArgument: typeArgument, isConst: constKeyword != null)
1099 ..fileOffset = constKeyword?.charOffset ?? beginToken.charOffset); 1101 ..fileOffset = constKeyword?.charOffset ?? beginToken.charOffset);
1100 } 1102 }
1101 1103
1102 @override 1104 @override
1103 void handleLiteralBool(Token token) { 1105 void handleLiteralBool(Token token) {
1104 debugEvent("LiteralBool"); 1106 debugEvent("LiteralBool");
1105 bool value = optional("true", token); 1107 bool value = optional("true", token);
1106 assert(value || optional("false", token)); 1108 assert(value || optional("false", token));
1107 push(new BoolLiteral(value)); 1109 push(new BoolLiteral(value)..fileOffset = token.charOffset);
1108 } 1110 }
1109 1111
1110 @override 1112 @override
1111 void handleLiteralDouble(Token token) { 1113 void handleLiteralDouble(Token token) {
1112 debugEvent("LiteralDouble"); 1114 debugEvent("LiteralDouble");
1113 push(new DoubleLiteral(double.parse(token.lexeme))); 1115 push(new DoubleLiteral(double.parse(token.lexeme))..fileOffset = token.charO ffset);
1114 } 1116 }
1115 1117
1116 @override 1118 @override
1117 void handleLiteralNull(Token token) { 1119 void handleLiteralNull(Token token) {
1118 debugEvent("LiteralNull"); 1120 debugEvent("LiteralNull");
1119 push(new NullLiteral()); 1121 push(new NullLiteral()..fileOffset = token.charOffset);
1120 } 1122 }
1121 1123
1122 @override 1124 @override
1123 void handleLiteralMap( 1125 void handleLiteralMap(
1124 int count, Token beginToken, Token constKeyword, Token endToken) { 1126 int count, Token beginToken, Token constKeyword, Token endToken) {
1125 debugEvent("LiteralMap"); 1127 debugEvent("LiteralMap");
1126 List<MapEntry> entries = popList(count) ?? <MapEntry>[]; 1128 List<MapEntry> entries = popList(count) ?? <MapEntry>[];
1127 List<DartType> typeArguments = pop(); 1129 List<DartType> typeArguments = pop();
1128 DartType keyType = const DynamicType(); 1130 DartType keyType = const DynamicType();
1129 DartType valueType = const DynamicType(); 1131 DartType valueType = const DynamicType();
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 int expressionCount, 2081 int expressionCount,
2080 Token defaultKeyword, 2082 Token defaultKeyword,
2081 int statementCount, 2083 int statementCount,
2082 Token firstToken, 2084 Token firstToken,
2083 Token endToken) { 2085 Token endToken) {
2084 debugEvent("SwitchCase"); 2086 debugEvent("SwitchCase");
2085 Block block = popBlock(statementCount); 2087 Block block = popBlock(statementCount);
2086 exitLocalScope(); 2088 exitLocalScope();
2087 List<Label> labels = pop(); 2089 List<Label> labels = pop();
2088 List<Expression> expressions = pop(); 2090 List<Expression> expressions = pop();
2089 push(new SwitchCase(expressions, block, isDefault: defaultKeyword != null) 2091 List<int> expressionsOffsets = <int>[];
Kevin Millikin (Google) 2017/03/20 12:29:47 expressionsOffsets ==> expressionOffsets
jensj 2017/03/21 10:06:19 Done.
2090 ..fileOffset = firstToken.charOffset); 2092 for (Expression expression in expressions) {
2093 expressionsOffsets.add(expression.fileOffset);
2094 }
2095 push(new SwitchCase(expressions, expressionsOffsets, block,
2096 isDefault: defaultKeyword != null)..fileOffset = firstToken.charOffset);
2091 push(labels); 2097 push(labels);
2092 } 2098 }
2093 2099
2094 @override 2100 @override
2095 void endSwitchStatement(Token switchKeyword, Token endToken) { 2101 void endSwitchStatement(Token switchKeyword, Token endToken) {
2096 debugEvent("SwitchStatement"); 2102 debugEvent("SwitchStatement");
2097 // Do nothing. Handled by [endSwitchBlock]. 2103 // Do nothing. Handled by [endSwitchBlock].
2098 } 2104 }
2099 2105
2100 @override 2106 @override
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 } else if (node is PrefixBuilder) { 2775 } else if (node is PrefixBuilder) {
2770 return node.name; 2776 return node.name;
2771 } else if (node is ThisAccessor) { 2777 } else if (node is ThisAccessor) {
2772 return node.isSuper ? "super" : "this"; 2778 return node.isSuper ? "super" : "this";
2773 } else if (node is BuilderAccessor) { 2779 } else if (node is BuilderAccessor) {
2774 return node.plainNameForRead; 2780 return node.plainNameForRead;
2775 } else { 2781 } else {
2776 return internalError("Unhandled: ${node.runtimeType}"); 2782 return internalError("Unhandled: ${node.runtimeType}");
2777 } 2783 }
2778 } 2784 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698