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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 742023002: Handle named and optional arguments in cps-ir. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 74a46e5b07330f8d5f38314cac9c8f7c2f6a91af..0850ef1f414d1ebc8b87a80fa6a4db4f9b8fc77e 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1847,12 +1847,10 @@ class SsaBuilder extends ResolvedVisitor {
FunctionElement target = elements[call].implementation;
Selector selector = elements.getSelector(call);
Link<ast.Node> arguments = call.arguments;
- List<HInstruction> compiledArguments = new List<HInstruction>();
+ List<HInstruction> compiledArguments;
inlinedFrom(constructor, () {
- addStaticSendArgumentsToList(selector,
- arguments,
- target,
- compiledArguments);
+ compiledArguments =
+ makeStaticArgumentList(selector, arguments, target);
});
inlineSuperOrRedirect(target,
compiledArguments,
@@ -1888,13 +1886,11 @@ class SsaBuilder extends ResolvedVisitor {
compiler.internalError(superClass,
"No default constructor available.");
}
- List<HInstruction> arguments = <HInstruction>[];
- selector.addArgumentsToList(const Link<ast.Node>(),
- arguments,
- target.implementation,
- null,
- handleConstantForOptionalParameter,
- compiler.world);
+ List<HInstruction> arguments =
+ selector.makeArgumentsList(const Link<ast.Node>(),
+ target.implementation,
+ null,
+ handleConstantForOptionalParameter);
inlineSuperOrRedirect(target,
arguments,
constructors,
@@ -3449,14 +3445,14 @@ class SsaBuilder extends ResolvedVisitor {
}
/**
- * Returns true if the arguments were compatible with the function signature.
+ * Returns a list with the evaluated [arguments] in the normalized order.
*
+ * Precondition: `this.applies(element, world)`.
* Invariant: [element] must be an implementation element.
*/
- bool addStaticSendArgumentsToList(Selector selector,
- Link<ast.Node> arguments,
- FunctionElement element,
- List<HInstruction> list) {
+ List<HInstruction> makeStaticArgumentList(Selector selector,
+ Link<ast.Node> arguments,
+ FunctionElement element) {
assert(invariant(element, element.isImplementation));
HInstruction compileArgument(ast.Node argument) {
@@ -3464,12 +3460,10 @@ class SsaBuilder extends ResolvedVisitor {
return pop();
}
- return selector.addArgumentsToList(arguments,
- list,
- element,
- compileArgument,
- handleConstantForOptionalParameter,
- compiler.world);
+ return selector.makeArgumentsList(arguments,
+ element,
+ compileArgument,
+ handleConstantForOptionalParameter);
}
void addGenericSendArgumentsToList(Link<ast.Node> link, List<HInstruction> list) {
@@ -3983,9 +3977,10 @@ class SsaBuilder extends ResolvedVisitor {
// TODO(5347): Try to avoid the need for calling [implementation] before
// calling [addStaticSendArgumentsToList].
FunctionElement function = element.implementation;
- bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
- function, inputs);
- assert(succeeded);
+ assert(selector.applies(function, compiler.world));
+ inputs = makeStaticArgumentList(selector,
+ node.arguments,
+ function);
push(buildInvokeSuper(selector, element, inputs));
} else if (element.isGenerativeConstructor) {
generateWrongArgumentCountError(node, element, node.arguments);
@@ -4264,13 +4259,13 @@ class SsaBuilder extends ResolvedVisitor {
}
// TODO(5347): Try to avoid the need for calling [implementation] before
// calling [addStaticSendArgumentsToList].
floitsch 2014/11/20 13:14:43 adapt comment.
sigurdm 2014/11/21 09:52:53 Done.
- bool succeeded = addStaticSendArgumentsToList(selector, send.arguments,
- constructor.implementation,
- inputs);
- if (!succeeded) {
+ if (!selector.applies(constructor.implementation, compiler.world)) {
generateWrongArgumentCountError(send, constructor, send.arguments);
return;
}
+ inputs.addAll(makeStaticArgumentList(selector,
+ send.arguments,
+ constructor.implementation));
if (constructor.isFactoryConstructor &&
!expectedType.typeArguments.isEmpty) {
@@ -4452,17 +4447,18 @@ class SsaBuilder extends ResolvedVisitor {
invariant(element, !element.isGenerativeConstructor);
generateIsDeferredLoadedCheckIfNeeded(node);
if (element.isFunction) {
- var inputs = <HInstruction>[];
// TODO(5347): Try to avoid the need for calling [implementation] before
// calling [addStaticSendArgumentsToList].
floitsch 2014/11/20 13:14:43 ditto.
sigurdm 2014/11/21 09:52:53 Done.
- bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
- element.implementation,
- inputs);
- if (!succeeded) {
+ if (!selector.applies(element.implementation, compiler.world)) {
generateWrongArgumentCountError(node, element, node.arguments);
return;
}
+ List<HInstruction> inputs =
+ makeStaticArgumentList(selector,
+ node.arguments,
+ element.implementation);
+
if (element == compiler.identicalFunction) {
pushWithPosition(
new HIdentity(inputs[0], inputs[1], null, backend.boolType), node);

Powered by Google App Engine
This is Rietveld 408576698