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

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

Issue 10823184: Basic type inference skeleton (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments 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 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 final bool REPORT_EXCESS_RESOLUTION = false; 10 final bool REPORT_EXCESS_RESOLUTION = false;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 List<CompilerTask> tasks; 274 List<CompilerTask> tasks;
275 ScannerTask scanner; 275 ScannerTask scanner;
276 DietParserTask dietParser; 276 DietParserTask dietParser;
277 ParserTask parser; 277 ParserTask parser;
278 PatchParserTask patchParser; 278 PatchParserTask patchParser;
279 TreeValidatorTask validator; 279 TreeValidatorTask validator;
280 ResolverTask resolver; 280 ResolverTask resolver;
281 TypeCheckerTask checker; 281 TypeCheckerTask checker;
282 ti.TypesTask typesTask;
282 Backend backend; 283 Backend backend;
283 ConstantHandler constantHandler; 284 ConstantHandler constantHandler;
284 EnqueueTask enqueuer; 285 EnqueueTask enqueuer;
285 286
286 static final SourceString MAIN = const SourceString('main'); 287 static final SourceString MAIN = const SourceString('main');
287 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); 288 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod');
288 static final SourceString NO_SUCH_METHOD_EXCEPTION = 289 static final SourceString NO_SUCH_METHOD_EXCEPTION =
289 const SourceString('NoSuchMethodException'); 290 const SourceString('NoSuchMethodException');
290 static final SourceString START_ROOT_ISOLATE = 291 static final SourceString START_ROOT_ISOLATE =
291 const SourceString('startRootIsolate'); 292 const SourceString('startRootIsolate');
(...skipping 20 matching lines...) Expand all
312 progress = new Stopwatch.start() { 313 progress = new Stopwatch.start() {
313 namer = new Namer(this); 314 namer = new Namer(this);
314 constantHandler = new ConstantHandler(this); 315 constantHandler = new ConstantHandler(this);
315 scanner = new ScannerTask(this); 316 scanner = new ScannerTask(this);
316 dietParser = new DietParserTask(this); 317 dietParser = new DietParserTask(this);
317 parser = new ParserTask(this); 318 parser = new ParserTask(this);
318 patchParser = new PatchParserTask(this); 319 patchParser = new PatchParserTask(this);
319 validator = new TreeValidatorTask(this); 320 validator = new TreeValidatorTask(this);
320 resolver = new ResolverTask(this); 321 resolver = new ResolverTask(this);
321 checker = new TypeCheckerTask(this); 322 checker = new TypeCheckerTask(this);
323 typesTask = new ti.TypesTask(this);
322 backend = emitJavascript ? 324 backend = emitJavascript ?
323 new JavaScriptBackend(this, generateSourceMap) : 325 new JavaScriptBackend(this, generateSourceMap) :
324 new dart_backend.DartBackend(this, validateUnparse); 326 new dart_backend.DartBackend(this, validateUnparse);
325 enqueuer = new EnqueueTask(this); 327 enqueuer = new EnqueueTask(this);
326 tasks = [scanner, dietParser, parser, resolver, checker, 328 tasks = [scanner, dietParser, parser, resolver, checker,
327 constantHandler, enqueuer]; 329 typesTask, constantHandler, enqueuer];
328 tasks.addAll(backend.tasks); 330 tasks.addAll(backend.tasks);
329 } 331 }
330 332
331 Universe get resolverWorld() => enqueuer.resolution.universe; 333 Universe get resolverWorld() => enqueuer.resolution.universe;
332 Universe get codegenWorld() => enqueuer.codegen.universe; 334 Universe get codegenWorld() => enqueuer.codegen.universe;
333 335
334 int getNextFreeClassId() => nextFreeClassId++; 336 int getNextFreeClassId() => nextFreeClassId++;
335 337
336 void ensure(bool condition) { 338 void ensure(bool condition) {
337 if (!condition) cancel('failed assertion in leg'); 339 if (!condition) cancel('failed assertion in leg');
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 world.populate(this, libraries.getValues()); 740 world.populate(this, libraries.getValues());
739 741
740 log('Resolving...'); 742 log('Resolving...');
741 phase = PHASE_RESOLVING; 743 phase = PHASE_RESOLVING;
742 backend.enqueueHelpers(enqueuer.resolution); 744 backend.enqueueHelpers(enqueuer.resolution);
743 processQueue(enqueuer.resolution, main); 745 processQueue(enqueuer.resolution, main);
744 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.'); 746 log('Resolved ${enqueuer.resolution.resolvedElements.length} elements.');
745 747
746 if (compilationFailed) return; 748 if (compilationFailed) return;
747 749
750 log('Inferring types...');
751 typesTask.onResolutionComplete();
752
748 log('Compiling...'); 753 log('Compiling...');
749 phase = PHASE_COMPILING; 754 phase = PHASE_COMPILING;
750 processQueue(enqueuer.codegen, main); 755 processQueue(enqueuer.codegen, main);
751 log("Recompiling ${enqueuer.codegen.recompilationCandidates.length} " 756 log("Recompiling ${enqueuer.codegen.recompilationCandidates.length} "
752 "methods..."); 757 "methods...");
753 phase = PHASE_RECOMPILING; 758 phase = PHASE_RECOMPILING;
754 processRecompilationQueue(enqueuer.codegen); 759 processRecompilationQueue(enqueuer.codegen);
755 log('Compiled ${codegenWorld.generatedCode.length} methods.'); 760 log('Compiled ${codegenWorld.generatedCode.length} methods.');
756 761
757 if (compilationFailed) return; 762 if (compilationFailed) return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 if (!element.isAccessor() && 852 if (!element.isAccessor() &&
848 ((kind === ElementKind.ABSTRACT_FIELD) || 853 ((kind === ElementKind.ABSTRACT_FIELD) ||
849 (kind.category & allowed) == 0)) { 854 (kind.category & allowed) == 0)) {
850 return null; 855 return null;
851 } 856 }
852 assert(parser !== null); 857 assert(parser !== null);
853 Node tree = parser.parse(element); 858 Node tree = parser.parse(element);
854 validator.validate(tree); 859 validator.validate(tree);
855 elements = resolver.resolve(element); 860 elements = resolver.resolve(element);
856 checker.check(tree, elements); 861 checker.check(tree, elements);
862 typesTask.analyze(tree, elements);
857 return elements; 863 return elements;
858 } 864 }
859 865
860 TreeElements analyze(WorkItem work, Enqueuer world) { 866 TreeElements analyze(WorkItem work, Enqueuer world) {
861 if (work.isAnalyzed()) { 867 if (work.isAnalyzed()) {
862 // TODO(ahe): Clean this up and find a better way for adding all resolved 868 // TODO(ahe): Clean this up and find a better way for adding all resolved
863 // elements. 869 // elements.
864 enqueuer.resolution.resolvedElements[work.element] = work.resolutionTree; 870 enqueuer.resolution.resolvedElements[work.element] = work.resolutionTree;
865 return work.resolutionTree; 871 return work.resolutionTree;
866 } 872 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 final endOffset = end.charOffset + end.slowCharCount; 1101 final endOffset = end.charOffset + end.slowCharCount;
1096 1102
1097 // [begin] and [end] might be the same for the same empty token. This 1103 // [begin] and [end] might be the same for the same empty token. This
1098 // happens for instance when scanning '$$'. 1104 // happens for instance when scanning '$$'.
1099 assert(endOffset >= beginOffset); 1105 assert(endOffset >= beginOffset);
1100 return f(beginOffset, endOffset); 1106 return f(beginOffset, endOffset);
1101 } 1107 }
1102 1108
1103 String toString() => 'SourceSpan($uri, $begin, $end)'; 1109 String toString() => 'SourceSpan($uri, $begin, $end)';
1104 } 1110 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/leg.dart » ('j') | dart/lib/compiler/implementation/lib/core.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698