about summary refs log tree commit diff
path: root/users/glittershark/achilles/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'users/glittershark/achilles/src/ast')
-rw-r--r--users/glittershark/achilles/src/ast/hir.rs20
-rw-r--r--users/glittershark/achilles/src/ast/mod.rs14
2 files changed, 30 insertions, 4 deletions
diff --git a/users/glittershark/achilles/src/ast/hir.rs b/users/glittershark/achilles/src/ast/hir.rs
index 6859174a2dd0..0212b3dbcdbb 100644
--- a/users/glittershark/achilles/src/ast/hir.rs
+++ b/users/glittershark/achilles/src/ast/hir.rs
@@ -219,12 +219,19 @@ pub enum Decl<'a, T> {
         body: Box<Expr<'a, T>>,
         type_: T,
     },
+
+    Extern {
+        name: Ident<'a>,
+        arg_types: Vec<T>,
+        ret_type: T,
+    },
 }
 
 impl<'a, T> Decl<'a, T> {
-    pub fn type_(&self) -> &T {
+    pub fn type_(&self) -> Option<&T> {
         match self {
-            Decl::Fun { type_, .. } => type_,
+            Decl::Fun { type_, .. } => Some(type_),
+            Decl::Extern { .. } => None,
         }
     }
 
@@ -247,6 +254,15 @@ impl<'a, T> Decl<'a, T> {
                 body: Box::new(body.traverse_type(f.clone())?),
                 type_: f(type_)?,
             }),
+            Decl::Extern {
+                name,
+                arg_types,
+                ret_type,
+            } => Ok(Decl::Extern {
+                name,
+                arg_types: arg_types.into_iter().map(f.clone()).try_collect()?,
+                ret_type: f(ret_type)?,
+            }),
         }
     }
 }
diff --git a/users/glittershark/achilles/src/ast/mod.rs b/users/glittershark/achilles/src/ast/mod.rs
index 3a2261aeda23..22d16c93645c 100644
--- a/users/glittershark/achilles/src/ast/mod.rs
+++ b/users/glittershark/achilles/src/ast/mod.rs
@@ -265,8 +265,18 @@ impl<'a> Fun<'a> {
 
 #[derive(Debug, PartialEq, Eq, Clone)]
 pub enum Decl<'a> {
-    Fun { name: Ident<'a>, body: Fun<'a> },
-    Ascription { name: Ident<'a>, type_: Type<'a> },
+    Fun {
+        name: Ident<'a>,
+        body: Fun<'a>,
+    },
+    Ascription {
+        name: Ident<'a>,
+        type_: Type<'a>,
+    },
+    Extern {
+        name: Ident<'a>,
+        type_: FunctionType<'a>,
+    },
 }
 
 ////