| 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 interface TreeElements { | 5 interface TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 Type getType(TypeAnnotation annotation); | 8 Type getType(TypeAnnotation annotation); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 new ClassResolverVisitor(compiler, element.getLibrary(), element); | 230 new ClassResolverVisitor(compiler, element.getLibrary(), element); |
| 231 visitor.visit(tree); | 231 visitor.visit(tree); |
| 232 element.isResolved = true; | 232 element.isResolved = true; |
| 233 }); | 233 }); |
| 234 } | 234 } |
| 235 | 235 |
| 236 FunctionSignature resolveSignature(FunctionElement element) { | 236 FunctionSignature resolveSignature(FunctionElement element) { |
| 237 return measure(() => SignatureResolver.analyze(compiler, element)); | 237 return measure(() => SignatureResolver.analyze(compiler, element)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 FunctionSignature resolveTypedef(TypedefElement element) { |
| 241 return measure(() => SignatureResolver.analyzeTypedef(compiler, element)); |
| 242 } |
| 243 |
| 240 error(Node node, MessageKind kind, [arguments = const []]) { | 244 error(Node node, MessageKind kind, [arguments = const []]) { |
| 241 ResolutionError message = new ResolutionError(kind, arguments); | 245 ResolutionError message = new ResolutionError(kind, arguments); |
| 242 compiler.reportError(node, message); | 246 compiler.reportError(node, message); |
| 243 } | 247 } |
| 244 } | 248 } |
| 245 | 249 |
| 246 class InitializerResolver { | 250 class InitializerResolver { |
| 247 final ResolverVisitor visitor; | 251 final ResolverVisitor visitor; |
| 248 final Map<SourceString, Node> initialized; | 252 final Map<SourceString, Node> initialized; |
| 249 Link<Node> initializers; | 253 Link<Node> initializers; |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); | 1127 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); |
| 1124 } | 1128 } |
| 1125 } | 1129 } |
| 1126 if (cls.typeParameters.length == 0) { | 1130 if (cls.typeParameters.length == 0) { |
| 1127 // Return the canonical type if it has no type parameters. | 1131 // Return the canonical type if it has no type parameters. |
| 1128 type = cls.computeType(compiler); | 1132 type = cls.computeType(compiler); |
| 1129 } else { | 1133 } else { |
| 1130 type = new InterfaceType(cls, arguments.toLink()); | 1134 type = new InterfaceType(cls, arguments.toLink()); |
| 1131 } | 1135 } |
| 1132 } else if (element.isTypedef()) { | 1136 } else if (element.isTypedef()) { |
| 1133 // TODO(ngeoffray): This is a hack to help us get support for the | 1137 type = element.computeType(compiler); |
| 1134 // DOM library. | |
| 1135 // TODO(ngeoffray): The list of types for the argument is wrong. | |
| 1136 type = new FunctionType(compiler.types.dynamicType, | |
| 1137 const EmptyLink<Type>(), | |
| 1138 element); | |
| 1139 } else if (element.isTypeVariable()) { | 1138 } else if (element.isTypeVariable()) { |
| 1140 type = element.computeType(compiler); | 1139 type = element.computeType(compiler); |
| 1141 } else { | 1140 } else { |
| 1142 compiler.cancel("unexpected element kind ${element.kind}", | 1141 compiler.cancel("unexpected element kind ${element.kind}", |
| 1143 node: node); | 1142 node: node); |
| 1144 } | 1143 } |
| 1145 } | 1144 } |
| 1146 return useType(node, type); | 1145 return useType(node, type); |
| 1147 } | 1146 } |
| 1148 | 1147 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1769 Link<Element> parameters = parametersBuilder.toLink(); | 1768 Link<Element> parameters = parametersBuilder.toLink(); |
| 1770 Type returnType = | 1769 Type returnType = |
| 1771 compiler.resolveTypeAnnotation(element, node.returnType); | 1770 compiler.resolveTypeAnnotation(element, node.returnType); |
| 1772 return new FunctionSignature(parameters, | 1771 return new FunctionSignature(parameters, |
| 1773 visitor.optionalParameters, | 1772 visitor.optionalParameters, |
| 1774 parametersBuilder.length, | 1773 parametersBuilder.length, |
| 1775 visitor.optionalParameterCount, | 1774 visitor.optionalParameterCount, |
| 1776 returnType); | 1775 returnType); |
| 1777 } | 1776 } |
| 1778 | 1777 |
| 1778 static FunctionSignature analyzeTypedef(Compiler compiler, |
| 1779 TypedefElement element) { |
| 1780 Typedef node = |
| 1781 compiler.parser.measure(() => element.parseNode(compiler)); |
| 1782 SignatureResolver visitor = new SignatureResolver(compiler, element); |
| 1783 Link<Node> nodes = node.formals.nodes; |
| 1784 LinkBuilder<Element> parametersBuilder = visitor.analyzeNodes(nodes); |
| 1785 Link<Element> parameters = parametersBuilder.toLink(); |
| 1786 Type returnType = |
| 1787 compiler.resolveTypeAnnotation(element, node.returnType); |
| 1788 return new FunctionSignature(parameters, |
| 1789 visitor.optionalParameters, |
| 1790 parametersBuilder.length, |
| 1791 visitor.optionalParameterCount, |
| 1792 returnType); |
| 1793 } |
| 1794 |
| 1779 // TODO(ahe): This is temporary. | 1795 // TODO(ahe): This is temporary. |
| 1780 void resolveExpression(Node node) { | 1796 void resolveExpression(Node node) { |
| 1781 if (node == null) return; | 1797 if (node == null) return; |
| 1782 node.accept(new ResolverVisitor(compiler, enclosingElement)); | 1798 node.accept(new ResolverVisitor(compiler, enclosingElement)); |
| 1783 } | 1799 } |
| 1784 | 1800 |
| 1785 // TODO(ahe): This is temporary. | 1801 // TODO(ahe): This is temporary. |
| 1786 ClassElement get currentClass() { | 1802 ClassElement get currentClass() { |
| 1787 return enclosingElement.isMember() | 1803 return enclosingElement.isMember() |
| 1788 ? enclosingElement.enclosingElement : null; | 1804 ? enclosingElement.enclosingElement : null; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 | 1957 |
| 1942 TopScope(LibraryElement library) : super(null, library); | 1958 TopScope(LibraryElement library) : super(null, library); |
| 1943 Element lookup(SourceString name) { | 1959 Element lookup(SourceString name) { |
| 1944 return library.find(name); | 1960 return library.find(name); |
| 1945 } | 1961 } |
| 1946 | 1962 |
| 1947 Element add(Element newElement) { | 1963 Element add(Element newElement) { |
| 1948 throw "Cannot add an element in the top scope"; | 1964 throw "Cannot add an element in the top scope"; |
| 1949 } | 1965 } |
| 1950 } | 1966 } |
| OLD | NEW |