Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: pkg/compiler/lib/src/constants/expressions.dart

Issue 2094273002: Fix evaluation of != (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698