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

Unified Diff: pkg/kernel/lib/binary/ast_from_binary.dart

Issue 2659343002: Add IR nodes needed for deferred loading. (Closed)
Patch Set: Update binary.md Created 3 years, 11 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 | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/binary/ast_from_binary.dart
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 8c940f69fe5586c80a9aab09cc9354c5f8db56a9..c4fc3ef034bf2466d5bdcea7cb9691e34a5e8c91 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -187,8 +187,7 @@ class BinaryBuilder {
readLibrary();
}
var mainMethod = readMemberReference(allowNull: true);
- return new Program(importTable, uriToSource)
- ..mainMethod = mainMethod;
+ return new Program(importTable, uriToSource)..mainMethod = mainMethod;
}
Map<String, Source> readUriToSource() {
@@ -226,6 +225,11 @@ class BinaryBuilder {
return importTable[index];
}
+ DeferredImport readDeferredImportReference() {
+ int index = readUInt();
+ return _currentLibrary.deferredImports[index];
+ }
+
Class readClassReference({bool allowNull: false}) {
int tag = readByte();
if (tag == Tag.NullReference) {
@@ -292,6 +296,7 @@ class BinaryBuilder {
// TODO(jensj): We currently save (almost the same) uri twice.
_currentLibrary.fileUri = readUriReference();
+ _readDeferredImports(_currentLibrary);
_fillLazilyLoadedList(_currentLibrary.classes, (int tag, int index) {
readClass(loader.getClassReference(_currentLibrary, tag, index), tag);
});
@@ -306,6 +311,19 @@ class BinaryBuilder {
debugPath.removeLast();
}
+ void _readDeferredImports(Library library) {
+ int count = readUInt();
+ library.deferredImports.length = count;
+ for (int i = 0; i < count; ++i) {
+ var importNode = _readDeferredImport();
+ library.deferredImports.add(importNode..parent = library);
+ }
+ }
+
+ DeferredImport _readDeferredImport() {
+ return new DeferredImport(readLibraryReference(), readStringReference());
+ }
+
void readClass(Class node, int tag) {
assert(node != null);
switch (tag) {
@@ -530,6 +548,10 @@ class BinaryBuilder {
? tagByte
: (tagByte & Tag.SpecializedTagMask);
switch (tag) {
+ case Tag.LoadLibrary:
+ return new LoadLibrary(readDeferredImportReference());
+ case Tag.CheckLibraryIsLoaded:
+ return new CheckLibraryIsLoaded(readDeferredImportReference());
case Tag.InvalidExpression:
return new InvalidExpression();
case Tag.VariableGet:
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698