Struct miden_assembly::ast::ModuleImports
source · pub struct ModuleImports { /* private fields */ }Expand description
Information about imports stored in the AST
Implementations§
source§impl ModuleImports
impl ModuleImports
sourcepub fn new(
imports: BTreeMap<String, LibraryPath>,
invoked_procs: BTreeMap<ProcedureId, (ProcedureName, LibraryPath)>
) -> Self
pub fn new( imports: BTreeMap<String, LibraryPath>, invoked_procs: BTreeMap<ProcedureId, (ProcedureName, LibraryPath)> ) -> Self
Create a new ModuleImports instance
§Panics
Panics if the number of imports is greater than MAX_IMPORTS, or if the number of invoked procedures is greater than MAX_INVOKED_IMPORTED_PROCS
sourcepub fn parse(tokens: &mut TokenStream<'_>) -> Result<Self, ParsingError>
pub fn parse(tokens: &mut TokenStream<'_>) -> Result<Self, ParsingError>
Parses all use statements into a map of imports which maps a module name (e.g., “u64”) to
its fully-qualified path (e.g., “std::math::u64”).
sourcepub fn get_module_path(&self, module_name: &str) -> Option<&LibraryPath>
pub fn get_module_path(&self, module_name: &str) -> Option<&LibraryPath>
Look up the path of the imported module with the given name.
sourcepub fn get_procedure_info(
&self,
id: &ProcedureId
) -> Option<(&ProcedureName, &LibraryPath)>
pub fn get_procedure_info( &self, id: &ProcedureId ) -> Option<(&ProcedureName, &LibraryPath)>
Look up the actual procedure name and module path associated with the given ProcedureId, if that procedure was imported and invoked in the current module.
sourcepub fn get_procedure_name(&self, id: &ProcedureId) -> Option<&ProcedureName>
pub fn get_procedure_name(&self, id: &ProcedureId) -> Option<&ProcedureName>
Look up the procedure name associated with the given ProcedureId, if that procedure was imported and invoked in the current module.
sourcepub fn get_procedure_path(&self, id: &ProcedureId) -> Option<&LibraryPath>
pub fn get_procedure_path(&self, id: &ProcedureId) -> Option<&LibraryPath>
Look up the LibraryPath associated with the given ProcedureId, if that procedure was imported and invoked in the current module.
sourcepub fn import_paths(&self) -> Vec<&LibraryPath>
pub fn import_paths(&self) -> Vec<&LibraryPath>
Return the paths of all imported module
sourcepub fn get_imported_procedures(&self) -> BTreeMap<ProcedureId, ProcedureName>
pub fn get_imported_procedures(&self) -> BTreeMap<ProcedureId, ProcedureName>
Returns a map containing IDs and names of imported procedures.
sourcepub fn add_invoked_proc(
&mut self,
proc_name: &ProcedureName,
module_name: &str,
token: &Token<'_>
) -> Result<ProcedureId, ParsingError>
pub fn add_invoked_proc( &mut self, proc_name: &ProcedureName, module_name: &str, token: &Token<'_> ) -> Result<ProcedureId, ParsingError>
Adds the specified procedure to the set of procedures invoked from imported modules and returns the ID of the invoked procedure.
§Errors
Return an error if
- The module with the specified name has not been imported via the
usestatement. - The total number of invoked procedures exceeds 2^{16} - 1.
Trait Implementations§
source§impl Clone for ModuleImports
impl Clone for ModuleImports
source§fn clone(&self) -> ModuleImports
fn clone(&self) -> ModuleImports
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ModuleImports
impl Debug for ModuleImports
source§impl Default for ModuleImports
impl Default for ModuleImports
source§fn default() -> ModuleImports
fn default() -> ModuleImports
source§impl Deserializable for ModuleImports
impl Deserializable for ModuleImports
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl PartialEq for ModuleImports
impl PartialEq for ModuleImports
source§fn eq(&self, other: &ModuleImports) -> bool
fn eq(&self, other: &ModuleImports) -> bool
self and other values to be equal, and is used
by ==.source§impl Serializable for ModuleImports
impl Serializable for ModuleImports
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.