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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10378047: Fix bad precedence for >>> operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/positive_bit_operations_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 9
10 String buildJavaScriptFunction(FunctionElement element, 10 String buildJavaScriptFunction(FunctionElement element,
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 } else { 1114 } else {
1115 visitInvokeStatic(node); 1115 visitInvokeStatic(node);
1116 } 1116 }
1117 } 1117 }
1118 1118
1119 // We want the outcome of bit-operations to be positive. We use the unsigned 1119 // We want the outcome of bit-operations to be positive. We use the unsigned
1120 // shift operator to achieve this. 1120 // shift operator to achieve this.
1121 visitBitInvokeBinary(HBinaryBitOp node, String op) { 1121 visitBitInvokeBinary(HBinaryBitOp node, String op) {
1122 if (node.builtin){ 1122 if (node.builtin){
1123 beginExpression(unsignedShiftPrecedences.precedence); 1123 beginExpression(unsignedShiftPrecedences.precedence);
1124 int oldPrecedence = this.expectedPrecedence;
1125 this.expectedPrecedence = JSPrecedence.SHIFT_PRECEDENCE;
1124 visitInvokeBinary(node, op); 1126 visitInvokeBinary(node, op);
1125 buffer.add(' >>> 0'); 1127 buffer.add(' >>> 0');
1128 this.expectedPrecedence = oldPrecedence;
1126 endExpression(unsignedShiftPrecedences.precedence); 1129 endExpression(unsignedShiftPrecedences.precedence);
1127 } else { 1130 } else {
1128 visitInvokeBinary(node, op); 1131 visitInvokeBinary(node, op);
1129 } 1132 }
1130 } 1133 }
1131 1134
1132 visitInvokeUnary(HInvokeUnary node, String op) { 1135 visitInvokeUnary(HInvokeUnary node, String op) {
1133 if (node.builtin) { 1136 if (node.builtin) {
1134 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); 1137 beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
1135 buffer.add('$op'); 1138 buffer.add('$op');
1136 use(node.operand, JSPrecedence.PREFIX_PRECEDENCE); 1139 use(node.operand, JSPrecedence.PREFIX_PRECEDENCE);
1137 endExpression(JSPrecedence.PREFIX_PRECEDENCE); 1140 endExpression(JSPrecedence.PREFIX_PRECEDENCE);
1138 } else { 1141 } else {
1139 visitInvokeStatic(node); 1142 visitInvokeStatic(node);
1140 } 1143 }
1141 } 1144 }
1142 1145
1143 // We want the outcome of bit-operations to be positive. We use the unsigned 1146 // We want the outcome of bit-operations to be positive. We use the unsigned
1144 // shift operator to achieve this. 1147 // shift operator to achieve this.
1145 visitBitInvokeUnary(HInvokeUnary node, String op) { 1148 visitBitInvokeUnary(HInvokeUnary node, String op) {
1146 if (node.builtin){ 1149 if (node.builtin){
1147 beginExpression(unsignedShiftPrecedences.precedence); 1150 beginExpression(unsignedShiftPrecedences.precedence);
1151 int oldPrecedence = this.expectedPrecedence;
1152 this.expectedPrecedence = JSPrecedence.SHIFT_PRECEDENCE;
1148 visitInvokeUnary(node, op); 1153 visitInvokeUnary(node, op);
1149 buffer.add(' >>> 0'); 1154 buffer.add(' >>> 0');
1155 this.expectedPrecedence = oldPrecedence;
1150 endExpression(unsignedShiftPrecedences.precedence); 1156 endExpression(unsignedShiftPrecedences.precedence);
1151 } else { 1157 } else {
1152 visitInvokeUnary(node, op); 1158 visitInvokeUnary(node, op);
1153 } 1159 }
1154 } 1160 }
1155 1161
1156 visitEquals(HEquals node) { 1162 visitEquals(HEquals node) {
1157 if (node.builtin) { 1163 if (node.builtin) {
1158 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 1164 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
1159 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); 1165 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE);
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 startBailoutSwitch(); 2493 startBailoutSwitch();
2488 } 2494 }
2489 } 2495 }
2490 2496
2491 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2497 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2492 if (labeledBlockInfo.body.start.hasGuards()) { 2498 if (labeledBlockInfo.body.start.hasGuards()) {
2493 endBailoutSwitch(); 2499 endBailoutSwitch();
2494 } 2500 }
2495 } 2501 }
2496 } 2502 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/positive_bit_operations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698