| 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 compileArgument: (node) => concreteArgumentMap[node]); | 725 compileArgument: (node) => concreteArgumentMap[node]); |
| 726 List<AstConstant> concreteArguments = | 726 List<AstConstant> concreteArguments = |
| 727 concreteArgumentMap.values.toList(); | 727 concreteArgumentMap.values.toList(); |
| 728 | 728 |
| 729 if (constructor == compiler.intEnvironment || | 729 if (constructor == compiler.intEnvironment || |
| 730 constructor == compiler.boolEnvironment || | 730 constructor == compiler.boolEnvironment || |
| 731 constructor == compiler.stringEnvironment) { | 731 constructor == compiler.stringEnvironment) { |
| 732 | 732 |
| 733 AstConstant createEvaluatedConstant(ConstantValue value) { | 733 AstConstant createEvaluatedConstant(ConstantValue value) { |
| 734 return new AstConstant( | 734 return new AstConstant( |
| 735 context, node, new ConstructedConstantExpresssion( | 735 context, node, new ConstructedConstantExpression( |
| 736 value, | 736 value, |
| 737 type, | 737 type, |
| 738 constructor, | 738 constructor, |
| 739 elements.getSelector(send), | 739 elements.getSelector(send), |
| 740 concreteArguments.map((e) => e.expression).toList())); | 740 concreteArguments.map((e) => e.expression).toList())); |
| 741 } | 741 } |
| 742 | 742 |
| 743 var firstArgument = normalizedArguments[0].value; | 743 var firstArgument = normalizedArguments[0].value; |
| 744 ConstantValue defaultValue = normalizedArguments[1].value; | 744 ConstantValue defaultValue = normalizedArguments[1].value; |
| 745 | 745 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 target = target.implementation; | 843 target = target.implementation; |
| 844 assert(invariant(node, target.isImplementation)); | 844 assert(invariant(node, target.isImplementation)); |
| 845 | 845 |
| 846 ConstructorEvaluator evaluator = new ConstructorEvaluator( | 846 ConstructorEvaluator evaluator = new ConstructorEvaluator( |
| 847 constructedType, target, handler, compiler); | 847 constructedType, target, handler, compiler); |
| 848 evaluator.evaluateConstructorFieldValues(normalizedArguments); | 848 evaluator.evaluateConstructorFieldValues(normalizedArguments); |
| 849 List<AstConstant> fieldConstants = | 849 List<AstConstant> fieldConstants = |
| 850 evaluator.buildFieldConstants(classElement); | 850 evaluator.buildFieldConstants(classElement); |
| 851 | 851 |
| 852 return new AstConstant( | 852 return new AstConstant( |
| 853 context, node, new ConstructedConstantExpresssion( | 853 context, node, new ConstructedConstantExpression( |
| 854 new ConstructedConstantValue( | 854 new ConstructedConstantValue( |
| 855 constructedType, | 855 constructedType, |
| 856 fieldConstants.map((e) => e.value).toList()), | 856 fieldConstants.map((e) => e.value).toList()), |
| 857 type, | 857 type, |
| 858 constructor, | 858 constructor, |
| 859 selector, | 859 selector, |
| 860 concreteArguments.map((e) => e.expression).toList())); | 860 concreteArguments.map((e) => e.expression).toList())); |
| 861 } | 861 } |
| 862 | 862 |
| 863 AstConstant visitParenthesizedExpression(ParenthesizedExpression node) { | 863 AstConstant visitParenthesizedExpression(ParenthesizedExpression node) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 ConstantValue get value => expression.value; | 1117 ConstantValue get value => expression.value; |
| 1118 | 1118 |
| 1119 String toString() => expression.toString(); | 1119 String toString() => expression.toString(); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 /// A synthetic constant used to recover from errors. | 1122 /// A synthetic constant used to recover from errors. |
| 1123 class ErroneousAstConstant extends AstConstant { | 1123 class ErroneousAstConstant extends AstConstant { |
| 1124 ErroneousAstConstant(Element element, Node node) | 1124 ErroneousAstConstant(Element element, Node node) |
| 1125 : super(element, node, new ErroneousConstantExpression()); | 1125 : super(element, node, new ErroneousConstantExpression()); |
| 1126 } | 1126 } |
| OLD | NEW |