diff --git a/compiler/passes/src/symbol_table/create.rs b/compiler/passes/src/symbol_table/create.rs index c13fc8c0e0..aaa85c5e26 100644 --- a/compiler/passes/src/symbol_table/create.rs +++ b/compiler/passes/src/symbol_table/create.rs @@ -36,22 +36,23 @@ impl<'a> CreateSymbolTable<'a> { } } -impl<'a> ExpressionVisitor<'a> for CreateSymbolTable<'a> {} +impl<'a> ExpressionVisitor<'a> for CreateSymbolTable<'a> { + type AdditionalInput = (); + type Output = (); +} impl<'a> StatementVisitor<'a> for CreateSymbolTable<'a> {} impl<'a> ProgramVisitor<'a> for CreateSymbolTable<'a> { - fn visit_function(&mut self, input: &'a Function) -> VisitResult { + fn visit_function(&mut self, input: &'a Function) { if let Err(err) = self.symbol_table.insert_fn(input.name(), input) { self.handler.emit_err(err); } - VisitResult::SkipChildren } - fn visit_circuit(&mut self, input: &'a Circuit) -> VisitResult { + fn visit_circuit(&mut self, input: &'a Circuit) { if let Err(err) = self.symbol_table.insert_circuit(input.name(), input) { self.handler.emit_err(err); } - VisitResult::SkipChildren } } diff --git a/compiler/passes/src/symbol_table/director.rs b/compiler/passes/src/symbol_table/director.rs deleted file mode 100644 index 8dfe4190fa..0000000000 --- a/compiler/passes/src/symbol_table/director.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2019-2022 Aleo Systems Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -use leo_ast::{ExpressionVisitorDirector, ProgramVisitorDirector, StatementVisitorDirector, VisitorDirector}; -use leo_errors::emitter::Handler; - -use crate::CreateSymbolTable; - -pub(crate) struct Director<'a> { - visitor: CreateSymbolTable<'a>, -} - -impl<'a> Director<'a> { - pub(crate) fn new(handler: &'a Handler) -> Self { - Self { - visitor: CreateSymbolTable::new(handler), - } - } -} - -impl<'a> VisitorDirector<'a> for Director<'a> { - type Visitor = CreateSymbolTable<'a>; - - fn visitor(self) -> Self::Visitor { - self.visitor - } - - fn visitor_ref(&mut self) -> &mut Self::Visitor { - &mut self.visitor - } -} - -impl<'a> ExpressionVisitorDirector<'a> for Director<'a> { - type AdditionalInput = (); - type Output = (); -} - -impl<'a> StatementVisitorDirector<'a> for Director<'a> {} - -impl<'a> ProgramVisitorDirector<'a> for Director<'a> {} diff --git a/compiler/passes/src/symbol_table/mod.rs b/compiler/passes/src/symbol_table/mod.rs index 89ee6a0fcf..8d38d53b23 100644 --- a/compiler/passes/src/symbol_table/mod.rs +++ b/compiler/passes/src/symbol_table/mod.rs @@ -17,9 +17,6 @@ pub mod create; pub use create::*; -pub mod director; -use director::*; - pub mod table; pub use table::*; @@ -31,7 +28,7 @@ pub use variable_symbol::*; use crate::Pass; -use leo_ast::{Ast, ProgramVisitorDirector, VisitorDirector}; +use leo_ast::{Ast, ProgramVisitor}; use leo_errors::{emitter::Handler, Result}; impl<'a> Pass for CreateSymbolTable<'a> { @@ -39,7 +36,7 @@ impl<'a> Pass for CreateSymbolTable<'a> { type Output = Result>; fn do_pass((ast, handler): Self::Input) -> Self::Output { - let mut visitor = Director::new(handler); + let mut visitor = CreateSymbolTable::new(handler); visitor.visit_program(ast.as_repr()); handler.last_err()?;