summaryrefslogtreecommitdiffstats
path: root/crates/rebel-lang/src/func.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-lang/src/func.rs')
-rw-r--r--crates/rebel-lang/src/func.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/rebel-lang/src/func.rs b/crates/rebel-lang/src/func.rs
new file mode 100644
index 0000000..19d3ea0
--- /dev/null
+++ b/crates/rebel-lang/src/func.rs
@@ -0,0 +1,33 @@
+use std::fmt::Display;
+
+use rebel_parse::ast::Block;
+
+use crate::{typing::Type, value::Value, Result};
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Func {
+ pub typ: FuncType,
+ pub def: 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 {
+ param_names: Vec<String>,
+ block: Block<'static>,
+ },
+}