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

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

Issue 2630743002: Remove use of FunctionSignature et al from call_structure.dart (Closed)
Patch Set: Created 3 years, 11 months 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
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/resolution.dart' show Resolution; 7 import 'common/resolution.dart' show Resolution;
8 import 'common/tasks.dart' show CompilerTask, Measurer; 8 import 'common/tasks.dart' show CompilerTask, Measurer;
9 import 'common.dart'; 9 import 'common.dart';
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 assert(invariant(node, target.isImplementation)); 858 assert(invariant(node, target.isImplementation));
859 859
860 AstConstant compileDefaultValue(VariableElement element) { 860 AstConstant compileDefaultValue(VariableElement element) {
861 ConstantExpression constant = handler.compileConstant(element); 861 ConstantExpression constant = handler.compileConstant(element);
862 return new AstConstant.fromDefaultValue( 862 return new AstConstant.fromDefaultValue(
863 element, constant, handler.getConstantValue(constant)); 863 element, constant, handler.getConstantValue(constant));
864 } 864 }
865 865
866 target.computeType(resolution); 866 target.computeType(resolution);
867 867
868 FunctionSignature signature = target.functionSignature; 868 if (!callStructure.signatureApplies(target.type)) {
869 if (!callStructure.signatureApplies(signature)) {
870 String name = Elements.constructorNameForDiagnostics( 869 String name = Elements.constructorNameForDiagnostics(
871 target.enclosingClass.name, target.name); 870 target.enclosingClass.name, target.name);
872 reporter.reportErrorMessage(node, 871 reporter.reportErrorMessage(node,
873 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, {'constructorName': name}); 872 MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS, {'constructorName': name});
874 873
875 return new List<AstConstant>.filled( 874 return new List<AstConstant>.filled(
876 target.functionSignature.parameterCount, 875 target.functionSignature.parameterCount,
877 new ErroneousAstConstant(context, node)); 876 new ErroneousAstConstant(context, node));
878 } 877 }
879 return callStructure.makeArgumentsList( 878 return Elements.makeArgumentsList<AstConstant>(
880 arguments, target, compileArgument, compileDefaultValue); 879 callStructure, arguments, target, compileArgument, compileDefaultValue);
881 } 880 }
882 881
883 AstConstant visitNewExpression(NewExpression node) { 882 AstConstant visitNewExpression(NewExpression node) {
884 if (!node.isConst) { 883 if (!node.isConst) {
885 return signalNotCompileTimeConstant(node); 884 return signalNotCompileTimeConstant(node);
886 } 885 }
887 886
888 Send send = node.send; 887 Send send = node.send;
889 ConstructorElement constructor = elements[send]; 888 ConstructorElement constructor = elements[send];
890 if (Elements.isUnresolved(constructor)) { 889 if (Elements.isUnresolved(constructor)) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 List<AstConstant> normalizedArguments) { 1105 List<AstConstant> normalizedArguments) {
1107 if (target.isRedirectingFactory) { 1106 if (target.isRedirectingFactory) {
1108 // This happens in case of cyclic redirection. 1107 // This happens in case of cyclic redirection.
1109 assert(invariant(node, compiler.compilationFailed, 1108 assert(invariant(node, compiler.compilationFailed,
1110 message: "makeConstructedConstant can only be called with the " 1109 message: "makeConstructedConstant can only be called with the "
1111 "effective target: $constructor")); 1110 "effective target: $constructor"));
1112 return new ErroneousAstConstant(context, node); 1111 return new ErroneousAstConstant(context, node);
1113 } 1112 }
1114 assert(invariant( 1113 assert(invariant(
1115 node, 1114 node,
1116 callStructure.signatureApplies(constructor.functionSignature) || 1115 callStructure.signatureApplies(constructor.type) ||
1117 compiler.compilationFailed, 1116 compiler.compilationFailed,
1118 message: "Call structure $callStructure does not apply to constructor " 1117 message: "Call structure $callStructure does not apply to constructor "
1119 "$constructor.")); 1118 "$constructor."));
1120 1119
1121 ConstructorEvaluator evaluator = 1120 ConstructorEvaluator evaluator =
1122 new ConstructorEvaluator(constructedType, target, handler, compiler); 1121 new ConstructorEvaluator(constructedType, target, handler, compiler);
1123 evaluator.evaluateConstructorFieldValues(normalizedArguments); 1122 evaluator.evaluateConstructorFieldValues(normalizedArguments);
1124 Map<FieldElement, AstConstant> fieldConstants = 1123 Map<FieldElement, AstConstant> fieldConstants =
1125 evaluator.buildFieldConstants(target.enclosingClass); 1124 evaluator.buildFieldConstants(target.enclosingClass);
1126 Map<FieldElement, ConstantValue> fieldValues = 1125 Map<FieldElement, ConstantValue> fieldValues =
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 * the [fieldValues] map. 1287 * the [fieldValues] map.
1289 */ 1288 */
1290 void evaluateConstructorInitializers() { 1289 void evaluateConstructorInitializers() {
1291 ResolvedAst resolvedAst = constructor.resolvedAst; 1290 ResolvedAst resolvedAst = constructor.resolvedAst;
1292 if (resolvedAst.kind != ResolvedAstKind.PARSED) { 1291 if (resolvedAst.kind != ResolvedAstKind.PARSED) {
1293 List<AstConstant> compiledArguments = <AstConstant>[]; 1292 List<AstConstant> compiledArguments = <AstConstant>[];
1294 1293
1295 Function compileArgument = (element) => definitions[element]; 1294 Function compileArgument = (element) => definitions[element];
1296 Function compileConstant = handler.compileConstant; 1295 Function compileConstant = handler.compileConstant;
1297 FunctionElement target = constructor.definingConstructor.implementation; 1296 FunctionElement target = constructor.definingConstructor.implementation;
1298 CallStructure.addForwardingElementArgumentsToList(constructor, 1297 Elements.addForwardingElementArgumentsToList<AstConstant>(constructor,
1299 compiledArguments, target, compileArgument, compileConstant); 1298 compiledArguments, target, compileArgument, compileConstant);
1300 CallStructure callStructure = 1299 CallStructure callStructure = new CallStructure(
1301 new CallStructure.fromSignature(target.functionSignature); 1300 target.functionSignature.parameterCount, target.type.namedParameters);
Siggi Cherem (dart-lang) 2017/01/13 17:11:07 do we want to also get rid of functionSignature he
Johnni Winther 2017/01/18 11:02:51 I considered adding a 'parameterCount' property to
1302 evaluateSuperOrRedirectSend(compiledArguments, callStructure, target); 1301 evaluateSuperOrRedirectSend(compiledArguments, callStructure, target);
1303 return; 1302 return;
1304 } 1303 }
1305 FunctionExpression functionNode = resolvedAst.node; 1304 FunctionExpression functionNode = resolvedAst.node;
1306 NodeList initializerList = functionNode.initializers; 1305 NodeList initializerList = functionNode.initializers;
1307 1306
1308 bool foundSuperOrRedirect = false; 1307 bool foundSuperOrRedirect = false;
1309 1308
1310 if (initializerList != null) { 1309 if (initializerList != null) {
1311 for (Link<Node> link = initializerList.nodes; 1310 for (Link<Node> link = initializerList.nodes;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 class _CompilerEnvironment implements Environment { 1448 class _CompilerEnvironment implements Environment {
1450 final Compiler compiler; 1449 final Compiler compiler;
1451 1450
1452 _CompilerEnvironment(this.compiler); 1451 _CompilerEnvironment(this.compiler);
1453 1452
1454 @override 1453 @override
1455 String readFromEnvironment(String name) { 1454 String readFromEnvironment(String name) {
1456 return compiler.fromEnvironment(name); 1455 return compiler.fromEnvironment(name);
1457 } 1456 }
1458 } 1457 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/elements/elements.dart » ('j') | pkg/compiler/lib/src/elements/elements.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698