| OLD | NEW |
| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 compiler.resolver.resolveMethodElement(constructor); | 700 compiler.resolver.resolveMethodElement(constructor); |
| 701 compiler.enqueue(new WorkItem.toCodegen(bodyElement, treeElements)); | 701 compiler.enqueue(new WorkItem.toCodegen(bodyElement, treeElements)); |
| 702 classElement.backendMembers = | 702 classElement.backendMembers = |
| 703 classElement.backendMembers.prepend(bodyElement); | 703 classElement.backendMembers.prepend(bodyElement); |
| 704 } | 704 } |
| 705 assert(bodyElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY); | 705 assert(bodyElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY); |
| 706 return bodyElement; | 706 return bodyElement; |
| 707 } | 707 } |
| 708 | 708 |
| 709 /** | 709 /** |
| 710 * Call [f] for every argument and parameter element of [target] | |
| 711 * that is used in the invocation [send]. | |
| 712 */ | |
| 713 forEachArgument(Send send, FunctionElement target, | |
| 714 f(VariableElement parameter, Node argument)) { | |
| 715 final FunctionParameters parameters = target.computeParameters(compiler); | |
| 716 Link<Element> parameterElements = parameters.requiredParameters; | |
| 717 for (Link<Node> arguments = send.arguments; | |
| 718 !arguments.isEmpty(); | |
| 719 arguments = arguments.tail) { | |
| 720 if (parameterElements.isEmpty()) { | |
| 721 parameterElements = parameters.optionalParameters; | |
| 722 } | |
| 723 f(parameterElements.head, arguments.head); | |
| 724 parameterElements = parameterElements.tail; | |
| 725 }; | |
| 726 } | |
| 727 | |
| 728 /** | |
| 729 * Run through the initializers and inline all field initializers. Returns the | 710 * Run through the initializers and inline all field initializers. Returns the |
| 730 * next constructor to analyze. | 711 * next constructor to analyze. |
| 731 */ | 712 */ |
| 732 FunctionElement analyzeInitializers(Link<Node> initializers) { | 713 FunctionElement analyzeInitializers(Link<Node> initializers) { |
| 733 FunctionElement nextConstructor; | 714 FunctionElement nextConstructor; |
| 734 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) { | 715 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) { |
| 735 assert(link.head is Send); | 716 assert(link.head is Send); |
| 736 if (link.head is !SendSet) { | 717 if (link.head is !SendSet) { |
| 737 // A super initializer or constructor redirection. | 718 // A super initializer or constructor redirection. |
| 738 Send call = link.head; | 719 Send call = link.head; |
| 739 assert(Initializers.isSuperConstructorCall(call) || | 720 assert(Initializers.isSuperConstructorCall(call) || |
| 740 Initializers.isConstructorRedirect(call)); | 721 Initializers.isConstructorRedirect(call)); |
| 741 assert(nextConstructor === null); | 722 assert(nextConstructor === null); |
| 742 nextConstructor = elements[call]; | 723 nextConstructor = elements[call]; |
| 743 // Visit arguments and map the corresponding parameter value to | 724 // Visit arguments and map the corresponding parameter value to |
| 744 // the resulting HInstruction value. | 725 // the resulting HInstruction value. |
| 745 forEachArgument(call, nextConstructor, (parameter, node) { | 726 List<HInstruction> arguments = new List<HInstruction>(); |
| 746 visit(node); | 727 addStaticSendArgumentsToList(call, nextConstructor, arguments); |
| 747 HInstruction value = pop(); | 728 int index = 0; |
| 748 localsHandler.updateLocal(parameter, value); | 729 FunctionParameters parameters = |
| 730 nextConstructor.computeParameters(compiler); |
| 731 parameters.forEachParameter((parameter) { |
| 732 localsHandler.updateLocal(parameter, arguments[index++]); |
| 749 }); | 733 }); |
| 750 } else { | 734 } else { |
| 751 // A field initializer. | 735 // A field initializer. |
| 752 SendSet init = link.head; | 736 SendSet init = link.head; |
| 753 Link<Node> arguments = init.arguments; | 737 Link<Node> arguments = init.arguments; |
| 754 assert(!arguments.isEmpty() && arguments.tail.isEmpty()); | 738 assert(!arguments.isEmpty() && arguments.tail.isEmpty()); |
| 755 visit(arguments.head); | 739 visit(arguments.head); |
| 756 // We treat the init field-elements like locals. In the context of | 740 // We treat the init field-elements like locals. In the context of |
| 757 // the factory this is correct, and simplifies dealing with | 741 // the factory this is correct, and simplifies dealing with |
| 758 // parameter-initializers (like A(this.x)). | 742 // parameter-initializers (like A(this.x)). |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 } | 2274 } |
| 2291 | 2275 |
| 2292 visitCatchBlock(CatchBlock node) { | 2276 visitCatchBlock(CatchBlock node) { |
| 2293 visit(node.block); | 2277 visit(node.block); |
| 2294 } | 2278 } |
| 2295 | 2279 |
| 2296 visitTypedef(Typedef node) { | 2280 visitTypedef(Typedef node) { |
| 2297 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); | 2281 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); |
| 2298 } | 2282 } |
| 2299 } | 2283 } |
| OLD | NEW |