| 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 | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void run(Compiler compiler, Enqueuer world) { | 46 void run(Compiler compiler, Enqueuer world) { |
| 47 CodeBuffer codeBuffer = world.universe.generatedCode[element]; | 47 CodeBuffer codeBuffer = world.universe.generatedCode[element]; |
| 48 if (codeBuffer !== null) return; | 48 if (codeBuffer !== null) return; |
| 49 resolutionTree = compiler.analyze(this, world); | 49 resolutionTree = compiler.analyze(this, world); |
| 50 compiler.codegen(this, world); | 50 compiler.codegen(this, world); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 class Backend { | 54 class Backend { |
| 55 final Compiler compiler; | 55 final Compiler compiler; |
| 56 final ConstantSystem constantSystem; |
| 56 | 57 |
| 57 Backend(this.compiler); | 58 Backend(this.compiler, |
| 59 [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) |
| 60 : this.constantSystem = constantSystem; |
| 58 | 61 |
| 59 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { | 62 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { |
| 60 lib.forEachExport((Element e) { | 63 lib.forEachExport((Element e) { |
| 61 if (e.isFunction()) world.addToWorkList(e); | 64 if (e.isFunction()) world.addToWorkList(e); |
| 62 }); | 65 }); |
| 63 } | 66 } |
| 64 | 67 |
| 65 abstract void enqueueHelpers(Enqueuer world); | 68 abstract void enqueueHelpers(Enqueuer world); |
| 66 abstract void codegen(WorkItem work); | 69 abstract void codegen(WorkItem work); |
| 67 abstract void processNativeClasses(Enqueuer world, | 70 abstract void processNativeClasses(Enqueuer world, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 int phase; | 178 int phase; |
| 176 | 179 |
| 177 bool compilationFailed = false; | 180 bool compilationFailed = false; |
| 178 | 181 |
| 179 bool hasCrashed = false; | 182 bool hasCrashed = false; |
| 180 | 183 |
| 181 Compiler([this.tracer = const Tracer(), | 184 Compiler([this.tracer = const Tracer(), |
| 182 this.enableTypeAssertions = false, | 185 this.enableTypeAssertions = false, |
| 183 this.enableUserAssertions = false, | 186 this.enableUserAssertions = false, |
| 184 this.enableMinification = false, | 187 this.enableMinification = false, |
| 185 bool emitJavascript = true, | 188 bool emitJavaScript = true, |
| 186 bool generateSourceMap = true, | 189 bool generateSourceMap = true, |
| 187 bool cutDeclarationTypes = false]) | 190 bool cutDeclarationTypes = false]) |
| 188 : libraries = new Map<String, LibraryElement>(), | 191 : libraries = new Map<String, LibraryElement>(), |
| 189 world = new World(), | 192 world = new World(), |
| 190 progress = new Stopwatch() { | 193 progress = new Stopwatch() { |
| 191 progress.start(); | 194 progress.start(); |
| 192 namer = new Namer(this); | 195 namer = new Namer(this); |
| 193 constantHandler = new ConstantHandler(this); | |
| 194 scanner = new ScannerTask(this); | 196 scanner = new ScannerTask(this); |
| 195 dietParser = new DietParserTask(this); | 197 dietParser = new DietParserTask(this); |
| 196 parser = new ParserTask(this); | 198 parser = new ParserTask(this); |
| 197 patchParser = new PatchParserTask(this); | 199 patchParser = new PatchParserTask(this); |
| 198 validator = new TreeValidatorTask(this); | 200 validator = new TreeValidatorTask(this); |
| 199 resolver = new ResolverTask(this); | 201 resolver = new ResolverTask(this); |
| 200 closureToClassMapper = new closureMapping.ClosureTask(this); | 202 closureToClassMapper = new closureMapping.ClosureTask(this); |
| 201 checker = new TypeCheckerTask(this); | 203 checker = new TypeCheckerTask(this); |
| 202 typesTask = new ti.TypesTask(this); | 204 typesTask = new ti.TypesTask(this); |
| 203 backend = emitJavascript ? | 205 backend = emitJavaScript ? |
| 204 new js_backend.JavaScriptBackend(this, generateSourceMap) : | 206 new js_backend.JavaScriptBackend(this, generateSourceMap) : |
| 205 new dart_backend.DartBackend(this, cutDeclarationTypes); | 207 new dart_backend.DartBackend(this, cutDeclarationTypes); |
| 208 constantHandler = new ConstantHandler(this, backend.constantSystem); |
| 206 enqueuer = new EnqueueTask(this); | 209 enqueuer = new EnqueueTask(this); |
| 207 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, | 210 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, |
| 208 checker, typesTask, constantHandler, enqueuer]; | 211 checker, typesTask, constantHandler, enqueuer]; |
| 209 tasks.addAll(backend.tasks); | 212 tasks.addAll(backend.tasks); |
| 210 } | 213 } |
| 211 | 214 |
| 212 Universe get resolverWorld => enqueuer.resolution.universe; | 215 Universe get resolverWorld => enqueuer.resolution.universe; |
| 213 Universe get codegenWorld => enqueuer.codegen.universe; | 216 Universe get codegenWorld => enqueuer.codegen.universe; |
| 214 | 217 |
| 215 int getNextFreeClassId() => nextFreeClassId++; | 218 int getNextFreeClassId() => nextFreeClassId++; |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 final endOffset = end.charOffset + end.slowCharCount; | 931 final endOffset = end.charOffset + end.slowCharCount; |
| 929 | 932 |
| 930 // [begin] and [end] might be the same for the same empty token. This | 933 // [begin] and [end] might be the same for the same empty token. This |
| 931 // happens for instance when scanning '$$'. | 934 // happens for instance when scanning '$$'. |
| 932 assert(endOffset >= beginOffset); | 935 assert(endOffset >= beginOffset); |
| 933 return f(beginOffset, endOffset); | 936 return f(beginOffset, endOffset); |
| 934 } | 937 } |
| 935 | 938 |
| 936 String toString() => 'SourceSpan($uri, $begin, $end)'; | 939 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 937 } | 940 } |
| OLD | NEW |