| OLD | NEW |
| 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 class WorkItem { | 5 class WorkItem { |
| 6 final Element element; | 6 final Element element; |
| 7 TreeElements resolutionTree; | 7 TreeElements resolutionTree; |
| 8 Function run; | 8 Function run; |
| 9 bool allowSpeculativeOptimization = true; | 9 bool allowSpeculativeOptimization = true; |
| 10 List<HTypeGuard> guards = const <HTypeGuard>[]; | 10 List<HTypeGuard> guards = const <HTypeGuard>[]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return compiler.codegen(this); | 29 return compiler.codegen(this); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 class Compiler implements DiagnosticListener { | 33 class Compiler implements DiagnosticListener { |
| 34 Queue<WorkItem> worklist; | 34 Queue<WorkItem> worklist; |
| 35 Universe universe; | 35 Universe universe; |
| 36 String assembledCode; | 36 String assembledCode; |
| 37 Namer namer; | 37 Namer namer; |
| 38 Types types; | 38 Types types; |
| 39 final String currentDirectory; | |
| 40 | 39 |
| 41 final Tracer tracer; | 40 final Tracer tracer; |
| 42 | 41 |
| 43 CompilerTask measuredTask; | 42 CompilerTask measuredTask; |
| 44 Element _currentElement; | 43 Element _currentElement; |
| 45 LibraryElement coreLibrary; | 44 LibraryElement coreLibrary; |
| 46 LibraryElement coreImplLibrary; | 45 LibraryElement coreImplLibrary; |
| 47 LibraryElement isolateLibrary; | 46 LibraryElement isolateLibrary; |
| 48 LibraryElement jsHelperLibrary; | 47 LibraryElement jsHelperLibrary; |
| 49 LibraryElement mainApp; | 48 LibraryElement mainApp; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 static final SourceString NO_SUCH_METHOD_EXCEPTION = | 88 static final SourceString NO_SUCH_METHOD_EXCEPTION = |
| 90 const SourceString('NoSuchMethodException'); | 89 const SourceString('NoSuchMethodException'); |
| 91 static final SourceString START_ROOT_ISOLATE = | 90 static final SourceString START_ROOT_ISOLATE = |
| 92 const SourceString('startRootIsolate'); | 91 const SourceString('startRootIsolate'); |
| 93 bool enabledNoSuchMethod = false; | 92 bool enabledNoSuchMethod = false; |
| 94 | 93 |
| 95 bool workListIsClosed = false; | 94 bool workListIsClosed = false; |
| 96 | 95 |
| 97 Stopwatch codegenProgress; | 96 Stopwatch codegenProgress; |
| 98 | 97 |
| 99 Compiler.withCurrentDirectory(String this.currentDirectory, | 98 Compiler([this.tracer = const Tracer()]) |
| 100 [this.tracer = const Tracer()]) | |
| 101 : types = new Types(), | 99 : types = new Types(), |
| 102 universe = new Universe(), | 100 universe = new Universe(), |
| 103 worklist = new Queue<WorkItem>(), | 101 worklist = new Queue<WorkItem>(), |
| 104 codegenProgress = new Stopwatch.start() { | 102 codegenProgress = new Stopwatch.start() { |
| 105 namer = new Namer(this); | 103 namer = new Namer(this); |
| 106 constantHandler = new ConstantHandler(this); | 104 constantHandler = new ConstantHandler(this); |
| 107 scanner = new ScannerTask(this); | 105 scanner = new ScannerTask(this); |
| 108 dietParser = new DietParserTask(this); | 106 dietParser = new DietParserTask(this); |
| 109 parser = new ParserTask(this); | 107 parser = new ParserTask(this); |
| 110 validator = new TreeValidatorTask(this); | 108 validator = new TreeValidatorTask(this); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 doubleClass = coreLibrary.find(const SourceString('double')); | 220 doubleClass = coreLibrary.find(const SourceString('double')); |
| 223 stringClass = coreLibrary.find(const SourceString('String')); | 221 stringClass = coreLibrary.find(const SourceString('String')); |
| 224 functionClass = coreLibrary.find(const SourceString('Function')); | 222 functionClass = coreLibrary.find(const SourceString('Function')); |
| 225 listClass = coreLibrary.find(const SourceString('List')); | 223 listClass = coreLibrary.find(const SourceString('List')); |
| 226 closureClass = jsHelperLibrary.find(const SourceString('Closure')); | 224 closureClass = jsHelperLibrary.find(const SourceString('Closure')); |
| 227 dynamicClass = jsHelperLibrary.find(const SourceString('Dynamic')); | 225 dynamicClass = jsHelperLibrary.find(const SourceString('Dynamic')); |
| 228 nullClass = jsHelperLibrary.find(const SourceString('Null')); | 226 nullClass = jsHelperLibrary.find(const SourceString('Null')); |
| 229 } | 227 } |
| 230 | 228 |
| 231 void scanBuiltinLibraries() { | 229 void scanBuiltinLibraries() { |
| 232 coreImplLibrary = scanBuiltinLibrary('coreimpl.dart'); | 230 coreImplLibrary = scanBuiltinLibrary('coreimpl'); |
| 233 jsHelperLibrary = scanBuiltinLibrary('js_helper.dart'); | 231 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 234 coreLibrary = scanBuiltinLibrary('core.dart'); | 232 coreLibrary = scanBuiltinLibrary('core'); |
| 235 | 233 |
| 236 // Since coreLibrary import the libraries "coreimpl", and | 234 // Since coreLibrary import the libraries "coreimpl", and |
| 237 // "js_helper", coreLibrary is null when they are being built. So | 235 // "js_helper", coreLibrary is null when they are being built. So |
| 238 // we add the implicit import of coreLibrary now. This can be | 236 // we add the implicit import of coreLibrary now. This can be |
| 239 // cleaned up when we have proper support for "dart:core" and | 237 // cleaned up when we have proper support for "dart:core" and |
| 240 // don't need to access it through the field "coreLibrary". | 238 // don't need to access it through the field "coreLibrary". |
| 241 // TODO(ahe): Clean this up as described above. | 239 // TODO(ahe): Clean this up as described above. |
| 242 scanner.importLibrary(coreImplLibrary, coreLibrary, null); | 240 scanner.importLibrary(coreImplLibrary, coreLibrary, null); |
| 243 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); | 241 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); |
| 244 addForeignFunctions(jsHelperLibrary); | 242 addForeignFunctions(jsHelperLibrary); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 541 } |
| 544 } | 542 } |
| 545 | 543 |
| 546 class SourceSpan { | 544 class SourceSpan { |
| 547 final Uri uri; | 545 final Uri uri; |
| 548 final int begin; | 546 final int begin; |
| 549 final int end; | 547 final int end; |
| 550 | 548 |
| 551 const SourceSpan(this.uri, this.begin, this.end); | 549 const SourceSpan(this.uri, this.begin, this.end); |
| 552 } | 550 } |
| OLD | NEW |