[][src]Struct inc::compiler::state::State

pub struct State {
    pub si: i64,
    pub asm: ASM,
    pub symbols: HashMap<String, usize>,
    pub functions: HashSet<String>,
    // some fields omitted
}

State for the code generator; easier to bundle it all into a struct than pass several arguments in.

Stack index points to the current available empty slot. Use and then decrement the index to add a new variable. Default to -word size

li is label index, a counter used to generate unique labels. See gen_label

symbols is a list of all strings known at compile time, so that they can be allocated in the binary instead of heap.

functions are all user defined functions

State should also implement some form of register allocation.

Fields

si: i64asm: ASMsymbols: HashMap<String, usize>functions: HashSet<String>

Methods

impl State[src]

pub fn enter(&mut self)[src]

pub fn leave(&mut self)[src]

pub fn get(&self, i: &str) -> Option<&Reference>[src]

pub fn set(&mut self, i: &str, r: Reference)[src]

pub fn alloc(&mut self) -> i64[src]

Allocate a word on the stack & return reference to existing empty slot

Since stack index points to existing free memory, it is useful to be able to use it and increment in one go.

Example:

This example is not tested
Save { r: RAX, si: s.alloc() }

pub fn dealloc(&mut self, count: i64)[src]

Explicitly free n words of memory from stack

pub fn gen_label(&mut self) -> String[src]

Generate a unique label for jump targets.

Trait Implementations

impl Default for State[src]

Auto Trait Implementations

impl Send for State

impl Unpin for State

impl Sync for State

impl UnwindSafe for State

impl RefUnwindSafe for State

Blanket Implementations

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

impl<T> From<T> for T[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.

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

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

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