Struct orca_wasm::ir::component::Component

source ·
pub struct Component<'a> {
Show 14 fields pub modules: Vec<Module<'a>>, pub alias: Vec<ComponentAlias<'a>>, pub core_types: Vec<CoreType<'a>>, pub component_types: Vec<ComponentType<'a>>, pub imports: Vec<ComponentImport<'a>>, pub exports: Vec<ComponentExport<'a>>, pub instances: Vec<Instance<'a>>, pub component_instance: Vec<ComponentInstance<'a>>, pub canons: Vec<CanonicalFunction>, pub custom_sections: CustomSections<'a>, pub components: Vec<Component<'a>>, pub num_modules: usize, pub start_section: Vec<ComponentStartFunction>, pub sections: Vec<(u32, ComponentSection)>, /* private fields */
}
Expand description

Intermediate Representation of a wasm component.

Fields§

§modules: Vec<Module<'a>>

Modules

§alias: Vec<ComponentAlias<'a>>

Alias

§core_types: Vec<CoreType<'a>>

Core Types

§component_types: Vec<ComponentType<'a>>

Component Types

§imports: Vec<ComponentImport<'a>>

Imports

§exports: Vec<ComponentExport<'a>>

Exports

§instances: Vec<Instance<'a>>

Core Instances

§component_instance: Vec<ComponentInstance<'a>>

Component Instances

§canons: Vec<CanonicalFunction>

Canons

§custom_sections: CustomSections<'a>

Custom sections

§components: Vec<Component<'a>>

Nested Components

§num_modules: usize

Number of modules

§start_section: Vec<ComponentStartFunction>

Component Start Section

§sections: Vec<(u32, ComponentSection)>

Sections of the Component. Represented as (#num of occurrences of a section, type of section)

Implementations§

source§

impl<'a> Component<'a>

source

pub fn new() -> Self

Creates a new Empty Component

source

pub fn add_module(&mut self, module: Module<'a>)

Add a Module to this Component.

source

pub fn add_globals(&mut self, global: Global, module_idx: usize) -> GlobalID

Add a Global to this Component.

source

pub fn parse(wasm: &'a [u8], enable_multi_memory: bool) -> Result<Self, Error>

Parse a Component from a wasm binary.

§Example
use orca_wasm::Component;

let file = "path_to_file";
let buff = wat::parse_file(file).expect("couldn't convert the input wat to Wasm");
let comp = Component::parse(&buff, false).unwrap();
source

pub fn encode(&mut self) -> Vec<u8>

Encode a Component to bytes..

§Example
use orca_wasm::Component;

let file = "path_to_file";
let buff = wat::parse_file(file).expect("couldn't convert the input wat to Wasm");
let mut comp = Component::parse(&buff, false).unwrap();
let result = comp.encode();
source

pub fn print(&self)

Print a rudimentary textual representation of a Component

source

pub fn emit_wasm(&mut self, file_name: &str) -> Result<(), Error>

Emit the Component into a wasm binary file.

source

pub fn get_fid_by_name( &self, name: &str, module_idx: ModuleID, ) -> Option<FunctionID>

Get Local Function ID by name

Trait Implementations§

source§

impl<'a> Debug for Component<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Component<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Component<'a>

§

impl<'a> RefUnwindSafe for Component<'a>

§

impl<'a> Send for Component<'a>

§

impl<'a> Sync for Component<'a>

§

impl<'a> Unpin for Component<'a>

§

impl<'a> UnwindSafe for Component<'a>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.