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

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

Issue 10825337: Add name and library to selectors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge from master. 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Make sure that the closure understands a call with the given 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 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 150 // need to make sure that closures can handle the optional argument if
151 // there exists a field or getter 'foo'. 151 // there exists a field or getter 'foo'.
152 var names = universe.instantiatedClassInstanceFields; 152 var names = universe.instantiatedClassInstanceFields;
153 // TODO(ahe): Might be enough to use invokedGetters. 153 // TODO(ahe): Might be enough to use invokedGetters.
154 for (SourceString name in names) { 154 for (SourceString name in names) {
155 Set<Selector> invokedSelectors = universe.invokedNames[name]; 155 Set<Selector> invokedSelectors = universe.invokedNames[name];
156 if (invokedSelectors != null) { 156 if (invokedSelectors != null) {
157 for (Selector selector in invokedSelectors) { 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);
158 registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME, 163 registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME,
159 selector); 164 call);
160 } 165 }
161 } 166 }
162 } 167 }
163 }); 168 });
164 } 169 }
165 170
166 void processInstantiatedClassMember(Element member) { 171 void processInstantiatedClassMember(Element member) {
167 if (universe.generatedCode.containsKey(member)) return; 172 if (universe.generatedCode.containsKey(member)) return;
168 if (resolvedElements[member] !== null) return; 173 if (resolvedElements[member] !== null) return;
169 174
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 cls.ensureResolved(compiler); 225 cls.ensureResolved(compiler);
221 cls.localMembers.forEach(processInstantiatedClassMember); 226 cls.localMembers.forEach(processInstantiatedClassMember);
222 cls = cls.superclass; 227 cls = cls.superclass;
223 } 228 }
224 }); 229 });
225 } 230 }
226 231
227 void registerNewSelector(SourceString name, 232 void registerNewSelector(SourceString name,
228 Selector selector, 233 Selector selector,
229 Map<SourceString, Set<Selector>> selectorsMap) { 234 Map<SourceString, Set<Selector>> selectorsMap) {
235 if (name != selector.name) {
236 String message = "$name != ${selector.name} (${selector.kind})";
237 compiler.internalError("Wrong selector name: $message.");
ahe 2012/08/15 07:37:59 Style-wise, I think I'd prefer: compiler.internal
238 }
230 Set<Selector> selectors = 239 Set<Selector> selectors =
231 selectorsMap.putIfAbsent(name, () => new Set<Selector>()); 240 selectorsMap.putIfAbsent(name, () => new Set<Selector>());
232 if (!selectors.contains(selector)) { 241 if (!selectors.contains(selector)) {
233 selectors.add(selector); 242 selectors.add(selector);
234 handleUnseenSelector(name, selector); 243 handleUnseenSelector(name, selector);
235 } 244 }
236 } 245 }
237 246
238 void registerInvocation(SourceString methodName, Selector selector) { 247 void registerInvocation(SourceString methodName, Selector selector) {
239 task.measure(() { 248 task.measure(() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 303 }
295 304
296 void registerDynamicGetter(SourceString methodName, Selector selector) { 305 void registerDynamicGetter(SourceString methodName, Selector selector) {
297 registerInvokedGetter(methodName, selector); 306 registerInvokedGetter(methodName, selector);
298 } 307 }
299 308
300 void registerDynamicSetter(SourceString methodName, Selector selector) { 309 void registerDynamicSetter(SourceString methodName, Selector selector) {
301 registerInvokedSetter(methodName, selector); 310 registerInvokedSetter(methodName, selector);
302 } 311 }
303 312
304 void registerFieldGetter(SourceString getterName, Type type) { 313 void registerFieldGetter(SourceString getterName,
314 LibraryElement library,
315 Type type) {
305 task.measure(() { 316 task.measure(() {
317 Selector getter = new Selector.getter(getterName, library);
306 registerNewSelector(getterName, 318 registerNewSelector(getterName,
307 new TypedSelector(type, Selector.GETTER), 319 new TypedSelector(type, getter),
308 universe.fieldGetters); 320 universe.fieldGetters);
309 }); 321 });
310 } 322 }
311 323
312 void registerFieldSetter(SourceString setterName, Type type) { 324 void registerFieldSetter(SourceString setterName,
325 LibraryElement library,
326 Type type) {
313 task.measure(() { 327 task.measure(() {
328 Selector setter = new Selector.setter(setterName, library);
314 registerNewSelector(setterName, 329 registerNewSelector(setterName,
315 new TypedSelector(type, Selector.SETTER), 330 new TypedSelector(type, setter),
316 universe.fieldSetters); 331 universe.fieldSetters);
317 }); 332 });
318 } 333 }
319 334
320 // TODO(ngeoffray): This should get a type. 335 // TODO(ngeoffray): This should get a type.
321 void registerIsCheck(Element element) { 336 void registerIsCheck(Element element) {
322 universe.isChecks.add(element); 337 universe.isChecks.add(element);
323 } 338 }
324 339
325 void forEach(f(WorkItem work)) { 340 void forEach(f(WorkItem work)) {
326 while (!queue.isEmpty()) { 341 while (!queue.isEmpty()) {
327 do { 342 do {
328 f(queue.removeLast()); 343 f(queue.removeLast());
329 } while (!queue.isEmpty()); 344 } while (!queue.isEmpty());
330 // TODO(ahe): we shouldn't register the field closure invocations here. 345 // TODO(ahe): we shouldn't register the field closure invocations here.
331 registerFieldClosureInvocations(); 346 registerFieldClosureInvocations();
332 } 347 }
333 } 348 }
334 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698