Chromium Code Reviews| Index: frog/leg/ssa/builder.dart |
| =================================================================== |
| --- frog/leg/ssa/builder.dart (revision 3778) |
| +++ frog/leg/ssa/builder.dart (working copy) |
| @@ -887,8 +887,35 @@ |
| if (selector.namedArgumentCount == 0) { |
| addGenericSendArgumentsToList(node.arguments, list); |
| } else { |
| - compiler.cancel( |
| - 'Unimplemented named argument for dynamic sends', node: node); |
| + // Visit positional arguments and add them to the list. |
|
kasperl
2012/02/01 10:21:21
I would factor this out into a couple of helper fu
|
| + Link<Node> arguments = node.arguments; |
| + int positionalArgumentCount = selector.positionalArgumentCount; |
| + for (int i = 0; |
| + i < positionalArgumentCount; |
| + arguments = arguments.tail, i++) { |
| + visit(arguments.head); |
| + list.add(pop()); |
| + } |
| + |
| + // Visit named arguments and add them into a temporary map. |
| + Map<SourceString, HInstruction> instructions = |
| + new Map<SourceString, HInstruction>(); |
| + List<SourceString> namedArguments = selector.namedArguments; |
| + int nameIndex = 0; |
| + for (; !arguments.isEmpty(); arguments = arguments.tail) { |
| + visit(arguments.head); |
| + instructions[namedArguments[nameIndex++]] = pop(); |
| + } |
| + |
| + // Iterate through the named arguments to add them to the list |
| + // of instructions, in the order set by the map. |
| + List<SourceString> keys = instructions.getKeys(); |
| + for (SourceString name in keys) { |
| + list.add(instructions[name]); |
| + } |
| + |
| + // Update the selector with an ordered list of named arguments. |
| + selector.orderedNamedArguments = keys; |
| } |
| } |