| OLD | NEW |
| 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 library tree_ir.optimization.logical_rewriter; | 5 library tree_ir.optimization.logical_rewriter; |
| 6 | 6 |
| 7 import '../tree_ir_nodes.dart'; | 7 import '../tree_ir_nodes.dart'; |
| 8 import 'optimization.dart' show Pass; | 8 import 'optimization.dart' show Pass; |
| 9 import '../../constants/values.dart' as values; | 9 import '../../constants/values.dart' as values; |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 bool operatorReturnsBool(BuiltinOperator operator) { | 241 bool operatorReturnsBool(BuiltinOperator operator) { |
| 242 switch (operator) { | 242 switch (operator) { |
| 243 case BuiltinOperator.StrictEq: | 243 case BuiltinOperator.StrictEq: |
| 244 case BuiltinOperator.StrictNeq: | 244 case BuiltinOperator.StrictNeq: |
| 245 case BuiltinOperator.LooseEq: | 245 case BuiltinOperator.LooseEq: |
| 246 case BuiltinOperator.LooseNeq: | 246 case BuiltinOperator.LooseNeq: |
| 247 case BuiltinOperator.NumLt: | 247 case BuiltinOperator.NumLt: |
| 248 case BuiltinOperator.NumLe: | 248 case BuiltinOperator.NumLe: |
| 249 case BuiltinOperator.NumGt: | 249 case BuiltinOperator.NumGt: |
| 250 case BuiltinOperator.NumGe: | 250 case BuiltinOperator.NumGe: |
| 251 case BuiltinOperator.IsNumber: |
| 252 case BuiltinOperator.IsNotNumber: |
| 253 case BuiltinOperator.IsFloor: |
| 254 case BuiltinOperator.IsNumberAndFloor: |
| 251 return true; | 255 return true; |
| 252 default: | 256 default: |
| 253 return false; | 257 return false; |
| 254 } | 258 } |
| 255 } | 259 } |
| 256 | 260 |
| 257 BuiltinOperator negateBuiltin(BuiltinOperator operator) { | 261 BuiltinOperator negateBuiltin(BuiltinOperator operator) { |
| 258 switch (operator) { | 262 switch (operator) { |
| 259 case BuiltinOperator.StrictEq: return BuiltinOperator.StrictNeq; | 263 case BuiltinOperator.StrictEq: return BuiltinOperator.StrictNeq; |
| 260 case BuiltinOperator.StrictNeq: return BuiltinOperator.StrictEq; | 264 case BuiltinOperator.StrictNeq: return BuiltinOperator.StrictEq; |
| 261 case BuiltinOperator.LooseEq: return BuiltinOperator.LooseNeq; | 265 case BuiltinOperator.LooseEq: return BuiltinOperator.LooseNeq; |
| 262 case BuiltinOperator.LooseNeq: return BuiltinOperator.LooseEq; | 266 case BuiltinOperator.LooseNeq: return BuiltinOperator.LooseEq; |
| 267 case BuiltinOperator.IsNumber: return BuiltinOperator.IsNotNumber; |
| 268 case BuiltinOperator.IsNotNumber: return BuiltinOperator.IsNumber; |
| 263 | 269 |
| 264 // Because of NaN, these do not have a negated form. | 270 // Because of NaN, these do not have a negated form. |
| 265 case BuiltinOperator.NumLt: | 271 case BuiltinOperator.NumLt: |
| 266 case BuiltinOperator.NumLe: | 272 case BuiltinOperator.NumLe: |
| 267 case BuiltinOperator.NumGt: | 273 case BuiltinOperator.NumGt: |
| 268 case BuiltinOperator.NumGe: | 274 case BuiltinOperator.NumGe: |
| 269 return null; | 275 return null; |
| 270 | 276 |
| 271 default: | 277 default: |
| 272 return null; | 278 return null; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 409 |
| 404 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) { | 410 Expression makeOr(Expression e1, Expression e2, {bool liftNots: true}) { |
| 405 if (e1 is Not && e2 is Not && liftNots) { | 411 if (e1 is Not && e2 is Not && liftNots) { |
| 406 return new Not(new LogicalOperator.and(e1.operand, e2.operand)); | 412 return new Not(new LogicalOperator.and(e1.operand, e2.operand)); |
| 407 } else { | 413 } else { |
| 408 return new LogicalOperator.or(e1, e2); | 414 return new LogicalOperator.or(e1, e2); |
| 409 } | 415 } |
| 410 } | 416 } |
| 411 } | 417 } |
| 412 | 418 |
| OLD | NEW |