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

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

Issue 9930005: Use default values of named arguments when invoking the default super constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 8 years, 8 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
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compile_time_constants.dart
diff --git a/lib/compiler/implementation/compile_time_constants.dart b/lib/compiler/implementation/compile_time_constants.dart
index 1f4b57fb4b4712149c90d05a3d7a8f9c74c7f7e2..60b9bf0a70722ad94e49cf3707cae7fe2c3c1c05 100644
--- a/lib/compiler/implementation/compile_time_constants.dart
+++ b/lib/compiler/implementation/compile_time_constants.dart
@@ -948,25 +948,29 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
error(node);
}
- /** Returns the list of constants that are passed to the static function. */
- List<Constant> evaluateArgumentsToConstructor(Send send,
+ /**
+ * Returns the list of constants that are passed to the static function.
+ */
+ List<Constant> evaluateArgumentsToConstructor(Selector selector,
+ Link<Node> arguments,
FunctionElement target) {
FunctionParameters parameters = target.computeParameters(compiler);
- List<Constant> arguments = <Constant>[];
- Selector selector = elements.getSelector(send);
+ List<Constant> compiledArguments = <Constant>[];
Function compileArgument = evaluate;
Function compileConstant = compiler.compileVariable;
- bool succeeded = selector.addSendArgumentsToList(
- send, arguments, parameters, compileArgument, compileConstant);
- if (!succeeded) error(send);
- return arguments;
+ bool succeeded = selector.addArgumentsToList(arguments, compiledArguments,
+ parameters, compileArgument,
+ compileConstant);
+ assert(succeeded);
+ return compiledArguments;
}
Constant visitNewExpression(NewExpression node) {
if (!node.isConst()) error(node);
- FunctionElement constructor = elements[node.send];
+ Send send = node.send;
+ FunctionElement constructor = elements[send];
ClassElement classElement = constructor.enclosingElement;
if (classElement.isInterface()) {
compiler.resolver.resolveMethodElement(constructor);
@@ -974,8 +978,9 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
classElement = constructor.enclosingElement;
}
+ Selector selector = elements.getSelector(send);
List<Constant> arguments =
- evaluateArgumentsToConstructor(node.send, constructor);
+ evaluateArgumentsToConstructor(selector, send.arguments, constructor);
ConstructorEvaluator evaluator =
new ConstructorEvaluator(constructor, compiler);
evaluator.evaluateConstructorFieldValues(arguments);
@@ -1044,13 +1049,18 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
});
}
- void evaluateSuperOrRedirectSend(FunctionElement targetConstructor,
- List<Constant> targetArguments) {
+ void evaluateSuperOrRedirectSend(Selector selector,
+ Link<Node> arguments,
+ FunctionElement targetConstructor) {
+ List<Constant> compiledArguments =
+ evaluateArgumentsToConstructor(selector, arguments, targetConstructor);
+
ConstructorEvaluator evaluator =
new ConstructorEvaluator(targetConstructor, compiler);
- evaluator.evaluateConstructorFieldValues(targetArguments);
+ evaluator.evaluateConstructorFieldValues(compiledArguments);
// Copy over the fieldValues from the super/redirect-constructor.
evaluator.fieldValues.forEach((key, value) => fieldValues[key] = value);
+ return true;
}
/**
@@ -1072,9 +1082,9 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
// A super initializer or constructor redirection.
Send call = link.head;
FunctionElement targetConstructor = elements[call];
- List<Constant> targetArguments =
- evaluateArgumentsToConstructor(call, targetConstructor);
- evaluateSuperOrRedirectSend(targetConstructor, targetArguments);
+ Selector selector = elements.getSelector(call);
+ Link<Node> arguments = call.arguments;
+ evaluateSuperOrRedirectSend(selector, arguments, targetConstructor);
foundSuperOrRedirect = true;
} else {
// A field initializer.
@@ -1098,9 +1108,13 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
FunctionElement targetConstructor =
superClass.lookupConstructor(superClass.name);
if (targetConstructor === null) {
- compiler.internalError("no default constructor available");
+ compiler.internalError("no default constructor available",
+ node: functionNode);
}
- evaluateSuperOrRedirectSend(targetConstructor, const <Constant>[]);
+
+ evaluateSuperOrRedirectSend(Selector.INVOCATION_0,
+ const EmptyLink<Node>(),
+ targetConstructor);
}
}
}
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698