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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1172693003: Move computeType to TypedElement and TypeDeclarationElement. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
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 resolution; 5 part of resolution;
6 6
7 /** 7 /**
8 * Core implementation of resolution. 8 * Core implementation of resolution.
9 * 9 *
10 * Do not subclass or instantiate this class outside this library 10 * Do not subclass or instantiate this class outside this library
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 // type literal. 752 // type literal.
753 DartType type; 753 DartType type;
754 754
755 // TODO(johnniwinther): Remove this hack when we can pass more complex 755 // TODO(johnniwinther): Remove this hack when we can pass more complex
756 // information between methods than resolved elements. 756 // information between methods than resolved elements.
757 if (target == compiler.typeClass && node.receiver == null) { 757 if (target == compiler.typeClass && node.receiver == null) {
758 // Potentially a 'dynamic' type literal. 758 // Potentially a 'dynamic' type literal.
759 type = registry.getType(node.selector); 759 type = registry.getType(node.selector);
760 } 760 }
761 if (type == null) { 761 if (type == null) {
762 type = target.computeType(compiler); 762 if (target.isTypedef || target.isClass) {
763 TypeDeclarationElement typeDeclaration = target;
764 typeDeclaration.computeType(compiler);
765 type = typeDeclaration.rawType;
766 } else {
767 TypeVariableElement typeVariable = target;
768 type = typeVariable.type;
769 }
763 } 770 }
764 registry.registerTypeLiteral(node, type); 771 registry.registerTypeLiteral(node, type);
765 772
766 if (!target.isTypeVariable) { 773 if (!target.isTypeVariable) {
767 // Don't try to make constants of calls and assignments to type literals. 774 // Don't try to make constants of calls and assignments to type literals.
768 if (!node.isCall && node.asSendSet() == null) { 775 if (!node.isCall && node.asSendSet() == null) {
769 analyzeConstantDeferred(node, enforceConst: false); 776 analyzeConstantDeferred(node, enforceConst: false);
770 } else { 777 } else {
771 // The node itself is not a constant but we register the selector (the 778 // The node itself is not a constant but we register the selector (the
772 // identifier that refers to the class/typedef) as a constant. 779 // identifier that refers to the class/typedef) as a constant.
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 registerPotentialAccessInClosure(node, element); 1719 registerPotentialAccessInClosure(node, element);
1713 1720
1714 return node.isPropertyAccess 1721 return node.isPropertyAccess
1715 ? new ElementResult(element) : const NoneResult(); 1722 ? new ElementResult(element) : const NoneResult();
1716 } 1723 }
1717 1724
1718 /// Handle access of a static or top level [element]. 1725 /// Handle access of a static or top level [element].
1719 ResolutionResult handleStaticOrTopLevelAccess( 1726 ResolutionResult handleStaticOrTopLevelAccess(
1720 Send node, Name name, Element element) { 1727 Send node, Name name, Element element) {
1721 1728
1729 MemberElement member;
1722 if (element.isAbstractField) { 1730 if (element.isAbstractField) {
1723 AbstractFieldElement abstractField = element; 1731 AbstractFieldElement abstractField = element;
1724 if (abstractField.getter != null) { 1732 if (abstractField.getter != null) {
1725 element = abstractField.getter; 1733 member = abstractField.getter;
1726 } else { 1734 } else {
1727 element = abstractField.setter; 1735 member = abstractField.setter;
1728 } 1736 }
1737 } else {
1738 member = element;
1729 } 1739 }
1730 // TODO(johnniwinther): Needed to provoke a parsing and with it discovery 1740 // TODO(johnniwinther): Needed to provoke a parsing and with it discovery
1731 // of parse errors to make [element] erroneous. Fix this! 1741 // of parse errors to make [element] erroneous. Fix this!
1732 element.computeType(compiler); 1742 member.computeType(compiler);
1733 1743
1734 Selector selector; 1744 Selector selector;
1735 CallStructure callStructure = CallStructure.NO_ARGS; 1745 CallStructure callStructure = CallStructure.NO_ARGS;
1736 if (node.isCall) { 1746 if (node.isCall) {
1737 callStructure = resolveArguments(node.argumentsNode); 1747 callStructure = resolveArguments(node.argumentsNode);
1738 selector = new Selector(SelectorKind.CALL, name, callStructure); 1748 selector = new Selector(SelectorKind.CALL, name, callStructure);
1739 } else { 1749 } else {
1740 selector = new Selector(SelectorKind.GETTER, name, callStructure); 1750 selector = new Selector(SelectorKind.GETTER, name, callStructure);
1741 } 1751 }
1742 AccessSemantics semantics = 1752 AccessSemantics semantics =
1743 computeStaticOrTopLevelAccessSemantics(node, element); 1753 computeStaticOrTopLevelAccessSemantics(node, member);
1744 if (node.isCall) { 1754 if (node.isCall) {
1745 bool isIncompatibleInvoke = false; 1755 bool isIncompatibleInvoke = false;
1746 switch (semantics.kind) { 1756 switch (semantics.kind) {
1747 case AccessKind.STATIC_METHOD: 1757 case AccessKind.STATIC_METHOD:
1748 case AccessKind.TOPLEVEL_METHOD: 1758 case AccessKind.TOPLEVEL_METHOD:
1749 MethodElementX method = semantics.element; 1759 MethodElementX method = semantics.element;
1750 method.computeSignature(compiler); 1760 method.computeSignature(compiler);
1751 if (!callStructure.signatureApplies(method)) { 1761 if (!callStructure.signatureApplies(method)) {
1752 registry.registerThrowNoSuchMethod(); 1762 registry.registerThrowNoSuchMethod();
1753 registry.registerDynamicInvocation(selector); 1763 registry.registerDynamicInvocation(selector);
(...skipping 10 matching lines...) Expand all
1764 case AccessKind.FINAL_TOPLEVEL_FIELD: 1774 case AccessKind.FINAL_TOPLEVEL_FIELD:
1765 case AccessKind.TOPLEVEL_GETTER: 1775 case AccessKind.TOPLEVEL_GETTER:
1766 registry.registerStaticUse(semantics.element); 1776 registry.registerStaticUse(semantics.element);
1767 selector = callStructure.callSelector; 1777 selector = callStructure.callSelector;
1768 registry.registerDynamicInvocation(selector); 1778 registry.registerDynamicInvocation(selector);
1769 break; 1779 break;
1770 case AccessKind.STATIC_SETTER: 1780 case AccessKind.STATIC_SETTER:
1771 case AccessKind.TOPLEVEL_SETTER: 1781 case AccessKind.TOPLEVEL_SETTER:
1772 case AccessKind.UNRESOLVED: 1782 case AccessKind.UNRESOLVED:
1773 registry.registerThrowNoSuchMethod(); 1783 registry.registerThrowNoSuchMethod();
1774 element = reportAndCreateErroneousElement( 1784 member = reportAndCreateErroneousElement(
1775 node.selector, name.text, 1785 node.selector, name.text,
1776 MessageKind.CANNOT_RESOLVE_GETTER, const {}); 1786 MessageKind.CANNOT_RESOLVE_GETTER, const {});
1777 break; 1787 break;
1778 default: 1788 default:
1779 internalError(node, 1789 internalError(node,
1780 "Unexpected statically resolved access $semantics."); 1790 "Unexpected statically resolved access $semantics.");
1781 break; 1791 break;
1782 } 1792 }
1783 registry.registerSendStructure(node, 1793 registry.registerSendStructure(node,
1784 isIncompatibleInvoke 1794 isIncompatibleInvoke
(...skipping 13 matching lines...) Expand all
1798 case AccessKind.STATIC_GETTER: 1808 case AccessKind.STATIC_GETTER:
1799 case AccessKind.TOPLEVEL_FIELD: 1809 case AccessKind.TOPLEVEL_FIELD:
1800 case AccessKind.FINAL_TOPLEVEL_FIELD: 1810 case AccessKind.FINAL_TOPLEVEL_FIELD:
1801 case AccessKind.TOPLEVEL_GETTER: 1811 case AccessKind.TOPLEVEL_GETTER:
1802 registry.registerStaticUse(semantics.element); 1812 registry.registerStaticUse(semantics.element);
1803 break; 1813 break;
1804 case AccessKind.STATIC_SETTER: 1814 case AccessKind.STATIC_SETTER:
1805 case AccessKind.TOPLEVEL_SETTER: 1815 case AccessKind.TOPLEVEL_SETTER:
1806 case AccessKind.UNRESOLVED: 1816 case AccessKind.UNRESOLVED:
1807 registry.registerThrowNoSuchMethod(); 1817 registry.registerThrowNoSuchMethod();
1808 element = reportAndCreateErroneousElement( 1818 member = reportAndCreateErroneousElement(
1809 node.selector, name.text, 1819 node.selector, name.text,
1810 MessageKind.CANNOT_RESOLVE_GETTER, const {}); 1820 MessageKind.CANNOT_RESOLVE_GETTER, const {});
1811 break; 1821 break;
1812 default: 1822 default:
1813 internalError(node, 1823 internalError(node,
1814 "Unexpected statically resolved access $semantics."); 1824 "Unexpected statically resolved access $semantics.");
1815 break; 1825 break;
1816 } 1826 }
1817 registry.registerSendStructure(node, 1827 registry.registerSendStructure(node,
1818 new GetStructure(semantics, selector)); 1828 new GetStructure(semantics, selector));
1819 } 1829 }
1820 1830
1821 // TODO(johnniwinther): Remove these when all information goes through 1831 // TODO(johnniwinther): Remove these when all information goes through
1822 // the [SendStructure]. 1832 // the [SendStructure].
1823 registry.useElement(node, element); 1833 registry.useElement(node, member);
1824 registry.setSelector(node, selector); 1834 registry.setSelector(node, selector);
1825 1835
1826 return node.isPropertyAccess 1836 return node.isPropertyAccess
1827 ? new ElementResult(element) : const NoneResult(); 1837 ? new ElementResult(member) : const NoneResult();
1828 } 1838 }
1829 1839
1830 /// Handle access to resolved [element]. 1840 /// Handle access to resolved [element].
1831 ResolutionResult handleResolvedSend(Send node, Name name, Element element) { 1841 ResolutionResult handleResolvedSend(Send node, Name name, Element element) {
1832 if (element.isAmbiguous) { 1842 if (element.isAmbiguous) {
1833 return handleAmbiguousSend(node, name, element); 1843 return handleAmbiguousSend(node, name, element);
1834 } 1844 }
1835 if (element.isErroneous) { 1845 if (element.isErroneous) {
1836 // This handles elements with parser errors. 1846 // This handles elements with parser errors.
1837 // TODO(johnniwinther): Elements with parse error should not set 1847 // TODO(johnniwinther): Elements with parse error should not set
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3265 } 3275 }
3266 return const NoneResult(); 3276 return const NoneResult();
3267 } 3277 }
3268 } 3278 }
3269 3279
3270 /// Looks up [name] in [scope] and unwraps the result. 3280 /// Looks up [name] in [scope] and unwraps the result.
3271 Element lookupInScope(Compiler compiler, Node node, 3281 Element lookupInScope(Compiler compiler, Node node,
3272 Scope scope, String name) { 3282 Scope scope, String name) {
3273 return Elements.unwrap(scope.lookup(name), compiler, node); 3283 return Elements.unwrap(scope.lookup(name), compiler, node);
3274 } 3284 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/class_members.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698