Skip to main content

ModuleInner

Struct ModuleInner 

Source
pub struct ModuleInner {
Show 21 fields pub name: String, pub url: String, pub code: Option<Gc<CompiledCode>>, pub meta: ModuleMeta, pub cells: Vec<Gc<Cell>>, pub dependencies: Vec<Option<Gc<ModuleRecord>>>, pub status: ModuleStatus, pub evaluation_error: Option<Value>, pub async_evaluation: bool, pub async_evaluation_order: u64, pub pending_async_dependencies: usize, pub async_parent_modules: Vec<Gc<ModuleRecord>>, pub cycle_root: Option<Gc<ModuleRecord>>, pub dfs_index: usize, pub dfs_ancestor_index: usize, pub top_level_capability: Option<(Gc<JsObject>, Value, Value)>, pub kind: ModuleKind, pub namespace: Option<Gc<JsObject>>, pub deferred_namespace: Option<Gc<JsObject>>, pub import_meta: Option<Gc<JsObject>>, pub star_cells: BTreeMap<String, Gc<Cell>>,
}
Expand description

Everything a module record holds; see ModuleRecord.

Fields§

§name: String

Canonical identity: the cache key, and what a cycle compares.

§url: String

What import.meta.url reports.

§code: Option<Gc<CompiledCode>>

The compiled body, or None for a JSON/text/bytes module.

§meta: ModuleMeta

The tables the compiler produced.

§cells: Vec<Gc<Cell>>

One cell per closure variable of the body; the body reads its bindings here.

§dependencies: Vec<Option<Gc<ModuleRecord>>>

Resolved dependencies, parallel to meta.requests.

§status: ModuleStatus

Where it is in its lifetime.

§evaluation_error: Option<Value>

The completion of a body that threw, rethrown on every later attempt.

§16.2.1.5.3.1 stores the abrupt completion on the record. Without it a second read through a deferred namespace ran the body again and produced a second, equal, but not identical error object — which import-defer/errors/module-throws compares by identity.

§async_evaluation: bool

§16.2.1.5.3.1’s [[AsyncEvaluation]]: the body has started and has not finished.

Not the same as status == EvaluatingAsync, because the flag is also what an importer looks at: a request whose target has this set makes the importer wait.

§async_evaluation_order: u64

§16.2.1.5.3.1’s [[AsyncEvaluationOrder]].

A monotonic counter, never reset. The ordering of modules that become ready in one batch is decided by it and is observable — module-code/top-level-await/fulfillment-order is exactly that assertion — so it cannot be “whatever order the vector happens to have”.

§pending_async_dependencies: usize

§16.2.1.5.3.1’s [[PendingAsyncDependencies]].

§async_parent_modules: Vec<Gc<ModuleRecord>>

§16.2.1.5.3.1’s [[AsyncParentModules]]: who is waiting for this module.

§cycle_root: Option<Gc<ModuleRecord>>

§16.2.1.5.3.1’s [[CycleRoot]]; None means “this module”.

§dfs_index: usize

§16.2.1.5.3.1’s [[DFSIndex]]: where the depth-first walk reached this module.

§dfs_ancestor_index: usize

§16.2.1.5.3.1’s [[DFSAncestorIndex]]: the earliest index reachable from here.

Equal to dfs_index exactly when this module is the root of its cycle, which is how §16.2.1.5.3.1 step 17 knows where to stop popping the stack.

§top_level_capability: Option<(Gc<JsObject>, Value, Value)>

[[TopLevelCapability]]: the promise a caller waits on for this module.

Stored as the capability triple so both settling functions are available — the module owns the promise, and whoever imports it chains onto the same one, which is what makes the second import() of a waiting module resolve no earlier than the first (dynamic-import-of-waiting-module).

§kind: ModuleKind

What kind of module it is.

§namespace: Option<Gc<JsObject>>

The namespace object, built on first use.

§deferred_namespace: Option<Gc<JsObject>>

The deferred namespace object, built on first use.

A second object rather than a flag on the first: the deferred namespace’s whole point is that reading it evaluates the module, and the eager one must stay usable on a module that is still Linked. It is cached here so two import defer clauses for one module hand back the same object, which the proposal requires.

§import_meta: Option<Gc<JsObject>>

import.meta, built at load time.

§star_cells: BTreeMap<String, Gc<Cell>>

The wrapper cell behind each export * as ns from "m", keyed by ns.

§16.2.1.6.3 ResolveExport identifies a binding by (module, name), and the ambiguity test compares those identities. A namespace re-export needs a cell in the export table, and building a fresh one per lookup gave the same export two different identities — so a name reached through two export * that both pass through one export * as ns looked ambiguous. Caching makes the identity stable, which is what namespace-unambiguous-if-export-star-as-from checks.

Trait Implementations§

Source§

impl Trace for ModuleInner

Source§

fn trace(&self, tracer: &mut Tracer<'_>)

Report every Gc owned by self to tracer.
Source§

fn external_bytes(&self) -> usize

Bytes this value owns outside its own box: a string’s buffer, an array’s element vector, a buffer’s bytes. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ModuleInner

§

impl !Send for ModuleInner

§

impl !Sync for ModuleInner

§

impl !UnwindSafe for ModuleInner

§

impl Forget for ModuleInner

§

impl Freeze for ModuleInner

§

impl Move for ModuleInner

§

impl Unpin for ModuleInner
where *const u8 is !null: Unpin, *const GcBox<CompiledCode> is !null: Unpin, *const GcBox<Cell> is !null: Unpin, *const GcBox<ModuleRecord> is !null: Unpin, *const GcBox<JsString> is !null: Unpin, *const GcBox<JsObject> is !null: Unpin, *const GcBox<JsSymbol> is !null: Unpin, *const GcBox<BigInt> is !null: Unpin, *const LeafNode<String, Gc<Cell>> is !null: Unpin, Box<(String, Gc<Cell>)>: Unpin,

§

impl UnsafeUnpin for ModuleInner

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.