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

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

Issue 12226074: Cleanup universe to not have backend related things. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 CodegenWorkItem(Element element, 74 CodegenWorkItem(Element element,
75 TreeElements this.resolutionTree, 75 TreeElements this.resolutionTree,
76 ItemCompilationContext compilationContext) 76 ItemCompilationContext compilationContext)
77 : super(element, compilationContext) { 77 : super(element, compilationContext) {
78 assert(invariant(element, resolutionTree != null, 78 assert(invariant(element, resolutionTree != null,
79 message: 'Resolution tree is null for $element in codegen work item')); 79 message: 'Resolution tree is null for $element in codegen work item'));
80 } 80 }
81 81
82 void run(Compiler compiler, CodegenEnqueuer world) { 82 void run(Compiler compiler, CodegenEnqueuer world) {
83 js.Expression code = world.universe.generatedCode[element]; 83 if (world.isProcessed(element)) return;
84 if (code != null) return;
85 compiler.codegen(this, world); 84 compiler.codegen(this, world);
86 } 85 }
87 } 86 }
88 87
89 class ReadingFilesTask extends CompilerTask { 88 class ReadingFilesTask extends CompilerTask {
90 ReadingFilesTask(Compiler compiler) : super(compiler); 89 ReadingFilesTask(Compiler compiler) : super(compiler);
91 String get name => 'Reading input files'; 90 String get name => 'Reading input files';
92 } 91 }
93 92
94 abstract class Backend { 93 abstract class Backend {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 checker = new TypeCheckerTask(this), 368 checker = new TypeCheckerTask(this),
370 typesTask = new ti.TypesTask(this), 369 typesTask = new ti.TypesTask(this),
371 constantHandler = new ConstantHandler(this, backend.constantSystem), 370 constantHandler = new ConstantHandler(this, backend.constantSystem),
372 enqueuer = new EnqueueTask(this)]; 371 enqueuer = new EnqueueTask(this)];
373 372
374 tasks.addAll(backend.tasks); 373 tasks.addAll(backend.tasks);
375 metadataHandler = new ConstantHandler( 374 metadataHandler = new ConstantHandler(
376 this, backend.constantSystem, isMetadata: true); 375 this, backend.constantSystem, isMetadata: true);
377 } 376 }
378 377
379 ResolutionUniverse get resolverWorld => enqueuer.resolution.universe; 378 Universe get resolverWorld => enqueuer.resolution.universe;
380 CodegenUniverse get codegenWorld => enqueuer.codegen.universe; 379 Universe get codegenWorld => enqueuer.codegen.universe;
381 380
382 int getNextFreeClassId() => nextFreeClassId++; 381 int getNextFreeClassId() => nextFreeClassId++;
383 382
384 void ensure(bool condition) { 383 void ensure(bool condition) {
385 if (!condition) cancel('failed assertion in leg'); 384 if (!condition) cancel('failed assertion in leg');
386 } 385 }
387 386
388 void unimplemented(String methodName, 387 void unimplemented(String methodName,
389 {Node node, Token token, HInstruction instruction, 388 {Node node, Token token, HInstruction instruction,
390 Element element}) { 389 Element element}) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 * were resolved, but not compiled (aka excess resolution). 714 * were resolved, but not compiled (aka excess resolution).
716 */ 715 */
717 checkQueues() { 716 checkQueues() {
718 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { 717 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) {
719 world.forEach((WorkItem work) { 718 world.forEach((WorkItem work) {
720 internalErrorOnElement(work.element, "Work list is not empty."); 719 internalErrorOnElement(work.element, "Work list is not empty.");
721 }); 720 });
722 } 721 }
723 if (!REPORT_EXCESS_RESOLUTION) return; 722 if (!REPORT_EXCESS_RESOLUTION) return;
724 var resolved = new Set.from(enqueuer.resolution.resolvedElements.keys); 723 var resolved = new Set.from(enqueuer.resolution.resolvedElements.keys);
725 for (Element e in codegenWorld.generatedCode.keys) { 724 for (Element e in enqueuer.codegen.generatedCode.keys) {
726 resolved.remove(e); 725 resolved.remove(e);
727 } 726 }
728 for (Element e in new Set.from(resolved)) { 727 for (Element e in new Set.from(resolved)) {
729 if (e.isClass() || 728 if (e.isClass() ||
730 e.isField() || 729 e.isField() ||
731 e.isTypeVariable() || 730 e.isTypeVariable() ||
732 e.isTypedef() || 731 e.isTypedef() ||
733 identical(e.kind, ElementKind.ABSTRACT_FIELD)) { 732 identical(e.kind, ElementKind.ABSTRACT_FIELD)) {
734 resolved.remove(e); 733 resolved.remove(e);
735 } 734 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 assert(invariant(element, element.isDeclaration)); 791 assert(invariant(element, element.isDeclaration));
793 world.resolvedElements[element] = result; 792 world.resolvedElements[element] = result;
794 return result; 793 return result;
795 } 794 }
796 795
797 void codegen(CodegenWorkItem work, CodegenEnqueuer world) { 796 void codegen(CodegenWorkItem work, CodegenEnqueuer world) {
798 assert(invariant(work.element, identical(world, enqueuer.codegen))); 797 assert(invariant(work.element, identical(world, enqueuer.codegen)));
799 if (progress.elapsedMilliseconds > 500) { 798 if (progress.elapsedMilliseconds > 500) {
800 // TODO(ahe): Add structured diagnostics to the compiler API and 799 // TODO(ahe): Add structured diagnostics to the compiler API and
801 // use it to separate this from the --verbose option. 800 // use it to separate this from the --verbose option.
802 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 801 log('Compiled ${enqueuer.codegen.generatedCode.length} methods.');
803 progress.reset(); 802 progress.reset();
804 } 803 }
805 backend.codegen(work); 804 backend.codegen(work);
806 } 805 }
807 806
808 DartType resolveTypeAnnotation(Element element, 807 DartType resolveTypeAnnotation(Element element,
809 TypeAnnotation annotation) { 808 TypeAnnotation annotation) {
810 return resolver.resolveTypeAnnotation(element, annotation); 809 return resolver.resolveTypeAnnotation(element, annotation);
811 } 810 }
812 811
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1121
1123 void close() {} 1122 void close() {}
1124 1123
1125 toString() => name; 1124 toString() => name;
1126 1125
1127 /// Convenience method for getting an [api.CompilerOutputProvider]. 1126 /// Convenience method for getting an [api.CompilerOutputProvider].
1128 static NullSink outputProvider(String name, String extension) { 1127 static NullSink outputProvider(String name, String extension) {
1129 return new NullSink('$name.$extension'); 1128 return new NullSink('$name.$extension');
1130 } 1129 }
1131 } 1130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698