diff options
author | David Robillard <d@drobilla.net> | 2010-12-29 00:35:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-29 00:35:28 +0000 |
commit | 42b51cce2575fa138fddf1cfd4581bf1d1568b24 (patch) | |
tree | 03ea8256f19d3418fd4e847391a4b5a84f8b6e0f /src/compile.cpp | |
parent | 703f1840af79ca4480c664190cdcf7e6fbd7b90e (diff) | |
download | resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.tar.gz resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.tar.bz2 resp-42b51cce2575fa138fddf1cfd4581bf1d1568b24.zip |
Literal lists (i.e. list quoting).
Compile type expressions.
Only compile a top-level function if program has code to run (i.e. isn't just definitions).
Cast tuples to Object when necessary to avoid LLVM IR type mismatches (for cons stores and return values).
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/resp/resp@369 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 20 |
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") |