pub struct InstantiableModule {
pub module: CompiledModule,
/* private fields */
}
Expand description
During the generation of a bytecode sequence, specific instantiations may need to be made, that may not yet exist in the underlying module. Instead of mutating the underlying module in order to record these instantiations in the locals signature table, we instead build wrapper around the underlying module containing the type instantiations, and at the end materialize this updated signature pool into a module. We also need the ability to quickly determine if an instantiation has already been created, and if so, at which index. So this also keeps a reverse lookup table of instantiation to SignatureIndex.
Fields§
§module: CompiledModule
Implementations§
source§impl InstantiableModule
impl InstantiableModule
pub fn new(module: CompiledModule) -> Self
sourcepub fn add_instantiation(
&mut self,
instantiant: Vec<SignatureToken>
) -> SignatureIndex
pub fn add_instantiation( &mut self, instantiant: Vec<SignatureToken> ) -> SignatureIndex
If the instantiant
is not in the instantiations
table, this adds the instantiant to the
instance_for_offset
for table, and adds the index to the reverse lookup table. Returns
the SignatureIndex for the instantiant
.
sourcepub fn add_struct_instantiation(
&mut self,
instantiant: StructDefInstantiation
) -> StructDefInstantiationIndex
pub fn add_struct_instantiation( &mut self, instantiant: StructDefInstantiation ) -> StructDefInstantiationIndex
If the instantiant
is not in the struct_instantiations
table, this adds the
instantiant to the struct_instance_for_offset
for table, and adds the index to the
reverse lookup table.
Returns the SignatureIndex for the instantiant
.
sourcepub fn add_function_instantiation(
&mut self,
instantiant: FunctionInstantiation
) -> FunctionInstantiationIndex
pub fn add_function_instantiation( &mut self, instantiant: FunctionInstantiation ) -> FunctionInstantiationIndex
If the instantiant
is not in the function_instantiations
table, this adds the
instantiant to the func_instance_for_offset
for table, and adds the index to the
reverse lookup table.
Returns the SignatureIndex for the instantiant
.
sourcepub fn add_field_instantiation(
&mut self,
instantiant: FieldInstantiation
) -> FieldInstantiationIndex
pub fn add_field_instantiation( &mut self, instantiant: FieldInstantiation ) -> FieldInstantiationIndex
If the instantiant
is not in the field_instantiations
table, this adds the
instantiant to the field_instance_for_offset
for table, and adds the index to the
reverse lookup table.
Returns the SignatureIndex for the instantiant
.
sourcepub fn instantiantiation_at(&self, index: SignatureIndex) -> &Vec<SignatureToken> ⓘ
pub fn instantiantiation_at(&self, index: SignatureIndex) -> &Vec<SignatureToken> ⓘ
Returns the type instantiation at index
. Errors if the instantiation does not exist.
sourcepub fn struct_instantiantiation_at(
&self,
index: StructDefInstantiationIndex
) -> &StructDefInstantiation
pub fn struct_instantiantiation_at( &self, index: StructDefInstantiationIndex ) -> &StructDefInstantiation
Returns the struct instantiation at index
. Errors if the instantiation does not exist.
sourcepub fn function_instantiantiation_at(
&self,
index: FunctionInstantiationIndex
) -> &FunctionInstantiation
pub fn function_instantiantiation_at( &self, index: FunctionInstantiationIndex ) -> &FunctionInstantiation
Returns the struct instantiation at index
. Errors if the instantiation does not exist.
sourcepub fn field_instantiantiation_at(
&self,
index: FieldInstantiationIndex
) -> &FieldInstantiation
pub fn field_instantiantiation_at( &self, index: FieldInstantiationIndex ) -> &FieldInstantiation
Returns the struct instantiation at index
. Errors if the instantiation does not exist.
sourcepub fn instantiate(self) -> CompiledModule
pub fn instantiate(self) -> CompiledModule
Consumes self, and adds the instantiations that have been built up to the underlying module, and returns the resultant compiled module.
Trait Implementations§
source§impl Clone for InstantiableModule
impl Clone for InstantiableModule
source§fn clone(&self) -> InstantiableModule
fn clone(&self) -> InstantiableModule
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more