aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 1de8a78..d2f0530 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -63,6 +63,7 @@ compile_cons(CEnv& cenv, const ATuple* cons) throw()
List tlist(type);
vector<CVal> fields;
for (ATuple::const_iterator i = cons->iter_at(1); i != cons->end(); ++i) {
+ assert(cenv.type(*i));
tlist.push_back(cenv.type(*i));
fields.push_back(resp_compile(cenv, *i));
}
@@ -97,6 +98,19 @@ compile_def(CEnv& cenv, const ATuple* def) throw()
}
static CVal
+compile_def_type(CEnv& cenv, const ATuple* def) throw()
+{
+ const ASymbol* name = def->frst()->as_tuple()->fst()->as_symbol();
+ cenv.engine()->compileType(cenv, name->sym(), def->frst());
+ for (ATuple::const_iterator i = def->iter_at(2); i != def->end(); ++i) {
+ const ATuple* exp = (*i)->as_tuple();
+ const ASymbol* tag = (*exp->begin())->as_symbol();
+ cenv.engine()->compileType(cenv, tag->sym(), exp);
+ }
+ return NULL;
+}
+
+static CVal
compile_do(CEnv& cenv, const ATuple* ado) throw()
{
CVal retVal = NULL;
@@ -111,7 +125,7 @@ compile_fn(CEnv& cenv, const ATuple* fn) throw()
{
assert(!cenv.currentFn);
- const AST* type = cenv.type(fn);
+ const AST* const type = cenv.type(fn);
CFunc f = cenv.findImpl(fn, type);
if (f)
return f;
@@ -127,7 +141,7 @@ compile_fn(CEnv& cenv, const ATuple* fn) throw()
retVal = resp_compile(cenv, *i);
// Write function conclusion and pop stack frame
- cenv.engine()->finishFn(cenv, f, retVal);
+ cenv.engine()->finishFn(cenv, f, retVal, type->as_tuple()->frrst());
cenv.pop();
cenv.currentFn = NULL;
@@ -204,7 +218,7 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
else if (form == "def")
return compile_def(cenv, call);
else if (form == "def-type")
- return NULL; // FIXME
+ return compile_def_type(cenv, call);
else if (form == "do")
return compile_do(cenv, call);
else if (form == "fn")