Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class TreeElements { | 5 class TreeElements { |
| 6 Map<Node, Element> map; | 6 Map<Node, Element> map; |
| 7 TreeElements() : map = new LinkedHashMap<Node, Element>(); | 7 TreeElements() : map = new LinkedHashMap<Node, Element>(); |
| 8 operator []=(Node node, Element element) => map[node] = element; | 8 operator []=(Node node, Element element) => map[node] = element; |
| 9 operator [](Node node) => map[node]; | 9 operator [](Node node) => map[node]; |
| 10 } | 10 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 final Compiler compiler; | 112 final Compiler compiler; |
| 113 final TreeElements mapping; | 113 final TreeElements mapping; |
| 114 final Element enclosingElement; | 114 final Element enclosingElement; |
| 115 bool inInstanceContext; | 115 bool inInstanceContext; |
| 116 Scope context; | 116 Scope context; |
| 117 | 117 |
| 118 ResolverVisitor(Compiler compiler, Element element) | 118 ResolverVisitor(Compiler compiler, Element element) |
| 119 : this.compiler = compiler, | 119 : this.compiler = compiler, |
| 120 this.mapping = new TreeElements(), | 120 this.mapping = new TreeElements(), |
| 121 this.enclosingElement = element, | 121 this.enclosingElement = element, |
| 122 inInstanceContext = | 122 inInstanceContext = element.isInstanceMember() |
| 123 element.isInstanceMember() || element.kind == ElementKind.CONSTRUCTOR, | 123 || element.isGenerativeConstructor(), |
|
ahe
2011/12/22 13:32:39
Much better!
| |
| 124 this.context = element.isMember() | 124 this.context = element.isMember() |
| 125 ? new ClassScope(element.enclosingElement, compiler.universe) | 125 ? new ClassScope(element.enclosingElement, compiler.universe) |
| 126 : new TopScope(compiler.universe); | 126 : new TopScope(compiler.universe); |
| 127 | 127 |
| 128 ResolverVisitor.from(ResolverVisitor other) | 128 ResolverVisitor.from(ResolverVisitor other) |
| 129 : compiler = other.compiler, | 129 : compiler = other.compiler, |
| 130 mapping = other.mapping, | 130 mapping = other.mapping, |
| 131 enclosingElement = other.enclosingElement, | 131 enclosingElement = other.enclosingElement, |
| 132 inInstanceContext = other.inInstanceContext, | 132 inInstanceContext = other.inInstanceContext, |
| 133 context = other.context; | 133 context = other.context; |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 class TopScope extends Scope { | 701 class TopScope extends Scope { |
| 702 Universe universe; | 702 Universe universe; |
| 703 | 703 |
| 704 TopScope(Universe this.universe) : super(null, null); | 704 TopScope(Universe this.universe) : super(null, null); |
| 705 Element lookup(SourceString name) => universe.find(name); | 705 Element lookup(SourceString name) => universe.find(name); |
| 706 | 706 |
| 707 Element add(Element element) { | 707 Element add(Element element) { |
| 708 throw "Cannot add an element in the top scope"; | 708 throw "Cannot add an element in the top scope"; |
| 709 } | 709 } |
| 710 } | 710 } |
| OLD | NEW |