diff options
Diffstat (limited to 'src/c.cpp')
-rw-r--r-- | src/c.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -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 |