| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |