diff options
author | David Robillard <d@drobilla.net> | 2012-12-15 07:06:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-12-15 07:06:22 +0000 |
commit | 10174ffc7ea08b7845dbe409a11811e820536468 (patch) | |
tree | c74187d11b7f35c739045e7000d2fa505ac9499a /src/compile.cpp | |
parent | 8148e755d3f587e6c212ba90efc151ea07de2703 (diff) | |
download | resp-10174ffc7ea08b7845dbe409a11811e820536468.tar.gz resp-10174ffc7ea08b7845dbe409a11811e820536468.tar.bz2 resp-10174ffc7ea08b7845dbe409a11811e820536468.zip |
Compile constructors as LLVM struct types.
Use LLVM type names instead of hyper verbose literal types in more places in general.
More work on quoting.
git-svn-id: http://svn.drobilla.net/resp/trunk@439 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index de53388..917944a 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -60,17 +60,21 @@ compile_cons(CEnv& cenv, const ATuple* cons) throw() return compile_literal_symbol(cenv, cons->frst()->as_symbol()); } - const ASymbol* tname = cons->fst()->as_symbol(); - ATuple* type = new ATuple(tname, NULL, Cursor()); + const ASymbol* sym = cons->fst()->as_symbol(); + ATuple* type = new ATuple(sym, NULL, Cursor()); List tlist(type); vector<CVal> fields; for (ATuple::const_iterator i = cons->iter_at(1); i != cons->end(); ++i) { tlist.push_back(cenv.type(*i)); fields.push_back(resp_compile(cenv, *i)); } - const std::string tstr = cenv.type(cons, Subst(), false)->as_symbol()->str(); + + std::string name = sym->str(); + if (name == "Closure") { + name = cenv.type(cons, Subst(), false)->as_symbol()->str(); + } return cenv.engine()->compileCons( - cenv, tstr.c_str(), type, compile_literal_symbol(cenv, tname), fields); + cenv, name.c_str(), type, compile_literal_symbol(cenv, sym), fields); } static CVal @@ -107,11 +111,11 @@ compile_def_type(CEnv& cenv, const ATuple* def) throw() { const ASymbol* name = def->frst()->to_symbol(); if (name) { - cenv.engine()->compileType(cenv, name->sym(), def->frrst()); + cenv.engine()->compileType(cenv, name->str(), def->frrst()); cenv.tenv.def(name, def->frrst()); } else { name = def->frst()->as_tuple()->fst()->as_symbol(); - cenv.engine()->compileType(cenv, name->sym(), def->frst()); + cenv.engine()->compileType(cenv, name->str(), 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(); @@ -143,7 +147,7 @@ compile_call(CEnv& cenv, const ATuple* call) throw() ATuple::const_iterator p = protT->iter_at(0); for (ATuple::const_iterator a = call->iter_at(2); a != call->end(); ++a, ++p) { CVal arg = resp_compile(cenv, *a); - if (cenv.type(*a) != cenv.resolveType(*p)) { + if (cenv.type(*a) != *p && cenv.type(*a) != cenv.resolveType(*p)) { args.push_back(cenv.engine()->compileCast(cenv, arg, *p)); } else { args.push_back(arg); |