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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 DartType; | 53 DartType; |
54 | 54 |
55 import 'package:compiler/implementation/scanner/scannerlib.dart' show | 55 import 'package:compiler/implementation/scanner/scannerlib.dart' show |
56 EOF_TOKEN, | 56 EOF_TOKEN, |
57 IDENTIFIER_TOKEN, | 57 IDENTIFIER_TOKEN, |
58 KEYWORD_TOKEN, | 58 KEYWORD_TOKEN, |
59 PartialClassElement, | 59 PartialClassElement, |
60 PartialElement, | 60 PartialElement, |
61 Token; | 61 Token; |
62 | 62 |
| 63 import 'package:compiler/implementation/js/js.dart' show |
| 64 prettyPrint; |
| 65 |
63 /// Enabled by the option --enable-dart-mind. Controls if this program should | 66 /// Enabled by the option --enable-dart-mind. Controls if this program should |
64 /// be querying Dart Mind. | 67 /// be querying Dart Mind. |
65 bool isDartMindEnabled = false; | 68 bool isDartMindEnabled = false; |
66 | 69 |
67 /// Iterator over lines from standard input (or the argument array). | 70 /// Iterator over lines from standard input (or the argument array). |
68 Iterator<String> stdin; | 71 Iterator<String> stdin; |
69 | 72 |
70 /// Enabled by the option --simulate-mutation. When true, this program will | 73 /// Enabled by the option --simulate-mutation. When true, this program will |
71 /// only prompt for one file name, and subsequent runs will read | 74 /// only prompt for one file name, and subsequent runs will read |
72 /// FILENAME.N.dart, where N starts at 1, and is increased on each iteration. | 75 /// FILENAME.N.dart, where N starts at 1, and is increased on each iteration. |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 poiTask = new PoiTask(cachedCompiler); | 420 poiTask = new PoiTask(cachedCompiler); |
418 cachedCompiler.tasks.add(poiTask); | 421 cachedCompiler.tasks.add(poiTask); |
419 } | 422 } |
420 | 423 |
421 if (!isFullCompile) { | 424 if (!isFullCompile) { |
422 printFormattedTime( | 425 printFormattedTime( |
423 'Analyzing changes and updating elements took', sw.elapsedMicroseconds); | 426 'Analyzing changes and updating elements took', sw.elapsedMicroseconds); |
424 } | 427 } |
425 sw.reset(); | 428 sw.reset(); |
426 | 429 |
427 Future<bool> compilation = cachedCompiler.run(updater.uri); | 430 Future<bool> compilation; |
| 431 |
| 432 if (updater.hasPendingUpdates) { |
| 433 List<Element> updatedElements = updater.applyUpdates(); |
| 434 compilation = new Future(() { |
| 435 cachedCompiler.progress.reset(); |
| 436 for (Element element in updatedElements) { |
| 437 cachedCompiler.enqueuer.resolution.addToWorkList(element); |
| 438 } |
| 439 cachedCompiler.processQueue(cachedCompiler.enqueuer.resolution, null); |
| 440 |
| 441 cachedCompiler.phase = Compiler.PHASE_DONE_RESOLVING; |
| 442 |
| 443 for (Element element in updatedElements) { |
| 444 cachedCompiler.enqueuer.codegen.addToWorkList(element); |
| 445 } |
| 446 cachedCompiler.processQueue(cachedCompiler.enqueuer.codegen, null); |
| 447 |
| 448 for (Element element in updatedElements) { |
| 449 var node = cachedCompiler.enqueuer.codegen.generatedCode[element]; |
| 450 print(prettyPrint(node, cachedCompiler).getText()); |
| 451 } |
| 452 |
| 453 return !cachedCompiler.compilationFailed; |
| 454 }); |
| 455 } else { |
| 456 compilation = cachedCompiler.run(updater.uri); |
| 457 } |
428 | 458 |
429 return compilation.then((success) { | 459 return compilation.then((success) { |
430 printVerbose('Compiler queue processed in ${sw.elapsedMicroseconds}us'); | 460 printVerbose('Compiler queue processed in ${sw.elapsedMicroseconds}us'); |
431 if (isVerbose) { | 461 if (isVerbose) { |
432 for (final task in cachedCompiler.tasks) { | 462 for (final task in cachedCompiler.tasks) { |
433 int time = task.timingMicroseconds; | 463 int time = task.timingMicroseconds; |
434 if (time != 0) { | 464 if (time != 0) { |
435 printFormattedTime('${task.name} took', time); | 465 printFormattedTime('${task.name} took', time); |
436 } | 466 } |
437 } | 467 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 787 |
758 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 788 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
759 return element.importScope; | 789 return element.importScope; |
760 } | 790 } |
761 | 791 |
762 class PoiTask extends CompilerTask { | 792 class PoiTask extends CompilerTask { |
763 PoiTask(Compiler compiler) : super(compiler); | 793 PoiTask(Compiler compiler) : super(compiler); |
764 | 794 |
765 String get name => 'POI'; | 795 String get name => 'POI'; |
766 } | 796 } |
OLD | NEW |