| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /// A [ConstantEnvironment] provides access for constants compiled for variable | 7 /// A [ConstantEnvironment] provides access for constants compiled for variable |
| 8 /// initializers. | 8 /// initializers. |
| 9 abstract class ConstantEnvironment { | 9 abstract class ConstantEnvironment { |
| 10 /// Returns the constant for the initializer of [element]. | 10 /// Returns the constant for the initializer of [element]. |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 AstConstant visitConditional(Conditional node) { | 603 AstConstant visitConditional(Conditional node) { |
| 604 AstConstant condition = evaluate(node.condition); | 604 AstConstant condition = evaluate(node.condition); |
| 605 if (condition == null) { | 605 if (condition == null) { |
| 606 return null; | 606 return null; |
| 607 } else if (!condition.value.isBool) { | 607 } else if (!condition.value.isBool) { |
| 608 DartType conditionType = condition.value.getType(compiler.coreTypes); | 608 DartType conditionType = condition.value.getType(compiler.coreTypes); |
| 609 if (isEvaluatingConstant) { | 609 if (isEvaluatingConstant) { |
| 610 compiler.reportError( | 610 compiler.reportError( |
| 611 node.condition, MessageKind.NOT_ASSIGNABLE, | 611 node.condition, MessageKind.NOT_ASSIGNABLE, |
| 612 {'fromType': conditionType, 'toType': compiler.boolClass.rawType}); | 612 {'fromType': conditionType, 'toType': compiler.boolClass.rawType}); |
| 613 // TODO(ahe): Don't throw, recover from error. |
| 614 throw new CompilerCancelledException(null); |
| 613 } | 615 } |
| 614 return null; | 616 return null; |
| 615 } | 617 } |
| 616 AstConstant thenExpression = evaluate(node.thenExpression); | 618 AstConstant thenExpression = evaluate(node.thenExpression); |
| 617 AstConstant elseExpression = evaluate(node.elseExpression); | 619 AstConstant elseExpression = evaluate(node.elseExpression); |
| 618 if (thenExpression == null || elseExpression == null) { | 620 if (thenExpression == null || elseExpression == null) { |
| 619 return null; | 621 return null; |
| 620 } | 622 } |
| 621 BoolConstantValue boolCondition = condition.value; | 623 BoolConstantValue boolCondition = condition.value; |
| 622 return new AstConstant( | 624 return new AstConstant( |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 return new AstConstant( | 1101 return new AstConstant( |
| 1100 element, | 1102 element, |
| 1101 element.initializer != null ? element.initializer : element.node, | 1103 element.initializer != null ? element.initializer : element.node, |
| 1102 constant); | 1104 constant); |
| 1103 } | 1105 } |
| 1104 | 1106 |
| 1105 ConstantValue get value => expression.value; | 1107 ConstantValue get value => expression.value; |
| 1106 | 1108 |
| 1107 String toString() => expression.toString(); | 1109 String toString() => expression.toString(); |
| 1108 } | 1110 } |
| OLD | NEW |