Struct passerine::compiler::gen::Compiler [−][src]
Compiler is a bytecode generator that walks an SST and produces (unoptimized) Bytecode.
There are plans to add a bytecode optimizer in the future.
Note that this struct should not be controlled manually,
use the gen
function instead.
Implementations
impl Compiler
[src]
pub fn base(ffi: FFI, scope: Scope) -> Compiler
[src]
Construct a new Compiler
.
pub fn enter_scope(&mut self, scope: Scope)
[src]
Replace the current compiler with a fresh one,
keeping a reference to the old one in self.enclosing
,
and moving the FFI into the current compiler.
pub fn exit_scope(&mut self) -> Compiler
[src]
Restore the enclosing compiler, returning the nested one for data (Lambda) extraction, and moving the FFI mappings back into the enclosing compiler.
pub fn walk(&mut self, sst: &Spanned<SST>) -> Result<(), Syntax>
[src]
Walks an SST to generate bytecode. At this stage, the SST should’ve been verified, pruned, typechecked, etc. A malformed SST will cause a panic, as SSTs should be correct at this stage, and for them to be incorrect is an error in the compiler itself.
pub fn symbol(&mut self, unique_symbol: UniqueSymbol)
[src]
Resovles a symbol lookup, e.g. something like x
.
pub fn data(&mut self, data: Data)
[src]
Takes a Data
leaf and and produces some code to load the constant
pub fn block(&mut self, children: Vec<Spanned<SST>>) -> Result<(), Syntax>
[src]
A block is a series of expressions where the last is returned. Each sup-expression is walked, the last value is left on the stack.
pub fn print(&mut self, expression: Spanned<SST>) -> Result<(), Syntax>
[src]
Generates a print expression Note that currently printing is a baked-in language feature, but the second the FFI becomes a thing it’ll no longer be one.
pub fn label(
&mut self,
name: String,
expression: Spanned<SST>
) -> Result<(), Syntax>
[src]
&mut self,
name: String,
expression: Spanned<SST>
) -> Result<(), Syntax>
Generates a Label construction that loads the variant, then wraps some data
pub fn tuple(&mut self, tuple: Vec<Spanned<SST>>) -> Result<(), Syntax>
[src]
Generates a Tuple construction that loads all fields in the tuple then rips them off the stack into a vec.
pub fn ffi(
&mut self,
name: String,
expression: Spanned<SST>,
span: Span
) -> Result<(), Syntax>
[src]
&mut self,
name: String,
expression: Spanned<SST>,
span: Span
) -> Result<(), Syntax>
Makes a Rust function callable from Passerine, by keeping a reference to that function.
pub fn resolve_assign(&mut self, unique_symbol: UniqueSymbol)
[src]
Resolves the assignment of a variable returns true if the variable was declared.
pub fn destructure(&mut self, pattern: Spanned<SSTPattern>, redeclare: bool)
[src]
Destructures a pattern into a series of unpack and assign instructions. Instructions match against the topmost stack item. Does delete the data that is matched against.
pub fn assign(
&mut self,
pattern: Spanned<SSTPattern>,
expression: Spanned<SST>
) -> Result<(), Syntax>
[src]
&mut self,
pattern: Spanned<SSTPattern>,
expression: Spanned<SST>
) -> Result<(), Syntax>
Assign a value to a variable.
pub fn lambda(
&mut self,
pattern: Spanned<SSTPattern>,
expression: Spanned<SST>,
scope: Scope
) -> Result<(), Syntax>
[src]
&mut self,
pattern: Spanned<SSTPattern>,
expression: Spanned<SST>,
scope: Scope
) -> Result<(), Syntax>
Recursively compiles a lambda declaration in a new scope.
pub fn call(
&mut self,
fun: Spanned<SST>,
arg: Spanned<SST>
) -> Result<(), Syntax>
[src]
&mut self,
fun: Spanned<SST>,
arg: Spanned<SST>
) -> Result<(), Syntax>
When a function is called, the top two items are taken off the stack, The topmost item is expected to be a function.
Auto Trait Implementations
impl !RefUnwindSafe for Compiler
impl !Send for Compiler
impl !Sync for Compiler
impl Unpin for Compiler
impl !UnwindSafe for Compiler
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,