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

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

Issue 11052011: Fix some warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 2 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
« no previous file with comments | « no previous file | lib/compiler/implementation/constants.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5
6 /** 6 /**
7 * If true, print a warning for each method that was resolved, but not 7 * If true, print a warning for each method that was resolved, but not
8 * compiled. 8 * compiled.
9 */ 9 */
10 const bool REPORT_EXCESS_RESOLUTION = false; 10 const bool REPORT_EXCESS_RESOLUTION = false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 bool isAnalyzed() => resolutionTree !== null; 50 bool isAnalyzed() => resolutionTree !== null;
51 51
52 void run(Compiler compiler, Enqueuer world) { 52 void run(Compiler compiler, Enqueuer world) {
53 CodeBuffer codeBuffer = world.universe.generatedCode[element]; 53 CodeBuffer codeBuffer = world.universe.generatedCode[element];
54 if (codeBuffer !== null) return; 54 if (codeBuffer !== null) return;
55 resolutionTree = compiler.analyze(this, world); 55 resolutionTree = compiler.analyze(this, world);
56 compiler.codegen(this, world); 56 compiler.codegen(this, world);
57 } 57 }
58 } 58 }
59 59
60 class Backend { 60 abstract class Backend {
61 final Compiler compiler; 61 final Compiler compiler;
62 final ConstantSystem constantSystem; 62 final ConstantSystem constantSystem;
63 63
64 Backend(this.compiler, 64 Backend(this.compiler,
65 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) 65 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM])
66 : this.constantSystem = constantSystem; 66 : this.constantSystem = constantSystem;
67 67
68 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { 68 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) {
69 lib.forEachExport((Element e) { 69 lib.forEachExport((Element e) {
70 if (e.isFunction()) world.addToWorkList(e); 70 if (e.isFunction()) world.addToWorkList(e);
71 }); 71 });
72 } 72 }
73 73
74 abstract void enqueueHelpers(Enqueuer world); 74 abstract void enqueueHelpers(Enqueuer world);
75 abstract void codegen(WorkItem work); 75 abstract void codegen(WorkItem work);
76 abstract void processNativeClasses(Enqueuer world, 76 abstract void processNativeClasses(Enqueuer world,
77 Collection<LibraryElement> libraries); 77 Collection<LibraryElement> libraries);
78 abstract void assembleProgram(); 78 abstract void assembleProgram();
79 abstract List<CompilerTask> get tasks; 79 abstract List<CompilerTask> get tasks;
80 80
81 // TODO(ahe,karlklose): rename this?
82 void dumpInferredTypes() {}
83
81 ItemCompilationContext createItemCompilationContext() { 84 ItemCompilationContext createItemCompilationContext() {
82 return new ItemCompilationContext(); 85 return new ItemCompilationContext();
83 } 86 }
84 87
85 SourceString getCheckedModeHelper(DartType type) => null; 88 SourceString getCheckedModeHelper(DartType type) => null;
86 } 89 }
87 90
88 class Compiler implements DiagnosticListener { 91 abstract class Compiler implements DiagnosticListener {
89 final Map<String, LibraryElement> libraries; 92 final Map<String, LibraryElement> libraries;
90 int nextFreeClassId = 0; 93 int nextFreeClassId = 0;
91 World world; 94 World world;
92 String assembledCode; 95 String assembledCode;
93 Types types; 96 Types types;
94 97
95 final bool enableMinification; 98 final bool enableMinification;
96 final bool enableTypeAssertions; 99 final bool enableTypeAssertions;
97 final bool enableUserAssertions; 100 final bool enableUserAssertions;
98 101
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 backend.processNativeClasses(world, libraries.getValues()); 588 backend.processNativeClasses(world, libraries.getValues());
586 world.addToWorkList(main); 589 world.addToWorkList(main);
587 progress.reset(); 590 progress.reset();
588 world.forEach((WorkItem work) { 591 world.forEach((WorkItem work) {
589 withCurrentElement(work.element, () => work.run(this, world)); 592 withCurrentElement(work.element, () => work.run(this, world));
590 }); 593 });
591 world.queueIsClosed = true; 594 world.queueIsClosed = true;
592 if (compilationFailed) return; 595 if (compilationFailed) return;
593 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 596 assert(world.checkNoEnqueuedInvokedInstanceMethods());
594 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) { 597 if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) {
595 print("Inferred argument types:"); 598 backend.dumpInferredTypes();
596 print("------------------------");
597 backend.argumentTypes.dump();
598 print("");
599 print("Inferred return types:");
600 print("----------------------");
601 backend.dumpReturnTypes();
602 print("");
603 print("Inferred field types:");
604 print("------------------------");
605 backend.fieldTypes.dump();
606 print("");
607 } 599 }
608 } 600 }
609 601
610 /** 602 /**
611 * Perform various checks of the queues. This includes checking that 603 * Perform various checks of the queues. This includes checking that
612 * the queues are empty (nothing was added after we stopped 604 * the queues are empty (nothing was added after we stopped
613 * processing the queues). Also compute the number of methods that 605 * processing the queues). Also compute the number of methods that
614 * were resolved, but not compiled (aka excess resolution). 606 * were resolved, but not compiled (aka excess resolution).
615 */ 607 */
616 checkQueues() { 608 checkQueues() {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 835 }
844 836
845 Script readScript(Uri uri, [ScriptTag node]) { 837 Script readScript(Uri uri, [ScriptTag node]) {
846 unimplemented('Compiler.readScript'); 838 unimplemented('Compiler.readScript');
847 } 839 }
848 840
849 String get legDirectory { 841 String get legDirectory {
850 unimplemented('Compiler.legDirectory'); 842 unimplemented('Compiler.legDirectory');
851 } 843 }
852 844
845 // TODO(karlklose): split into findHelperFunction and findHelperClass and
846 // add a check that the element has the expected kind.
853 Element findHelper(SourceString name) 847 Element findHelper(SourceString name)
854 => jsHelperLibrary.findLocal(name); 848 => jsHelperLibrary.findLocal(name);
855 Element findInterceptor(SourceString name) 849 Element findInterceptor(SourceString name)
856 => interceptorsLibrary.findLocal(name); 850 => interceptorsLibrary.findLocal(name);
857 851
858 bool get isMockCompilation => false; 852 bool get isMockCompilation => false;
859 } 853 }
860 854
861 class CompilerTask { 855 class CompilerTask {
862 final Compiler compiler; 856 final Compiler compiler;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 * information in the generated error message. 934 * information in the generated error message.
941 */ 935 */
942 bool invariant(Spannable spannable, var condition, {String message: null}) { 936 bool invariant(Spannable spannable, var condition, {String message: null}) {
943 // TODO(johnniwinther): Use [spannable] and [message] to provide better 937 // TODO(johnniwinther): Use [spannable] and [message] to provide better
944 // information on assertion errors. 938 // information on assertion errors.
945 if (condition is Function){ 939 if (condition is Function){
946 condition = condition(); 940 condition = condition();
947 } 941 }
948 return spannable != null && condition; 942 return spannable != null && condition;
949 } 943 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698