diff options
author | David Robillard <d@drobilla.net> | 2012-12-15 21:48:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-12-15 21:48:21 +0000 |
commit | d3708205163f784343733661d9fa01ff14f8b751 (patch) | |
tree | a771a4956753c66cd2c8b7c5eb9f1e4a0b30834a /src/compile.cpp | |
parent | 10174ffc7ea08b7845dbe409a11811e820536468 (diff) | |
download | resp-d3708205163f784343733661d9fa01ff14f8b751.tar.gz resp-d3708205163f784343733661d9fa01ff14f8b751.tar.bz2 resp-d3708205163f784343733661d9fa01ff14f8b751.zip |
Write forward declarations for all types and functions for mutual and/or nested recursion.
git-svn-id: http://svn.drobilla.net/resp/trunk@440 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 24 |
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") |