Update how visitors work, add NameId type
* Visitors are now defined on a per-type level, allowing for greater flexibility in combining and re-using behavior * NameId is used for namespaces, which are used to index locally scoped variables. Syms are used for free namespaces, specifically in objects. All NameIDs are symbols, while not all symbols are NameIDs. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#[macro_use] pub mod visit;
|
||||
pub mod block;
|
||||
pub mod error;
|
||||
pub mod ir;
|
||||
pub mod name;
|
||||
pub mod visit;
|
||||
|
||||
use crate::compile::name::NameStack;
|
||||
|
||||
@@ -10,23 +10,17 @@ use crate::compile::name::NameStack;
|
||||
// * Collect names as symbols
|
||||
// * Create basic blocks
|
||||
|
||||
pub struct Ctx<'t> {
|
||||
text: &'t str,
|
||||
pub struct Ctx {
|
||||
name_stack: NameStack,
|
||||
}
|
||||
|
||||
impl<'t> Ctx<'t> {
|
||||
pub fn new(text: &'t str) -> Self {
|
||||
impl Ctx {
|
||||
pub fn new() -> Self {
|
||||
Ctx {
|
||||
text,
|
||||
name_stack: NameStack::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(&self) -> &'t str {
|
||||
self.text
|
||||
}
|
||||
|
||||
pub fn name_stack(&self) -> &NameStack {
|
||||
&self.name_stack
|
||||
}
|
||||
@@ -35,16 +29,3 @@ impl<'t> Ctx<'t> {
|
||||
&mut self.name_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