| Index: pkg/kernel/lib/ast.dart
|
| diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
|
| index f35e754d4d1c5238c2e6257267b16a26fcf38ddb..155189c9d82e27e963fa21cd396ddbda7b5f0811 100644
|
| --- a/pkg/kernel/lib/ast.dart
|
| +++ b/pkg/kernel/lib/ast.dart
|
| @@ -179,6 +179,7 @@ class Library extends TreeNode implements Comparable<Library> {
|
| bool isExternal;
|
|
|
| String name;
|
| + final List<DeferredImport> deferredImports;
|
| final List<Class> classes;
|
| final List<Procedure> procedures;
|
| final List<Field> fields;
|
| @@ -186,10 +187,12 @@ class Library extends TreeNode implements Comparable<Library> {
|
| Library(this.importUri,
|
| {this.name,
|
| this.isExternal: false,
|
| + List<DeferredImport> imports,
|
| List<Class> classes,
|
| List<Procedure> procedures,
|
| List<Field> fields})
|
| - : this.classes = classes ?? <Class>[],
|
| + : this.deferredImports = imports ?? <DeferredImport>[],
|
| + this.classes = classes ?? <Class>[],
|
| this.procedures = procedures ?? <Procedure>[],
|
| this.fields = fields ?? <Field>[] {
|
| setParents(this.classes, this);
|
| @@ -248,6 +251,22 @@ class Library extends TreeNode implements Comparable<Library> {
|
| }
|
| }
|
|
|
| +/// An import of form: `import <url> deferred as <name>;`.
|
| +class DeferredImport extends TreeNode {
|
| + Library importedLibrary;
|
| + String name;
|
| +
|
| + DeferredImport(this.importedLibrary, this.name);
|
| +
|
| + Library get enclosingLibrary => parent;
|
| +
|
| + accept(TreeVisitor v) => v.visitDeferredImport(this);
|
| +
|
| + visitChildren(Visitor v) {}
|
| +
|
| + transformChildren(Transformer v) {}
|
| +}
|
| +
|
| /// The degree to which the contents of a class have been loaded into memory.
|
| ///
|
| /// Each level imply the requirements of the previous ones.
|
| @@ -2434,6 +2453,51 @@ class Let extends Expression {
|
| }
|
| }
|
|
|
| +/// Attempt to load the library referred to by a deferred import.
|
| +///
|
| +/// This instruction is concerned with:
|
| +/// - keeping track whether the deferred import is marked as 'loaded'
|
| +/// - keeping track of whether the library code has already been downloaded
|
| +/// - actually downloading and linking the library
|
| +///
|
| +/// Should return a future. The value in this future will be the same value
|
| +/// seen by callers of `loadLibrary` functions.
|
| +///
|
| +/// On backends that link the entire program eagerly, this instruction needs
|
| +/// to mark the deferred import as 'loaded' and return a future.
|
| +class LoadLibrary extends Expression {
|
| + /// Reference to a deferred import in the enclosing library.
|
| + DeferredImport import;
|
| +
|
| + LoadLibrary(this.import);
|
| +
|
| + DartType getStaticType(TypeEnvironment types) {
|
| + return types.futureType(const DynamicType());
|
| + }
|
| +
|
| + accept(ExpressionVisitor v) => v.visitLoadLibrary(this);
|
| +
|
| + visitChildren(Visitor v) {}
|
| + transformChildren(Transformer v) {}
|
| +}
|
| +
|
| +/// Checks that the given deferred import has been marked as 'loaded'.
|
| +class CheckLibraryIsLoaded extends Expression {
|
| + /// Reference to a deferred import in the enclosing library.
|
| + DeferredImport import;
|
| +
|
| + CheckLibraryIsLoaded(this.import);
|
| +
|
| + DartType getStaticType(TypeEnvironment types) {
|
| + return types.objectType;
|
| + }
|
| +
|
| + accept(ExpressionVisitor v) => v.visitCheckLibraryIsLoaded(this);
|
| +
|
| + visitChildren(Visitor v) {}
|
| + transformChildren(Transformer v) {}
|
| +}
|
| +
|
| // ------------------------------------------------------------------------
|
| // STATEMENTS
|
| // ------------------------------------------------------------------------
|
|
|