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/backend_api.dart' show BackendClasses; | 7 import 'common/backend_api.dart' show BackendClasses; |
8 import 'common/resolution.dart' show Resolution; | 8 import 'common/resolution.dart' show Resolution; |
9 import 'common/tasks.dart' show CompilerTask, Measurer; | 9 import 'common/tasks.dart' show CompilerTask, Measurer; |
10 import 'common.dart'; | 10 import 'common.dart'; |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 assert(invariant(node, target.isImplementation)); | 860 assert(invariant(node, target.isImplementation)); |
861 | 861 |
862 AstConstant compileDefaultValue(VariableElement element) { | 862 AstConstant compileDefaultValue(VariableElement element) { |
863 ConstantExpression constant = handler.compileConstant(element); | 863 ConstantExpression constant = handler.compileConstant(element); |
864 return new AstConstant.fromDefaultValue( | 864 return new AstConstant.fromDefaultValue( |
865 element, constant, handler.getConstantValue(constant)); | 865 element, constant, handler.getConstantValue(constant)); |
866 } | 866 } |
867 | 867 |
868 target.computeType(resolution); | 868 target.computeType(resolution); |
869 | 869 |
870 if (!callStructure.signatureApplies(target.type)) { | 870 if (!callStructure.signatureApplies(target.parameterStructure)) { |
871 String name = Elements.constructorNameForDiagnostics( | 871 String name = Elements.constructorNameForDiagnostics( |
872 target.enclosingClass.name, target.name); | 872 target.enclosingClass.name, target.name); |
873 reporter.reportErrorMessage(node, | 873 reporter.reportErrorMessage(node, |
874 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, {'constructorName': name}); | 874 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, {'constructorName': name}); |
875 | 875 |
876 return new List<AstConstant>.filled( | 876 return new List<AstConstant>.filled( |
877 target.functionSignature.parameterCount, | 877 target.functionSignature.parameterCount, |
878 new ErroneousAstConstant(context, node)); | 878 new ErroneousAstConstant(context, node)); |
879 } | 879 } |
880 return Elements.makeArgumentsList<AstConstant>( | 880 return Elements.makeArgumentsList<AstConstant>( |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 List<AstConstant> normalizedArguments) { | 1107 List<AstConstant> normalizedArguments) { |
1108 if (target.isRedirectingFactory) { | 1108 if (target.isRedirectingFactory) { |
1109 // This happens in case of cyclic redirection. | 1109 // This happens in case of cyclic redirection. |
1110 assert(invariant(node, compiler.compilationFailed, | 1110 assert(invariant(node, compiler.compilationFailed, |
1111 message: "makeConstructedConstant can only be called with the " | 1111 message: "makeConstructedConstant can only be called with the " |
1112 "effective target: $constructor")); | 1112 "effective target: $constructor")); |
1113 return new ErroneousAstConstant(context, node); | 1113 return new ErroneousAstConstant(context, node); |
1114 } | 1114 } |
1115 assert(invariant( | 1115 assert(invariant( |
1116 node, | 1116 node, |
1117 callStructure.signatureApplies(constructor.type) || | 1117 callStructure.signatureApplies(constructor.parameterStructure) || |
1118 compiler.compilationFailed, | 1118 compiler.compilationFailed, |
1119 message: "Call structure $callStructure does not apply to constructor " | 1119 message: "Call structure $callStructure does not apply to constructor " |
1120 "$constructor.")); | 1120 "$constructor.")); |
1121 | 1121 |
1122 ConstructorEvaluator evaluator = | 1122 ConstructorEvaluator evaluator = |
1123 new ConstructorEvaluator(constructedType, target, handler, compiler); | 1123 new ConstructorEvaluator(constructedType, target, handler, compiler); |
1124 evaluator.evaluateConstructorFieldValues(normalizedArguments); | 1124 evaluator.evaluateConstructorFieldValues(normalizedArguments); |
1125 Map<FieldElement, AstConstant> fieldConstants = | 1125 Map<FieldElement, AstConstant> fieldConstants = |
1126 evaluator.buildFieldConstants(target.enclosingClass); | 1126 evaluator.buildFieldConstants(target.enclosingClass); |
1127 Map<FieldElement, ConstantValue> fieldValues = | 1127 Map<FieldElement, ConstantValue> fieldValues = |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 @override | 1477 @override |
1478 ConstantExpression getFieldConstant(FieldElement field) { | 1478 ConstantExpression getFieldConstant(FieldElement field) { |
1479 return field.constant; | 1479 return field.constant; |
1480 } | 1480 } |
1481 | 1481 |
1482 @override | 1482 @override |
1483 ConstantExpression getLocalConstant(LocalVariableElement local) { | 1483 ConstantExpression getLocalConstant(LocalVariableElement local) { |
1484 return local.constant; | 1484 return local.constant; |
1485 } | 1485 } |
1486 } | 1486 } |
OLD | NEW |