pub struct Fn<'a> { /* private fields */ }Expand description
Emit instructions for one bytecode function.
Implementations§
Source§impl<'a> Fn<'a>
impl<'a> Fn<'a>
Sourcepub fn reg(&mut self, index: u8) -> Reg
pub fn reg(&mut self, index: u8) -> Reg
Bind to an explicit register index without growing the declared frame.
Sourcepub fn window(&mut self, count: u8) -> RegWindow
pub fn window(&mut self, count: u8) -> RegWindow
Allocate count contiguous locals; useful before Self::native_n.
Sourcepub fn load_i32(&mut self, n: i32) -> Reg
pub fn load_i32(&mut self, n: i32) -> Reg
Load a small immediate into a new local.
Examples found in repository?
More examples
pub fn sub(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn mul(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn div(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn modulo(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn neg(&mut self, src: Reg) -> Reg
pub fn eq(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn eq_imm(&mut self, lhs: Reg, imm: i32) -> Reg
pub fn lt(&mut self, lhs: Reg, rhs: Reg) -> Reg
pub fn le(&mut self, lhs: Reg, rhs: Reg) -> Reg
Sourcepub fn while_lt<F>(&mut self, counter: Reg, limit: Reg, body: F)
pub fn while_lt<F>(&mut self, counter: Reg, limit: Reg, body: F)
While counter < limit (interpreter Branch skips on falsy).
pub fn label(&mut self) -> Label
pub fn bind(&mut self, label: Label)
pub fn jump(&mut self, label: Label)
Sourcepub fn branch_if_falsy(&mut self, cond: Reg, target: Label)
pub fn branch_if_falsy(&mut self, cond: Reg, target: Label)
Branch when cond is falsy (0).
Sourcepub fn return_(&mut self, value: Reg)
pub fn return_(&mut self, value: Reg)
Examples found in repository?
More examples
pub fn call(&mut self, function: FuncId, argc: u8) -> Reg
pub fn halt(&mut self)
pub fn yield_(&mut self)
pub fn sleep(&mut self, millis: Reg)
pub fn exit(&mut self, reg: Reg)
Sourcepub fn self_cap(&mut self) -> Reg
pub fn self_cap(&mut self) -> Reg
Self Cap (SEND / ASK target for this flow).
Despite the opcode name (SelfPid), the value is a crate::Value::Cap,
not a Pid. In BEAM terms this is closer to a reply address grant
than to self() — use Self::hop_sender on a delivered hop for
authenticated origin identity.
Sourcepub fn self_address(&mut self) -> Reg
pub fn self_address(&mut self) -> Reg
Alias for Self::self_cap — preferred name when coming from BEAM.
pub fn spawn(&mut self, function: FuncId, argc: u8) -> Reg
Sourcepub fn spawn_with_rights(
&mut self,
function: FuncId,
argc: u8,
rights: CapRights,
) -> Reg
pub fn spawn_with_rights( &mut self, function: FuncId, argc: u8, rights: CapRights, ) -> Reg
Spawn a child that receives only rights ⊆ parent authority.
Sourcepub fn spawn_confined(&mut self, function: FuncId, argc: u8) -> Reg
pub fn spawn_confined(&mut self, function: FuncId, argc: u8) -> Reg
Spawn with rights = NONE (confined by default).
Sourcepub fn spawn_at(&mut self, dst: Reg, function: FuncId, argc: u8)
pub fn spawn_at(&mut self, dst: Reg, function: FuncId, argc: u8)
Spawn into an explicit destination register (e.g. reg(255)).
Sourcepub fn delegate(&mut self, src: Reg, rights: CapRights) -> Reg
pub fn delegate(&mut self, src: Reg, rights: CapRights) -> Reg
Attenuate src into a new Cap (rights mask is an immediate).
pub fn send(&mut self, target_cap: Reg, msg: Reg)
pub fn receive(&mut self) -> Reg
pub fn receive_timeout(&mut self, millis: Reg) -> Reg
pub fn receive_match(&mut self, tag: Reg) -> Reg
pub fn receive_match_imm(&mut self, tag: u16) -> Reg
Sourcepub fn ask(&mut self, target_cap: Reg, msg: Reg) -> Reg
pub fn ask(&mut self, target_cap: Reg, msg: Reg) -> Reg
RPC hop: deliver msg to target_cap, wait for correlated reply.
If the target exits first, dest is a crate::TAG_SYS_EXIT hop
(not a hang).
Sourcepub fn ask_timeout(&mut self, target_cap: Reg, msg: Reg, millis: Reg) -> Reg
pub fn ask_timeout(&mut self, target_cap: Reg, msg: Reg, millis: Reg) -> Reg
Like Self::ask, but writes Unit into the dest if millis elapses.
Sourcepub fn monitor(&mut self, target_cap: Reg) -> Reg
pub fn monitor(&mut self, target_cap: Reg) -> Reg
One-way watch: when the flow addressed by target_cap exits, this
flow receives a crate::TAG_SYS_DOWN hop. Returns a monitor ref (Int).
pub fn demonitor(&mut self, monitor: Reg)
Sourcepub fn link(&mut self, target_cap: Reg) -> Reg
pub fn link(&mut self, target_cap: Reg) -> Reg
Bidirectional link: abnormal exit of either side kills the peer.
pub fn unlink(&mut self, link: Reg)
pub fn trap(&mut self, code: i32)
Sourcepub fn native1_from(&mut self, src: Reg, native: u32) -> Reg
pub fn native1_from(&mut self, src: Reg, native: u32) -> Reg
Copy src, call a one-arg native, return the result in a new local.
The source register is preserved (CallNative clobbers its argument slot).
Sourcepub fn native1_on(&mut self, src: Reg, native: u32)
pub fn native1_on(&mut self, src: Reg, native: u32)
Side-effect native on a copy of src (e.g. print).
Sourcepub fn native_n(&mut self, base: Reg, native: u32, argc: u8)
pub fn native_n(&mut self, base: Reg, native: u32, argc: u8)
CallNative with argc args already at base..base+argc.
Sourcepub fn call_native(&mut self, base: Reg, native: u32, argc: u8)
pub fn call_native(&mut self, base: Reg, native: u32, argc: u8)
Call a native with argc args already in base..base+argc.
Sourcepub fn call_native0(&mut self, native: u32) -> Reg
pub fn call_native0(&mut self, native: u32) -> Reg
Call a zero-arg native; returns the result register.
Sourcepub fn hop(&mut self, request_id: Reg, tag: i32, payload: Reg) -> Reg
pub fn hop(&mut self, request_id: Reg, tag: i32, payload: Reg) -> Reg
Build an outgoing Atomic Hop (request_id, tag, payload).
The scheduler overwrites sender and mints reply_cap on Self::send
/ Self::ask — do not forge a sender (see crate::docs::security).
Sourcepub fn hop_sender(&mut self, msg: Reg) -> Reg
pub fn hop_sender(&mut self, msg: Reg) -> Reg
Extract authenticated origin from a delivered hop (Value::Pid).
pub fn hop_request_id(&mut self, msg: Reg) -> Reg
pub fn hop_tag(&mut self, msg: Reg) -> Reg
pub fn hop_payload(&mut self, msg: Reg) -> Reg
Sourcepub fn hop_reply_cap(&mut self, msg: Reg) -> Reg
pub fn hop_reply_cap(&mut self, msg: Reg) -> Reg
Reply address grant minted for the original sender (Value::Cap).
Sourcepub fn reply_to(&mut self, req: Reg, tag: i32, payload: Reg) -> Reg
pub fn reply_to(&mut self, req: Reg, tag: i32, payload: Reg) -> Reg
Build a reply hop echoing request_id from req.
Sourcepub fn send_reply(&mut self, req: Reg, tag: i32, payload: Reg)
pub fn send_reply(&mut self, req: Reg, tag: i32, payload: Reg)
Reply to req via its reply_cap (typical server pattern).
Sourcepub fn make_msg(
&mut self,
native_index: u32,
request_id: Reg,
tag: i32,
payload: Reg,
) -> Reg
pub fn make_msg( &mut self, native_index: u32, request_id: Reg, tag: i32, payload: Reg, ) -> Reg
Build a Value::Message via make_msg at native_index.
There is no sender operand — the scheduler stamps identity on Send.
A 4-arg legacy encoding is still accepted by the native (first arg
discarded) so forged-sender regressions keep compiling.