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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart

Issue 913213002: Handle super calls to fields or getters that look like method calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.ir_builder; 5 part of dart2js.ir_builder;
6 6
7 /** 7 /**
8 * This task iterates through all resolved elements and builds [ir.Node]s. The 8 * This task iterates through all resolved elements and builds [ir.Node]s. The
9 * nodes are stored in the [nodes] map and accessible through [hasIr] and 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and
10 * [getIr]. 10 * [getIr].
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 assert(selector.isCall); 751 assert(selector.isCall);
752 assert(element is FunctionElement); 752 assert(element is FunctionElement);
753 List<ir.Primitive> arguments = node.arguments.mapToList(visit); 753 List<ir.Primitive> arguments = node.arguments.mapToList(visit);
754 arguments = normalizeStaticArguments(selector, element, arguments); 754 arguments = normalizeStaticArguments(selector, element, arguments);
755 return irBuilder.buildStaticInvocation(element, selector, arguments); 755 return irBuilder.buildStaticInvocation(element, selector, arguments);
756 } 756 }
757 } 757 }
758 758
759 ir.Primitive visitSuperSend(ast.Send node) { 759 ir.Primitive visitSuperSend(ast.Send node) {
760 assert(irBuilder.isOpen); 760 assert(irBuilder.isOpen);
761 if (node.isPropertyAccess) { 761 Selector selector = elements.getSelector(node);
762 return visitGetterSend(node); 762 Element target = elements[node];
763
764 if (selector.isCall && (target.isGetter || target.isField)) {
765 // We are invoking a field or getter as if it was a method, e.g:
766 //
767 // class A { get foo => {..} }
768 // class B extends A {
769 // m() {
770 // super.foo(1, 2, 3); }
771 // }
772 // }
773 //
774 // We invoke the getter of 'foo' and then invoke the 'call' method on
775 // the result, using the given arguments.
776 Selector getter = new Selector.getterFrom(selector);
777 Selector call = new Selector.callClosureFrom(selector);
778 ir.Primitive receiver =
779 irBuilder.buildSuperInvocation(target, getter, []);
780 List<ir.Primitive> arguments = node.arguments.mapToList(visit);
781 arguments = normalizeDynamicArguments(selector, arguments);
782 return irBuilder.buildCallInvocation(receiver, call, arguments);
783 } else if (selector.isCall) {
784 // We are invoking a method.
785 assert(target is FunctionElement);
786 List<ir.Primitive> arguments = node.arguments.mapToList(visit);
787 arguments = normalizeStaticArguments(selector, target, arguments);
788 return irBuilder.buildSuperInvocation(target, selector, arguments);
763 } else { 789 } else {
764 Selector selector = elements.getSelector(node); 790 // We are invoking a getter, operator, indexer, etc.
765 Element target = elements[node]; 791 List<ir.Primitive> arguments = node.argumentsNode == null
766 List<ir.Primitive> arguments = node.arguments.mapToList(visit); 792 ? <ir.Primitive>[]
767 if (selector.isCall) { 793 : node.arguments.mapToList(visit);
768 arguments = normalizeStaticArguments(selector, target, arguments);
769 }
770 return irBuilder.buildSuperInvocation(target, selector, arguments); 794 return irBuilder.buildSuperInvocation(target, selector, arguments);
771 } 795 }
772 } 796 }
773 797
774 visitTypePrefixSend(ast.Send node) { 798 visitTypePrefixSend(ast.Send node) {
775 compiler.internalError(node, "visitTypePrefixSend should not be called."); 799 compiler.internalError(node, "visitTypePrefixSend should not be called.");
776 } 800 }
777 801
778 ir.Primitive visitTypeLiteralSend(ast.Send node) { 802 ir.Primitive visitTypeLiteralSend(ast.Send node) {
779 assert(irBuilder.isOpen); 803 assert(irBuilder.isOpen);
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 for (String argName in selector.getOrderedNamedArguments()) { 1707 for (String argName in selector.getOrderedNamedArguments()) {
1684 int nameIndex = selector.namedArguments.indexOf(argName); 1708 int nameIndex = selector.namedArguments.indexOf(argName);
1685 int translatedIndex = selector.positionalArgumentCount + nameIndex; 1709 int translatedIndex = selector.positionalArgumentCount + nameIndex;
1686 result.add(arguments[translatedIndex]); 1710 result.add(arguments[translatedIndex]);
1687 } 1711 }
1688 return result; 1712 return result;
1689 } 1713 }
1690 1714
1691 } 1715 }
1692 1716
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698