diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 64d5eee..81005d0 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -14,13 +14,12 @@ mod test; pub struct State<'a> { values: ScopeStack<'a, Rc, ValueEntry>, - symbol_table_handle: SymbolTableHandle, } impl<'a> State<'a> { - pub fn new(symbol_table_handle: SymbolTableHandle) -> State<'a> { + pub fn new() -> State<'a> { let values = ScopeStack::new(Some(format!("global"))); - State { values, symbol_table_handle } + State { values } } pub fn debug_print(&self) -> String { @@ -30,7 +29,6 @@ impl<'a> State<'a> { fn new_frame(&'a self, items: &'a Vec, bound_vars: &BoundVars) -> State<'a> { let mut inner_state = State { values: self.values.new_scope(None), - symbol_table_handle: self.symbol_table_handle.clone(), }; for (bound_var, val) in bound_vars.iter().zip(items.iter()) { if let Some(bv) = bound_var.as_ref() { @@ -263,7 +261,6 @@ impl<'a> State<'a> { } let mut func_state = State { values: self.values.new_scope(name.map(|n| format!("{}", n))), - symbol_table_handle: self.symbol_table_handle.clone(), }; for (param, val) in params.into_iter().zip(args.into_iter()) { let val = func_state.expression(Node::Expr(val))?; diff --git a/schala-lang/language/src/eval/test.rs b/schala-lang/language/src/eval/test.rs index d361286..5c534cc 100644 --- a/schala-lang/language/src/eval/test.rs +++ b/schala-lang/language/src/eval/test.rs @@ -12,14 +12,14 @@ fn evaluate_all_outputs(input: &str) -> Vec> { let (mut ast, source_map) = crate::util::quick_ast(input); let source_map = Rc::new(RefCell::new(source_map)); let symbol_table = Rc::new(RefCell::new(SymbolTable::new(source_map))); - let mut state = State::new(symbol_table); - state.symbol_table_handle.borrow_mut().add_top_level_symbols(&ast).unwrap(); + symbol_table.borrow_mut().add_top_level_symbols(&ast).unwrap(); { - let mut scope_resolver = ScopeResolver::new(state.symbol_table_handle.clone()); + let mut scope_resolver = ScopeResolver::new(symbol_table.clone()); let _ = scope_resolver.resolve(&mut ast); } - let reduced = reduce(&ast, &state.symbol_table_handle.borrow()); + let reduced = reduce(&ast, &symbol_table.borrow()); + let mut state = State::new(); let all_output = state.evaluate(reduced, true); all_output } diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index 8446e03..a5a41e2 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -47,7 +47,7 @@ impl Schala { symbol_table: symbols.clone(), source_map: source_map.clone(), resolver: crate::scope_resolution::ScopeResolver::new(symbols.clone()), - state: eval::State::new(symbols), + state: eval::State::new(), type_context: typechecking::TypeContext::new(), active_parser: parsing::Parser::new(source_map) }