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

Side by Side 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, 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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 for (SourceString name in orderedNames) { 914 for (SourceString name in orderedNames) {
915 list.add(instructions[name]); 915 list.add(instructions[name]);
916 } 916 }
917 } 917 }
918 } 918 }
919 919
920 void addStaticSendArgumentsToList(Send node, 920 void addStaticSendArgumentsToList(Send node,
921 FunctionElement element, 921 FunctionElement element,
922 List<HInstruction> list) { 922 List<HInstruction> list) {
923 Selector selector = elements.getSelector(node); 923 Selector selector = elements.getSelector(node);
924 FunctionParameters parameters = element.computeParameters(compiler);
924 if (!selector.applies(compiler, element)) { 925 if (!selector.applies(compiler, element)) {
925 // TODO(ngeoffray): Match the VM behavior and throw an 926 // TODO(ngeoffray): Match the VM behavior and throw an
926 // exception at runtime. 927 // exception at runtime.
927 compiler.cancel('Unimplemented non-matching static call', node: node); 928 compiler.cancel('Unimplemented non-matching static call', node: node);
928 } else if (selector.namedArgumentCount == 0) { 929 } else if (selector.positionalArgumentCount == parameters.parameterCount) {
929 addGenericSendArgumentsToList(node.arguments, list); 930 addGenericSendArgumentsToList(node.arguments, list);
930 } else { 931 } else {
931 // If there are named arguments, provide them in the order 932 // If there are named arguments, provide them in the order
932 // expected by the called function, which is the source order. 933 // expected by the called function, which is the source order.
933 FunctionParameters parameters = element.computeParameters(compiler);
934 934
935 // Visit positional arguments and add them to the list. 935 // Visit positional arguments and add them to the list.
936 Link<Node> arguments = node.arguments; 936 Link<Node> arguments = node.arguments;
937 int positionalArgumentCount = selector.positionalArgumentCount; 937 int positionalArgumentCount = selector.positionalArgumentCount;
938 for (int i = 0; 938 for (int i = 0;
939 i < positionalArgumentCount; 939 i < positionalArgumentCount;
940 arguments = arguments.tail, i++) { 940 arguments = arguments.tail, i++) {
941 visit(arguments.head); 941 visit(arguments.head);
942 list.add(pop()); 942 list.add(pop());
943 } 943 }
(...skipping 25 matching lines...) Expand all
969 for (int i = 0; i < selector.namedArguments.length; i++) { 969 for (int i = 0; i < selector.namedArguments.length; i++) {
970 SourceString name = selector.namedArguments[i]; 970 SourceString name = selector.namedArguments[i];
971 if (name == parameter.name) { 971 if (name == parameter.name) {
972 foundIndex = i; 972 foundIndex = i;
973 break; 973 break;
974 } 974 }
975 } 975 }
976 if (foundIndex != -1) { 976 if (foundIndex != -1) {
977 list.add(namedArguments[foundIndex]); 977 list.add(namedArguments[foundIndex]);
978 } else { 978 } else {
979 // TODO(ngeoffray): Add the default value. 979 push(new HLiteral(
980 push(new HLiteral(null, HType.UNKNOWN)); 980 compiler.compileVariable(parameter), HType.UNKNOWN));
981 list.add(pop()); 981 list.add(pop());
982 } 982 }
983 } 983 }
984 } 984 }
985 } 985 }
986 986
987 void addGenericSendArgumentsToList(Link<Node> link, List<HInstruction> list) { 987 void addGenericSendArgumentsToList(Link<Node> link, List<HInstruction> list) {
988 for (; !link.isEmpty(); link = link.tail) { 988 for (; !link.isEmpty(); link = link.tail) {
989 visit(link.head); 989 visit(link.head);
990 list.add(pop()); 990 list.add(pop());
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 } 1527 }
1528 1528
1529 visitCatchBlock(CatchBlock node) { 1529 visitCatchBlock(CatchBlock node) {
1530 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); 1530 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node);
1531 } 1531 }
1532 1532
1533 visitTypedef(Typedef node) { 1533 visitTypedef(Typedef node) {
1534 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); 1534 compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
1535 } 1535 }
1536 } 1536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698