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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/deferred_load.dart

Issue 15096006: Handle constants that mix eager and deferred types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library deferred_load; 5 library deferred_load;
6 6
7 import 'dart:uri' 7 import 'dart:uri'
8 show Uri; 8 show Uri;
9 9
10 import 'dart:collection' 10 import 'dart:collection'
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 }); 157 });
158 } 158 }
159 159
160 /// Returns all elements in the tree map of [element], but not the 160 /// Returns all elements in the tree map of [element], but not the
161 /// transitive closure. 161 /// transitive closure.
162 Set<Element> allElementsResolvedFrom(Element element) { 162 Set<Element> allElementsResolvedFrom(Element element) {
163 element = element.implementation; 163 element = element.implementation;
164 Set<Element> result = new LinkedHashSet<Element>(); 164 Set<Element> result = new LinkedHashSet<Element>();
165 if (element.isGenerativeConstructor()) { 165 if (element.isGenerativeConstructor()) {
166 // When instantiating a class, we record a reference to the 166 // When instantiating a class, we record a reference to the
167 // constructor, not the class itself. 167 // constructor, not the class itself.
ngeoffray 2013/05/14 07:17:38 Update comment.
ahe 2013/05/14 10:01:24 I extended the comment. It is not wrong.
168 element = element.getEnclosingClass().implementation; 168 result.addAll(
169 allElementsResolvedFrom(element.getEnclosingClass().implementation));
169 } 170 }
170 if (element.isClass()) { 171 if (element.isClass()) {
171 // If we see a class, add everything its instance members refer 172 // If we see a class, add everything its instance members refer
172 // to. Static members are not relevant. 173 // to. Static members are not relevant.
173 ClassElement cls = element.declaration; 174 ClassElement cls = element.declaration;
174 cls.forEachLocalMember((Element e) { 175 cls.forEachLocalMember((Element e) {
175 if (!e.isInstanceMember()) return; 176 if (!e.isInstanceMember()) return;
176 result.addAll(DependencyCollector.collect(e.implementation, compiler)); 177 result.addAll(DependencyCollector.collect(e.implementation, compiler));
177 }); 178 });
178 if (cls.implementation != cls) { 179 if (cls.implementation != cls) {
179 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this? 180 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this?
180 cls.implementation.forEachLocalMember((Element e) { 181 cls.implementation.forEachLocalMember((Element e) {
181 if (!e.isInstanceMember()) return; 182 if (!e.isInstanceMember()) return;
182 result.addAll(DependencyCollector.collect(e.implementation, 183 result.addAll(DependencyCollector.collect(e.implementation,
183 compiler)); 184 compiler));
184 }); 185 });
185 } 186 }
186 for (var type in cls.allSupertypes) { 187 for (var type in cls.allSupertypes) {
187 result.add(type.element.implementation); 188 result.add(type.element.implementation);
188 } 189 }
189 result.add(cls.implementation); 190 result.add(cls.implementation);
190 } else if (Elements.isStaticOrTopLevel(element)) { 191 } else if (Elements.isStaticOrTopLevel(element)
192 || element.isConstructor()
193 || element.isGenerativeConstructorBody()) {
ngeoffray 2013/05/14 07:17:38 Are you really seeing generative constructor bodie
ahe 2013/05/14 10:01:24 I don't think I saw generative constructor bodies.
191 result.addAll(DependencyCollector.collect(element, compiler)); 194 result.addAll(DependencyCollector.collect(element, compiler));
192 } 195 }
193 // Other elements, in particular instance members, are ignored as 196 // Other elements, in particular instance members, are ignored as
194 // they are processed as part of the class. 197 // they are processed as part of the class.
195 return result; 198 return result;
196 } 199 }
197 200
198 void addTransitiveClosureTo(Set<Element> elements) { 201 void addTransitiveClosureTo(Set<Element> elements) {
199 Set<Element> workSet = new LinkedHashSet.from(elements); 202 Set<Element> workSet = new LinkedHashSet.from(elements);
200 Set<Element> closure = new LinkedHashSet<Element>(); 203 Set<Element> closure = new LinkedHashSet<Element>();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 class DependencyCollector extends Visitor { 244 class DependencyCollector extends Visitor {
242 final Set<Element> dependencies = new LinkedHashSet<Element>(); 245 final Set<Element> dependencies = new LinkedHashSet<Element>();
243 final TreeElements elements; 246 final TreeElements elements;
244 final Compiler compiler; 247 final Compiler compiler;
245 248
246 DependencyCollector(this.elements, this.compiler); 249 DependencyCollector(this.elements, this.compiler);
247 250
248 visitNode(Node node) { 251 visitNode(Node node) {
249 node.visitChildren(this); 252 node.visitChildren(this);
250 Element dependency = elements[node]; 253 Element dependency = elements[node];
251 if (dependency == null) return; 254 if (Elements.isUnresolved(dependency)) return;
252 dependencies.add(dependency.implementation); 255 dependencies.add(dependency.implementation);
253 } 256 }
254 257
255 static Set<Element> collect(Element element, Compiler compiler) { 258 static Set<Element> collect(Element element, Compiler compiler) {
256 TreeElements elements = 259 TreeElements elements =
257 compiler.enqueuer.resolution.getCachedElements(element); 260 compiler.enqueuer.resolution.getCachedElements(element);
258 if (elements == null) return new LinkedHashSet<Element>(); 261 if (elements == null) return new LinkedHashSet<Element>();
259 Node node = element.parseNode(compiler); 262 Node node = element.parseNode(compiler);
260 var collector = new DependencyCollector(elements, compiler); 263 var collector = new DependencyCollector(elements, compiler);
261 node.accept(collector); 264 node.accept(collector);
262 collector.dependencies.addAll(elements.otherDependencies); 265 collector.dependencies.addAll(elements.otherDependencies);
263 return collector.dependencies; 266 return collector.dependencies;
264 } 267 }
265 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698