summaryrefslogtreecommitdiffstats
path: root/crates/rebel-lang/src/func.rs
blob: 8f1aed3f626fdcbe9f84589eb5e83dd224e0dc73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::fmt::Display;

use crate::{
	typing::Type,
	value::{Result, Value},
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Func {
	pub typ: FuncType,
	pub def: Option<FuncDef>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FuncType {
	pub params: Vec<Type>,
	pub ret: Type,
}

impl Display for FuncType {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		// TODO
		write!(f, "fn( ... ) -> {}", self.ret)
	}
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FuncDef {
	Intrinsic(fn(&[Value]) -> Result<Value>),
	Body,
}