use crate::StaticAnalyzer;
use leo_ast::*;
use snarkvm::console::network::Network;
impl<N: Network> ExpressionVisitor for StaticAnalyzer<'_, N> {
type AdditionalInput = ();
type Output = ();
fn visit_associated_function(
&mut self,
input: &AssociatedFunctionExpression,
_additional: &Self::AdditionalInput,
) -> Self::Output {
let core_function = match CoreFunction::from_symbols(input.variant.name, input.name.name) {
Some(core_function) => core_function,
None => unreachable!("Typechecking guarantees that this function exists."),
};
if core_function == CoreFunction::FutureAwait {
self.assert_future_await(&input.arguments.first(), input.span());
}
}
fn visit_call(&mut self, input: &CallExpression, _: &Self::AdditionalInput) -> Self::Output {
let Expression::Identifier(ident) = &*input.function else {
unreachable!("Parsing guarantees that a function name is always an identifier.");
};
let caller_program = self.current_program.unwrap();
let callee_program = input.program.unwrap_or(caller_program);
if self.non_async_external_call_seen
&& self.variant == Some(Variant::AsyncTransition)
&& callee_program != caller_program
{
self.assert_simple_async_transition_call(callee_program, ident.name, input.span());
}
let function_program = input.program.unwrap_or(self.current_program.unwrap());
let func_symbol = self
.symbol_table
.lookup_function(Location::new(function_program, ident.name))
.expect("Type checking guarantees functions exist.");
if func_symbol.function.variant == Variant::Transition {
self.non_async_external_call_seen = true;
}
}
}