use crate::diagnostics::Span;
use super::analysis_types::{InferredType, ConstraintType};
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct TypeInformation {
pub expression_types: HashMap<Span, InferredType>,
pub function_signatures: HashMap<String, FunctionSignature>,
pub constraints: Vec<TypeConstraint>,
pub errors: Vec<TypeError>,
}
#[derive(Debug, Clone)]
pub struct FunctionSignature {
pub name: String,
pub parameters: Vec<InferredType>,
pub return_type: InferredType,
pub variadic: bool,
}
#[derive(Debug, Clone)]
pub struct TypeConstraint {
pub left: InferredType,
pub right: InferredType,
pub constraint_type: ConstraintType,
pub location: Option<Span>,
}
#[derive(Debug, Clone)]
pub struct TypeError {
pub message: String,
pub expected: Option<InferredType>,
pub actual: Option<InferredType>,
pub location: Option<Span>,
}
impl TypeInformation {
pub fn new() -> Self {
Self {
expression_types: HashMap::new(),
function_signatures: HashMap::new(),
constraints: Vec::new(),
errors: Vec::new(),
}
}
}
impl Default for TypeInformation {
fn default() -> Self {
Self::new()
}
}