Chromium Code Reviews| Index: lib/compiler/implementation/resolver.dart |
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
| index 20fdff4c87c125aa2d3b166b974f73d14bca8f2f..4fac453f071391d0c80a3a9221556ea579e301bb 100644 |
| --- a/lib/compiler/implementation/resolver.dart |
| +++ b/lib/compiler/implementation/resolver.dart |
| @@ -10,18 +10,29 @@ abstract class TreeElements { |
| } |
| class TreeElementMapping implements TreeElements { |
| + final Element currentElement; |
| final Map<Node, Element> map; |
| final Map<Node, Selector> selectors; |
| final Map<TypeAnnotation, DartType> types; |
| final Set<Element> checkedParameters; |
| - TreeElementMapping() |
| - : map = new LinkedHashMap<Node, Element>(), |
| + TreeElementMapping([Element element]) |
|
ngeoffray
2012/09/17 12:46:24
Could you not make it optional? Also you can write
Johnni Winther
2012/09/20 08:12:23
Several call-sites uses optionality.
|
| + : currentElement = element, |
| + map = new LinkedHashMap<Node, Element>(), |
| selectors = new LinkedHashMap<Node, Selector>(), |
| types = new LinkedHashMap<TypeAnnotation, DartType>(), |
| checkedParameters = new Set<Element>(); |
| - operator []=(Node node, Element element) => map[node] = element; |
| + operator []=(Node node, Element element) { |
| + if (node is FunctionExpression && node.modifiers != null) { |
|
ngeoffray
2012/09/17 12:46:24
Put this 'if' in the assert.
Johnni Winther
2012/09/20 08:12:23
Done.
|
| + assert (!node.modifiers.isExternal()); |
| + } |
| + if (!element.isErroneous() && currentElement != null && element.isPatch) { |
|
ngeoffray
2012/09/17 12:46:24
ditto.
Johnni Winther
2012/09/20 08:12:23
Done.
|
| + assert(currentElement.getImplementationLibrary().isPatch); |
| + } |
| + |
| + map[node] = element; |
| + } |
| operator [](Node node) => map[node]; |
| void remove(Node node) { map.remove(node); } |
| @@ -111,6 +122,7 @@ class ResolverTask extends CompilerTask { |
| } |
| TreeElements resolveMethodElement(FunctionElement element) { |
| + assert(element.isDeclaration); |
| return compiler.withCurrentElement(element, () { |
| bool isConstructor = element.kind === ElementKind.GENERATIVE_CONSTRUCTOR; |
| TreeElements elements = |
| @@ -965,7 +977,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION; |
| ResolverVisitor(Compiler compiler, Element element) |
| - : this.mapping = new TreeElementMapping(), |
| + : this.mapping = new TreeElementMapping(element), |
| this.enclosingElement = element, |
| // When the element is a field, we are actually resolving its |
| // initial value, which should not have access to instance |
| @@ -1520,7 +1532,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| } else if (Elements.isStaticOrTopLevel(target)) { |
| // TODO(kasperl): It seems like we're not supposed to register |
| // the use of classes. Wouldn't it be simpler if we just did? |
| - if (!target.isClass()) world.registerStaticUse(target); |
| + if (!target.isClass()) world.registerStaticUse(target.declaration); |
| } |
| // TODO(kasperl): Pass the selector directly. |
| @@ -1599,14 +1611,14 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| // parameters. We cannot do this rigth now because of the |
| // List constructor. |
| } |
| - world.registerStaticUse(constructor); |
| + world.registerStaticUse(constructor.declaration); |
| compiler.withCurrentElement(constructor, () { |
| FunctionExpression tree = constructor.parseNode(compiler); |
| compiler.resolver.resolveConstructorImplementation(constructor, tree); |
| }); |
| - world.registerStaticUse(constructor.defaultImplementation); |
| + world.registerStaticUse(constructor.defaultImplementation.declaration); |
| ClassElement cls = constructor.defaultImplementation.getEnclosingClass(); |
| - world.registerInstantiatedClass(cls); |
| + world.registerInstantiatedClass(cls.declaration); |
| cls.forEachInstanceField( |
| includeBackendMembers: false, |
| includeSuperMembers: true, |
| @@ -2650,7 +2662,7 @@ class VariableScope extends Scope { |
| throw "Cannot add element to VariableScope"; |
| } |
| - Element lookup(SourceString name) => parent.lookup(name); |
| + Element localLookup(SourceString name) => null; |
| String toString() => '$element > $parent'; |
| } |