Skip to main content

Program

Struct Program 

Source
pub struct Program {
    pub functions: Vec<Function>,
    pub layouts: Vec<Layout>,
    pub strings: Vec<Arc<str>>,
    pub args: Vec<Vec<Arg>>,
    pub tables: Vec<Table>,
    pub host_ops: Vec<HostOp>,
    pub builtins: Vec<Builtin>,
    pub str_layout: LayoutId,
    pub bytes_layout: LayoutId,
    pub buffer_layout: LayoutId,
    pub boxed_layout: LayoutId,
    pub by_name: BTreeMap<(Arc<str>, Arc<str>), FunctionId>,
}
Expand description

A whole lowered package.

Fields§

§functions: Vec<Function>§layouts: Vec<Layout>§strings: Vec<Arc<str>>§args: Vec<Vec<Arg>>§tables: Vec<Table>§host_ops: Vec<HostOp>§builtins: Vec<Builtin>§str_layout: LayoutId

The layout every string object shares.

One field rather than a layout in each Inst::Str, because every string in a program has the same shape and the machine should not have to be told it once per literal. A program that mentions no string still declares it: the machine allocates one for a host’s answer, and a table it has to check for emptiness first is a branch on a path that always takes the same side.

§bytes_layout: LayoutId

The layout every byte run under construction shares.

A program-wide constant for the reason Program::str_layout is one: Inst::AllocBytes should not have to be told this layout per call site, and ADR 0051 gives every run the same crate::layout::Shape::Bytes shape whatever string it will become.

§buffer_layout: LayoutId

The layout every byte buffer’s owner shares.

A program-wide constant for Program::bytes_layout’s reason, and the other half of the pair: an owner and its store are allocated together by Inst::AllocBuffer, so neither layout is named at a call site. ADR 0052 gives every buffer the same crate::layout::Shape::ByteBuffer shape whatever bytes it will hold, because an owner’s two words are a length and a reference whatever the store’s capacity.

§boxed_layout: LayoutId

The layout every Inst::Box allocates its object as.

A program-wide constant for the same reason Program::str_layout is one: every box has the same object shape, and what differs — the layout of the value inside it — is in the box’s first payload word. The machine should not have to search a table for a shape that is always the same, and a search that fails has to answer something.

§by_name: BTreeMap<(Arc<str>, Arc<str>), FunctionId>

module.name to id, for an entry point named on a command line.

Implementations§

Source§

impl Program

Source

pub fn function(&self, id: FunctionId) -> &Function

Source

pub fn layout(&self, id: LayoutId) -> &Layout

Source

pub fn string(&self, id: StrId) -> &Arc<str>

Source

pub fn arg_list(&self, id: ArgsId) -> &[Arg]

Source

pub fn table(&self, id: TableId) -> &Table

Source

pub fn host_op(&self, id: HostOpId) -> &HostOp

Source

pub fn builtin(&self, id: BuiltinId) -> &Builtin

Source

pub fn function_named(&self, module: &str, name: &str) -> Option<FunctionId>

The id of module.name, if the program has it.

Trait Implementations§

Source§

impl Clone for Program

Source§

fn clone(&self) -> Program

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Program

Source§

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

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

impl Default for Program

Source§

fn default() -> Program

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.