| 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 dart2js.constants.expressions; | 5 library dart2js.constants.expressions; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 sb.write('Binary(left='); | 863 sb.write('Binary(left='); |
| 864 left._createStructuredText(sb); | 864 left._createStructuredText(sb); |
| 865 sb.write(',op=$operator,right='); | 865 sb.write(',op=$operator,right='); |
| 866 right._createStructuredText(sb); | 866 right._createStructuredText(sb); |
| 867 sb.write(')'); | 867 sb.write(')'); |
| 868 } | 868 } |
| 869 | 869 |
| 870 @override | 870 @override |
| 871 ConstantValue evaluate( | 871 ConstantValue evaluate( |
| 872 Environment environment, ConstantSystem constantSystem) { | 872 Environment environment, ConstantSystem constantSystem) { |
| 873 return constantSystem.lookupBinary(operator).fold( | 873 ConstantValue leftValue = left.evaluate(environment, constantSystem); |
| 874 left.evaluate(environment, constantSystem), | 874 ConstantValue rightValue = right.evaluate(environment, constantSystem); |
| 875 right.evaluate(environment, constantSystem)); | 875 switch (operator.kind) { |
| 876 case BinaryOperatorKind.NOT_EQ: |
| 877 BoolConstantValue equals = |
| 878 constantSystem.equal.fold(leftValue, rightValue); |
| 879 return equals.negate(); |
| 880 default: |
| 881 return constantSystem |
| 882 .lookupBinary(operator) |
| 883 .fold(leftValue, rightValue); |
| 884 } |
| 876 } | 885 } |
| 877 | 886 |
| 878 ConstantExpression apply(NormalizedArguments arguments) { | 887 ConstantExpression apply(NormalizedArguments arguments) { |
| 879 return new BinaryConstantExpression( | 888 return new BinaryConstantExpression( |
| 880 left.apply(arguments), operator, right.apply(arguments)); | 889 left.apply(arguments), operator, right.apply(arguments)); |
| 881 } | 890 } |
| 882 | 891 |
| 883 DartType getKnownType(CoreTypes coreTypes) { | 892 DartType getKnownType(CoreTypes coreTypes) { |
| 884 DartType knownLeftType = left.getKnownType(coreTypes); | 893 DartType knownLeftType = left.getKnownType(coreTypes); |
| 885 DartType knownRightType = right.getKnownType(coreTypes); | 894 DartType knownRightType = right.getKnownType(coreTypes); |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 visit(exp.name); | 1882 visit(exp.name); |
| 1874 if (exp.defaultValue != null) { | 1883 if (exp.defaultValue != null) { |
| 1875 sb.write(', defaultValue: '); | 1884 sb.write(', defaultValue: '); |
| 1876 visit(exp.defaultValue); | 1885 visit(exp.defaultValue); |
| 1877 } | 1886 } |
| 1878 sb.write(')'); | 1887 sb.write(')'); |
| 1879 } | 1888 } |
| 1880 | 1889 |
| 1881 String toString() => sb.toString(); | 1890 String toString() => sb.toString(); |
| 1882 } | 1891 } |
| OLD | NEW |