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

Side by Side Diff: lib/compiler/implementation/enqueue.dart

Issue 10854158: Make selector registration in the resolver and code generator more explicit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 EnqueueTask extends CompilerTask { 5 class EnqueueTask extends CompilerTask {
6 final Enqueuer codegen; 6 final Enqueuer codegen;
7 final Enqueuer resolution; 7 final Enqueuer resolution;
8 8
9 String get name() => 'Enqueue'; 9 String get name() => 'Enqueue';
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 } 137 }
138 }); 138 });
139 return true; 139 return true;
140 } 140 }
141 141
142 void processInstantiatedClass(ClassElement cls) { 142 void processInstantiatedClass(ClassElement cls) {
143 cls.localMembers.forEach(processInstantiatedClassMember); 143 cls.localMembers.forEach(processInstantiatedClassMember);
144 } 144 }
145 145
146 void registerFieldClosureInvocations() {
147 task.measure(() {
148 // Make sure that the closure understands a call with the given
149 // selector. For a method-invocation of the form o.foo(a: 499), we
150 // need to make sure that closures can handle the optional argument if
151 // there exists a field or getter 'foo'.
152 var names = universe.instantiatedClassInstanceFields;
153 // TODO(ahe): Might be enough to use invokedGetters.
154 for (SourceString name in names) {
155 Set<Selector> invokedSelectors = universe.invokedNames[name];
156 if (invokedSelectors != null) {
157 for (Selector selector in invokedSelectors) {
158 Selector call = new Selector.call(
159 compiler.namer.CLOSURE_INVOCATION_NAME,
160 selector.library, // TODO(kasperl): Use "default" library?
161 selector.argumentCount,
162 selector.namedArguments);
163 registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME,
164 call);
165 }
166 }
167 }
168 });
169 }
170
171 void processInstantiatedClassMember(Element member) { 146 void processInstantiatedClassMember(Element member) {
172 if (universe.generatedCode.containsKey(member)) return; 147 if (universe.generatedCode.containsKey(member)) return;
173 if (resolvedElements[member] !== null) return; 148 if (resolvedElements[member] !== null) return;
174 149
175 if (!member.isInstanceMember()) return; 150 if (!member.isInstanceMember()) return;
176 if (member.isField()) return; 151 if (member.isField()) return;
177 152
178 String memberName = member.name.slowToString(); 153 String memberName = member.name.slowToString();
179 Link<Element> members = instanceMembersByName.putIfAbsent( 154 Link<Element> members = instanceMembersByName.putIfAbsent(
180 memberName, () => const EmptyLink<Element>()); 155 memberName, () => const EmptyLink<Element>());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 processInstanceMembers(methodName, (Element member) { 263 processInstanceMembers(methodName, (Element member) {
289 if (selector.applies(member, compiler)) { 264 if (selector.applies(member, compiler)) {
290 addToWorkList(member); 265 addToWorkList(member);
291 return true; 266 return true;
292 } 267 }
293 return false; 268 return false;
294 }); 269 });
295 } 270 }
296 271
297 void registerStaticUse(Element element) { 272 void registerStaticUse(Element element) {
298 addToWorkList(element); 273 if (element !== null) addToWorkList(element);
299 } 274 }
300 275
301 void registerGetOfStaticFunction(FunctionElement element) { 276 void registerGetOfStaticFunction(FunctionElement element) {
302 registerStaticUse(element); 277 registerStaticUse(element);
303 universe.staticFunctionsNeedingGetter.add(element); 278 universe.staticFunctionsNeedingGetter.add(element);
304 } 279 }
305 280
306 void registerDynamicInvocation(SourceString methodName, Selector selector) { 281 void registerDynamicInvocation(SourceString methodName, Selector selector) {
307 assert(selector !== null); 282 assert(selector !== null);
308 registerInvocation(methodName, selector); 283 registerInvocation(methodName, selector);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 }); 317 });
343 } 318 }
344 319
345 // TODO(ngeoffray): This should get a type. 320 // TODO(ngeoffray): This should get a type.
346 void registerIsCheck(Element element) { 321 void registerIsCheck(Element element) {
347 universe.isChecks.add(element); 322 universe.isChecks.add(element);
348 } 323 }
349 324
350 void forEach(f(WorkItem work)) { 325 void forEach(f(WorkItem work)) {
351 while (!queue.isEmpty()) { 326 while (!queue.isEmpty()) {
352 do { 327 f(queue.removeLast()); // TODO(kasperl): Why isn't this removeFirst?
ahe 2012/08/16 12:09:54 Main is added last and we want to process it first
353 f(queue.removeLast());
354 } while (!queue.isEmpty());
355 // TODO(ahe): we shouldn't register the field closure invocations here.
356 registerFieldClosureInvocations();
357 } 328 }
358 } 329 }
359 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698