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

Unified Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 19754002: Rewrite how we handle synthesized constructors in the compiler. This was motivated by issue https:/… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/compile_time_constants.dart (revision 25147)
+++ sdk/lib/_internal/compiler/implementation/compile_time_constants.dart (working copy)
@@ -689,7 +689,7 @@
compiler.analyzeElement(constructor.declaration);
InterfaceType type = elements.getType(node);
- if ( constructor.isRedirectingFactory) {
+ if (constructor.isRedirectingFactory) {
type = constructor.computeTargetType(compiler, type);
}
@@ -704,7 +704,7 @@
List<Constant> arguments = evaluateArgumentsToConstructor(
node, selector, send.arguments, constructor);
ConstructorEvaluator evaluator =
- new ConstructorEvaluator(node, constructor, handler, compiler);
+ new ConstructorEvaluator(constructor, handler, compiler);
evaluator.evaluateConstructorFieldValues(arguments);
List<Constant> jsNewArguments = evaluator.buildJsNewArguments(classElement);
@@ -761,8 +761,7 @@
*
* Invariant: [constructor] must be an implementation element.
*/
- ConstructorEvaluator(Node node,
- FunctionElement constructor,
+ ConstructorEvaluator(FunctionElement constructor,
ConstantHandler handler,
Compiler compiler)
: this.constructor = constructor,
@@ -772,7 +771,7 @@
compiler.resolver.resolveMethodElement(constructor.declaration),
compiler,
isConst: true) {
- assert(invariant(node, constructor.isImplementation));
+ assert(invariant(constructor, constructor.isImplementation));
}
Constant visitSend(Send send) {
@@ -828,15 +827,10 @@
});
}
- void evaluateSuperOrRedirectSend(Node currentNode,
- Selector selector,
- Link<Node> arguments,
+ void evaluateSuperOrRedirectSend(List<Constant> compiledArguments,
FunctionElement targetConstructor) {
- List<Constant> compiledArguments = evaluateArgumentsToConstructor(
- currentNode, selector, arguments, targetConstructor);
-
ConstructorEvaluator evaluator = new ConstructorEvaluator(
- currentNode, targetConstructor, handler, compiler);
+ targetConstructor, handler, compiler);
evaluator.evaluateConstructorFieldValues(compiledArguments);
// Copy over the fieldValues from the super/redirect-constructor.
// No need to go through [updateFieldValue] because the
@@ -849,6 +843,21 @@
* the [fieldValues] map.
*/
void evaluateConstructorInitializers() {
+ if (constructor.isSynthesized) {
+ List<Constant> compiledArguments = <Constant>[];
+
+ Function compileArgument = (element) => definitions[element];
+ Function compileConstant = handler.compileConstant;
+ FunctionElement target = constructor.targetConstructor.implementation;
+ Selector.addForwardingElementArgumentsToList(constructor,
+ compiledArguments,
+ target,
+ compileArgument,
+ compileConstant,
+ compiler);
+ evaluateSuperOrRedirectSend(compiledArguments, target);
+ return;
+ }
FunctionExpression functionNode = constructor.parseNode(compiler);
NodeList initializerList = functionNode.initializers;
@@ -862,11 +871,10 @@
if (link.head is !SendSet) {
// A super initializer or constructor redirection.
Send call = link.head;
- FunctionElement targetConstructor = elements[call];
- Selector selector = elements.getSelector(call);
- Link<Node> arguments = call.arguments;
- evaluateSuperOrRedirectSend(
- call, selector, arguments, targetConstructor);
+ FunctionElement target = elements[call];
+ List<Constant> compiledArguments = evaluateArgumentsToConstructor(
+ call, elements.getSelector(call), call.arguments, target);
+ evaluateSuperOrRedirectSend(compiledArguments, target);
foundSuperOrRedirect = true;
} else {
// A field initializer.
@@ -897,11 +905,9 @@
compiler.internalError("no default constructor available",
node: functionNode);
}
-
- evaluateSuperOrRedirectSend(functionNode,
- selector,
- const Link<Node>(),
- targetConstructor);
+ List<Constant> compiledArguments = evaluateArgumentsToConstructor(
+ functionNode, selector, const Link<Node>(), targetConstructor);
+ evaluateSuperOrRedirectSend(compiledArguments, targetConstructor);
}
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/closure.dart ('k') | sdk/lib/_internal/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698