| 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 bool allowSpeculativeOptimization = true; | 8 bool allowSpeculativeOptimization = true; |
| 9 List<HTypeGuard> guards = const <HTypeGuard>[]; | 9 List<HTypeGuard> guards = const <HTypeGuard>[]; |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } finally { | 118 } finally { |
| 119 _currentElement = old; | 119 _currentElement = old; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 List<CompilerTask> tasks; | 123 List<CompilerTask> tasks; |
| 124 ScannerTask scanner; | 124 ScannerTask scanner; |
| 125 DietParserTask dietParser; | 125 DietParserTask dietParser; |
| 126 ParserTask parser; | 126 ParserTask parser; |
| 127 TreeValidatorTask validator; | 127 TreeValidatorTask validator; |
| 128 UnparseValidator unparseValidator; |
| 128 ResolverTask resolver; | 129 ResolverTask resolver; |
| 129 TypeCheckerTask checker; | 130 TypeCheckerTask checker; |
| 130 Backend backend; | 131 Backend backend; |
| 131 ConstantHandler constantHandler; | 132 ConstantHandler constantHandler; |
| 132 EnqueueTask enqueuer; | 133 EnqueueTask enqueuer; |
| 133 | 134 |
| 134 static final SourceString MAIN = const SourceString('main'); | 135 static final SourceString MAIN = const SourceString('main'); |
| 135 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 136 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 136 static final SourceString NO_SUCH_METHOD_EXCEPTION = | 137 static final SourceString NO_SUCH_METHOD_EXCEPTION = |
| 137 const SourceString('NoSuchMethodException'); | 138 const SourceString('NoSuchMethodException'); |
| 138 static final SourceString START_ROOT_ISOLATE = | 139 static final SourceString START_ROOT_ISOLATE = |
| 139 const SourceString('startRootIsolate'); | 140 const SourceString('startRootIsolate'); |
| 140 bool enabledNoSuchMethod = false; | 141 bool enabledNoSuchMethod = false; |
| 141 | 142 |
| 142 Stopwatch codegenProgress; | 143 Stopwatch codegenProgress; |
| 143 | 144 |
| 144 Compiler([this.tracer = const Tracer(), | 145 Compiler([this.tracer = const Tracer(), |
| 145 this.enableTypeAssertions = false, | 146 this.enableTypeAssertions = false, |
| 146 bool emitJavascript = true]) | 147 bool emitJavascript = true, |
| 148 validateUnparse = false]) |
| 147 : libraries = new Map<String, LibraryElement>(), | 149 : libraries = new Map<String, LibraryElement>(), |
| 148 world = new World(), | 150 world = new World(), |
| 149 codegenProgress = new Stopwatch.start() { | 151 codegenProgress = new Stopwatch.start() { |
| 150 namer = new Namer(this); | 152 namer = new Namer(this); |
| 151 constantHandler = new ConstantHandler(this); | 153 constantHandler = new ConstantHandler(this); |
| 152 scanner = new ScannerTask(this); | 154 scanner = new ScannerTask(this); |
| 153 dietParser = new DietParserTask(this); | 155 dietParser = new DietParserTask(this); |
| 154 parser = new ParserTask(this); | 156 parser = new ParserTask(this); |
| 155 validator = new TreeValidatorTask(this); | 157 validator = new TreeValidatorTask(this); |
| 158 unparseValidator = new UnparseValidator(this, validateUnparse); |
| 156 resolver = new ResolverTask(this); | 159 resolver = new ResolverTask(this); |
| 157 checker = new TypeCheckerTask(this); | 160 checker = new TypeCheckerTask(this); |
| 158 backend = emitJavascript ? | 161 backend = emitJavascript ? |
| 159 new JavaScriptBackend(this) : new DartBackend(this); | 162 new JavaScriptBackend(this) : new DartBackend(this); |
| 160 enqueuer = new EnqueueTask(this); | 163 enqueuer = new EnqueueTask(this); |
| 161 tasks = [scanner, dietParser, parser, resolver, checker, | 164 tasks = [scanner, dietParser, parser, resolver, checker, |
| 162 constantHandler, enqueuer]; | 165 unparseValidator, constantHandler, enqueuer]; |
| 163 } | 166 } |
| 164 | 167 |
| 165 Universe get codegenWorld() => enqueuer.codegen.universe; | 168 Universe get codegenWorld() => enqueuer.codegen.universe; |
| 166 | 169 |
| 167 int getNextFreeClassId() => nextFreeClassId++; | 170 int getNextFreeClassId() => nextFreeClassId++; |
| 168 | 171 |
| 169 void ensure(bool condition) { | 172 void ensure(bool condition) { |
| 170 if (!condition) cancel('failed assertion in leg'); | 173 if (!condition) cancel('failed assertion in leg'); |
| 171 } | 174 } |
| 172 | 175 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (!enqueuer.codegen.queue.isEmpty()) { | 370 if (!enqueuer.codegen.queue.isEmpty()) { |
| 368 internalErrorOnElement(enqueuer.codegen.queue.first().element, | 371 internalErrorOnElement(enqueuer.codegen.queue.first().element, |
| 369 "work list is not empty"); | 372 "work list is not empty"); |
| 370 } | 373 } |
| 371 } | 374 } |
| 372 | 375 |
| 373 TreeElements analyzeElement(Element element) { | 376 TreeElements analyzeElement(Element element) { |
| 374 assert(parser !== null); | 377 assert(parser !== null); |
| 375 Node tree = parser.parse(element); | 378 Node tree = parser.parse(element); |
| 376 validator.validate(tree); | 379 validator.validate(tree); |
| 380 unparseValidator.check(element); |
| 377 TreeElements elements = resolver.resolve(element); | 381 TreeElements elements = resolver.resolve(element); |
| 378 checker.check(tree, elements); | 382 checker.check(tree, elements); |
| 379 return elements; | 383 return elements; |
| 380 } | 384 } |
| 381 | 385 |
| 382 TreeElements analyze(WorkItem work) { | 386 TreeElements analyze(WorkItem work) { |
| 383 work.resolutionTree = analyzeElement(work.element); | 387 work.resolutionTree = analyzeElement(work.element); |
| 384 return work.resolutionTree; | 388 return work.resolutionTree; |
| 385 } | 389 } |
| 386 | 390 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 590 } |
| 587 } | 591 } |
| 588 | 592 |
| 589 class SourceSpan { | 593 class SourceSpan { |
| 590 final Uri uri; | 594 final Uri uri; |
| 591 final int begin; | 595 final int begin; |
| 592 final int end; | 596 final int end; |
| 593 | 597 |
| 594 const SourceSpan(this.uri, this.begin, this.end); | 598 const SourceSpan(this.uri, this.begin, this.end); |
| 595 } | 599 } |
| OLD | NEW |