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

Unified Diff: dart/frog/leg/ssa/builder.dart

Issue 9315028: Support default values for optional parameters. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/frog/leg/ssa/builder.dart
===================================================================
--- dart/frog/leg/ssa/builder.dart (revision 3786)
+++ dart/frog/leg/ssa/builder.dart (working copy)
@@ -921,16 +921,16 @@
FunctionElement element,
List<HInstruction> list) {
Selector selector = elements.getSelector(node);
+ FunctionParameters parameters = element.computeParameters(compiler);
if (!selector.applies(compiler, element)) {
// TODO(ngeoffray): Match the VM behavior and throw an
// exception at runtime.
compiler.cancel('Unimplemented non-matching static call', node: node);
- } else if (selector.namedArgumentCount == 0) {
+ } else if (selector.positionalArgumentCount == parameters.parameterCount) {
addGenericSendArgumentsToList(node.arguments, list);
} else {
// If there are named arguments, provide them in the order
// expected by the called function, which is the source order.
- FunctionParameters parameters = element.computeParameters(compiler);
// Visit positional arguments and add them to the list.
Link<Node> arguments = node.arguments;
@@ -976,8 +976,8 @@
if (foundIndex != -1) {
list.add(namedArguments[foundIndex]);
} else {
- // TODO(ngeoffray): Add the default value.
- push(new HLiteral(null, HType.UNKNOWN));
+ push(new HLiteral(
+ compiler.compileVariable(parameter), HType.UNKNOWN));
list.add(pop());
}
}

Powered by Google App Engine
This is Rietveld 408576698