| 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 |
| 11 import 'dart:io' as io; | 11 import 'dart:io' as io; |
| 12 | 12 |
| 13 import 'dart:convert' show | 13 import 'dart:convert' show |
| 14 UTF8; | 14 UTF8; |
| 15 | 15 |
| 16 import 'package:dart2js_incremental/dart2js_incremental.dart' show | 16 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
| 17 reuseCompiler; | 17 reuseCompiler; |
| 18 | 18 |
| 19 import 'package:dart2js_incremental/library_updater.dart' show | 19 import 'package:dart2js_incremental/library_updater.dart' show |
| 20 LibraryUpdater; | 20 LibraryUpdater; |
| 21 | 21 |
| 22 import 'package:compiler/implementation/source_file_provider.dart' show | 22 import 'package:compiler/implementation/source_file_provider.dart' show |
| 23 FormattingDiagnosticHandler; | 23 FormattingDiagnosticHandler; |
| 24 | 24 |
| 25 import 'package:compiler/compiler.dart' as api; | 25 import 'package:compiler/compiler.dart' as api; |
| 26 | 26 |
| 27 import 'package:compiler/implementation/dart2jslib.dart' show | 27 import 'package:compiler/implementation/dart2jslib.dart' show |
| 28 Compiler, | 28 Compiler, |
| 29 CompilerTask, |
| 29 Enqueuer, | 30 Enqueuer, |
| 30 QueueFilter, | 31 QueueFilter, |
| 31 WorkItem; | 32 WorkItem; |
| 32 | 33 |
| 33 import 'package:compiler/implementation/elements/visitor.dart' show | 34 import 'package:compiler/implementation/elements/visitor.dart' show |
| 34 ElementVisitor; | 35 ElementVisitor; |
| 35 | 36 |
| 36 import 'package:compiler/implementation/elements/elements.dart' show | 37 import 'package:compiler/implementation/elements/elements.dart' show |
| 37 AbstractFieldElement, | 38 AbstractFieldElement, |
| 38 ClassElement, | 39 ClassElement, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 /// really need. | 89 /// really need. |
| 89 bool isVerbose = false; | 90 bool isVerbose = false; |
| 90 | 91 |
| 91 /// When true (the default value) print serialized scope information at the | 92 /// When true (the default value) print serialized scope information at the |
| 92 /// provided position. | 93 /// provided position. |
| 93 const bool PRINT_SCOPE_INFO = | 94 const bool PRINT_SCOPE_INFO = |
| 94 const bool.fromEnvironment('PRINT_SCOPE_INFO', defaultValue: true); | 95 const bool.fromEnvironment('PRINT_SCOPE_INFO', defaultValue: true); |
| 95 | 96 |
| 96 Stopwatch wallClock = new Stopwatch(); | 97 Stopwatch wallClock = new Stopwatch(); |
| 97 | 98 |
| 99 PoiTask poiTask; |
| 100 |
| 98 Compiler cachedCompiler; | 101 Compiler cachedCompiler; |
| 99 | 102 |
| 100 /// Iterator for reading lines from [io.stdin]. | 103 /// Iterator for reading lines from [io.stdin]. |
| 101 class StdinIterator implements Iterator<String> { | 104 class StdinIterator implements Iterator<String> { |
| 102 String current; | 105 String current; |
| 103 | 106 |
| 104 bool moveNext() { | 107 bool moveNext() { |
| 105 current = io.stdin.readLineSync(); | 108 current = io.stdin.readLineSync(); |
| 106 return true; | 109 return true; |
| 107 } | 110 } |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 '--no-source-maps', | 366 '--no-source-maps', |
| 364 '--verbose', | 367 '--verbose', |
| 365 '--categories=Client,Server', | 368 '--categories=Client,Server', |
| 366 '--incremental-support', | 369 '--incremental-support', |
| 367 '--disable-type-inference', | 370 '--disable-type-inference', |
| 368 ]; | 371 ]; |
| 369 | 372 |
| 370 LibraryUpdater updater = | 373 LibraryUpdater updater = |
| 371 new LibraryUpdater( | 374 new LibraryUpdater( |
| 372 cachedCompiler, inputProvider, script, printWallClock, printVerbose); | 375 cachedCompiler, inputProvider, script, printWallClock, printVerbose); |
| 376 Future<bool> reuseLibrary(LibraryElement library) { |
| 377 return poiTask.measure(() => updater.reuseLibrary(library)); |
| 378 } |
| 373 | 379 |
| 374 return reuseCompiler( | 380 return reuseCompiler( |
| 375 diagnosticHandler: handler, | 381 diagnosticHandler: handler, |
| 376 inputProvider: inputProvider, | 382 inputProvider: inputProvider, |
| 377 options: options, | 383 options: options, |
| 378 cachedCompiler: cachedCompiler, | 384 cachedCompiler: cachedCompiler, |
| 379 libraryRoot: libraryRoot, | 385 libraryRoot: libraryRoot, |
| 380 packageRoot: packageRoot, | 386 packageRoot: packageRoot, |
| 381 packagesAreImmutable: true, | 387 packagesAreImmutable: true, |
| 382 reuseLibrary: updater.reuseLibrary).then((Compiler newCompiler) { | 388 reuseLibrary: reuseLibrary).then((Compiler newCompiler) { |
| 383 var filter = new ScriptOnlyFilter(script); | 389 var filter = new ScriptOnlyFilter(script); |
| 384 newCompiler.enqueuerFilter = filter; | 390 newCompiler.enqueuerFilter = filter; |
| 385 return runPoiInternal(newCompiler, updater, position); | 391 return runPoiInternal(newCompiler, updater, position); |
| 386 }); | 392 }); |
| 387 } | 393 } |
| 388 | 394 |
| 389 Future<Element> runPoiInternal( | 395 Future<Element> runPoiInternal( |
| 390 Compiler newCompiler, | 396 Compiler newCompiler, |
| 391 LibraryUpdater updater, | 397 LibraryUpdater updater, |
| 392 int position) { | 398 int position) { |
| 399 |
| 393 cachedCompiler = newCompiler; | 400 cachedCompiler = newCompiler; |
| 401 if (poiTask == null || poiTask.compiler != cachedCompiler) { |
| 402 poiTask = new PoiTask(cachedCompiler); |
| 403 cachedCompiler.tasks.add(poiTask); |
| 404 } |
| 394 | 405 |
| 395 Future<bool> compilation = cachedCompiler.run(updater.uri); | 406 Future<bool> compilation = cachedCompiler.run(updater.uri); |
| 396 | 407 |
| 397 return compilation.then((success) { | 408 return compilation.then((success) { |
| 398 if (isVerbose) { | 409 if (isVerbose) { |
| 399 for (final task in cachedCompiler.tasks) { | 410 for (final task in cachedCompiler.tasks) { |
| 400 int time = task.timingMicroseconds; | 411 int time = task.timingMicroseconds; |
| 401 if (time != 0) { | 412 if (time != 0) { |
| 402 printFormattedTime('${task.name} took', time); | 413 printFormattedTime('${task.name} took', time); |
| 403 } | 414 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 buffer.write('\n'); | 729 buffer.write('\n'); |
| 719 indented.write('}'); | 730 indented.write('}'); |
| 720 } | 731 } |
| 721 } | 732 } |
| 722 | 733 |
| 723 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; | 734 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; |
| 724 | 735 |
| 725 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 736 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
| 726 return element.importScope; | 737 return element.importScope; |
| 727 } | 738 } |
| 739 |
| 740 class PoiTask extends CompilerTask { |
| 741 PoiTask(Compiler compiler) : super(compiler); |
| 742 |
| 743 String get name => 'POI'; |
| 744 } |
| OLD | NEW |