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 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 target.kind == ElementKind.FOREIGN && | 1801 target.kind == ElementKind.FOREIGN && |
1802 selector.name == const SourceString('JS')) { | 1802 selector.name == const SourceString('JS')) { |
1803 world.nativeEnqueuer.registerJsCall(node, this); | 1803 world.nativeEnqueuer.registerJsCall(node, this); |
1804 } | 1804 } |
1805 } | 1805 } |
1806 | 1806 |
1807 // TODO(ngeoffray): Warn if target is null and the send is | 1807 // TODO(ngeoffray): Warn if target is null and the send is |
1808 // unqualified. | 1808 // unqualified. |
1809 useElement(node, target); | 1809 useElement(node, target); |
1810 registerSend(selector, target); | 1810 registerSend(selector, target); |
| 1811 if (node.isPropertyAccess) { |
| 1812 // It might be the closurization of a method. |
| 1813 world.registerInstantiatedClass(compiler.functionClass); |
| 1814 } |
1811 return node.isPropertyAccess ? target : null; | 1815 return node.isPropertyAccess ? target : null; |
1812 } | 1816 } |
1813 | 1817 |
1814 void warnArgumentMismatch(Send node, Element target) { | 1818 void warnArgumentMismatch(Send node, Element target) { |
1815 // TODO(karlklose): we can be more precise about the reason of the | 1819 // TODO(karlklose): we can be more precise about the reason of the |
1816 // mismatch. | 1820 // mismatch. |
1817 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS, | 1821 warning(node.argumentsNode, MessageKind.INVALID_ARGUMENTS, |
1818 [target.name]); | 1822 [target.name]); |
1819 } | 1823 } |
1820 | 1824 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 | 1923 |
1920 visitLiteralInt(LiteralInt node) { | 1924 visitLiteralInt(LiteralInt node) { |
1921 world.registerInstantiatedClass(compiler.intClass); | 1925 world.registerInstantiatedClass(compiler.intClass); |
1922 } | 1926 } |
1923 | 1927 |
1924 visitLiteralDouble(LiteralDouble node) { | 1928 visitLiteralDouble(LiteralDouble node) { |
1925 world.registerInstantiatedClass(compiler.doubleClass); | 1929 world.registerInstantiatedClass(compiler.doubleClass); |
1926 } | 1930 } |
1927 | 1931 |
1928 visitLiteralBool(LiteralBool node) { | 1932 visitLiteralBool(LiteralBool node) { |
| 1933 world.registerInstantiatedClass(compiler.boolClass); |
1929 } | 1934 } |
1930 | 1935 |
1931 visitLiteralString(LiteralString node) { | 1936 visitLiteralString(LiteralString node) { |
1932 world.registerInstantiatedClass(compiler.stringClass); | 1937 world.registerInstantiatedClass(compiler.stringClass); |
1933 } | 1938 } |
1934 | 1939 |
1935 visitLiteralNull(LiteralNull node) { | 1940 visitLiteralNull(LiteralNull node) { |
| 1941 world.registerInstantiatedClass(compiler.nullClass); |
1936 } | 1942 } |
1937 | 1943 |
1938 visitStringJuxtaposition(StringJuxtaposition node) { | 1944 visitStringJuxtaposition(StringJuxtaposition node) { |
1939 world.registerInstantiatedClass(compiler.stringClass); | 1945 world.registerInstantiatedClass(compiler.stringClass); |
1940 node.visitChildren(this); | 1946 node.visitChildren(this); |
1941 } | 1947 } |
1942 | 1948 |
1943 visitNodeList(NodeList node) { | 1949 visitNodeList(NodeList node) { |
1944 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { | 1950 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { |
1945 visit(link.head); | 1951 visit(link.head); |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 variables = new VariableListElement.node( | 2778 variables = new VariableListElement.node( |
2773 definitions, ElementKind.VARIABLE_LIST, resolver.enclosingElement); | 2779 definitions, ElementKind.VARIABLE_LIST, resolver.enclosingElement); |
2774 } | 2780 } |
2775 | 2781 |
2776 SourceString visitSendSet(SendSet node) { | 2782 SourceString visitSendSet(SendSet node) { |
2777 assert(node.arguments.tail.isEmpty); // Sanity check | 2783 assert(node.arguments.tail.isEmpty); // Sanity check |
2778 resolver.visit(node.arguments.head); | 2784 resolver.visit(node.arguments.head); |
2779 return visit(node.selector); | 2785 return visit(node.selector); |
2780 } | 2786 } |
2781 | 2787 |
2782 SourceString visitIdentifier(Identifier node) => node.source; | 2788 SourceString visitIdentifier(Identifier node) { |
| 2789 // The variable is initialized to null. |
| 2790 resolver.world.registerInstantiatedClass(compiler.nullClass); |
| 2791 return node.source; |
| 2792 } |
2783 | 2793 |
2784 visitNodeList(NodeList node) { | 2794 visitNodeList(NodeList node) { |
2785 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { | 2795 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { |
2786 SourceString name = visit(link.head); | 2796 SourceString name = visit(link.head); |
2787 VariableElement element = | 2797 VariableElement element = |
2788 new VariableElement(name, variables, kind, link.head); | 2798 new VariableElement(name, variables, kind, link.head); |
2789 resolver.defineElement(link.head, element); | 2799 resolver.defineElement(link.head, element); |
2790 } | 2800 } |
2791 } | 2801 } |
2792 } | 2802 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 return e; | 3150 return e; |
3141 } | 3151 } |
3142 | 3152 |
3143 /// Assumed to be called by [resolveRedirectingFactory]. | 3153 /// Assumed to be called by [resolveRedirectingFactory]. |
3144 Element visitReturn(Return node) { | 3154 Element visitReturn(Return node) { |
3145 Node expression = node.expression; | 3155 Node expression = node.expression; |
3146 return finishConstructorReference(visit(expression), | 3156 return finishConstructorReference(visit(expression), |
3147 expression, expression); | 3157 expression, expression); |
3148 } | 3158 } |
3149 } | 3159 } |
OLD | NEW |