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

Side by Side Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1425823004: Make dart2js accept constant null values in string interpolations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Also test int/bool.fromEnvironment returning null. Created 5 years, 1 month 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/language/constant_string_interpolation2_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) 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 library dart2js.compile_time_constant_evaluator; 5 library dart2js.compile_time_constant_evaluator;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/resolution.dart' show 8 import 'common/resolution.dart' show
9 Resolution; 9 Resolution;
10 import 'common/tasks.dart' show 10 import 'common/tasks.dart' show
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 StringConstantValue initialStringValue = initialString.value; 501 StringConstantValue initialStringValue = initialString.value;
502 DartString accumulator = initialStringValue.primitiveValue; 502 DartString accumulator = initialStringValue.primitiveValue;
503 for (StringInterpolationPart part in node.parts) { 503 for (StringInterpolationPart part in node.parts) {
504 AstConstant subexpression = evaluate(part.expression); 504 AstConstant subexpression = evaluate(part.expression);
505 if (subexpression == null) { 505 if (subexpression == null) {
506 return null; 506 return null;
507 } 507 }
508 subexpressions.add(subexpression.expression); 508 subexpressions.add(subexpression.expression);
509 ConstantValue expression = subexpression.value; 509 ConstantValue expression = subexpression.value;
510 DartString expressionString; 510 DartString expressionString;
511 if (expression.isNum || expression.isBool) { 511 if (expression.isNum || expression.isBool || expression.isNull) {
512 PrimitiveConstantValue primitive = expression; 512 PrimitiveConstantValue primitive = expression;
513 expressionString = 513 expressionString =
514 new DartString.literal(primitive.primitiveValue.toString()); 514 new DartString.literal(primitive.primitiveValue.toString());
515 } else if (expression.isString) { 515 } else if (expression.isString) {
516 PrimitiveConstantValue primitive = expression; 516 PrimitiveConstantValue primitive = expression;
517 expressionString = primitive.primitiveValue; 517 expressionString = primitive.primitiveValue;
518 } else { 518 } else {
519 // TODO(johnniwinther): Specialize message to indicated that the problem 519 // TODO(johnniwinther): Specialize message to indicated that the problem
520 // is not constness but the types of the const expressions. 520 // is not constness but the types of the const expressions.
521 return signalNotCompileTimeConstant(part.expression); 521 return signalNotCompileTimeConstant(part.expression);
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 class _CompilerEnvironment implements Environment { 1272 class _CompilerEnvironment implements Environment {
1273 final Compiler compiler; 1273 final Compiler compiler;
1274 1274
1275 _CompilerEnvironment(this.compiler); 1275 _CompilerEnvironment(this.compiler);
1276 1276
1277 @override 1277 @override
1278 String readFromEnvironment(String name) { 1278 String readFromEnvironment(String name) {
1279 return compiler.fromEnvironment(name); 1279 return compiler.fromEnvironment(name);
1280 } 1280 }
1281 } 1281 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/constant_string_interpolation2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698