aboutsummaryrefslogtreecommitdiffstats
path: root/src/repl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repl.cpp')
-rw-r--r--src/repl.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/repl.cpp b/src/repl.cpp
index afa81e9..16d766f 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -32,8 +32,8 @@ using namespace std;
static inline const AST*
dump(CEnv& cenv, const Code& code)
{
- for (Code::const_iterator i = code.begin(); i != code.end(); ++i)
- pprint(cout, *i, &cenv, (cenv.args.find("-a") != cenv.args.end()));
+ for (auto c : code)
+ pprint(cout, c, &cenv, (cenv.args.find("-a") != cenv.args.end()));
return 0;
}
@@ -91,8 +91,8 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
// Convert to CPS (currently not used in the compilation process)
if (cenv.args.find("-C") != cenv.args.end()) {
Code cps;
- for (Code::const_iterator i = parsed.begin(); i != parsed.end(); ++i) {
- const AST* exp = resp_cps(cenv, *i, cenv.penv.sym("display"));
+ for (auto i : parsed) {
+ const AST* exp = resp_cps(cenv, i, cenv.penv.sym("display"));
if (exp) {
cps.push_back(exp);
}
@@ -120,8 +120,8 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
for (const Pass* p = passes; p->pass; ++p) {
const Code& input = stages.back();
Code output;
- for (Code::const_iterator i = input.begin(); i != input.end(); ++i) {
- const AST* exp = (*p->pass)(cenv, output, *i);
+ for (auto i : input) {
+ const AST* exp = (*p->pass)(cenv, output, i);
if (exp) {
output.push_back(exp);
}
@@ -136,18 +136,18 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
// Flatten expressions
const AST* retT = NULL;
Code exprs;
- for (Code::const_iterator i = stages.back().begin(); i != stages.back().end(); ++i) {
- const ATuple* call = (*i)->to_tuple();
- if (call && (is_form(*i, "def-type")
- || (is_form(*i, "define") && is_form(call->frrst(), "lambda")))) {
+ for (auto i : stages.back()) {
+ const ATuple* call = i->to_tuple();
+ if (call && (is_form(i, "def-type")
+ || (is_form(i, "define") && is_form(call->frrst(), "lambda")))) {
resp_flatten(cenv, defs, call);
- } else if (call && is_form(*i, "prot")) {
- defs.push_back(*i);
+ } else if (call && is_form(i, "prot")) {
+ defs.push_back(i);
} else {
- const ATuple* tup = (*i)->to_tuple();
+ const ATuple* tup = i->to_tuple();
if (!tup || !tup->empty()) {
- exprs.push_back(*i);
- retT = cenv.type(*i);
+ exprs.push_back(i);
+ retT = cenv.type(i);
}
}
}
@@ -163,8 +163,8 @@ compile(CEnv& cenv, const Code& parsed, Code& defs, bool& hasMain, const char* m
tup(Cursor(), cenv.penv.sym("fn-start"), main, NULL));
const AST* mainRet = NULL;
- for (Code::const_iterator i = exprs.begin(); i != exprs.end(); ++i)
- mainRet = resp_flatten(cenv, defs, *i);
+ for (auto e : exprs)
+ mainRet = resp_flatten(cenv, defs, e);
defs.push_back(
tup(Cursor(), cenv.penv.sym("fn-end"), main, mainRet, NULL));
@@ -210,9 +210,9 @@ eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute)
}
// Compile flattened code
- for (Code::const_iterator i = defs.begin(); i != defs.end(); ++i) {
- resp_compile(cenv, *i);
- Object::pool.addRoot(*i);
+ for (auto d : defs) {
+ resp_compile(cenv, d);
+ Object::pool.addRoot(d);
}
if (cenv.args.find("-S") != cenv.args.end()) {
cenv.engine()->writeModule(cenv, cenv.out);
@@ -274,8 +274,8 @@ repl(CEnv& cenv)
}
// Compile flattened code
- for (Code::const_iterator i = defs.begin(); i != defs.end(); ++i) {
- resp_compile(cenv, *i);
+ for (auto d : defs) {
+ resp_compile(cenv, d);
}
if (cenv.args.find("-S") != cenv.args.end()) {
cenv.engine()->writeModule(cenv, cenv.out);