Add a lot of new stuff to the compile mod
* compile::sym is now compile::name * add basic block structure * add visitor pattern * some other minor things (e.g. syn::ast::prelude) Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,30 +1,41 @@
|
||||
pub mod sym;
|
||||
pub mod block;
|
||||
pub mod error;
|
||||
pub mod ir;
|
||||
pub mod name;
|
||||
pub mod visit;
|
||||
|
||||
use crate::{
|
||||
syn::ast::Stmt,
|
||||
compile::sym::SymStack,
|
||||
compile::name::NameStack,
|
||||
};
|
||||
|
||||
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,
|
||||
pub struct Ctx<'t> {
|
||||
text: &'t str,
|
||||
name_stack: NameStack,
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
pub fn sym_stack(&self) -> &SymStack {
|
||||
&self.sym_stack
|
||||
impl<'t> Ctx<'t> {
|
||||
pub fn new(text: &'t str) -> Self {
|
||||
Ctx {
|
||||
text,
|
||||
name_stack: NameStack::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sym_stack_mut(&mut self) -> &mut SymStack {
|
||||
&mut self.sym_stack
|
||||
pub fn text(&self) -> &'t str {
|
||||
self.text
|
||||
}
|
||||
|
||||
pub fn name_stack(&self) -> &NameStack {
|
||||
&self.name_stack
|
||||
}
|
||||
|
||||
pub fn name_stack_mut(&mut self) -> &mut NameStack {
|
||||
&mut self.name_stack
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user