| OLD | NEW | 
|---|
| 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 trydart.poi; | 5 library trydart.poi; | 
| 6 | 6 | 
| 7 import 'dart:async' show | 7 import 'dart:async' show | 
| 8     Completer, | 8     Completer, | 
| 9     Future; | 9     Future; | 
| 10 | 10 | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 82 | 82 | 
| 83 /// Counts the number of times [runPoi] has been invoked. | 83 /// Counts the number of times [runPoi] has been invoked. | 
| 84 int poiCount; | 84 int poiCount; | 
| 85 | 85 | 
| 86 int globalCounter = 0; | 86 int globalCounter = 0; | 
| 87 | 87 | 
| 88 /// Enabled by the option --verbose (or -v). Prints more information than you | 88 /// Enabled by the option --verbose (or -v). Prints more information than you | 
| 89 /// really need. | 89 /// really need. | 
| 90 bool isVerbose = false; | 90 bool isVerbose = false; | 
| 91 | 91 | 
|  | 92 /// Enabled by the option --compile. Also compiles the program after analyzing | 
|  | 93 /// the POI. | 
|  | 94 bool isCompiler = false; | 
|  | 95 | 
| 92 /// When true (the default value) print serialized scope information at the | 96 /// When true (the default value) print serialized scope information at the | 
| 93 /// provided position. | 97 /// provided position. | 
| 94 const bool PRINT_SCOPE_INFO = | 98 const bool PRINT_SCOPE_INFO = | 
| 95     const bool.fromEnvironment('PRINT_SCOPE_INFO', defaultValue: true); | 99     const bool.fromEnvironment('PRINT_SCOPE_INFO', defaultValue: true); | 
| 96 | 100 | 
| 97 Stopwatch wallClock = new Stopwatch(); | 101 Stopwatch wallClock = new Stopwatch(); | 
| 98 | 102 | 
| 99 PoiTask poiTask; | 103 PoiTask poiTask; | 
| 100 | 104 | 
| 101 Compiler cachedCompiler; | 105 Compiler cachedCompiler; | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 143         case '--simulate-mutation': | 147         case '--simulate-mutation': | 
| 144           isSimulateMutationEnabled = true; | 148           isSimulateMutationEnabled = true; | 
| 145           break; | 149           break; | 
| 146         case '--enable-dart-mind': | 150         case '--enable-dart-mind': | 
| 147           isDartMindEnabled = true; | 151           isDartMindEnabled = true; | 
| 148           break; | 152           break; | 
| 149         case '-v': | 153         case '-v': | 
| 150         case '--verbose': | 154         case '--verbose': | 
| 151           isVerbose = true; | 155           isVerbose = true; | 
| 152           break; | 156           break; | 
|  | 157         case '--compile': | 
|  | 158           isCompiler = true; | 
|  | 159           break; | 
| 153         default: | 160         default: | 
| 154           throw 'Unknown option: $argument.'; | 161           throw 'Unknown option: $argument.'; | 
| 155       } | 162       } | 
| 156     } else { | 163     } else { | 
| 157       nonOptionArguments.add(argument); | 164       nonOptionArguments.add(argument); | 
| 158     } | 165     } | 
| 159   } | 166   } | 
| 160   if (nonOptionArguments.isEmpty) { | 167   if (nonOptionArguments.isEmpty) { | 
| 161     stdin = new StdinIterator(); | 168     stdin = new StdinIterator(); | 
| 162   } else { | 169   } else { | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 358     int position, | 365     int position, | 
| 359     api.CompilerInputProvider inputProvider, | 366     api.CompilerInputProvider inputProvider, | 
| 360     api.DiagnosticHandler handler) { | 367     api.DiagnosticHandler handler) { | 
| 361   Stopwatch sw = new Stopwatch()..start(); | 368   Stopwatch sw = new Stopwatch()..start(); | 
| 362   Uri libraryRoot = Uri.base.resolve('sdk/'); | 369   Uri libraryRoot = Uri.base.resolve('sdk/'); | 
| 363   Uri packageRoot = Uri.base.resolveUri( | 370   Uri packageRoot = Uri.base.resolveUri( | 
| 364       new Uri.file('${io.Platform.packageRoot}/')); | 371       new Uri.file('${io.Platform.packageRoot}/')); | 
| 365 | 372 | 
| 366   var options = [ | 373   var options = [ | 
| 367       '--analyze-main', | 374       '--analyze-main', | 
| 368       '--analyze-only', |  | 
| 369       '--no-source-maps', | 375       '--no-source-maps', | 
| 370       '--verbose', | 376       '--verbose', | 
| 371       '--categories=Client,Server', | 377       '--categories=Client,Server', | 
| 372       '--incremental-support', | 378       '--incremental-support', | 
| 373       '--disable-type-inference', | 379       '--disable-type-inference', | 
| 374   ]; | 380   ]; | 
| 375 | 381 | 
|  | 382   if (!isCompiler) { | 
|  | 383     options.add('--analyze-only'); | 
|  | 384   } | 
|  | 385 | 
| 376   LibraryUpdater updater = | 386   LibraryUpdater updater = | 
| 377       new LibraryUpdater( | 387       new LibraryUpdater( | 
| 378           cachedCompiler, inputProvider, script, printWallClock, printVerbose); | 388           cachedCompiler, inputProvider, script, printWallClock, printVerbose); | 
| 379   Future<bool> reuseLibrary(LibraryElement library) { | 389   Future<bool> reuseLibrary(LibraryElement library) { | 
| 380     return poiTask.measure(() => updater.reuseLibrary(library)); | 390     return poiTask.measure(() => updater.reuseLibrary(library)); | 
| 381   } | 391   } | 
| 382 | 392 | 
| 383   return reuseCompiler( | 393   return reuseCompiler( | 
| 384       diagnosticHandler: handler, | 394       diagnosticHandler: handler, | 
| 385       inputProvider: inputProvider, | 395       inputProvider: inputProvider, | 
| 386       options: options, | 396       options: options, | 
| 387       cachedCompiler: cachedCompiler, | 397       cachedCompiler: cachedCompiler, | 
| 388       libraryRoot: libraryRoot, | 398       libraryRoot: libraryRoot, | 
| 389       packageRoot: packageRoot, | 399       packageRoot: packageRoot, | 
| 390       packagesAreImmutable: true, | 400       packagesAreImmutable: true, | 
| 391       reuseLibrary: reuseLibrary).then((Compiler newCompiler) { | 401       reuseLibrary: reuseLibrary).then((Compiler newCompiler) { | 
| 392     var filter = new ScriptOnlyFilter(script); | 402     if (!isCompiler) { | 
| 393     newCompiler.enqueuerFilter = filter; | 403       newCompiler.enqueuerFilter = new ScriptOnlyFilter(script); | 
|  | 404     } | 
| 394     return runPoiInternal(newCompiler, sw, updater, position); | 405     return runPoiInternal(newCompiler, sw, updater, position); | 
| 395   }); | 406   }); | 
| 396 } | 407 } | 
| 397 | 408 | 
| 398 Future<Element> runPoiInternal( | 409 Future<Element> runPoiInternal( | 
| 399     Compiler newCompiler, | 410     Compiler newCompiler, | 
| 400     Stopwatch sw, | 411     Stopwatch sw, | 
| 401     LibraryUpdater updater, | 412     LibraryUpdater updater, | 
| 402     int position) { | 413     int position) { | 
| 403   bool isFullCompile = cachedCompiler != newCompiler; | 414   bool isFullCompile = cachedCompiler != newCompiler; | 
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 746 | 757 | 
| 747 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 758 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 
| 748   return element.importScope; | 759   return element.importScope; | 
| 749 } | 760 } | 
| 750 | 761 | 
| 751 class PoiTask extends CompilerTask { | 762 class PoiTask extends CompilerTask { | 
| 752   PoiTask(Compiler compiler) : super(compiler); | 763   PoiTask(Compiler compiler) : super(compiler); | 
| 753 | 764 | 
| 754   String get name => 'POI'; | 765   String get name => 'POI'; | 
| 755 } | 766 } | 
| OLD | NEW | 
|---|