y_lang/typechecker/
info.rs

1use crate::loader::Module;
2
3use super::variabletype::VariableType;
4
5/// Struct containing type information about a certain expression.
6#[derive(Default, Debug, Clone, PartialEq, Eq)]
7pub struct TypeInfo {
8    /// The concrete type of the expression associated with this type information.
9    pub _type: VariableType,
10    /// The module, where this expression (or at least the value of this expression) originates
11    /// from.
12    pub source: Option<Module<()>>,
13}
14
15impl TypeInfo {
16    /// The size of the type of this expression in memory.
17    pub fn var_size(&self) -> usize {
18        self._type.size()
19    }
20
21    pub fn source(&self) -> Option<Module<()>> {
22        self.source.clone()
23    }
24}