aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 917944a..64dee08 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -111,8 +111,12 @@ compile_def_type(CEnv& cenv, const ATuple* def) throw()
{
const ASymbol* name = def->frst()->to_symbol();
if (name) {
- cenv.engine()->compileType(cenv, name->str(), def->frrst());
- cenv.tenv.def(name, def->frrst());
+ if (def->rrst()) { // Definition
+ cenv.engine()->compileType(cenv, name->str(), def->frrst());
+ cenv.tenv.def(name, def->frrst());
+ } else { // Forward declaration
+ cenv.engine()->compileType(cenv, name->str(), NULL);
+ }
} else {
name = def->frst()->as_tuple()->fst()->as_symbol();
cenv.engine()->compileType(cenv, name->str(), def->frst());
@@ -154,7 +158,19 @@ compile_call(CEnv& cenv, const ATuple* call) throw()
}
}
- return cenv.engine()->compileCall(cenv, f, cenv.type(call->fst())->as_tuple(), args);
+ return cenv.engine()->compileCall(cenv, f, cenv.type(call->frst())->as_tuple(), args);
+}
+
+static CVal
+compile_prot(CEnv& cenv, const ATuple* call) throw()
+{
+ const ASymbol* name = call->list_ref(1)->as_symbol();
+ const ATuple* type = cenv.type(name)->as_tuple();
+ const ATuple* args = call->frrst()->as_tuple()->frst()->as_tuple();
+
+ cenv.engine()->compileProt(cenv, name->sym(), args, type);
+
+ return NULL;
}
static CVal
@@ -220,6 +236,8 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return compile_def_type(cenv, call);
else if (form == "quote")
return compile_quote(cenv, call);
+ else if (form == "prot")
+ return compile_prot(cenv, call);
else if (form == "fn-start")
return compile_fn_start(cenv, call);
else if (form == "fn-end")