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

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: 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Make sure that the closure understands a call with the given 145 // Make sure that the closure understands a call with the given
146 // selector. For a method-invocation of the form o.foo(a: 499), we 146 // selector. For a method-invocation of the form o.foo(a: 499), we
147 // need to make sure that closures can handle the optional argument if 147 // need to make sure that closures can handle the optional argument if
148 // there exists a field or getter 'foo'. 148 // there exists a field or getter 'foo'.
149 var names = universe.instantiatedClassInstanceFields; 149 var names = universe.instantiatedClassInstanceFields;
150 // TODO(ahe): Might be enough to use invokedGetters. 150 // TODO(ahe): Might be enough to use invokedGetters.
151 for (SourceString name in names) { 151 for (SourceString name in names) {
152 Set<Selector> invokedSelectors = universe.invokedNames[name]; 152 Set<Selector> invokedSelectors = universe.invokedNames[name];
153 if (invokedSelectors != null) { 153 if (invokedSelectors != null) {
154 for (Selector selector in invokedSelectors) { 154 for (Selector selector in invokedSelectors) {
155 Selector call = new Selector.call(
156 compiler.namer.CLOSURE_INVOCATION_NAME,
157 selector.library, // TODO(kasperl): Use default library somehow ?
158 selector.argumentCount,
159 selector.namedArguments);
155 registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME, 160 registerDynamicInvocation(compiler.namer.CLOSURE_INVOCATION_NAME,
156 selector); 161 call);
157 } 162 }
158 } 163 }
159 } 164 }
160 }); 165 });
161 } 166 }
162 167
163 void processInstantiatedClassMember(Element member) { 168 void processInstantiatedClassMember(Element member) {
164 if (universe.generatedCode.containsKey(member)) return; 169 if (universe.generatedCode.containsKey(member)) return;
165 if (resolvedElements[member] !== null) return; 170 if (resolvedElements[member] !== null) return;
166 171
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 cls.ensureResolved(compiler); 222 cls.ensureResolved(compiler);
218 cls.members.forEach(processInstantiatedClassMember); 223 cls.members.forEach(processInstantiatedClassMember);
219 cls = cls.superclass; 224 cls = cls.superclass;
220 } 225 }
221 }); 226 });
222 } 227 }
223 228
224 void registerNewSelector(SourceString name, 229 void registerNewSelector(SourceString name,
225 Selector selector, 230 Selector selector,
226 Map<SourceString, Set<Selector>> selectorsMap) { 231 Map<SourceString, Set<Selector>> selectorsMap) {
232 if (name != selector.name) {
233 String message = "$name != ${selector.name} (${selector.kind})";
234 compiler.internalError("Wrong selector name: $message.");
235 }
227 Set<Selector> selectors = 236 Set<Selector> selectors =
228 selectorsMap.putIfAbsent(name, () => new Set<Selector>()); 237 selectorsMap.putIfAbsent(name, () => new Set<Selector>());
229 if (!selectors.contains(selector)) { 238 if (!selectors.contains(selector)) {
230 selectors.add(selector); 239 selectors.add(selector);
231 handleUnseenSelector(name, selector); 240 handleUnseenSelector(name, selector);
232 } 241 }
233 } 242 }
234 243
235 void registerInvocation(SourceString methodName, Selector selector) { 244 void registerInvocation(SourceString methodName, Selector selector) {
236 task.measure(() { 245 task.measure(() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 300 }
292 301
293 void registerDynamicGetter(SourceString methodName, Selector selector) { 302 void registerDynamicGetter(SourceString methodName, Selector selector) {
294 registerInvokedGetter(methodName, selector); 303 registerInvokedGetter(methodName, selector);
295 } 304 }
296 305
297 void registerDynamicSetter(SourceString methodName, Selector selector) { 306 void registerDynamicSetter(SourceString methodName, Selector selector) {
298 registerInvokedSetter(methodName, selector); 307 registerInvokedSetter(methodName, selector);
299 } 308 }
300 309
301 void registerFieldGetter(SourceString getterName, Type type) { 310 void registerFieldGetter(SourceString getterName,
311 LibraryElement library,
312 Type type) {
302 task.measure(() { 313 task.measure(() {
314 Selector getter = new Selector.getter(getterName, library);
303 registerNewSelector(getterName, 315 registerNewSelector(getterName,
304 new TypedSelector(type, Selector.GETTER), 316 new TypedSelector(type, getter),
305 universe.fieldGetters); 317 universe.fieldGetters);
306 }); 318 });
307 } 319 }
308 320
309 void registerFieldSetter(SourceString setterName, Type type) { 321 void registerFieldSetter(SourceString setterName,
322 LibraryElement library,
323 Type type) {
310 task.measure(() { 324 task.measure(() {
325 Selector setter = new Selector.setter(setterName, library);
311 registerNewSelector(setterName, 326 registerNewSelector(setterName,
312 new TypedSelector(type, Selector.SETTER), 327 new TypedSelector(type, setter),
313 universe.fieldSetters); 328 universe.fieldSetters);
314 }); 329 });
315 } 330 }
316 331
317 // TODO(ngeoffray): This should get a type. 332 // TODO(ngeoffray): This should get a type.
318 void registerIsCheck(Element element) { 333 void registerIsCheck(Element element) {
319 universe.isChecks.add(element); 334 universe.isChecks.add(element);
320 } 335 }
321 336
322 void forEach(f(WorkItem work)) { 337 void forEach(f(WorkItem work)) {
323 while (!queue.isEmpty()) { 338 while (!queue.isEmpty()) {
324 do { 339 do {
325 f(queue.removeLast()); 340 f(queue.removeLast());
326 } while (!queue.isEmpty()); 341 } while (!queue.isEmpty());
327 // TODO(ahe): we shouldn't register the field closure invocations here. 342 // TODO(ahe): we shouldn't register the field closure invocations here.
328 registerFieldClosureInvocations(); 343 registerFieldClosureInvocations();
329 } 344 }
330 } 345 }
331 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698