Chromium Code Reviews| 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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 typeArguments = typeArguments.tail) { | 1100 typeArguments = typeArguments.tail) { |
| 1101 if (++index > cls.typeParameters.length) { | 1101 if (++index > cls.typeParameters.length) { |
| 1102 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 1102 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 1103 } | 1103 } |
| 1104 arguments.addLast(resolveTypeAnnotation(typeArguments.head)); | 1104 arguments.addLast(resolveTypeAnnotation(typeArguments.head)); |
| 1105 } | 1105 } |
| 1106 if (index < cls.typeParameters.length) { | 1106 if (index < cls.typeParameters.length) { |
| 1107 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); | 1107 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); |
| 1108 } | 1108 } |
| 1109 } | 1109 } |
| 1110 type = new InterfaceType(cls.name, cls, arguments.toLink()); | 1110 if (arguments.length == 0) { |
| 1111 } else if (element.isTypedef()) { | 1111 type = element.computeType(compiler); |
|
ahe
2012/04/19 08:20:06
I think you have a different design in mind than t
karlklose
2012/04/25 11:45:43
As discussed, the check must be on the number of t
| |
| 1112 // TODO(karlklose): implement typedefs. We return a fake type that the | 1112 } else { |
| 1113 // code generator can use to detect typedefs in is-checks. | 1113 type = new InterfaceType(cls.name, cls, arguments.toLink()); |
| 1114 type = new InterfaceType(element.name, element); | 1114 } |
| 1115 } else if (element.isTypedef() || element.isTypeVariable()) { | |
| 1116 type = element.computeType(compiler); | |
| 1115 } else { | 1117 } else { |
| 1116 type = element.computeType(compiler); | 1118 compiler.internalErrorOnElement(element, "unexpected element kind"); |
| 1117 } | 1119 } |
| 1118 } | 1120 } |
| 1119 return useType(node, type); | 1121 return useType(node, type); |
| 1120 } | 1122 } |
| 1121 | 1123 |
| 1122 visitModifiers(Modifiers node) { | 1124 visitModifiers(Modifiers node) { |
| 1123 // TODO(ngeoffray): Implement this. | 1125 // TODO(ngeoffray): Implement this. |
| 1124 unimplemented(node, 'modifiers'); | 1126 unimplemented(node, 'modifiers'); |
| 1125 } | 1127 } |
| 1126 | 1128 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 | 1736 |
| 1735 // TODO(ahe): This is temporary. | 1737 // TODO(ahe): This is temporary. |
| 1736 void resolveExpression(Node node) { | 1738 void resolveExpression(Node node) { |
| 1737 if (node == null) return; | 1739 if (node == null) return; |
| 1738 node.accept(new ResolverVisitor(compiler, enclosingElement)); | 1740 node.accept(new ResolverVisitor(compiler, enclosingElement)); |
| 1739 } | 1741 } |
| 1740 | 1742 |
| 1741 // TODO(ahe): This is temporary. | 1743 // TODO(ahe): This is temporary. |
| 1742 void resolveType(Node node) { | 1744 void resolveType(Node node) { |
| 1743 if (node == null) return; | 1745 if (node == null) return; |
| 1744 // Find the correct member context to perform the lookup in. | 1746 node.accept(new ResolverVisitor(compiler, enclosingElement)); |
| 1745 Element outer = enclosingElement; | |
| 1746 Element context = outer; | |
| 1747 while (outer !== null) { | |
| 1748 if (outer.isMember()) { | |
| 1749 context = outer; | |
| 1750 break; | |
| 1751 } | |
| 1752 outer = outer.enclosingElement; | |
| 1753 } | |
| 1754 node.accept(new ResolverVisitor(compiler, context)); | |
| 1755 } | 1747 } |
| 1756 | 1748 |
| 1757 // TODO(ahe): This is temporary. | 1749 // TODO(ahe): This is temporary. |
| 1758 ClassElement get currentClass() { | 1750 ClassElement get currentClass() { |
| 1759 return enclosingElement.isMember() | 1751 return enclosingElement.isMember() |
| 1760 ? enclosingElement.enclosingElement : null; | 1752 ? enclosingElement.enclosingElement : null; |
| 1761 } | 1753 } |
| 1762 } | 1754 } |
| 1763 | 1755 |
| 1764 class ConstructorResolver extends CommonResolverVisitor<Element> { | 1756 class ConstructorResolver extends CommonResolverVisitor<Element> { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1913 | 1905 |
| 1914 TopScope(LibraryElement library) : super(null, library); | 1906 TopScope(LibraryElement library) : super(null, library); |
| 1915 Element lookup(SourceString name) { | 1907 Element lookup(SourceString name) { |
| 1916 return library.find(name); | 1908 return library.find(name); |
| 1917 } | 1909 } |
| 1918 | 1910 |
| 1919 Element add(Element newElement) { | 1911 Element add(Element newElement) { |
| 1920 throw "Cannot add an element in the top scope"; | 1912 throw "Cannot add an element in the top scope"; |
| 1921 } | 1913 } |
| 1922 } | 1914 } |
| OLD | NEW |