pub struct BytecodeCompiler;Expand description
A simple compiler from common expression patterns to bytecode chunks.
Implementations§
Source§impl BytecodeCompiler
impl BytecodeCompiler
Sourcepub fn compile_nat(n: u64) -> BytecodeChunk
pub fn compile_nat(n: u64) -> BytecodeChunk
Compile a chunk that simply pushes a natural number and halts.
Sourcepub fn compile_add(a: u64, b: u64) -> BytecodeChunk
pub fn compile_add(a: u64, b: u64) -> BytecodeChunk
Compile a chunk that adds two naturals and halts.
Sourcepub fn compile_if(cond: bool, then_val: u64, else_val: u64) -> BytecodeChunk
pub fn compile_if(cond: bool, then_val: u64, else_val: u64) -> BytecodeChunk
Compile a conditional: if cond then then_val else else_val.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BytecodeCompiler
impl RefUnwindSafe for BytecodeCompiler
impl Send for BytecodeCompiler
impl Sync for BytecodeCompiler
impl Unpin for BytecodeCompiler
impl UnsafeUnpin for BytecodeCompiler
impl UnwindSafe for BytecodeCompiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more