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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 11688010: NoSuchMethod on different super accesses/invocations handled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 // Register this invocation to collect the types used at all call sites. 1670 // Register this invocation to collect the types used at all call sites.
1671 backend.registerStaticInvocation(node, types); 1671 backend.registerStaticInvocation(node, types);
1672 } 1672 }
1673 use(node.target); 1673 use(node.target);
1674 push(new js.Call(pop(), visitArguments(node.inputs)), node); 1674 push(new js.Call(pop(), visitArguments(node.inputs)), node);
1675 } 1675 }
1676 1676
1677 visitInvokeSuper(HInvokeSuper node) { 1677 visitInvokeSuper(HInvokeSuper node) {
1678 Element superMethod = node.element; 1678 Element superMethod = node.element;
1679 Element superClass = superMethod.getEnclosingClass(); 1679 Element superClass = superMethod.getEnclosingClass();
1680 if (superMethod.kind == ElementKind.FIELD) { 1680 if (superMethod.isField()) {
1681 ClassElement currentClass = work.element.getEnclosingClass(); 1681 ClassElement currentClass = work.element.getEnclosingClass();
1682 if (currentClass.isClosure()) { 1682 if (currentClass.isClosure()) {
1683 ClosureClassElement closure = currentClass; 1683 ClosureClassElement closure = currentClass;
1684 currentClass = closure.methodElement.getEnclosingClass(); 1684 currentClass = closure.methodElement.getEnclosingClass();
1685 } 1685 }
1686 String fieldName; 1686 String fieldName;
1687 if (currentClass.isShadowedByField(superMethod)) { 1687 if (currentClass.isShadowedByField(superMethod)) {
1688 fieldName = backend.namer.shadowedFieldName(superMethod); 1688 fieldName = backend.namer.shadowedFieldName(superMethod);
1689 } else { 1689 } else {
1690 LibraryElement library = superMethod.getLibrary(); 1690 LibraryElement library = superMethod.getLibrary();
1691 SourceString name = superMethod.name; 1691 SourceString name = superMethod.name;
1692 fieldName = backend.namer.instanceFieldName(library, name); 1692 fieldName = backend.namer.instanceFieldName(library, name);
1693 } 1693 }
1694 use(node.inputs[1]); 1694 use(node.inputs[1]);
1695 js.PropertyAccess access = 1695 js.PropertyAccess access =
1696 new js.PropertyAccess.field(pop(), fieldName); 1696 new js.PropertyAccess.field(pop(), fieldName);
1697 if (node.isSetter) { 1697 if (node.isSetter) {
1698 use(node.value); 1698 use(node.value);
1699 push(new js.Assignment(access, pop()), node); 1699 push(new js.Assignment(access, pop()), node);
1700 } else { 1700 } else {
1701 push(access, node); 1701 push(access, node);
1702 } 1702 }
1703 } else { 1703 } else {
1704 bool isPropertyAccess = false;
1704 String methodName; 1705 String methodName;
1705 if (superMethod.kind == ElementKind.FUNCTION || 1706 if (superMethod.isGetter()) {
1706 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
1707 methodName = backend.namer.instanceMethodName(superMethod);
1708 } else if (superMethod.kind == ElementKind.GETTER) {
1709 methodName = 1707 methodName =
1710 backend.namer.getterName(currentLibrary, superMethod.name); 1708 backend.namer.getterName(currentLibrary, superMethod.name);
1711 } else { 1709 } else if (node.isSetter || superMethod.isSetter()) {
1712 assert(superMethod.kind == ElementKind.SETTER);
1713 methodName = 1710 methodName =
1714 backend.namer.setterName(currentLibrary, superMethod.name); 1711 backend.namer.setterName(currentLibrary, superMethod.name);
1712 } else if (superMethod.isFunction() ||
1713 superMethod.isGenerativeConstructor()) {
1714 if (node.isGetter) {
1715 methodName =
1716 backend.namer.getterName(currentLibrary, superMethod.name);
1717 isPropertyAccess = true;
1718 } else {
1719 methodName = backend.namer.instanceMethodName(superMethod);
1720 }
1715 } 1721 }
1716 String className = backend.namer.isolateAccess(superClass); 1722 String className = backend.namer.isolateAccess(superClass);
1717 js.VariableUse classReference = new js.VariableUse(className); 1723 js.VariableUse classReference = new js.VariableUse(className);
1718 js.PropertyAccess prototype = 1724 js.PropertyAccess prototype =
1719 new js.PropertyAccess.field(classReference, "prototype"); 1725 new js.PropertyAccess.field(classReference, "prototype");
1720 js.PropertyAccess method = 1726 if (isPropertyAccess) {
1721 new js.PropertyAccess.field(prototype, methodName); 1727 // Property access of a function. Obtain the bound closure instead of
1722 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node); 1728 // invoking the function.
1729 push(jsPropertyCall(prototype, methodName,
1730 visitArguments(node.inputs)), node);
1731 } else {
1732 js.PropertyAccess method =
1733 new js.PropertyAccess.field(prototype, methodName);
1734 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node);
1735 }
1723 } 1736 }
1724 world.registerStaticUse(superMethod); 1737 world.registerStaticUse(superMethod);
1725 } 1738 }
1726 1739
1727 visitFieldGet(HFieldGet node) { 1740 visitFieldGet(HFieldGet node) {
1728 use(node.receiver); 1741 use(node.receiver);
1729 if (node.element == backend.jsArrayLength 1742 if (node.element == backend.jsArrayLength
1730 || node.element == backend.jsStringLength) { 1743 || node.element == backend.jsStringLength) {
1731 // We're accessing a native JavaScript property called 'length' 1744 // We're accessing a native JavaScript property called 'length'
1732 // on a JS String or a JS array. Therefore, the name of that 1745 // on a JS String or a JS array. Therefore, the name of that
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 if (leftType.canBeNull() && rightType.canBeNull()) { 3091 if (leftType.canBeNull() && rightType.canBeNull()) {
3079 if (left.isConstantNull() || right.isConstantNull() || 3092 if (left.isConstantNull() || right.isConstantNull() ||
3080 (leftType.isPrimitive() && leftType == rightType)) { 3093 (leftType.isPrimitive() && leftType == rightType)) {
3081 return '=='; 3094 return '==';
3082 } 3095 }
3083 return null; 3096 return null;
3084 } else { 3097 } else {
3085 return '==='; 3098 return '===';
3086 } 3099 }
3087 } 3100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698