Add vm and compile modules
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
42
src/compile/mod.rs
Normal file
42
src/compile/mod.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
pub mod sym;
|
||||
|
||||
use crate::{
|
||||
syn::ast::Stmt,
|
||||
compile::sym::SymStack,
|
||||
};
|
||||
|
||||
pub trait Pass {
|
||||
type Out;
|
||||
fn pass(&self, ctx: &mut Ctx) -> Self::Out;
|
||||
}
|
||||
|
||||
// * Desugar
|
||||
// * Collect names as symbols
|
||||
// * Create basic blocks
|
||||
|
||||
pub struct Ctx {
|
||||
sym_stack: SymStack,
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
pub fn sym_stack(&self) -> &SymStack {
|
||||
&self.sym_stack
|
||||
}
|
||||
|
||||
pub fn sym_stack_mut(&mut self) -> &mut SymStack {
|
||||
&mut self.sym_stack
|
||||
}
|
||||
}
|
||||
|
||||
// no sugar in the syntax quite yet
|
||||
/*
|
||||
pub struct Desugar;
|
||||
|
||||
impl Pass<Vec<Stmt>> for Desugar {
|
||||
type Out = Vec<Stmt>;
|
||||
|
||||
fn pass(&mut self, input: Vec<Stmt>) -> Vec<Stmt> {
|
||||
input
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user