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

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

Issue 2118203002: Correct evaluation of interpolated `null` (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 expressions.map((a) => a.apply(arguments)).toList()); 656 expressions.map((a) => a.apply(arguments)).toList());
657 } 657 }
658 658
659 @override 659 @override
660 ConstantValue evaluate( 660 ConstantValue evaluate(
661 Environment environment, ConstantSystem constantSystem) { 661 Environment environment, ConstantSystem constantSystem) {
662 DartString accumulator; 662 DartString accumulator;
663 for (ConstantExpression expression in expressions) { 663 for (ConstantExpression expression in expressions) {
664 ConstantValue value = expression.evaluate(environment, constantSystem); 664 ConstantValue value = expression.evaluate(environment, constantSystem);
665 DartString valueString; 665 DartString valueString;
666 if (value.isNum || value.isBool) { 666 if (value.isNum || value.isBool || value.isNull) {
667 PrimitiveConstantValue primitive = value; 667 PrimitiveConstantValue primitive = value;
668 valueString = 668 valueString =
669 new DartString.literal(primitive.primitiveValue.toString()); 669 new DartString.literal(primitive.primitiveValue.toString());
670 } else if (value.isString) { 670 } else if (value.isString) {
671 PrimitiveConstantValue primitive = value; 671 PrimitiveConstantValue primitive = value;
672 valueString = primitive.primitiveValue; 672 valueString = primitive.primitiveValue;
673 } else { 673 } else {
674 // TODO(johnniwinther): Specialize message to indicated that the problem 674 // TODO(johnniwinther): Specialize message to indicated that the problem
675 // is not constness but the types of the const expressions. 675 // is not constness but the types of the const expressions.
676 return new NonConstantValue(); 676 return new NonConstantValue();
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 visit(exp.name); 1891 visit(exp.name);
1892 if (exp.defaultValue != null) { 1892 if (exp.defaultValue != null) {
1893 sb.write(', defaultValue: '); 1893 sb.write(', defaultValue: ');
1894 visit(exp.defaultValue); 1894 visit(exp.defaultValue);
1895 } 1895 }
1896 sb.write(')'); 1896 sb.write(')');
1897 } 1897 }
1898 1898
1899 String toString() => sb.toString(); 1899 String toString() => sb.toString();
1900 } 1900 }
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