use super::StaticAnalyzingVisitor;
use leo_ast::*;
impl ExpressionVisitor for StaticAnalyzingVisitor<'_> {
type AdditionalInput = ();
type Output = ();
fn visit_associated_function(
&mut self,
input: &AssociatedFunctionExpression,
_additional: &Self::AdditionalInput,
) -> Self::Output {
let Some(core_function) = CoreFunction::from_symbols(input.variant.name, input.name.name) else {
panic!("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 {
panic!("Parsing guarantees that a function name is always an identifier.");
};
let caller_program = self.current_program;
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);
let func_symbol = self
.state
.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;
}
}
}