Add vm and compile modules

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-16 12:56:52 -04:00
parent a60471f526
commit a15dde0fc2
13 changed files with 392 additions and 46 deletions

42
src/compile/mod.rs Normal file
View 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
}
}
*/