| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 const DART_CONSTANT_SYSTEM = const DartConstantSystem(); | 7 const DART_CONSTANT_SYSTEM = const DartConstantSystem(); |
| 8 | 8 |
| 9 class BitNotOperation implements UnaryOperation { | 9 class BitNotOperation implements UnaryOperation { |
| 10 final String name = '~'; | 10 final String name = '~'; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (left.isInt && right.isInt) { | 224 if (left.isInt && right.isInt) { |
| 225 IntConstant leftInt = left; | 225 IntConstant leftInt = left; |
| 226 IntConstant rightInt = right; | 226 IntConstant rightInt = right; |
| 227 int result = leftInt.value + rightInt.value; | 227 int result = leftInt.value + rightInt.value; |
| 228 return DART_CONSTANT_SYSTEM.createInt(result); | 228 return DART_CONSTANT_SYSTEM.createInt(result); |
| 229 } else if (left.isNum && right.isNum) { | 229 } else if (left.isNum && right.isNum) { |
| 230 NumConstant leftNum = left; | 230 NumConstant leftNum = left; |
| 231 NumConstant rightNum = right; | 231 NumConstant rightNum = right; |
| 232 double result = leftNum.value + rightNum.value; | 232 double result = leftNum.value + rightNum.value; |
| 233 return DART_CONSTANT_SYSTEM.createDouble(result); | 233 return DART_CONSTANT_SYSTEM.createDouble(result); |
| 234 } else if (left.isString && right.isString) { |
| 235 StringConstant leftString = left; |
| 236 StringConstant rightString = right; |
| 237 DartString result = |
| 238 new DartString.concat(leftString.value, rightString.value); |
| 239 return DART_CONSTANT_SYSTEM.createString(result); |
| 234 } else { | 240 } else { |
| 235 return null; | 241 return null; |
| 236 } | 242 } |
| 237 } | 243 } |
| 238 apply(left, right) => left + right; | 244 apply(left, right) => left + right; |
| 239 } | 245 } |
| 240 | 246 |
| 241 abstract class RelationalNumOperation implements BinaryOperation { | 247 abstract class RelationalNumOperation implements BinaryOperation { |
| 242 const RelationalNumOperation(); | 248 const RelationalNumOperation(); |
| 243 Constant fold(Constant left, Constant right) { | 249 Constant fold(Constant left, Constant right) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 bool isInt(Constant constant) => constant.isInt; | 366 bool isInt(Constant constant) => constant.isInt; |
| 361 bool isDouble(Constant constant) => constant.isDouble; | 367 bool isDouble(Constant constant) => constant.isDouble; |
| 362 bool isString(Constant constant) => constant.isString; | 368 bool isString(Constant constant) => constant.isString; |
| 363 bool isBool(Constant constant) => constant.isBool; | 369 bool isBool(Constant constant) => constant.isBool; |
| 364 bool isNull(Constant constant) => constant.isNull; | 370 bool isNull(Constant constant) => constant.isNull; |
| 365 | 371 |
| 366 bool isSubtype(Compiler compiler, DartType s, DartType t) { | 372 bool isSubtype(Compiler compiler, DartType s, DartType t) { |
| 367 return compiler.types.isSubtype(s, t); | 373 return compiler.types.isSubtype(s, t); |
| 368 } | 374 } |
| 369 } | 375 } |
| OLD | NEW |