Move compile::Ctx to its own mod, compile::ctx::Ctx
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
use crate::{
|
||||
compile::{visit::*, Ctx},
|
||||
compile::{ctx::Ctx, visit::*},
|
||||
obj::prelude::*,
|
||||
syn::{ast::prelude::*, span::*},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// NameStack
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct NameStack {
|
||||
next_sym: usize,
|
||||
stack: Vec<HashMap<String, NameId>>,
|
||||
@@ -71,7 +75,11 @@ impl NameStack {
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect local names and push them to the top layer of the name stack.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CollectNames
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Collect local stack names and push them to the top layer of the name stack.
|
||||
pub struct CollectNames<'c, 't> {
|
||||
ctx: &'c mut Ctx,
|
||||
text: &'t str,
|
||||
@@ -133,9 +141,17 @@ impl Visit<BaseExpr> for CollectNames<'_, '_> {
|
||||
|
||||
fn visit(&mut self, expr: &BaseExpr) -> Self::Out {
|
||||
// This is a LHS standalone expr
|
||||
if let BaseExpr { kind: BaseExprKind::Ident, .. } = expr {
|
||||
if let BaseExpr {
|
||||
kind: BaseExprKind::Ident,
|
||||
..
|
||||
} = expr
|
||||
{
|
||||
let name = expr.text_at(self.text).to_string();
|
||||
self.ctx.name_stack_mut().add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CollectSyms
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user