Struct passerine::common::lambda::Lambda[][src]

pub struct Lambda {
    pub decls: usize,
    pub code: Vec<u8>,
    pub spans: Vec<(usize, Span)>,
    pub constants: Vec<Data>,
    pub captures: Vec<Captured>,
    pub ffi: Vec<FFIFunction>,
}

Represents a single interpretable chunk of bytecode, think a function.

Fields

decls: usize

Number of variables declared in this scope.

code: Vec<u8>

Each byte is an opcode or a number-stream.

spans: Vec<(usize, Span)>

Each usize indexes the bytecode op that begins each line.

constants: Vec<Data>

Number-stream indexed, used to load constants.

captures: Vec<Captured>

List of positions of locals in the scope where this lambda is defined, indexes must be gauranteed to be data on the heap.

ffi: Vec<FFIFunction>

List of FFI functions (i.e. Rust functions) that can be called from this function.

Implementations

impl Lambda[src]

pub fn empty() -> Lambda[src]

Creates a new empty Lambda to be filled.

pub fn emit(&mut self, op: Opcode)[src]

Emits an opcode as a byte.

pub fn emit_bytes(&mut self, bytes: &mut Vec<u8>)[src]

Emits a series of bytes.

pub fn emit_span(&mut self, span: &Span)[src]

Emits a span, should be called before an opcode is emmited. This function ties opcodes to spans in source. See index_span as well.

pub fn demit(&mut self)[src]

Removes the last emitted byte.

pub fn index_data(&mut self, data: Data) -> usize[src]

Given some data, this function adds it to the constants table, and returns the data’s index. The constants table is push only, so constants are identified by their index. The resulting usize can be split up into a number byte stream, and be inserted into the bytecode.

pub fn index_span(&self, index: usize) -> Span[src]

Look up the nearest span at or before the index of a specific bytecode op.

pub fn add_ffi(&mut self, function: FFIFunction) -> usize[src]

Adds a ffi function to the ffi table, without checking for duplicates. The Compiler ensures that functions are valid and not duplicated during codegen.

Trait Implementations

impl Clone for Lambda[src]

impl Debug for Lambda[src]

impl Display for Lambda[src]

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

Dump a human-readable breakdown of a Lambda’s bytecode. Including constants, captures, and variables declared.

impl PartialEq<Lambda> for Lambda[src]

impl StructuralPartialEq for Lambda[src]

Auto Trait Implementations

impl !RefUnwindSafe for Lambda

impl !Send for Lambda

impl !Sync for Lambda

impl Unpin for Lambda

impl !UnwindSafe for Lambda

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.