aboutsummaryrefslogtreecommitdiffstats
path: root/src/compile.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-02 06:16:29 +0000
committerDavid Robillard <d@drobilla.net>2010-12-02 06:16:29 +0000
commit563a807be78bfe12e5bfbb9ff0d6da44242696c4 (patch)
tree13cf7ce3b90d072d6e7106c7d2eb4da33209acb0 /src/compile.cpp
parent32ac40a9ef62d2109563e36fb7cd478426c3489f (diff)
downloadresp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.tar.gz
resp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.tar.bz2
resp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.zip
Represent code as list structure (i.e. traditional LISP lists built from pairs), rather than tuple structure.
Remove unused/crufty depoly stage. Remove cps from AST interface (but keep cps.cpp code around for later). Improved command line interface for compilation stages (options -T -L -S). git-svn-id: http://svn.drobilla.net/resp/resp@277 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/compile.cpp')
-rw-r--r--src/compile.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index e2d306a..da9683e 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -40,7 +40,7 @@ AString::compile(CEnv& cenv) const throw()
CVal
AQuote::compile(CEnv& cenv) const throw()
{
- return (*(begin() + 1))->compile(cenv);
+ return list_ref(1)->compile(cenv);
}
CVal
@@ -77,7 +77,7 @@ AFn::compile(CEnv& cenv) const throw()
// Write function body
CVal retVal = NULL;
- for (AFn::const_iterator i = begin() + 2; i != end(); ++i)
+ for (AFn::const_iterator i = iter_at(2); i != end(); ++i)
retVal = (*i)->compile(cenv);
// Write function conclusion
@@ -101,7 +101,7 @@ ACall::compile(CEnv& cenv) const throw()
f = cenv.currentFn; // Recursive call (callee defined as a stub)
vector<CVal> args;
- for (const_iterator e = begin() + 1; e != end(); ++e)
+ for (const_iterator e = iter_at(1); e != end(); ++e)
args.push_back((*e)->compile(cenv));
return cenv.engine()->compileCall(cenv, f, cenv.type(head()), args);
@@ -136,10 +136,11 @@ ACons::compile(CEnv& cenv) const throw()
CVal
ATuple::compile(CEnv& cenv) const throw()
{
- AType* type = tup<AType>(loc, const_cast<ASymbol*>(head()->as<const ASymbol*>()), 0);
+ AType* type = new AType(const_cast<ASymbol*>(head()->as<const ASymbol*>()), NULL, Cursor());
+ TList tlist(type);
vector<CVal> fields;
- for (const_iterator i = begin() + 1; i != end(); ++i) {
- type->push_back(const_cast<AType*>(cenv.type(*i)));
+ for (const_iterator i = iter_at(1); i != end(); ++i) {
+ tlist.push_back(const_cast<AType*>(cenv.type(*i)));
fields.push_back((*i)->compile(cenv));
}
return cenv.engine()->compileTup(cenv, type, type->compile(cenv), fields);
@@ -162,9 +163,9 @@ AType::compile(CEnv& cenv) const throw()
CVal
ADot::compile(CEnv& cenv) const throw()
{
- const_iterator i = begin();
- AST* tup = *++i;
- ALiteral<int32_t>* index = (*++i)->as<ALiteral<int32_t>*>();
+ const_iterator i = begin();
+ const AST* tup = *++i;
+ const ALiteral<int32_t>* index = (*++i)->as<const ALiteral<int32_t>*>();
CVal tupVal = tup->compile(cenv);
return cenv.engine()->compileDot(cenv, tupVal, index->val);
}