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

Unified Diff: sdk/lib/_internal/compiler/implementation/enqueue.dart

Issue 16035026: Fix 2 host-checked error with the enqueuer: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/enqueue.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/enqueue.dart (revision 23812)
+++ sdk/lib/_internal/compiler/implementation/enqueue.dart (working copy)
@@ -111,42 +111,22 @@
*
* Invariant: [element] must be a declaration element.
*/
- void addToWorkList(Element element, [TreeElements elements]) {
+ void addToWorkList(Element element) {
assert(invariant(element, element.isDeclaration));
if (element.isForeign(compiler)) return;
if (element.isForwardingConstructor) {
- addToWorkList(element.targetConstructor, elements);
+ addToWorkList(element.targetConstructor);
return;
}
- if (!addElementToWorkList(element, elements)) return;
-
- // Enable runtime type support if we discover a getter called runtimeType.
- // We have to enable runtime type before hitting the codegen, so
- // that constructors know whether they need to generate code for
- // runtime type.
- if (element.isGetter() && element.name == Compiler.RUNTIME_TYPE) {
- compiler.enabledRuntimeType = true;
- // TODO(ahe): Record precise dependency here.
- compiler.backend.registerRuntimeType(compiler.globalDependencies);
- } else if (element == compiler.functionApplyMethod) {
- compiler.enabledFunctionApply = true;
- } else if (element == compiler.invokeOnMethod) {
- compiler.enabledInvokeOn = true;
- }
-
- nativeEnqueuer.registerElement(element);
+ addElementToWorkList(element);
}
/**
* Adds [element] to the work list if it has not already been processed.
- *
- * Returns [:true:] if the [element] should be processed.
*/
- // TODO(johnniwinther): Change to 'Returns true if the element was added to
- // the work list'?
- bool addElementToWorkList(Element element, [TreeElements elements]);
+ void addElementToWorkList(Element element);
ahe 2013/06/11 08:56:20 I think it would be a great time to rename either
ngeoffray 2013/06/11 09:05:14 Done.
void registerInstantiatedType(InterfaceType type, TreeElements elements) {
ClassElement cls = type.element;
@@ -607,11 +587,13 @@
bool isProcessed(Element member) => resolvedElements.containsKey(member);
- TreeElements getCachedElements(Element element) {
+ TreeElements getCachedElements(element) {
ahe 2013/06/11 08:56:20 Why remove the type annotation here?
ngeoffray 2013/06/11 09:05:14 Because I'm using the 'constructor' field and that
// TODO(ngeoffray): Get rid of this check.
if (element.enclosingElement.isClosure()) {
closureMapping.ClosureClassElement cls = element.enclosingElement;
element = cls.methodElement;
+ } else if (element.isGenerativeConstructorBody()) {
+ element = element.constructor;
}
Element owner = element.getOutermostEnclosingMemberOrTopLevel();
if (owner == null) {
@@ -620,35 +602,15 @@
return resolvedElements[owner.declaration];
}
- /**
- * Sets the resolved elements of [element] to [elements], or if [elements] is
- * [:null:], to the elements found through [getCachedElements].
- *
- * Returns the resolved elements.
- */
- TreeElements ensureCachedElements(Element element, TreeElements elements) {
- if (elements == null) {
- elements = getCachedElements(element);
- }
- resolvedElements[element] = elements;
- return elements;
- }
-
- bool addElementToWorkList(Element element, [TreeElements elements]) {
+ bool addElementToWorkList(Element element) {
+ if (getCachedElements(element) != null) return;
if (queueIsClosed) {
- if (getCachedElements(element) != null) return false;
throw new SpannableAssertionFailure(element,
"Resolution work list is closed.");
}
- if (elements == null) {
- elements = getCachedElements(element);
- }
compiler.world.registerUsedElement(element);
- if (elements == null) {
- queue.add(
- new ResolutionWorkItem(element, itemCompilationContextCreator()));
- }
+ queue.add(new ResolutionWorkItem(element, itemCompilationContextCreator()));
// Enable isolate support if we start using something from the
// isolate library, or timers for the async library.
@@ -667,7 +629,22 @@
}
}
- return true;
+ // Enable runtime type support if we discover a getter called runtimeType.
ahe 2013/06/11 08:56:20 This comment is out of date, more cases have been
ngeoffray 2013/06/11 09:05:14 Done.
+ // We have to enable runtime type before hitting the codegen, so
+ // that constructors know whether they need to generate code for
+ // runtime type.
+ if (element.isGetter() && element.name == Compiler.RUNTIME_TYPE) {
+ compiler.enabledRuntimeType = true;
+ // TODO(ahe): Record precise dependency here.
+ compiler.backend.registerRuntimeType(compiler.globalDependencies);
+ } else if (element == compiler.functionApplyMethod) {
+ compiler.enabledFunctionApply = true;
+ } else if (element == compiler.invokeOnMethod) {
+ compiler.enabledInvokeOn = true;
+ }
+
+ nativeEnqueuer.registerElement(element);
+ return;
ahe 2013/06/11 08:56:20 Remove return.
ngeoffray 2013/06/11 09:05:14 Done.
}
void enableIsolateSupport(LibraryElement element) {
@@ -746,23 +723,18 @@
bool isProcessed(Element member) =>
member.isAbstract(compiler) || generatedCode.containsKey(member);
- bool addElementToWorkList(Element element, [TreeElements elements]) {
+ bool addElementToWorkList(Element element) {
// Codegen inlines field initializers, so it does not need to add
// individual fields in the work list.
- if (element.isField() && element.isInstanceMember()) return true;
+ if (element.isField() && element.isInstanceMember()) return;
if (queueIsClosed) {
throw new SpannableAssertionFailure(element,
"Codegen work list is closed.");
}
- elements =
- compiler.enqueuer.resolution.ensureCachedElements(element, elements);
-
CodegenWorkItem workItem = new CodegenWorkItem(
- element, elements, itemCompilationContextCreator());
+ element, itemCompilationContextCreator());
queue.add(workItem);
-
- return true;
}
void forEach(f(WorkItem work)) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698