| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // Ensure the signature of the synthesized element is | 613 // Ensure the signature of the synthesized element is |
| 614 // resolved. This is the only place where the resolver is | 614 // resolved. This is the only place where the resolver is |
| 615 // seeing this element. | 615 // seeing this element. |
| 616 element.computeSignature(compiler); | 616 element.computeSignature(compiler); |
| 617 if (!target.isErroneous) { | 617 if (!target.isErroneous) { |
| 618 registry.registerStaticUse(target); | 618 registry.registerStaticUse(target); |
| 619 registry.registerImplicitSuperCall(target); | 619 registry.registerImplicitSuperCall(target); |
| 620 } | 620 } |
| 621 return registry.mapping; | 621 return registry.mapping; |
| 622 } else { | 622 } else { |
| 623 assert(element.isDeferredLoaderGetter); | 623 assert(element.isDeferredLoaderGetter || element.isErroneous); |
| 624 return _ensureTreeElements(element); | 624 return _ensureTreeElements(element); |
| 625 } | 625 } |
| 626 } else { | 626 } else { |
| 627 element.parseNode(compiler); | 627 element.parseNode(compiler); |
| 628 element.computeType(compiler); | 628 element.computeType(compiler); |
| 629 processAsyncMarker(compiler, element); | 629 processAsyncMarker(compiler, element); |
| 630 FunctionElementX implementation = element; | 630 FunctionElementX implementation = element; |
| 631 if (element.isExternal) { | 631 if (element.isExternal) { |
| 632 implementation = compiler.backend.resolveExternalFunction(element); | 632 implementation = compiler.backend.resolveExternalFunction(element); |
| 633 } | 633 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 764 |
| 765 // [factory] must already be analyzed but the [TreeElements] might not | 765 // [factory] must already be analyzed but the [TreeElements] might not |
| 766 // have been stored in the enqueuer cache yet. | 766 // have been stored in the enqueuer cache yet. |
| 767 // TODO(johnniwinther): Store [TreeElements] in the cache before | 767 // TODO(johnniwinther): Store [TreeElements] in the cache before |
| 768 // resolution of the element. | 768 // resolution of the element. |
| 769 TreeElements treeElements = factory.treeElements; | 769 TreeElements treeElements = factory.treeElements; |
| 770 assert(invariant(node, treeElements != null, | 770 assert(invariant(node, treeElements != null, |
| 771 message: 'No TreeElements cached for $factory.')); | 771 message: 'No TreeElements cached for $factory.')); |
| 772 FunctionExpression functionNode = factory.parseNode(compiler); | 772 FunctionExpression functionNode = factory.parseNode(compiler); |
| 773 RedirectingFactoryBody redirectionNode = functionNode.body; | 773 RedirectingFactoryBody redirectionNode = functionNode.body; |
| 774 InterfaceType factoryType = treeElements.getType(redirectionNode); | 774 DartType factoryType = treeElements.getType(redirectionNode); |
| 775 | 775 if (!factoryType.isDynamic) { |
| 776 targetType = targetType.substByContext(factoryType); | 776 targetType = targetType.substByContext(factoryType); |
| 777 } |
| 777 factory.effectiveTarget = target; | 778 factory.effectiveTarget = target; |
| 778 factory.effectiveTargetType = targetType; | 779 factory.effectiveTargetType = targetType; |
| 779 } | 780 } |
| 780 } | 781 } |
| 781 | 782 |
| 782 /** | 783 /** |
| 783 * Load and resolve the supertypes of [cls]. | 784 * Load and resolve the supertypes of [cls]. |
| 784 * | 785 * |
| 785 * Warning: do not call this method directly. It should only be | 786 * Warning: do not call this method directly. It should only be |
| 786 * called by [resolveClass] and [ClassSupertypeResolver]. | 787 * called by [resolveClass] and [ClassSupertypeResolver]. |
| (...skipping 4077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4864 if (element.isClass) { | 4865 if (element.isClass) { |
| 4865 ClassElement cls = element; | 4866 ClassElement cls = element; |
| 4866 cls.ensureResolved(compiler); | 4867 cls.ensureResolved(compiler); |
| 4867 // The unnamed constructor may not exist, so [e] may become unresolved. | 4868 // The unnamed constructor may not exist, so [e] may become unresolved. |
| 4868 element = resolveConstructor(cls, diagnosticNode, ''); | 4869 element = resolveConstructor(cls, diagnosticNode, ''); |
| 4869 } else { | 4870 } else { |
| 4870 element = failOrReturnErroneousElement( | 4871 element = failOrReturnErroneousElement( |
| 4871 element, diagnosticNode, element.name, MessageKind.NOT_A_TYPE, | 4872 element, diagnosticNode, element.name, MessageKind.NOT_A_TYPE, |
| 4872 {'node': diagnosticNode}); | 4873 {'node': diagnosticNode}); |
| 4873 } | 4874 } |
| 4875 } else if (element.isErroneous && element is! ErroneousElementX) { |
| 4876 element = new ErroneousConstructorElementX( |
| 4877 MessageKind.NOT_A_TYPE, {'node': diagnosticNode}, |
| 4878 element.name, element); |
| 4874 } | 4879 } |
| 4880 |
| 4875 if (type == null) { | 4881 if (type == null) { |
| 4876 if (Elements.isUnresolved(element)) { | 4882 if (Elements.isUnresolved(element)) { |
| 4877 type = const DynamicType(); | 4883 type = const DynamicType(); |
| 4878 } else { | 4884 } else { |
| 4879 type = element.enclosingClass.rawType; | 4885 type = element.enclosingClass.rawType; |
| 4880 } | 4886 } |
| 4881 } | 4887 } |
| 4882 resolver.registry.setType(expression, type); | 4888 resolver.registry.setType(expression, type); |
| 4883 return element; | 4889 return element; |
| 4884 } | 4890 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4966 } | 4972 } |
| 4967 } | 4973 } |
| 4968 | 4974 |
| 4969 /// Looks up [name] in [scope] and unwraps the result. | 4975 /// Looks up [name] in [scope] and unwraps the result. |
| 4970 Element lookupInScope(Compiler compiler, Node node, | 4976 Element lookupInScope(Compiler compiler, Node node, |
| 4971 Scope scope, String name) { | 4977 Scope scope, String name) { |
| 4972 return Elements.unwrap(scope.lookup(name), compiler, node); | 4978 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 4973 } | 4979 } |
| 4974 | 4980 |
| 4975 TreeElements _ensureTreeElements(AnalyzableElementX element) { | 4981 TreeElements _ensureTreeElements(AnalyzableElementX element) { |
| 4982 if (element.isErroneous) return new TreeElementMapping(element); |
| 4976 if (element._treeElements == null) { | 4983 if (element._treeElements == null) { |
| 4977 element._treeElements = new TreeElementMapping(element); | 4984 element._treeElements = new TreeElementMapping(element); |
| 4978 } | 4985 } |
| 4979 return element._treeElements; | 4986 return element._treeElements; |
| 4980 } | 4987 } |
| 4981 | 4988 |
| 4982 abstract class AnalyzableElementX implements AnalyzableElement { | 4989 abstract class AnalyzableElementX implements AnalyzableElement { |
| 4983 TreeElements _treeElements; | 4990 TreeElements _treeElements; |
| 4984 | 4991 |
| 4985 bool get hasTreeElements => _treeElements != null; | 4992 bool get hasTreeElements => _treeElements != null; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5029 } | 5036 } |
| 5030 | 5037 |
| 5031 /// The result for the resolution of the `assert` method. | 5038 /// The result for the resolution of the `assert` method. |
| 5032 class AssertResult implements ResolutionResult { | 5039 class AssertResult implements ResolutionResult { |
| 5033 const AssertResult(); | 5040 const AssertResult(); |
| 5034 | 5041 |
| 5035 Element get element => null; | 5042 Element get element => null; |
| 5036 | 5043 |
| 5037 String toString() => 'AssertResult()'; | 5044 String toString() => 'AssertResult()'; |
| 5038 } | 5045 } |
| OLD | NEW |