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

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

Issue 15888010: Re-apply "Implement operator== and hashCode for bound closures." (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 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 23383)
+++ sdk/lib/_internal/compiler/implementation/enqueue.dart (working copy)
@@ -87,6 +87,8 @@
final Function itemCompilationContextCreator;
final Map<String, Link<Element>> instanceMembersByName
= new Map<String, Link<Element>>();
+ final Map<String, Link<Element>> instanceFunctionsByName
+ = new Map<String, Link<Element>>();
final Set<ClassElement> seenClasses = new Set<ClassElement>();
final Universe universe = new Universe();
@@ -209,20 +211,24 @@
if (member.name == Compiler.NO_SUCH_METHOD) {
enableNoSuchMethod(member);
}
- if (universe.hasInvocation(member, compiler)) {
- return addToWorkList(member);
- }
// If there is a property access with the same name as a method we
// need to emit the method.
if (universe.hasInvokedGetter(member, compiler)) {
- // We will emit a closure, so make sure the closure class is
+ // We will emit a closure, so make sure the bound closure class is
// generated.
- compiler.closureClass.ensureResolved(compiler);
- registerInstantiatedClass(compiler.closureClass,
+ registerInstantiatedClass(compiler.boundClosureClass,
// Precise dependency is not important here.
compiler.globalDependencies);
return addToWorkList(member);
}
+ // Store the member in [instanceFunctionsByName] to catch
+ // getters on the function.
+ Link<Element> members = instanceFunctionsByName.putIfAbsent(
+ memberName, () => const Link<Element>());
+ instanceFunctionsByName[memberName] = members.prepend(member);
+ if (universe.hasInvocation(member, compiler)) {
+ return addToWorkList(member);
+ }
} else if (member.kind == ElementKind.GETTER) {
if (universe.hasInvokedGetter(member, compiler)) {
return addToWorkList(member);
@@ -386,18 +392,28 @@
void registerNewSymbol(TreeElements elements) {
}
- processInstanceMembers(SourceString n, bool f(Element e)) {
+ processLink(Map<String, Link<Element>> map,
+ SourceString n,
+ bool f(Element e)) {
String memberName = n.slowToString();
- Link<Element> members = instanceMembersByName[memberName];
+ Link<Element> members = map[memberName];
if (members != null) {
LinkBuilder<Element> remaining = new LinkBuilder<Element>();
for (; !members.isEmpty; members = members.tail) {
if (!f(members.head)) remaining.addLast(members.head);
}
- instanceMembersByName[memberName] = remaining.toLink();
+ map[memberName] = remaining.toLink();
}
}
+ processInstanceMembers(SourceString n, bool f(Element e)) {
+ processLink(instanceMembersByName, n, f);
+ }
+
+ processInstanceFunctions(SourceString n, bool f(Element e)) {
+ processLink(instanceFunctionsByName, n, f);
+ }
+
void handleUnseenSelector(SourceString methodName, Selector selector) {
processInstanceMembers(methodName, (Element member) {
if (selector.appliesUnnamed(member, compiler)) {
@@ -424,6 +440,19 @@
}
return false;
});
+ if (selector.isGetter()) {
+ processInstanceFunctions(methodName, (Element member) {
+ if (selector.appliesUnnamed(member, compiler)) {
+ // We will emit a closure, so make sure the bound closure class is
+ // generated.
+ registerInstantiatedClass(compiler.boundClosureClass,
+ // Precise dependency is not important here.
+ compiler.globalDependencies);
+ return true;
+ }
+ return false;
+ });
+ }
}
/**
@@ -439,6 +468,8 @@
void registerGetOfStaticFunction(FunctionElement element) {
registerStaticUse(element);
+ registerInstantiatedClass(compiler.closureClass,
+ compiler.globalDependencies);
universe.staticFunctionsNeedingGetter.add(element);
}

Powered by Google App Engine
This is Rietveld 408576698