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 Element operator[](Node node); | 8 Element operator[](Node node); |
9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
10 DartType getType(Node node); | 10 DartType getType(Node node); |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1728 // with the same arguments. | 1728 // with the same arguments. |
1729 Selector call = new Selector.callClosureFrom(selector); | 1729 Selector call = new Selector.callClosureFrom(selector); |
1730 world.registerDynamicInvocation(call.name, call); | 1730 world.registerDynamicInvocation(call.name, call); |
1731 } else if (target.impliesType()) { | 1731 } else if (target.impliesType()) { |
1732 // We call 'call()' on a Type instance returned from the reference to a | 1732 // We call 'call()' on a Type instance returned from the reference to a |
1733 // class or typedef literal. We do not need to register this call as a | 1733 // class or typedef literal. We do not need to register this call as a |
1734 // dynamic invocation, because we statically know what the target is. | 1734 // dynamic invocation, because we statically know what the target is. |
1735 } else if (!selector.applies(target, compiler)) { | 1735 } else if (!selector.applies(target, compiler)) { |
1736 warnArgumentMismatch(node, target); | 1736 warnArgumentMismatch(node, target); |
1737 } | 1737 } |
1738 | |
1739 if (selector.name == const SourceString('JS')) { | |
ngeoffray
2012/11/15 12:49:57
Add a target.kind == ElementKind.FOREIGN. Otherwis
| |
1740 world.nativeEnqueuer.registerJsCall(node, this); | |
1741 } | |
1738 } | 1742 } |
1739 | 1743 |
1740 // TODO(ngeoffray): Warn if target is null and the send is | 1744 // TODO(ngeoffray): Warn if target is null and the send is |
1741 // unqualified. | 1745 // unqualified. |
1742 useElement(node, target); | 1746 useElement(node, target); |
1743 registerSend(selector, target); | 1747 registerSend(selector, target); |
1744 return node.isPropertyAccess ? target : null; | 1748 return node.isPropertyAccess ? target : null; |
1745 } | 1749 } |
1746 | 1750 |
1747 void warnArgumentMismatch(Send node, Element target) { | 1751 void warnArgumentMismatch(Send node, Element target) { |
1748 // TODO(karlklose): we can be more precise about the reason of the | 1752 // TODO(karlklose): we can be more precise about the reason of the |
1749 // mismatch. | 1753 // mismatch. |
1750 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS, | 1754 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS, |
1751 [target.name]); | 1755 [target.name]); |
1752 } | 1756 } |
1753 | 1757 |
1758 /// Callback for native enqueuer to parse a type. Returns [:null:] on error. | |
1759 DartType resolveTypeFromString(String typeName) { | |
1760 Element element = scope.lookup(new SourceString(typeName)); | |
1761 if (element == null) return null; | |
1762 if (element is! ClassElement) return null; | |
1763 element.ensureResolved(compiler); | |
1764 return element.computeType(compiler); | |
1765 } | |
1766 | |
1754 visitSendSet(SendSet node) { | 1767 visitSendSet(SendSet node) { |
1755 Element target = resolveSend(node); | 1768 Element target = resolveSend(node); |
1756 Element setter = target; | 1769 Element setter = target; |
1757 Element getter = target; | 1770 Element getter = target; |
1758 SourceString operatorName = node.assignmentOperator.source; | 1771 SourceString operatorName = node.assignmentOperator.source; |
1759 String source = operatorName.stringValue; | 1772 String source = operatorName.stringValue; |
1760 bool isComplex = !identical(source, '='); | 1773 bool isComplex = !identical(source, '='); |
1761 if (!Elements.isUnresolved(target) | 1774 if (!Elements.isUnresolved(target) |
1762 && target.kind == ElementKind.ABSTRACT_FIELD) { | 1775 && target.kind == ElementKind.ABSTRACT_FIELD) { |
1763 AbstractFieldElement field = target; | 1776 AbstractFieldElement field = target; |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3073 return e; | 3086 return e; |
3074 } | 3087 } |
3075 | 3088 |
3076 /// Assumed to be called by [resolveRedirectingFactory]. | 3089 /// Assumed to be called by [resolveRedirectingFactory]. |
3077 Element visitReturn(Return node) { | 3090 Element visitReturn(Return node) { |
3078 Node expression = node.expression; | 3091 Node expression = node.expression; |
3079 return finishConstructorReference(visit(expression), | 3092 return finishConstructorReference(visit(expression), |
3080 expression, expression); | 3093 expression, expression); |
3081 } | 3094 } |
3082 } | 3095 } |
OLD | NEW |