From 59f5032a61d5016d4f0f90580b347a514f791759 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 12 Jul 2019 02:11:24 -0700 Subject: [PATCH] SymbolTable in reducer --- schala-lang/language/src/reduced_ast.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 2531c74..7117394 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -95,13 +95,13 @@ pub enum Func { } } -struct Reducer { - +struct Reducer<'a> { + symbol_table: &'a SymbolTable, } -impl Reducer { - fn new() -> Reducer { - Reducer { } +impl<'a> Reducer<'a> { + fn new(symbol_table: &'a SymbolTable) -> Reducer { + Reducer { symbol_table } } fn output(&mut self) -> Result { @@ -109,12 +109,12 @@ impl Reducer { } } -impl ASTVisitor for Reducer { +impl<'a> ASTVisitor for Reducer<'a> { } -pub fn perform_reduction(mut input: AST, _symbol_table: &SymbolTable) -> Result { - let mut reducer = Reducer::new(); +pub fn perform_reduction(mut input: AST, symbol_table: &SymbolTable) -> Result { + let mut reducer = Reducer::new(symbol_table); let _ = input.visit(&mut reducer).map_err(|e| e.to_string())?; reducer.output() }