| 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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 */ | 123 */ |
| 124 bool stopAfterTypeInference = false; | 124 bool stopAfterTypeInference = false; |
| 125 | 125 |
| 126 /// Output provider from user of Compiler API. | 126 /// Output provider from user of Compiler API. |
| 127 api.CompilerOutput userOutputProvider; | 127 api.CompilerOutput userOutputProvider; |
| 128 | 128 |
| 129 List<Uri> librariesToAnalyzeWhenRun; | 129 List<Uri> librariesToAnalyzeWhenRun; |
| 130 | 130 |
| 131 ResolvedUriTranslator get resolvedUriTranslator; | 131 ResolvedUriTranslator get resolvedUriTranslator; |
| 132 | 132 |
| 133 Tracer tracer; | |
| 134 | |
| 135 LibraryElement mainApp; | 133 LibraryElement mainApp; |
| 136 FunctionElement mainFunction; | 134 FunctionElement mainFunction; |
| 137 | 135 |
| 138 DiagnosticReporter get reporter => _reporter; | 136 DiagnosticReporter get reporter => _reporter; |
| 139 CommonElements get commonElements => _coreTypes; | 137 CommonElements get commonElements => _coreTypes; |
| 140 CoreClasses get coreClasses => _coreTypes; | 138 CoreClasses get coreClasses => _coreTypes; |
| 141 CoreTypes get coreTypes => _coreTypes; | 139 CoreTypes get coreTypes => _coreTypes; |
| 142 Resolution get resolution => _resolution; | 140 Resolution get resolution => _resolution; |
| 143 ParsingContext get parsingContext => _parsingContext; | 141 ParsingContext get parsingContext => _parsingContext; |
| 144 | 142 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (makeReporter != null) { | 208 if (makeReporter != null) { |
| 211 _reporter = makeReporter(this, options); | 209 _reporter = makeReporter(this, options); |
| 212 } else { | 210 } else { |
| 213 _reporter = new CompilerDiagnosticReporter(this, options); | 211 _reporter = new CompilerDiagnosticReporter(this, options); |
| 214 } | 212 } |
| 215 _resolution = createResolution(); | 213 _resolution = createResolution(); |
| 216 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and | 214 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and |
| 217 // make its field final. | 215 // make its field final. |
| 218 _coreTypes = new _CompilerCoreTypes(_resolution, reporter); | 216 _coreTypes = new _CompilerCoreTypes(_resolution, reporter); |
| 219 types = new Types(_resolution); | 217 types = new Types(_resolution); |
| 220 tracer = new Tracer(this, this.outputProvider); | |
| 221 | 218 |
| 222 if (options.verbose) { | 219 if (options.verbose) { |
| 223 progress = new Stopwatch()..start(); | 220 progress = new Stopwatch()..start(); |
| 224 } | 221 } |
| 225 | 222 |
| 226 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing | 223 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing |
| 227 // for global dependencies. | 224 // for global dependencies. |
| 228 globalDependencies = new GlobalDependencyRegistry(); | 225 globalDependencies = new GlobalDependencyRegistry(); |
| 229 | 226 |
| 230 if (makeBackend != null) { | 227 if (makeBackend != null) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Compiles the dart script at [uri]. | 334 // Compiles the dart script at [uri]. |
| 338 // | 335 // |
| 339 // The resulting future will complete with true if the compilation | 336 // The resulting future will complete with true if the compilation |
| 340 // succeeded. | 337 // succeeded. |
| 341 Future<bool> run(Uri uri) => selfTask.measureSubtask("Compiler.run", () { | 338 Future<bool> run(Uri uri) => selfTask.measureSubtask("Compiler.run", () { |
| 342 measurer.startWallClock(); | 339 measurer.startWallClock(); |
| 343 | 340 |
| 344 return new Future.sync(() => runInternal(uri)) | 341 return new Future.sync(() => runInternal(uri)) |
| 345 .catchError((error) => _reporter.onError(uri, error)) | 342 .catchError((error) => _reporter.onError(uri, error)) |
| 346 .whenComplete(() { | 343 .whenComplete(() { |
| 347 tracer.close(); | |
| 348 measurer.stopWallClock(); | 344 measurer.stopWallClock(); |
| 349 }).then((_) { | 345 }).then((_) { |
| 350 return !compilationFailed; | 346 return !compilationFailed; |
| 351 }); | 347 }); |
| 352 }); | 348 }); |
| 353 | 349 |
| 354 /// This method is called immediately after the [LibraryElement] [library] has | 350 /// This method is called immediately after the [LibraryElement] [library] has |
| 355 /// been created. | 351 /// been created. |
| 356 /// | 352 /// |
| 357 /// Use this callback method to store references to specific libraries. | 353 /// Use this callback method to store references to specific libraries. |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 onProgress: showCodegenProgress); | 726 onProgress: showCodegenProgress); |
| 731 enqueuer.codegen.logSummary(reporter.log); | 727 enqueuer.codegen.logSummary(reporter.log); |
| 732 | 728 |
| 733 int programSize = backend.assembleProgram(closedWorld); | 729 int programSize = backend.assembleProgram(closedWorld); |
| 734 | 730 |
| 735 if (options.dumpInfo) { | 731 if (options.dumpInfo) { |
| 736 dumpInfoTask.reportSize(programSize); | 732 dumpInfoTask.reportSize(programSize); |
| 737 dumpInfoTask.dumpInfo(closedWorld); | 733 dumpInfoTask.dumpInfo(closedWorld); |
| 738 } | 734 } |
| 739 | 735 |
| 740 backend.sourceInformationStrategy.onComplete(); | 736 backend.onCodegenEnd(); |
| 741 | 737 |
| 742 checkQueues(); | 738 checkQueues(); |
| 743 }); | 739 }); |
| 744 | 740 |
| 745 /// Perform the steps needed to fully end the resolution phase. | 741 /// Perform the steps needed to fully end the resolution phase. |
| 746 ClosedWorldRefiner closeResolution() { | 742 ClosedWorldRefiner closeResolution() { |
| 747 phase = PHASE_DONE_RESOLVING; | 743 phase = PHASE_DONE_RESOLVING; |
| 748 | 744 |
| 749 WorldImpl world = resolverWorld.openWorld.closeWorld(reporter); | 745 WorldImpl world = resolverWorld.openWorld.closeWorld(reporter); |
| 750 // Compute whole-program-knowledge that the backend needs. (This might | 746 // Compute whole-program-knowledge that the backend needs. (This might |
| (...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 _ElementScanner(this.scanner); | 2225 _ElementScanner(this.scanner); |
| 2230 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2226 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2231 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2227 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2232 } | 2228 } |
| 2233 | 2229 |
| 2234 class _EmptyEnvironment implements Environment { | 2230 class _EmptyEnvironment implements Environment { |
| 2235 const _EmptyEnvironment(); | 2231 const _EmptyEnvironment(); |
| 2236 | 2232 |
| 2237 String valueOf(String key) => null; | 2233 String valueOf(String key) => null; |
| 2238 } | 2234 } |
| OLD | NEW |