| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 if (left.isInt && right.isInt) { | 226 if (left.isInt && right.isInt) { |
| 227 IntConstantValue leftInt = left; | 227 IntConstantValue leftInt = left; |
| 228 IntConstantValue rightInt = right; | 228 IntConstantValue rightInt = right; |
| 229 int result = leftInt.primitiveValue + rightInt.primitiveValue; | 229 int result = leftInt.primitiveValue + rightInt.primitiveValue; |
| 230 return DART_CONSTANT_SYSTEM.createInt(result); | 230 return DART_CONSTANT_SYSTEM.createInt(result); |
| 231 } else if (left.isNum && right.isNum) { | 231 } else if (left.isNum && right.isNum) { |
| 232 NumConstantValue leftNum = left; | 232 NumConstantValue leftNum = left; |
| 233 NumConstantValue rightNum = right; | 233 NumConstantValue rightNum = right; |
| 234 double result = leftNum.primitiveValue + rightNum.primitiveValue; | 234 double result = leftNum.primitiveValue + rightNum.primitiveValue; |
| 235 return DART_CONSTANT_SYSTEM.createDouble(result); | 235 return DART_CONSTANT_SYSTEM.createDouble(result); |
| 236 } else if (left.isString && right.isString) { |
| 237 StringConstantValue leftString = left; |
| 238 StringConstantValue rightString = right; |
| 239 DartString result = new DartString.concat(leftString.primitiveValue, |
| 240 rightString.primitiveValue); |
| 241 return DART_CONSTANT_SYSTEM.createString(result); |
| 236 } else { | 242 } else { |
| 237 return null; | 243 return null; |
| 238 } | 244 } |
| 239 } | 245 } |
| 240 apply(left, right) => left + right; | 246 apply(left, right) => left + right; |
| 241 } | 247 } |
| 242 | 248 |
| 243 abstract class RelationalNumOperation implements BinaryOperation { | 249 abstract class RelationalNumOperation implements BinaryOperation { |
| 244 const RelationalNumOperation(); | 250 const RelationalNumOperation(); |
| 245 ConstantValue fold(ConstantValue left, ConstantValue right) { | 251 ConstantValue fold(ConstantValue left, ConstantValue right) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 bool isInt(ConstantValue constant) => constant.isInt; | 405 bool isInt(ConstantValue constant) => constant.isInt; |
| 400 bool isDouble(ConstantValue constant) => constant.isDouble; | 406 bool isDouble(ConstantValue constant) => constant.isDouble; |
| 401 bool isString(ConstantValue constant) => constant.isString; | 407 bool isString(ConstantValue constant) => constant.isString; |
| 402 bool isBool(ConstantValue constant) => constant.isBool; | 408 bool isBool(ConstantValue constant) => constant.isBool; |
| 403 bool isNull(ConstantValue constant) => constant.isNull; | 409 bool isNull(ConstantValue constant) => constant.isNull; |
| 404 | 410 |
| 405 bool isSubtype(DartTypes types, DartType s, DartType t) { | 411 bool isSubtype(DartTypes types, DartType s, DartType t) { |
| 406 return types.isSubtype(s, t); | 412 return types.isSubtype(s, t); |
| 407 } | 413 } |
| 408 } | 414 } |
| OLD | NEW |