use std::fmt::Display;
use serde::{Deserialize, Serialize};
use leo_ast::{Function, Location, Mode, Type};
use leo_span::Span;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum VariableType {
Const,
Input(Mode),
Mut,
}
impl Display for VariableType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use VariableType::*;
match self {
Const => write!(f, "const var"),
Input(m) => write!(f, "{m} input"),
Mut => write!(f, "mut var"),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct VariableSymbol {
pub type_: Type,
pub span: Span,
pub declaration: VariableType,
}
impl Display for VariableSymbol {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.declaration, self.type_)?;
Ok(())
}
}
#[derive(Clone, Debug)]
pub struct FunctionSymbol {
pub function: Function,
pub finalizer: Option<Finalizer>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Finalizer {
pub location: Location,
pub future_inputs: Vec<Location>,
pub inferred_inputs: Vec<Type>,
}