pub struct Module {
instance_files: Vec<FileID>,
instances: IndexSet<(InstanceID, Symbol)>,
pub timestamp: Instant,
pub files: HashMap<FileID, Arc<LinkedAstDocument>>,
pub ok: bool,
}
Expand description
An actual instance of a root file with all subfiles
A module is basically a depth first iteration of all features and recusive sub file contents Each import statement creates a new instance of some ast file. So features and attributes can exist multiple times in diffrent instances. This struct allows for easy instance iteration and resolution. Since references in diffrent instances have diffrent resolutions, we currently reresolve references to non local symbols, TODO this can be avoided using a static instance encoding scheme?.
Fields§
§instance_files: Vec<FileID>
§instances: IndexSet<(InstanceID, Symbol)>
§timestamp: Instant
§files: HashMap<FileID, Arc<LinkedAstDocument>>
§ok: bool
Implementations§
source§impl Module
impl Module
pub fn get_instance(&self, instance: InstanceID, sym: Symbol) -> InstanceID
pub fn new( root: FileID, fs: &FileSystem, files: &HashMap<FileID, Arc<LinkedAstDocument>>, ) -> Module
sourcepub fn resolve_value(&self, src_sym: ModuleSymbol) -> ModuleSymbol
pub fn resolve_value(&self, src_sym: ModuleSymbol) -> ModuleSymbol
Resolves references inside this module
sourcepub fn resolve_config<E: FnMut(Range<usize>, String)>(
&self,
doc: &Vec<ConfigEntry>,
err: E,
) -> (HashMap<ModuleSymbol, ConfigValue>, HashMap<ModuleSymbol, Range<usize>>)
pub fn resolve_config<E: FnMut(Range<usize>, String)>( &self, doc: &Vec<ConfigEntry>, err: E, ) -> (HashMap<ModuleSymbol, ConfigValue>, HashMap<ModuleSymbol, Range<usize>>)
Bind a recursive configuration doc to a linear set of symbols Add layer for cardinality
pub fn file(&self, instance: InstanceID) -> &AstDocument
pub fn type_of(&self, sym: ModuleSymbol) -> Type
sourcepub fn instances<'a>(
&'a self,
) -> impl Iterator<Item = (InstanceID, &'a AstDocument)>
pub fn instances<'a>( &'a self, ) -> impl Iterator<Item = (InstanceID, &'a AstDocument)>
Visit all instances in the module
pub fn instances_depth<'a>( &'a self, ) -> impl Iterator<Item = (ModuleSymbol, InstanceID, &'a AstDocument, u32)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnwindSafe for Module
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more