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:
2020-05-20 14:41:12 -04:00
parent 3ce7384f15
commit 32591f5e29
15 changed files with 306 additions and 206 deletions

View File

@@ -43,10 +43,10 @@ fn main() -> Result<()> {
let ast = parser.next_body()?;
//println!("{:#?}", ast);
let mut ctx = compile::Ctx::new(text.as_str());
let mut ctx = compile::Ctx::new();
ctx.name_stack_mut().push_default();
{
let mut collect_names = compile::name::CollectNames::new(&mut ctx);
let mut collect_names = compile::name::CollectNames::new(&mut ctx, text.as_str());
collect_names.collect(&ast);
}
let names = ctx.name_stack_mut().pop().unwrap();