Wire functions through everything, with some unimplemented, and add a basic scoped map.

This commit is contained in:
2023-10-07 11:06:28 +02:00
parent eba5227ebc
commit 736d27953f
18 changed files with 392 additions and 97 deletions

View File

@@ -1,4 +1,4 @@
use super::ast::{Expression, Program, Statement};
use super::ast::{Expression, Program, Statement, TopLevel};
use internment::ArcIntern;
use std::collections::HashSet;
@@ -10,7 +10,7 @@ impl Program {
pub fn strings(&self) -> HashSet<ArcIntern<String>> {
let mut result = HashSet::new();
for stmt in self.statements.iter() {
for stmt in self.items.iter() {
stmt.register_strings(&mut result);
}
@@ -18,6 +18,15 @@ impl Program {
}
}
impl TopLevel {
fn register_strings(&self, string_set: &mut HashSet<ArcIntern<String>>) {
match self {
TopLevel::Function(_, _, body) => body.register_strings(string_set),
TopLevel::Statement(stmt) => stmt.register_strings(string_set),
}
}
}
impl Statement {
fn register_strings(&self, string_set: &mut HashSet<ArcIntern<String>>) {
match self {