| OLD | NEW |
| 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 interface Operation { | 5 interface Operation { |
| 6 final SourceString name; | 6 final SourceString name; |
| 7 bool isUserDefinable(); | 7 bool isUserDefinable(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 interface UnaryOperation extends Operation { | 10 interface UnaryOperation extends Operation { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 NumConstant leftNum = left; | 228 NumConstant leftNum = left; |
| 229 NumConstant rightNum = right; | 229 NumConstant rightNum = right; |
| 230 return new DoubleConstant(leftNum.value + rightNum.value); | 230 return new DoubleConstant(leftNum.value + rightNum.value); |
| 231 } else if (left.isString() && !right.isObject()) { | 231 } else if (left.isString() && !right.isObject()) { |
| 232 PrimitiveConstant primitiveRight = right; | 232 PrimitiveConstant primitiveRight = right; |
| 233 DartString rightDartString = primitiveRight.toDartString(); | 233 DartString rightDartString = primitiveRight.toDartString(); |
| 234 StringConstant leftString = left; | 234 StringConstant leftString = left; |
| 235 if (rightDartString.isEmpty()) { | 235 if (rightDartString.isEmpty()) { |
| 236 return left; | 236 return left; |
| 237 } else if (leftString.value.isEmpty()) { | 237 } else if (leftString.value.isEmpty()) { |
| 238 // TODO(floitsch): There is no right.node. Find a node some other way. |
| 238 return new StringConstant(rightDartString, right.node); | 239 return new StringConstant(rightDartString, right.node); |
| 239 } else { | 240 } else { |
| 240 DartString concatenated = | 241 DartString concatenated = |
| 241 new ConsDartString(leftString.value, rightDartString); | 242 new ConsDartString(leftString.value, rightDartString); |
| 242 return new StringConstant(concatenated, leftString.node); | 243 return new StringConstant(concatenated, leftString.node); |
| 243 } | 244 } |
| 244 } else { | 245 } else { |
| 245 return null; | 246 return null; |
| 246 } | 247 } |
| 247 } | 248 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 bool isUserDefinable() => false; | 314 bool isUserDefinable() => false; |
| 314 const IdentityOperation(); | 315 const IdentityOperation(); |
| 315 Constant fold(Constant left, Constant right) { | 316 Constant fold(Constant left, Constant right) { |
| 316 // In order to preserve runtime semantics which says that NaN !== NaN don't | 317 // In order to preserve runtime semantics which says that NaN !== NaN don't |
| 317 // constant fold NaN === NaN. Otherwise the output depends on inlined | 318 // constant fold NaN === NaN. Otherwise the output depends on inlined |
| 318 // variables and other optimizations. | 319 // variables and other optimizations. |
| 319 if (left.isNaN() && right.isNaN()) return null; | 320 if (left.isNaN() && right.isNaN()) return null; |
| 320 return new BoolConstant(left == right); | 321 return new BoolConstant(left == right); |
| 321 } | 322 } |
| 322 } | 323 } |
| OLD | NEW |