| 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 17 matching lines...) Expand all Loading... |
| 28 String codegen(Compiler compiler) { | 28 String codegen(Compiler compiler) { |
| 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 final Types types; | 38 Types types; |
| 39 | 39 |
| 40 final Tracer tracer; | 40 final Tracer tracer; |
| 41 | 41 |
| 42 CompilerTask measuredTask; | 42 CompilerTask measuredTask; |
| 43 Element _currentElement; | 43 Element _currentElement; |
| 44 LibraryElement coreLibrary; | 44 LibraryElement coreLibrary; |
| 45 LibraryElement coreImplLibrary; | 45 LibraryElement coreImplLibrary; |
| 46 LibraryElement isolateLibrary; | 46 LibraryElement isolateLibrary; |
| 47 LibraryElement jsHelperLibrary; | 47 LibraryElement jsHelperLibrary; |
| 48 LibraryElement mainApp; | 48 LibraryElement mainApp; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 const SourceString('NoSuchMethodException'); | 89 const SourceString('NoSuchMethodException'); |
| 90 static final SourceString START_ROOT_ISOLATE = | 90 static final SourceString START_ROOT_ISOLATE = |
| 91 const SourceString('startRootIsolate'); | 91 const SourceString('startRootIsolate'); |
| 92 bool enabledNoSuchMethod = false; | 92 bool enabledNoSuchMethod = false; |
| 93 | 93 |
| 94 bool workListIsClosed = false; | 94 bool workListIsClosed = false; |
| 95 | 95 |
| 96 Stopwatch codegenProgress; | 96 Stopwatch codegenProgress; |
| 97 | 97 |
| 98 Compiler([this.tracer = const Tracer()]) | 98 Compiler([this.tracer = const Tracer()]) |
| 99 : types = new Types(), | 99 : universe = new Universe(), |
| 100 universe = new Universe(), | |
| 101 worklist = new Queue<WorkItem>(), | 100 worklist = new Queue<WorkItem>(), |
| 102 codegenProgress = new Stopwatch.start() { | 101 codegenProgress = new Stopwatch.start() { |
| 103 namer = new Namer(this); | 102 namer = new Namer(this); |
| 104 constantHandler = new ConstantHandler(this); | 103 constantHandler = new ConstantHandler(this); |
| 105 scanner = new ScannerTask(this); | 104 scanner = new ScannerTask(this); |
| 106 dietParser = new DietParserTask(this); | 105 dietParser = new DietParserTask(this); |
| 107 parser = new ParserTask(this); | 106 parser = new ParserTask(this); |
| 108 validator = new TreeValidatorTask(this); | 107 validator = new TreeValidatorTask(this); |
| 109 resolver = new ResolverTask(this); | 108 resolver = new ResolverTask(this); |
| 110 checker = new TypeCheckerTask(this); | 109 checker = new TypeCheckerTask(this); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // and see Dynamic this way. | 205 // and see Dynamic this way. |
| 207 withCurrentElement(dynamicClass, () { | 206 withCurrentElement(dynamicClass, () { |
| 208 library.define(dynamicClass, this); | 207 library.define(dynamicClass, this); |
| 209 }); | 208 }); |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 abstract LibraryElement scanBuiltinLibrary(String filename); | 212 abstract LibraryElement scanBuiltinLibrary(String filename); |
| 214 | 213 |
| 215 void initializeSpecialClasses() { | 214 void initializeSpecialClasses() { |
| 216 objectClass = coreLibrary.find(const SourceString('Object')); | 215 bool coreLibValid = true; |
| 217 boolClass = coreLibrary.find(const SourceString('bool')); | 216 ClassElement lookupSpecialClass(SourceString name) { |
| 218 numClass = coreLibrary.find(const SourceString('num')); | 217 ClassElement result = coreLibrary.find(name); |
| 219 intClass = coreLibrary.find(const SourceString('int')); | 218 if (result === null) { |
| 220 doubleClass = coreLibrary.find(const SourceString('double')); | 219 log('core library class $name missing'); |
| 221 stringClass = coreLibrary.find(const SourceString('String')); | 220 coreLibValid = false; |
| 222 functionClass = coreLibrary.find(const SourceString('Function')); | 221 } |
| 223 listClass = coreLibrary.find(const SourceString('List')); | 222 return result; |
| 224 closureClass = jsHelperLibrary.find(const SourceString('Closure')); | 223 } |
| 225 dynamicClass = types.dynamicType.element; | 224 objectClass = lookupSpecialClass(const SourceString('Object')); |
| 226 nullClass = jsHelperLibrary.find(const SourceString('Null')); | 225 boolClass = lookupSpecialClass(const SourceString('bool')); |
| 226 numClass = lookupSpecialClass(const SourceString('num')); |
| 227 intClass = lookupSpecialClass(const SourceString('int')); |
| 228 doubleClass = lookupSpecialClass(const SourceString('double')); |
| 229 stringClass = lookupSpecialClass(const SourceString('String')); |
| 230 functionClass = lookupSpecialClass(const SourceString('Function')); |
| 231 listClass = lookupSpecialClass(const SourceString('List')); |
| 232 closureClass = lookupSpecialClass(const SourceString('Closure')); |
| 233 dynamicClass = lookupSpecialClass(const SourceString('Dynamic')); |
| 234 nullClass = lookupSpecialClass(const SourceString('Null')); |
| 235 types = new Types(dynamicClass); |
| 236 if (!coreLibValid) { |
| 237 cancel('core library does not contain required classes'); |
| 238 } |
| 227 } | 239 } |
| 228 | 240 |
| 229 void scanBuiltinLibraries() { | 241 void scanBuiltinLibraries() { |
| 230 coreImplLibrary = scanBuiltinLibrary('coreimpl'); | 242 coreImplLibrary = scanBuiltinLibrary('coreimpl'); |
| 231 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); | 243 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 232 coreLibrary = scanBuiltinLibrary('core'); | 244 coreLibrary = scanBuiltinLibrary('core'); |
| 233 | 245 |
| 234 // Since coreLibrary import the libraries "coreimpl", and | 246 // Since coreLibrary import the libraries "coreimpl", and |
| 235 // "js_helper", coreLibrary is null when they are being built. So | 247 // "js_helper", coreLibrary is null when they are being built. So |
| 236 // we add the implicit import of coreLibrary now. This can be | 248 // we add the implicit import of coreLibrary now. This can be |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 551 } |
| 540 } | 552 } |
| 541 | 553 |
| 542 class SourceSpan { | 554 class SourceSpan { |
| 543 final Uri uri; | 555 final Uri uri; |
| 544 final int begin; | 556 final int begin; |
| 545 final int end; | 557 final int end; |
| 546 | 558 |
| 547 const SourceSpan(this.uri, this.begin, this.end); | 559 const SourceSpan(this.uri, this.begin, this.end); |
| 548 } | 560 } |
| OLD | NEW |