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: LayoutIdThe 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: LayoutIdThe 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: LayoutIdThe 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: LayoutIdThe 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
impl Program
pub fn function(&self, id: FunctionId) -> &Function
pub fn layout(&self, id: LayoutId) -> &Layout
pub fn string(&self, id: StrId) -> &Arc<str>
pub fn arg_list(&self, id: ArgsId) -> &[Arg]
pub fn table(&self, id: TableId) -> &Table
pub fn host_op(&self, id: HostOpId) -> &HostOp
pub fn builtin(&self, id: BuiltinId) -> &Builtin
Sourcepub fn function_named(&self, module: &str, name: &str) -> Option<FunctionId>
pub fn function_named(&self, module: &str, name: &str) -> Option<FunctionId>
The id of module.name, if the program has it.