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

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

Issue 13261008: Check for cyclic reference in typedefs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 8 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 part of dart2js; 5 part of dart2js;
6 6
7 class EnqueueTask extends CompilerTask { 7 class EnqueueTask extends CompilerTask {
8 final ResolutionEnqueuer resolution; 8 final ResolutionEnqueuer resolution;
9 final CodegenEnqueuer codegen; 9 final CodegenEnqueuer codegen;
10 10
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 compiler.backend.registerIsCheck(type, this, elements); 386 compiler.backend.registerIsCheck(type, this, elements);
387 } 387 }
388 388
389 void registerAsCheck(DartType type, TreeElements elements) { 389 void registerAsCheck(DartType type, TreeElements elements) {
390 registerIsCheck(type, elements); 390 registerIsCheck(type, elements);
391 compiler.backend.registerAsCheck(type, elements); 391 compiler.backend.registerAsCheck(type, elements);
392 } 392 }
393 393
394 void forEach(f(WorkItem work)); 394 void forEach(f(WorkItem work));
395 395
396 void forEachPostProcessing(f(PostProcessing work)) {}
397
396 void logSummary(log(message)) { 398 void logSummary(log(message)) {
397 _logSpecificSummary(log); 399 _logSpecificSummary(log);
398 nativeEnqueuer.logSummary(log); 400 nativeEnqueuer.logSummary(log);
399 } 401 }
400 402
401 /// Log summary specific to the concrete enqueuer. 403 /// Log summary specific to the concrete enqueuer.
402 void _logSpecificSummary(log(message)); 404 void _logSpecificSummary(log(message));
403 405
404 String toString() => 'Enqueuer($name)'; 406 String toString() => 'Enqueuer($name)';
405 } 407 }
406 408
407 /// [Enqueuer] which is specific to resolution. 409 /// [Enqueuer] which is specific to resolution.
408 class ResolutionEnqueuer extends Enqueuer { 410 class ResolutionEnqueuer extends Enqueuer {
409 /** 411 /**
410 * Map from declaration elements to the [TreeElements] object holding the 412 * Map from declaration elements to the [TreeElements] object holding the
411 * resolution mapping for the element implementation. 413 * resolution mapping for the element implementation.
412 * 414 *
413 * Invariant: Key elements are declaration elements. 415 * Invariant: Key elements are declaration elements.
414 */ 416 */
415 final Map<Element, TreeElements> resolvedElements; 417 final Map<Element, TreeElements> resolvedElements;
416 418
417 final Queue<ResolutionWorkItem> queue; 419 final Queue<ResolutionWorkItem> queue;
418 420
421 final Queue<PostProcessing> postQueue;
422
419 ResolutionEnqueuer(Compiler compiler, 423 ResolutionEnqueuer(Compiler compiler,
420 ItemCompilationContext itemCompilationContextCreator()) 424 ItemCompilationContext itemCompilationContextCreator())
421 : super('resolution enqueuer', compiler, itemCompilationContextCreator), 425 : super('resolution enqueuer', compiler, itemCompilationContextCreator),
422 resolvedElements = new Map<Element, TreeElements>(), 426 resolvedElements = new Map<Element, TreeElements>(),
423 queue = new Queue<ResolutionWorkItem>(); 427 queue = new Queue<ResolutionWorkItem>(),
428 postQueue = new Queue<PostProcessing>();
424 429
425 bool get isResolutionQueue => true; 430 bool get isResolutionQueue => true;
426 431
427 bool isProcessed(Element member) => resolvedElements.containsKey(member); 432 bool isProcessed(Element member) => resolvedElements.containsKey(member);
428 433
429 TreeElements getCachedElements(Element element) { 434 TreeElements getCachedElements(Element element) {
430 // TODO(ngeoffray): Get rid of this check. 435 // TODO(ngeoffray): Get rid of this check.
431 if (element.enclosingElement.isClosure()) { 436 if (element.enclosingElement.isClosure()) {
432 closureMapping.ClosureClassElement cls = element.enclosingElement; 437 closureMapping.ClosureClassElement cls = element.enclosingElement;
433 element = cls.methodElement; 438 element = cls.methodElement;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 addToWorkList(compiler.createInvocationMirrorElement); 519 addToWorkList(compiler.createInvocationMirrorElement);
515 } 520 }
516 521
517 void forEach(f(WorkItem work)) { 522 void forEach(f(WorkItem work)) {
518 while (!queue.isEmpty) { 523 while (!queue.isEmpty) {
519 // TODO(johnniwinther): Find an optimal process order for resolution. 524 // TODO(johnniwinther): Find an optimal process order for resolution.
520 f(queue.removeLast()); 525 f(queue.removeLast());
521 } 526 }
522 } 527 }
523 528
529 void addPostProcessing(Element element, PostProcess process) {
530 if (queueIsClosed) {
531 throw new SpannableAssertionFailure(element,
532 "Resolution work list is closed.");
533 }
534 postQueue.add(new PostProcessing(element, process));
535 }
536
537 void forEachPostProcessing(f(PostProcessing work)) {
538 while (!postQueue.isEmpty) {
539 f(postQueue.removeFirst());
540 }
541 }
542
524 void registerJsCall(Send node, ResolverVisitor resolver) { 543 void registerJsCall(Send node, ResolverVisitor resolver) {
525 nativeEnqueuer.registerJsCall(node, resolver); 544 nativeEnqueuer.registerJsCall(node, resolver);
526 } 545 }
527 546
528 void _logSpecificSummary(log(message)) { 547 void _logSpecificSummary(log(message)) {
529 log('Resolved ${resolvedElements.length} elements.'); 548 log('Resolved ${resolvedElements.length} elements.');
530 } 549 }
531 } 550 }
532 551
533 /// [Enqueuer] which is specific to code generation. 552 /// [Enqueuer] which is specific to code generation.
(...skipping 29 matching lines...) Expand all
563 while(!queue.isEmpty) { 582 while(!queue.isEmpty) {
564 // TODO(johnniwinther): Find an optimal process order for codegen. 583 // TODO(johnniwinther): Find an optimal process order for codegen.
565 f(queue.removeLast()); 584 f(queue.removeLast());
566 } 585 }
567 } 586 }
568 587
569 void _logSpecificSummary(log(message)) { 588 void _logSpecificSummary(log(message)) {
570 log('Compiled ${generatedCode.length} methods.'); 589 log('Compiled ${generatedCode.length} methods.');
571 } 590 }
572 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698