Chromium Code Reviews| Index: lib/compiler/implementation/resolver.dart |
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
| index 4d48866514c95619f2f715eece5cae4ee62aa3b9..2de3345e70392ac39544ce87a4dabf9fcc32e04f 100644 |
| --- a/lib/compiler/implementation/resolver.dart |
| +++ b/lib/compiler/implementation/resolver.dart |
| @@ -10,18 +10,34 @@ 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() |
| + TreeElementMapping([Element this.currentElement]) |
| : 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) { |
| + assert(invariant(node, () { |
|
ahe
2012/09/20 11:12:07
How about allowing function arguments in invariant
Johnni Winther
2012/09/21 09:18:25
Done.
|
| + if (node is FunctionExpression && node.modifiers != null) { |
| + return !node.modifiers.isExternal(); |
| + } |
| + return true; |
| + }())); |
| + assert(invariant(node, (){ |
| + if (!element.isErroneous() && currentElement != null && element.isPatch) { |
| + return currentElement.getImplementationLibrary().isPatch; |
| + } |
| + return true; |
| + }())); |
| + |
| + map[node] = element; |
| + } |
| operator [](Node node) => map[node]; |
| void remove(Node node) { map.remove(node); } |
| @@ -111,6 +127,7 @@ class ResolverTask extends CompilerTask { |
| } |
| TreeElements resolveMethodElement(FunctionElement element) { |
| + assert(invariant(element, element.isDeclaration)); |
| return compiler.withCurrentElement(element, () { |
| bool isConstructor = element.kind === ElementKind.GENERATIVE_CONSTRUCTOR; |
| TreeElements elements = |
| @@ -973,7 +990,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 |
| @@ -1544,7 +1561,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); |
|
ahe
2012/09/20 11:12:07
Why is this necessary?
Johnni Winther
2012/09/21 09:18:25
[target] might be the implementation element and o
ahe
2012/09/21 09:26:42
Why might it be the implementation element?
Johnni Winther
2012/09/21 10:08:13
If we are in a patch library, target might resolve
ahe
2012/09/21 12:11:31
Why?
Johnni Winther
2012/09/21 12:20:14
Because the patch scope (the scope created within
ahe
2012/09/21 12:21:22
Why?
ahe
2012/09/21 12:58:09
We discussed this offline.
Seems that our invaria
|
| } |
| var interceptor = |
| @@ -1621,14 +1638,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); |
|
ahe
2012/09/20 11:12:07
Why?
Johnni Winther
2012/09/21 09:18:25
Same reason as before: [constructor] might be an i
|
| 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, |
| @@ -2712,7 +2729,7 @@ class VariableScope extends Scope { |
| throw "Cannot add element to VariableScope"; |
| } |
| - Element lookup(SourceString name) => parent.lookup(name); |
| + Element localLookup(SourceString name) => null; |
|
ahe
2012/09/20 11:12:07
I don't understand this change.
Johnni Winther
2012/09/21 09:18:25
[lookup] is defined in [Scope] to call [:parent.lo
|
| String toString() => '$element > $parent'; |
| } |