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

Side by Side Diff: frog/leg/ssa/builder.dart

Issue 9316026: Support named arguments for dynamic calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 var left = pop(); 880 var left = pop();
881 visitBinary(left, op, right); 881 visitBinary(left, op, right);
882 } 882 }
883 } 883 }
884 884
885 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { 885 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) {
886 Selector selector = elements.getSelector(node); 886 Selector selector = elements.getSelector(node);
887 if (selector.namedArgumentCount == 0) { 887 if (selector.namedArgumentCount == 0) {
888 addGenericSendArgumentsToList(node.arguments, list); 888 addGenericSendArgumentsToList(node.arguments, list);
889 } else { 889 } else {
890 compiler.cancel( 890 // Visit positional arguments and add them to the list.
891 'Unimplemented named argument for dynamic sends', node: node); 891 Link<Node> arguments = node.arguments;
892 int positionalArgumentCount = selector.positionalArgumentCount;
893 for (int i = 0;
894 i < positionalArgumentCount;
895 arguments = arguments.tail, i++) {
896 visit(arguments.head);
897 list.add(pop());
898 }
899
900 // Visit named arguments and add them into a temporary map.
901 Map<SourceString, HInstruction> instructions =
902 new Map<SourceString, HInstruction>();
903 List<SourceString> namedArguments = selector.namedArguments;
904 int nameIndex = 0;
905 for (; !arguments.isEmpty(); arguments = arguments.tail) {
906 visit(arguments.head);
907 instructions[namedArguments[nameIndex++]] = pop();
908 }
909
910 // Iterate through the named arguments to add them to the list
911 // of instructions, in the order set by the map.
912 List<SourceString> keys = instructions.getKeys();
913 for (SourceString name in keys) {
914 list.add(instructions[name]);
915 }
916
917 // Update the selector with an ordered list of named arguments.
918 selector.orderedNamedArguments = keys;
floitsch 2012/02/01 12:19:17 Why/how is keys ordered?
ngeoffray 2012/02/01 13:02:40 As discussed, ordered it in another way.
892 } 919 }
893 } 920 }
894 921
895 void addStaticSendArgumentsToList(Send node, 922 void addStaticSendArgumentsToList(Send node,
896 FunctionElement element, 923 FunctionElement element,
897 List<HInstruction> list) { 924 List<HInstruction> list) {
898 Selector selector = elements.getSelector(node); 925 Selector selector = elements.getSelector(node);
899 if (!selector.applies(compiler, element)) { 926 if (!selector.applies(compiler, element)) {
900 // TODO(ngeoffray): Match the VM behavior and throw an 927 // TODO(ngeoffray): Match the VM behavior and throw an
901 // exception at runtime. 928 // exception at runtime.
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1529 }
1503 1530
1504 visitCatchBlock(CatchBlock node) { 1531 visitCatchBlock(CatchBlock node) {
1505 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); 1532 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node);
1506 } 1533 }
1507 1534
1508 visitTypedef(Typedef node) { 1535 visitTypedef(Typedef node) {
1509 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); 1536 compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
1510 } 1537 }
1511 } 1538 }
OLDNEW
« frog/leg/namer.dart ('K') | « frog/leg/namer.dart ('k') | frog/leg/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698