Files
lang/src/ir/lvl1/def.rs
2024-11-26 22:42:39 -05:00

38 lines
638 B
Rust

use super::{FileSpan, Type};
use std::fmt::Debug;
pub struct FnDef {
pub name: String,
pub args: Vec<VarDef>,
pub ret: Type,
pub origin: Origin,
}
pub struct TypeDef {
pub name: String,
pub args: usize,
pub origin: Origin,
}
#[derive(Clone)]
pub struct VarDef {
pub name: String,
pub ty: Type,
pub origin: Origin,
}
#[derive(Debug, Clone, Copy)]
pub enum Origin {
Builtin,
File(FileSpan),
}
impl FnDef {
pub fn ty(&self) -> Type {
Type::Fn {
args: self.args.iter().map(|a| a.ty.clone()).collect(),
ret: Box::new(self.ret.clone()),
}
}
}