Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10628007: Resolve typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 TreeElements resolveParameter(Element element) { 205 TreeElements resolveParameter(Element element) {
206 Node tree = element.parseNode(compiler); 206 Node tree = element.parseNode(compiler);
207 ResolverVisitor visitor = 207 ResolverVisitor visitor =
208 new ResolverVisitor(compiler, element.enclosingElement); 208 new ResolverVisitor(compiler, element.enclosingElement);
209 initializerDo(tree, visitor.visit); 209 initializerDo(tree, visitor.visit);
210 return visitor.mapping; 210 return visitor.mapping;
211 } 211 }
212 212
213 Type resolveTypeAnnotation(Element element, TypeAnnotation annotation) { 213 Type resolveTypeAnnotation(Element element, TypeAnnotation annotation) {
214 if (annotation === null) return compiler.types.dynamicType; 214 if (annotation === null) return compiler.types.dynamicType;
215 ResolverVisitor visitor = new ResolverVisitor(compiler, element); 215 Scope context = new TopScope(element.getLibrary());
ahe 2012/06/22 08:59:11 Why are you calling a "scope" a "context"?
216 Type result = visitor.resolveTypeAnnotation(annotation); 216 Type result;
217 Element contextElement = element.getEnclosingClassOrTypedef();
218 if (contextElement !== null &&
219 (contextElement.isTypedef() || contextElement.isClass())) {
220 var typeDefinition = contextElement;
221 context = new TypeVariablesScope(context, contextElement,
ahe 2012/06/22 08:59:11 Why is this not set up when resolving the type ali
222 typeDefinition.typeParameters);
223 TypeResolver typeResolver = new TypeResolver(compiler);
224 result = typeResolver.resolveTypeAnnotation(annotation,
225 inContext: context,
226 onFailure: warning);
227 } else {
228 ResolverVisitor visitor = new ResolverVisitor(compiler, element);
229 result = visitor.resolveTypeAnnotation(annotation);
230 }
217 if (result === null) { 231 if (result === null) {
218 // TODO(karklose): warning. 232 // TODO(karklose): warning.
219 return compiler.types.dynamicType; 233 return compiler.types.dynamicType;
220 } 234 }
221 return result; 235 return result;
222 } 236 }
223 237
224 void resolveClass(ClassElement element) { 238 void resolveClass(ClassElement element) {
225 if (element.isResolved) return; 239 if (element.isResolved) return;
226 measure(() { 240 measure(() {
(...skipping 11 matching lines...) Expand all
238 compiler.parser.measure(() => element.parseNode(compiler)); 252 compiler.parser.measure(() => element.parseNode(compiler));
239 return measure(() => SignatureResolver.analyze( 253 return measure(() => SignatureResolver.analyze(
240 compiler, node.parameters, node.returnType, element)); 254 compiler, node.parameters, node.returnType, element));
241 }); 255 });
242 } 256 }
243 257
244 FunctionSignature resolveTypedef(TypedefElement element) { 258 FunctionSignature resolveTypedef(TypedefElement element) {
245 return compiler.withCurrentElement(element, () { 259 return compiler.withCurrentElement(element, () {
246 Typedef node = 260 Typedef node =
247 compiler.parser.measure(() => element.parseNode(compiler)); 261 compiler.parser.measure(() => element.parseNode(compiler));
248 return measure(() => SignatureResolver.analyze( 262 TypedefResolverVisitor visitor =
249 compiler, node.formals, node.returnType, element)); 263 new TypedefResolverVisitor(compiler, element.getLibrary(), element);
264 return measure(() => visitor.visit(node));
250 }); 265 });
251 } 266 }
252 267
253 FunctionType computeFunctionType(Element element, 268 FunctionType computeFunctionType(Element element,
254 FunctionSignature signature) { 269 FunctionSignature signature) {
255 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); 270 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
256 for (Link<Element> link = signature.requiredParameters; 271 for (Link<Element> link = signature.requiredParameters;
257 !link.isEmpty(); 272 !link.isEmpty();
258 link = link.tail) { 273 link = link.tail) {
259 parameterTypes.addLast(link.head.computeType(compiler)); 274 parameterTypes.addLast(link.head.computeType(compiler));
260 // TODO(karlklose): optional parameters. 275 // TODO(karlklose): optional parameters.
261 } 276 }
262 return new FunctionType(signature.returnType, 277 return new FunctionType(signature.returnType,
263 parameterTypes.toLink(), 278 parameterTypes.toLink(),
264 element); 279 element);
265 } 280 }
266 281
267 error(Node node, MessageKind kind, [arguments = const []]) { 282 error(Node node, MessageKind kind, [arguments = const []]) {
268 ResolutionError message = new ResolutionError(kind, arguments); 283 ResolutionError message = new ResolutionError(kind, arguments);
269 compiler.reportError(node, message); 284 compiler.reportError(node, message);
270 } 285 }
286
287 warning(Node node, MessageKind kind, [arguments = const []]) {
288 ResolutionWarning message = new ResolutionWarning(kind, arguments);
289 compiler.reportWarning(node, message);
290 }
271 } 291 }
272 292
273 class InitializerResolver { 293 class InitializerResolver {
274 final ResolverVisitor visitor; 294 final ResolverVisitor visitor;
275 final Map<SourceString, Node> initialized; 295 final Map<SourceString, Node> initialized;
276 Link<Node> initializers; 296 Link<Node> initializers;
277 bool hasSuper; 297 bool hasSuper;
278 298
279 InitializerResolver(this.visitor) 299 InitializerResolver(this.visitor)
280 : initialized = new Map<SourceString, Node>(), hasSuper = false; 300 : initialized = new Map<SourceString, Node>(), hasSuper = false;
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 } 1550 }
1531 visitIn(node.formals, scope); 1551 visitIn(node.formals, scope);
1532 visitIn(node.block, scope); 1552 visitIn(node.block, scope);
1533 } 1553 }
1534 1554
1535 visitTypedef(Typedef node) { 1555 visitTypedef(Typedef node) {
1536 unimplemented(node, 'typedef'); 1556 unimplemented(node, 'typedef');
1537 } 1557 }
1538 } 1558 }
1539 1559
1540 class ClassResolverVisitor extends CommonResolverVisitor<Type> { 1560 class TypeDefinitionVisitor extends CommonResolverVisitor<Type> {
1541 Scope context; 1561 Scope context;
1542 ClassElement classElement; 1562 LibraryElement library;
1563 Element enclosing;
1564 Function report;
1543 1565
1544 ClassResolverVisitor(Compiler compiler, LibraryElement library, 1566 visitTypeRequired(Node node) {
1545 ClassElement this.classElement) 1567 Function oldReport = report;
1546 : context = new TopScope(library), 1568 report = error;
1547 super(compiler); 1569 Type result = super.visit(node);
1570 report = oldReport;
1571 return result;
1572 }
1548 1573
1549 Type visitClassNode(ClassNode node) { 1574 TypeDefinitionVisitor(Compiler compiler, LibraryElement library,
1550 compiler.ensure(classElement !== null); 1575 Element this.enclosing)
1551 compiler.ensure(!classElement.isResolved); 1576 : this.library = library,
1552 final Link<Node> parameters = 1577 context = new TopScope(library),
1553 node.typeParameters !== null ? node.typeParameters.nodes 1578 super(compiler) {
1554 : const EmptyLink<TypeVariable>(); 1579 report = warning;
1580 }
1581
1582 abstract Map<SourceString, Element> get typeParameters();
1583
1584 Type visitTypeAnnotation(TypeAnnotation node) {
1585 return visit(node.typeName);
1586 }
1587
1588 Type visitIdentifier(Identifier node) {
1589 // TODO(karlklose): use a TypeResolver here.
1590 if (node.source.stringValue === 'void') return compiler.types.voidType;
1591 Element element = context.lookup(node.source);
1592 if (element === null) {
1593 report(node, MessageKind.CANNOT_RESOLVE_TYPE, [node]);
1594 return null;
1595 } else if (!element.impliesType() && !element.isTypeVariable()) {
1596 report(node, MessageKind.NOT_A_TYPE, [node]);
1597 return null;
1598 } else {
1599 if (element.isClass()) {
1600 compiler.resolver.toResolve.add(element);
1601 }
1602 if (element.isTypeVariable()) {
1603 TypeVariableElement variableElement = element;
1604 return variableElement.type;
1605 } else {
1606 return element.computeType(compiler);
1607 }
1608 }
1609 return null;
1610 }
1611
1612 Type visitSend(Send node) {
1613 Identifier prefix = node.receiver.asIdentifier();
1614 if (prefix === null) {
1615 report(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1616 return null;
1617 }
1618 Element element = context.lookup(prefix.source);
1619 if (element === null || element.kind !== ElementKind.PREFIX) {
1620 report(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1621 return null;
1622 }
1623 PrefixElement prefixElement = element;
1624 Identifier selector = node.selector.asIdentifier();
1625 var e = prefixElement.lookupLocalMember(selector.source);
1626 if (e === null || !e.impliesType()) {
1627 report(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, [node.selector]);
1628 return null;
1629 }
1630 return e.computeType(compiler);
1631 }
1632
1633 createTypeVariables(NodeList node) {
1634 if (node === null) return;
1555 // Create types and elements for type variable. 1635 // Create types and elements for type variable.
1556 for (Link<Node> link = parameters; !link.isEmpty(); link = link.tail) { 1636 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) {
1557 TypeVariable typeNode = link.head; 1637 TypeVariable typeNode = link.head;
1558 SourceString variableName = typeNode.name.source; 1638 SourceString variableName = typeNode.name.source;
1559 TypeVariableType variableType = new TypeVariableType(variableName); 1639 TypeVariableType variableType = new TypeVariableType(variableName);
1560 TypeVariableElement variableElement = 1640 TypeVariableElement variableElement =
1561 new TypeVariableElement(variableName, classElement, node, 1641 new TypeVariableElement(variableName, enclosing, typeNode,
1562 variableType); 1642 variableType);
1563 variableType.element = variableElement; 1643 variableType.element = variableElement;
1564 classElement.typeParameters[variableName] = variableElement; 1644 typeParameters[variableName] = variableElement;
1565 context = new TypeVariablesScope(context, classElement);
1566 } 1645 }
1646 }
1647
1648 visitNodeList(NodeList node) {
1649 if (node === null) return;
1567 // Resolve the bounds of type variables. 1650 // Resolve the bounds of type variables.
1568 for (Link<Node> link = parameters; !link.isEmpty(); link = link.tail) { 1651 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) {
1569 TypeVariable typeNode = link.head; 1652 TypeVariable typeNode = link.head;
1570 SourceString variableName = typeNode.name.source; 1653 SourceString variableName = typeNode.name.source;
1571 TypeVariableElement variableElement = 1654 TypeVariableElement variableElement = typeParameters[variableName];
1572 classElement.typeParameters[variableName];
1573 if (typeNode.bound !== null) { 1655 if (typeNode.bound !== null) {
1574 Type boundType = visit(typeNode.bound); 1656 Type boundType = visit(typeNode.bound);
1575 if (boundType !== null && boundType.element == variableElement) { 1657 if (boundType !== null && boundType.element == variableElement) {
1576 warning(node, MessageKind.CYCLIC_TYPE_VARIABLE, 1658 report(node, MessageKind.CYCLIC_TYPE_VARIABLE,
1577 [variableElement.name]); 1659 [variableElement.name]);
1578 } else if (boundType !== null) { 1660 } else if (boundType !== null) {
1579 variableElement.bound = boundType; 1661 variableElement.bound = boundType;
1580 } else { 1662 } else {
1581 variableElement.bound = compiler.objectClass.computeType(compiler); 1663 variableElement.bound = compiler.objectClass.computeType(compiler);
1582 } 1664 }
1583 } 1665 }
1584 } 1666 }
1667 }
1668 }
1669
1670 class TypedefResolverVisitor extends TypeDefinitionVisitor {
1671 TypedefElement get typedefElement() => enclosing;
1672 get typeParameters() => typedefElement.typeParameters;
1673
1674 TypedefResolverVisitor(Compiler compiler, LibraryElement library,
1675 TypedefElement typedefElement)
1676 : super(compiler, library, typedefElement);
1677
1678 visitVariableDefinitions(VariableDefinitions variables) {
1679 return visit(variables.type);
1680 }
1681
1682 visitTypedef(Typedef node) {
1683 createTypeVariables(node.typeParameters);
1684 FunctionType type = new FunctionType(compiler.types.dynamicType,
1685 null, typedefElement);
1686 typedefElement.cachedType = type;
1687 context = new TypeVariablesScope(context, enclosing, typeParameters);
1688 Type returnType = visit(node.returnType);
1689 if (returnType === null) {
1690 returnType = compiler.types.dynamicType;
1691 } else if (returnType.element === typedefElement) {
1692 warning(node.returnType, MessageKind.CYCLIC_TYPEDEF);
1693 returnType = compiler.types.dynamicType;
1694 }
1695 LinkBuilder<Type> formalsTypes = new LinkBuilder<Type>();
1696 TypeResolver typeResolver = new TypeResolver(compiler);
1697 for (Link<Node> formals = node.formals.nodes;
1698 !formals.isEmpty();
1699 formals = formals.tail) {
1700 if (formals.head.asNodeList() !== null) {
1701 // If there is a NodeList in the formal parameter list, it is the list
1702 // of optional parameters.
1703 // TODO(karlklose): support optional parameters.
1704 break;
1705 }
1706 Type formalType = visit(formals.head);
1707 if (formalType === null) {
1708 formalType = compiler.types.dynamicType;
1709 } else {
1710 if (formalType.element === typedefElement) {
1711 warning(formals.head, MessageKind.CYCLIC_TYPEDEF);
1712 formalType = compiler.types.dynamicType;
1713 }
1714 }
1715 formalsTypes.addLast(formalType);
1716 }
1717 type.parameterTypes = formalsTypes.toLink();
1718 // Resolve type parameter bounds.
1719 visit(node.typeParameters);
1720 }
1721 }
1722
1723 class ClassResolverVisitor extends TypeDefinitionVisitor {
1724 ClassElement get classElement() => enclosing;
1725
1726 get typeParameters() => classElement.typeParameters;
1727
1728 ClassResolverVisitor(Compiler compiler, LibraryElement library,
1729 ClassElement classElement)
1730 : super(compiler, library, classElement);
1731
1732 Type visitClassNode(ClassNode node) {
1733 compiler.ensure(classElement !== null);
1734 compiler.ensure(!classElement.isResolved);
1735 createTypeVariables(node.typeParameters);
1736 // Resolve type paramters.
1737 context = new TypeVariablesScope(context, enclosing, typeParameters);
1738 visit(node.typeParameters);
1585 // Find super type. 1739 // Find super type.
1586 Type supertype = visit(node.superclass); 1740 Type supertype = visitTypeRequired(node.superclass);
1587 if (supertype !== null && supertype.element.isExtendable()) { 1741 if (supertype !== null && supertype.element.isExtendable()) {
1588 classElement.supertype = supertype; 1742 classElement.supertype = supertype;
1589 if (isBlackListed(supertype)) { 1743 if (isBlackListed(supertype)) {
1590 error(node.superclass, MessageKind.CANNOT_EXTEND, [supertype]); 1744 error(node.superclass, MessageKind.CANNOT_EXTEND, [supertype]);
1591 } 1745 }
1592 } else if (supertype !== null) { 1746 } else if (supertype !== null) {
1593 error(node.superclass, MessageKind.TYPE_NAME_EXPECTED); 1747 error(node.superclass, MessageKind.TYPE_NAME_EXPECTED);
1594 } 1748 }
1595 final objectElement = compiler.objectClass; 1749 final objectElement = compiler.objectClass;
1596 if (classElement !== objectElement && classElement.supertype === null) { 1750 if (classElement !== objectElement && classElement.supertype === null) {
1597 if (objectElement === null) { 1751 if (objectElement === null) {
1598 compiler.internalError("Internal error: cannot resolve Object", 1752 compiler.internalError("Internal error: cannot resolve Object",
1599 node: node); 1753 node: node);
1600 } else if (!objectElement.isResolved) { 1754 } else if (!objectElement.isResolved) {
1601 compiler.resolver.toResolve.add(objectElement); 1755 compiler.resolver.toResolve.add(objectElement);
1602 } 1756 }
1603 classElement.supertype = new InterfaceType(objectElement); 1757 classElement.supertype = new InterfaceType(objectElement);
1604 } 1758 }
1605 if (node.defaultClause !== null) { 1759 if (node.defaultClause !== null) {
1606 classElement.defaultClass = visit(node.defaultClause); 1760 classElement.defaultClass = visitTypeRequired(node.defaultClause);
1607 } 1761 }
1608 for (Link<Node> link = node.interfaces.nodes; 1762 for (Link<Node> link = node.interfaces.nodes;
1609 !link.isEmpty(); 1763 !link.isEmpty();
1610 link = link.tail) { 1764 link = link.tail) {
1611 Type interfaceType = visit(link.head); 1765 Type interfaceType = visitTypeRequired(link.head);
1612 if (interfaceType !== null && interfaceType.element.isExtendable()) { 1766 if (interfaceType !== null && interfaceType.element.isExtendable()) {
1613 classElement.interfaces = 1767 classElement.interfaces =
1614 classElement.interfaces.prepend(interfaceType); 1768 classElement.interfaces.prepend(interfaceType);
1615 if (isBlackListed(interfaceType)) { 1769 if (isBlackListed(interfaceType)) {
1616 error(link.head, MessageKind.CANNOT_IMPLEMENT, [interfaceType]); 1770 error(link.head, MessageKind.CANNOT_IMPLEMENT, [interfaceType]);
1617 } 1771 }
1618 } else { 1772 } else {
1619 error(link.head, MessageKind.TYPE_NAME_EXPECTED); 1773 error(link.head, MessageKind.TYPE_NAME_EXPECTED);
1620 } 1774 }
1621 } 1775 }
1622 calculateAllSupertypes(classElement, new Set<ClassElement>()); 1776 calculateAllSupertypes(classElement, new Set<ClassElement>());
1623 addDefaultConstructorIfNeeded(classElement); 1777 addDefaultConstructorIfNeeded(classElement);
1624 return classElement.computeType(compiler); 1778 return classElement.computeType(compiler);
1625 } 1779 }
1626 1780
1627 Type visitTypeAnnotation(TypeAnnotation node) {
1628 return visit(node.typeName);
1629 }
1630
1631 Type visitIdentifier(Identifier node) {
1632 Element element = context.lookup(node.source);
1633 if (element === null) {
1634 error(node, MessageKind.CANNOT_RESOLVE_TYPE, [node]);
1635 return null;
1636 } else if (!element.impliesType() && !element.isTypeVariable()) {
1637 error(node, MessageKind.NOT_A_TYPE, [node]);
1638 return null;
1639 } else {
1640 if (element.isClass()) {
1641 compiler.resolver.toResolve.add(element);
1642 }
1643 if (element.isTypeVariable()) {
1644 TypeVariableElement variableElement = element;
1645 return variableElement.type;
1646 } else if (element.isTypedef()) {
1647 compiler.unimplemented('visitIdentifier for typedefs', node: node);
1648 } else {
1649 // TODO(ngeoffray): Use type variables.
1650 return element.computeType(compiler);
1651 }
1652 }
1653 return null;
1654 }
1655
1656 Type visitSend(Send node) {
1657 Identifier prefix = node.receiver.asIdentifier();
1658 if (prefix === null) {
1659 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1660 return null;
1661 }
1662 Element element = context.lookup(prefix.source);
1663 if (element === null || element.kind !== ElementKind.PREFIX) {
1664 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1665 return null;
1666 }
1667 PrefixElement prefixElement = element;
1668 Identifier selector = node.selector.asIdentifier();
1669 var e = prefixElement.lookupLocalMember(selector.source);
1670 if (e === null || !e.impliesType()) {
1671 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, [node.selector]);
1672 return null;
1673 }
1674 return e.computeType(compiler);
1675 }
1676
1677 Link<Type> getOrCalculateAllSupertypes(ClassElement cls, 1781 Link<Type> getOrCalculateAllSupertypes(ClassElement cls,
1678 [Set<ClassElement> seen]) { 1782 [Set<ClassElement> seen]) {
1679 Link<Type> allSupertypes = cls.allSupertypes; 1783 Link<Type> allSupertypes = cls.allSupertypes;
1680 if (allSupertypes !== null) return allSupertypes; 1784 if (allSupertypes !== null) return allSupertypes;
1681 if (seen === null) { 1785 if (seen === null) {
1682 seen = new Set<ClassElement>(); 1786 seen = new Set<ClassElement>();
1683 } 1787 }
1684 if (seen.contains(cls)) { 1788 if (seen.contains(cls)) {
1685 error(cls.parseNode(compiler), 1789 error(cls.parseNode(compiler),
1686 MessageKind.CYCLIC_CLASS_HIERARCHY, 1790 MessageKind.CYCLIC_CLASS_HIERARCHY,
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 class Scope { 2128 class Scope {
2025 final Element element; 2129 final Element element;
2026 final Scope parent; 2130 final Scope parent;
2027 2131
2028 Scope(this.parent, this.element); 2132 Scope(this.parent, this.element);
2029 abstract Element add(Element element); 2133 abstract Element add(Element element);
2030 abstract Element lookup(SourceString name); 2134 abstract Element lookup(SourceString name);
2031 } 2135 }
2032 2136
2033 class TypeVariablesScope extends Scope { 2137 class TypeVariablesScope extends Scope {
2034 TypeVariablesScope(parent, ClassElement element) : super(parent, element); 2138 final Map<SourceString, TypeVariableElement> variables;
2139
2140 TypeVariablesScope(parent, element, this.variables) : super(parent, element);
2141
2035 Element add(Element newElement) { 2142 Element add(Element newElement) {
2036 throw "Cannot add element to TypeVariableScope"; 2143 throw "Cannot add element to TypeVariableScope";
2037 } 2144 }
2145
2038 Element lookup(SourceString name) { 2146 Element lookup(SourceString name) {
2039 ClassElement cls = element; 2147 Element result = variables[name];
2040 Element result = cls.lookupTypeParameter(name);
2041 if (result !== null) return result; 2148 if (result !== null) return result;
2042 if (parent !== null) return parent.lookup(name); 2149 if (parent !== null) return parent.lookup(name);
2043 } 2150 }
2044 } 2151 }
2045 2152
2046 class MethodScope extends Scope { 2153 class MethodScope extends Scope {
2047 final Map<SourceString, Element> elements; 2154 final Map<SourceString, Element> elements;
2048 2155
2049 MethodScope(Scope parent, Element element) 2156 MethodScope(Scope parent, Element element)
2050 : super(parent, element), this.elements = new Map<SourceString, Element>(); 2157 : super(parent, element), this.elements = new Map<SourceString, Element>();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 2200
2094 TopScope(LibraryElement library) : super(null, library); 2201 TopScope(LibraryElement library) : super(null, library);
2095 Element lookup(SourceString name) { 2202 Element lookup(SourceString name) {
2096 return library.find(name); 2203 return library.find(name);
2097 } 2204 }
2098 2205
2099 Element add(Element newElement) { 2206 Element add(Element newElement) {
2100 throw "Cannot add an element in the top scope"; 2207 throw "Cannot add an element in the top scope";
2101 } 2208 }
2102 } 2209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698