| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 class Compiler implements DiagnosticListener { | 66 class Compiler implements DiagnosticListener { |
| 67 final Map<String, LibraryElement> libraries; | 67 final Map<String, LibraryElement> libraries; |
| 68 int nextFreeClassId = 0; | 68 int nextFreeClassId = 0; |
| 69 World world; | 69 World world; |
| 70 String assembledCode; | 70 String assembledCode; |
| 71 Namer namer; | 71 Namer namer; |
| 72 Types types; | 72 Types types; |
| 73 |
| 74 final bool enableMinification; |
| 73 final bool enableTypeAssertions; | 75 final bool enableTypeAssertions; |
| 74 final bool enableUserAssertions; | 76 final bool enableUserAssertions; |
| 75 | 77 |
| 76 final Tracer tracer; | 78 final Tracer tracer; |
| 77 | 79 |
| 78 CompilerTask measuredTask; | 80 CompilerTask measuredTask; |
| 79 Element _currentElement; | 81 Element _currentElement; |
| 80 LibraryElement coreLibrary; | 82 LibraryElement coreLibrary; |
| 81 LibraryElement coreImplLibrary; | 83 LibraryElement coreImplLibrary; |
| 82 LibraryElement isolateLibrary; | 84 LibraryElement isolateLibrary; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 static const int PHASE_RECOMPILING = 3; | 161 static const int PHASE_RECOMPILING = 3; |
| 160 int phase; | 162 int phase; |
| 161 | 163 |
| 162 bool compilationFailed = false; | 164 bool compilationFailed = false; |
| 163 | 165 |
| 164 bool hasCrashed = false; | 166 bool hasCrashed = false; |
| 165 | 167 |
| 166 Compiler([this.tracer = const Tracer(), | 168 Compiler([this.tracer = const Tracer(), |
| 167 this.enableTypeAssertions = false, | 169 this.enableTypeAssertions = false, |
| 168 this.enableUserAssertions = false, | 170 this.enableUserAssertions = false, |
| 171 this.enableMinification = false, |
| 169 bool emitJavascript = true, | 172 bool emitJavascript = true, |
| 170 bool generateSourceMap = true, | 173 bool generateSourceMap = true, |
| 171 bool minify = false, | |
| 172 bool cutDeclarationTypes = false]) | 174 bool cutDeclarationTypes = false]) |
| 173 : libraries = new Map<String, LibraryElement>(), | 175 : libraries = new Map<String, LibraryElement>(), |
| 174 world = new World(), | 176 world = new World(), |
| 175 progress = new Stopwatch.start() { | 177 progress = new Stopwatch.start() { |
| 176 namer = new Namer(this); | 178 namer = new Namer(this); |
| 177 constantHandler = new ConstantHandler(this); | 179 constantHandler = new ConstantHandler(this); |
| 178 scanner = new ScannerTask(this); | 180 scanner = new ScannerTask(this); |
| 179 dietParser = new DietParserTask(this); | 181 dietParser = new DietParserTask(this); |
| 180 parser = new ParserTask(this); | 182 parser = new ParserTask(this); |
| 181 patchParser = new PatchParserTask(this); | 183 patchParser = new PatchParserTask(this); |
| 182 validator = new TreeValidatorTask(this); | 184 validator = new TreeValidatorTask(this); |
| 183 resolver = new ResolverTask(this); | 185 resolver = new ResolverTask(this); |
| 184 closureToClassMapper = new closureMapping.ClosureTask(this); | 186 closureToClassMapper = new closureMapping.ClosureTask(this); |
| 185 checker = new TypeCheckerTask(this); | 187 checker = new TypeCheckerTask(this); |
| 186 typesTask = new ti.TypesTask(this); | 188 typesTask = new ti.TypesTask(this); |
| 187 backend = emitJavascript ? | 189 backend = emitJavascript ? |
| 188 new js_backend.JavaScriptBackend(this, generateSourceMap) : | 190 new js_backend.JavaScriptBackend(this, generateSourceMap) : |
| 189 new dart_backend.DartBackend(this, minify, cutDeclarationTypes); | 191 new dart_backend.DartBackend(this, cutDeclarationTypes); |
| 190 enqueuer = new EnqueueTask(this); | 192 enqueuer = new EnqueueTask(this); |
| 191 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, | 193 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, |
| 192 checker, typesTask, constantHandler, enqueuer]; | 194 checker, typesTask, constantHandler, enqueuer]; |
| 193 tasks.addAll(backend.tasks); | 195 tasks.addAll(backend.tasks); |
| 194 } | 196 } |
| 195 | 197 |
| 196 Universe get resolverWorld => enqueuer.resolution.universe; | 198 Universe get resolverWorld => enqueuer.resolution.universe; |
| 197 Universe get codegenWorld => enqueuer.codegen.universe; | 199 Universe get codegenWorld => enqueuer.codegen.universe; |
| 198 | 200 |
| 199 int getNextFreeClassId() => nextFreeClassId++; | 201 int getNextFreeClassId() => nextFreeClassId++; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 final endOffset = end.charOffset + end.slowCharCount; | 896 final endOffset = end.charOffset + end.slowCharCount; |
| 895 | 897 |
| 896 // [begin] and [end] might be the same for the same empty token. This | 898 // [begin] and [end] might be the same for the same empty token. This |
| 897 // happens for instance when scanning '$$'. | 899 // happens for instance when scanning '$$'. |
| 898 assert(endOffset >= beginOffset); | 900 assert(endOffset >= beginOffset); |
| 899 return f(beginOffset, endOffset); | 901 return f(beginOffset, endOffset); |
| 900 } | 902 } |
| 901 | 903 |
| 902 String toString() => 'SourceSpan($uri, $begin, $end)'; | 904 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 903 } | 905 } |
| OLD | NEW |