use crate::{
GlobalItemsCollection,
GlobalVarsCollection,
Pass,
PathResolution,
SymbolTable,
TypeChecking,
TypeCheckingInput,
};
use leo_ast::ProgramReconstructor as _;
use leo_errors::Result;
use leo_span::Symbol;
mod ast;
mod program;
mod visitor;
use visitor::*;
pub struct ProcessingAsync;
impl Pass for ProcessingAsync {
type Input = TypeCheckingInput;
type Output = ();
const NAME: &str = "ProcessingAsync";
fn do_pass(input: Self::Input, state: &mut crate::CompilerState) -> Result<Self::Output> {
let mut ast = std::mem::take(&mut state.ast);
let mut visitor = ProcessingAsyncVisitor {
state,
max_inputs: input.max_inputs,
current_program: Symbol::intern(""),
current_function: Symbol::intern(""),
new_async_functions: Vec::new(),
modified: false,
};
ast.ast = visitor.reconstruct_program(ast.ast);
visitor.state.handler.last_err()?;
visitor.state.ast = ast;
if visitor.modified {
visitor.state.symbol_table = SymbolTable::default();
GlobalVarsCollection::do_pass((), state)?;
PathResolution::do_pass((), state)?;
GlobalItemsCollection::do_pass((), state)?;
TypeChecking::do_pass(input.clone(), state)?;
}
Ok(())
}
}