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

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

Issue 10915104: Move namer into javascript backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 SourceString getCheckedModeHelper(DartType type) => null; 79 SourceString getCheckedModeHelper(DartType type) => null;
80 } 80 }
81 81
82 class Compiler implements DiagnosticListener { 82 class Compiler implements DiagnosticListener {
83 final Map<String, LibraryElement> libraries; 83 final Map<String, LibraryElement> libraries;
84 int nextFreeClassId = 0; 84 int nextFreeClassId = 0;
85 World world; 85 World world;
86 String assembledCode; 86 String assembledCode;
87 Namer namer;
88 Types types; 87 Types types;
89 88
90 final bool enableMinification; 89 final bool enableMinification;
91 final bool enableTypeAssertions; 90 final bool enableTypeAssertions;
92 final bool enableUserAssertions; 91 final bool enableUserAssertions;
93 92
94 final Tracer tracer; 93 final Tracer tracer;
95 94
96 CompilerTask measuredTask; 95 CompilerTask measuredTask;
97 Element _currentElement; 96 Element _currentElement;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 this.enableTypeAssertions = false, 184 this.enableTypeAssertions = false,
186 this.enableUserAssertions = false, 185 this.enableUserAssertions = false,
187 this.enableMinification = false, 186 this.enableMinification = false,
188 bool emitJavaScript = true, 187 bool emitJavaScript = true,
189 bool generateSourceMap = true, 188 bool generateSourceMap = true,
190 bool cutDeclarationTypes = false]) 189 bool cutDeclarationTypes = false])
191 : libraries = new Map<String, LibraryElement>(), 190 : libraries = new Map<String, LibraryElement>(),
192 world = new World(), 191 world = new World(),
193 progress = new Stopwatch() { 192 progress = new Stopwatch() {
194 progress.start(); 193 progress.start();
195 namer = new Namer(this);
196 scanner = new ScannerTask(this); 194 scanner = new ScannerTask(this);
197 dietParser = new DietParserTask(this); 195 dietParser = new DietParserTask(this);
198 parser = new ParserTask(this); 196 parser = new ParserTask(this);
199 patchParser = new PatchParserTask(this); 197 patchParser = new PatchParserTask(this);
200 validator = new TreeValidatorTask(this); 198 validator = new TreeValidatorTask(this);
201 resolver = new ResolverTask(this); 199 resolver = new ResolverTask(this);
202 closureToClassMapper = new closureMapping.ClosureTask(this); 200 closureToClassMapper = new closureMapping.ClosureTask(this);
203 checker = new TypeCheckerTask(this); 201 checker = new TypeCheckerTask(this);
204 typesTask = new ti.TypesTask(this); 202 typesTask = new ti.TypesTask(this);
205 backend = emitJavaScript ? 203 backend = emitJavaScript ?
206 new js_backend.JavaScriptBackend(this, generateSourceMap) : 204 new js_backend.JavaScriptBackend(this, generateSourceMap) :
207 new dart_backend.DartBackend(this, cutDeclarationTypes); 205 new dart_backend.DartBackend(this, cutDeclarationTypes);
208 constantHandler = new ConstantHandler(this, backend.constantSystem); 206 constantHandler = new ConstantHandler(this, backend.constantSystem);
209 enqueuer = new EnqueueTask(this); 207 enqueuer = new EnqueueTask(this);
210 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, 208 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper,
211 checker, typesTask, constantHandler, enqueuer]; 209 checker, typesTask, constantHandler, enqueuer];
212 tasks.addAll(backend.tasks); 210 tasks.addAll(backend.tasks);
213 } 211 }
214 212
213 // TODO(floitsch): remove once the compile-time constant handler doesn't
214 // depend on it anymore.
215 js_backend.Namer get namer => (backend as js_backend.JavaScriptBackend).namer;
kasperl 2012/09/06 07:47:53 This seems hacky. Looking forward to getting rid o
216
215 Universe get resolverWorld => enqueuer.resolution.universe; 217 Universe get resolverWorld => enqueuer.resolution.universe;
216 Universe get codegenWorld => enqueuer.codegen.universe; 218 Universe get codegenWorld => enqueuer.codegen.universe;
217 219
218 int getNextFreeClassId() => nextFreeClassId++; 220 int getNextFreeClassId() => nextFreeClassId++;
219 221
220 void ensure(bool condition) { 222 void ensure(bool condition) {
221 if (!condition) cancel('failed assertion in leg'); 223 if (!condition) cancel('failed assertion in leg');
222 } 224 }
223 225
224 void unimplemented(String methodName, 226 void unimplemented(String methodName,
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 final endOffset = end.charOffset + end.slowCharCount; 928 final endOffset = end.charOffset + end.slowCharCount;
927 929
928 // [begin] and [end] might be the same for the same empty token. This 930 // [begin] and [end] might be the same for the same empty token. This
929 // happens for instance when scanning '$$'. 931 // happens for instance when scanning '$$'.
930 assert(endOffset >= beginOffset); 932 assert(endOffset >= beginOffset);
931 return f(beginOffset, endOffset); 933 return f(beginOffset, endOffset);
932 } 934 }
933 935
934 String toString() => 'SourceSpan($uri, $begin, $end)'; 936 String toString() => 'SourceSpan($uri, $begin, $end)';
935 } 937 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698