Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: dart/pkg/dart2js_incremental/lib/library_updater.dart

Issue 627673002: Add LibraryUpdater.hasPendingUpdates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Return a list to avoid applying the updates many times. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/tests/try/poi/library_updater_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/dart2js_incremental/lib/library_updater.dart
diff --git a/dart/pkg/dart2js_incremental/lib/library_updater.dart b/dart/pkg/dart2js_incremental/lib/library_updater.dart
index 69172b4448254c7e215b116ed217d56bed42f5c1..246f7797e3cefcbe6e153f999adc814950af0068 100644
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart
@@ -17,6 +17,7 @@ import 'package:compiler/implementation/dart2jslib.dart' show
Script;
import 'package:compiler/implementation/elements/elements.dart' show
+ Element,
LibraryElement;
import 'package:compiler/implementation/scanner/scannerlib.dart' show
@@ -52,6 +53,10 @@ class LibraryUpdater {
// changed.
final Uri uri;
+ // When [true], updates must be applied (using [applyUpdates]) before the
+ // [compiler]'s state correctly reflects the updated program.
+ bool hasPendingUpdates = false;
+
final List<Update> updates = <Update>[];
LibraryUpdater(
@@ -71,13 +76,7 @@ class LibraryUpdater {
return new Future.value(false);
}
return inputProvider(uri).then((List<int> bytes) {
- if (canReuseLibrary(library, bytes)) {
- // TODO(ahe): Temporary. Since we don't yet apply the updates, the
- // library cannot be reused if there are updates.
- return updates.isEmpty;
- } else {
- return false;
- }
+ return canReuseLibrary(library, bytes);
});
}
@@ -137,6 +136,7 @@ class LibraryUpdater {
return false;
}
}
+ hasPendingUpdates = true;
return true;
}
@@ -171,6 +171,10 @@ class LibraryUpdater {
updates.add(new FunctionUpdate(compiler, before, after));
return true;
}
+
+ List<Element> applyUpdates() {
+ return updates.map((Update update) => update.apply()).toList();
+ }
}
/// Represents an update (aka patch) of [before] to [after]. We use the word
« no previous file with comments | « no previous file | dart/tests/try/poi/library_updater_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698