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

Side by Side Diff: pkg/kernel/lib/text/ast_to_text.dart

Issue 2949753002: Print static types of conditional expressions. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « pkg/front_end/testcases/void-methods.dart.strong.expect ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library kernel.ast_to_text; 4 library kernel.ast_to_text;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 8
9 class Namer<T> { 9 class Namer<T> {
10 int index = 0; 10 int index = 0;
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 832
833 visitLogicalExpression(LogicalExpression node) { 833 visitLogicalExpression(LogicalExpression node) {
834 int precedence = Precedence.binaryPrecedence[node.operator]; 834 int precedence = Precedence.binaryPrecedence[node.operator];
835 writeExpression(node.left, precedence); 835 writeExpression(node.left, precedence);
836 writeSpaced(node.operator); 836 writeSpaced(node.operator);
837 writeExpression(node.right, precedence + 1); 837 writeExpression(node.right, precedence + 1);
838 } 838 }
839 839
840 visitConditionalExpression(ConditionalExpression node) { 840 visitConditionalExpression(ConditionalExpression node) {
841 writeExpression(node.condition, Precedence.LOGICAL_OR); 841 writeExpression(node.condition, Precedence.LOGICAL_OR);
842 writeSpaced('?'); 842 ensureSpace();
843 write('?');
844 writeStaticType(node.staticType);
845 writeSpace();
843 writeExpression(node.then); 846 writeExpression(node.then);
844 writeSpaced(':'); 847 writeSpaced(':');
845 writeExpression(node.otherwise); 848 writeExpression(node.otherwise);
846 } 849 }
847 850
848 String getEscapedCharacter(int codeUnit) { 851 String getEscapedCharacter(int codeUnit) {
849 switch (codeUnit) { 852 switch (codeUnit) {
850 case 9: 853 case 9:
851 return r'\t'; 854 return r'\t';
852 case 10: 855 case 10:
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 void writeInterfaceTarget(Name name, Member target) { 1110 void writeInterfaceTarget(Name name, Member target) {
1108 if (target != null) { 1111 if (target != null) {
1109 writeSymbol('{'); 1112 writeSymbol('{');
1110 writeMemberReference(target); 1113 writeMemberReference(target);
1111 writeSymbol('}'); 1114 writeSymbol('}');
1112 } else { 1115 } else {
1113 writeName(name); 1116 writeName(name);
1114 } 1117 }
1115 } 1118 }
1116 1119
1120 void writeStaticType(DartType type) {
1121 if (type != null) {
1122 writeSymbol('{');
1123 writeType(type);
1124 writeSymbol('}');
1125 }
1126 }
1127
1117 visitPropertyGet(PropertyGet node) { 1128 visitPropertyGet(PropertyGet node) {
1118 writeExpression(node.receiver, Precedence.PRIMARY); 1129 writeExpression(node.receiver, Precedence.PRIMARY);
1119 writeSymbol('.'); 1130 writeSymbol('.');
1120 writeInterfaceTarget(node.name, node.interfaceTarget); 1131 writeInterfaceTarget(node.name, node.interfaceTarget);
1121 } 1132 }
1122 1133
1123 visitPropertySet(PropertySet node) { 1134 visitPropertySet(PropertySet node) {
1124 writeExpression(node.receiver, Precedence.PRIMARY); 1135 writeExpression(node.receiver, Precedence.PRIMARY);
1125 writeSymbol('.'); 1136 writeSymbol('.');
1126 writeInterfaceTarget(node.name, node.interfaceTarget); 1137 writeInterfaceTarget(node.name, node.interfaceTarget);
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 } 1666 }
1656 throw 'illegal ProcedureKind: $kind'; 1667 throw 'illegal ProcedureKind: $kind';
1657 } 1668 }
1658 1669
1659 class ExpressionPrinter { 1670 class ExpressionPrinter {
1660 final Printer writeer; 1671 final Printer writeer;
1661 final int minimumPrecedence; 1672 final int minimumPrecedence;
1662 1673
1663 ExpressionPrinter(this.writeer, this.minimumPrecedence); 1674 ExpressionPrinter(this.writeer, this.minimumPrecedence);
1664 } 1675 }
OLDNEW
« no previous file with comments | « pkg/front_end/testcases/void-methods.dart.strong.expect ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698