aboutsummaryrefslogtreecommitdiffstats
path: root/src/c.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-08-20 01:58:26 +0000
committerDavid Robillard <d@drobilla.net>2010-08-20 01:58:26 +0000
commit4861eb2317df37c83415debf65480249002f4180 (patch)
tree31da803fc9ec29f657587a7539636fda6307a567 /src/c.cpp
parent594370a2a381545aea8d0631a86f422f84ee2792 (diff)
downloadresp-4861eb2317df37c83415debf65480249002f4180.tar.gz
resp-4861eb2317df37c83415debf65480249002f4180.tar.bz2
resp-4861eb2317df37c83415debf65480249002f4180.zip
Make AST::compile const and make Module compilation API take const AST*.
git-svn-id: http://svn.drobilla.net/resp/resp@265 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/c.cpp')
-rw-r--r--src/c.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/c.cpp b/src/c.cpp
index 7f4a563..66ab971 100644
--- a/src/c.cpp
+++ b/src/c.cpp
@@ -150,14 +150,14 @@ struct CEngine : public Engine {
return varname;
}
- CFunc compileFunction(CEnv& cenv, AFn* fn, const AType* type);
+ CFunc compileFunction(CEnv& cenv, const AFn* fn, const AType* type);
CVal compileTup(CEnv& cenv, const AType* type, const vector<CVal>& fields);
CVal compileDot(CEnv& cenv, CVal tup, int32_t index);
- CVal compileLiteral(CEnv& cenv, AST* lit);
+ CVal compileLiteral(CEnv& cenv, const AST* lit);
CVal compileString(CEnv& cenv, const char* str);
- CVal compilePrimitive(CEnv& cenv, APrimitive* prim);
- CVal compileIf(CEnv& cenv, AIf* aif);
+ CVal compilePrimitive(CEnv& cenv, const APrimitive* prim);
+ CVal compileIf(CEnv& cenv, const AIf* aif);
CVal compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal val);
CVal getGlobal(CEnv& cenv, const string& sym, CVal val);
@@ -196,7 +196,7 @@ CEngine::compileDot(CEnv& cenv, CVal tup, int32_t index)
}
CVal
-CEngine::compileLiteral(CEnv& cenv, AST* lit)
+CEngine::compileLiteral(CEnv& cenv, const AST* lit)
{
return new Value(lit->str());
}
@@ -208,7 +208,7 @@ CEngine::compileString(CEnv& cenv, const char* str)
}
CFunc
-CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type)
+CEngine::compileFunction(CEnv& cenv, const AFn* fn, const AType* type)
{
assert(type->concrete());
@@ -242,7 +242,7 @@ CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type)
// Write function body
try {
CVal retVal = NULL;
- for (AFn::iterator i = fn->begin() + 2; i != fn->end(); ++i)
+ for (AFn::const_iterator i = fn->begin() + 2; i != fn->end(); ++i)
retVal = (*i)->compile(cenv);
cenv.engine()->finishFunction(cenv, f, retVal);
} catch (Error& e) {
@@ -255,13 +255,13 @@ CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType* type)
}
CVal
-CEngine::compileIf(CEnv& cenv, AIf* aif)
+CEngine::compileIf(CEnv& cenv, const AIf* aif)
{
Value* varname = new string(cenv.penv.gensymstr("if"));
out += (format("%s %s;\n") % *llType(cenv.type(aif)) % *varname).str();
size_t idx = 1;
- for (AIf::iterator i = aif->begin() + 1; ; ++i, idx += 2) {
- AIf::iterator next = i;
+ for (AIf::const_iterator i = aif->begin() + 1; ; ++i, idx += 2) {
+ AIf::const_iterator next = i;
if (++next == aif->end())
break;
@@ -287,14 +287,14 @@ CEngine::compileIf(CEnv& cenv, AIf* aif)
}
CVal
-CEngine::compilePrimitive(CEnv& cenv, APrimitive* prim)
+CEngine::compilePrimitive(CEnv& cenv, const APrimitive* prim)
{
- APrimitive::iterator i = prim->begin();
+ APrimitive::const_iterator i = prim->begin();
++i;
Value* a = llVal((*i++)->compile(cenv));
Value* b = llVal((*i++)->compile(cenv));
- const string n = prim->head()->to<ASymbol*>()->str();
+ const string n = prim->head()->to<const ASymbol*>()->str();
string op = n;
// Convert operator to C operator if they don't match