[−][src]Struct inc::compiler::state::State
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: i64
asm: ASM
symbols: 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:
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
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,