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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/optimization/logical_rewriter.dart

Issue 1050133006: Add structural equality to ConstantExpression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of tree_ir.optimization; 5 part of tree_ir.optimization;
6 6
7 /// Rewrites logical expressions to be more compact in the Tree IR. 7 /// Rewrites logical expressions to be more compact in the Tree IR.
8 /// 8 ///
9 /// In this class an expression is said to occur in "boolean context" if 9 /// In this class an expression is said to occur in "boolean context" if
10 /// its result is immediately applied to boolean conversion. 10 /// its result is immediately applied to boolean conversion.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 e.thenExpression = (e.thenExpression as Not).operand; 305 e.thenExpression = (e.thenExpression as Not).operand;
306 e.elseExpression = (e.elseExpression as Not).operand; 306 e.elseExpression = (e.elseExpression as Not).operand;
307 return new Not(e); 307 return new Not(e);
308 } 308 }
309 return e; 309 return e;
310 } 310 }
311 if (e is Constant && e.value.isBool) { 311 if (e is Constant && e.value.isBool) {
312 // !true ==> false 312 // !true ==> false
313 if (!polarity) { 313 if (!polarity) {
314 values.BoolConstantValue value = e.value; 314 values.BoolConstantValue value = e.value;
315 return new Constant.primitive(value.negate()); 315 return new Constant.bool(value.negate());
316 } 316 }
317 return e; 317 return e;
318 } 318 }
319 e = visitExpression(e); 319 e = visitExpression(e);
320 return polarity ? e : new Not(e); 320 return polarity ? e : new Not(e);
321 } 321 }
322 322
323 bool isTrue(Expression e) { 323 bool isTrue(Expression e) {
324 return e is Constant && e.value.isTrue; 324 return e is Constant && e.value.isTrue;
325 } 325 }
(...skipping 12 matching lines...) Expand all
338 338
339 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) { 339 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) {
340 if (e1 is Not && e2 is Not && liftNots) { 340 if (e1 is Not && e2 is Not && liftNots) {
341 return new Not(new LogicalOperator.and(e1.operand, e2.operand)); 341 return new Not(new LogicalOperator.and(e1.operand, e2.operand));
342 } else { 342 } else {
343 return new LogicalOperator.or(e1, e2); 343 return new LogicalOperator.or(e1, e2);
344 } 344 }
345 } 345 }
346 } 346 }
347 347
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/type_variable_handler.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698