This commit is contained in:
Kartik K. Agaram 2015-04-24 20:23:34 -07:00
parent dcfca05e08
commit 8eff791921
2 changed files with 11 additions and 11 deletions

View File

@ -32,8 +32,8 @@ recipe main [
//: Later layers will change this.
struct routine {
recipe_number running_recipe;
size_t running_at;
routine(recipe_number r) :running_recipe(r), running_at(0) {}
size_t running_step_index;
routine(recipe_number r) :running_recipe(r), running_step_index(0) {}
bool completed() const;
};
@ -52,7 +52,7 @@ void run_current_routine()
while (!Current_routine->completed()) // later layers will modify condition
{
// Running One Instruction.
size_t& pc = running_at();
size_t& pc = current_step_index();
//? trace("foo") << "2: " << pc << " " << &pc; //? 1
if (current_instruction().is_label) { ++pc; continue; }
//? cout << "AAA " << Trace_stream << " ^" << Trace_stream->dump_layer << "$\n"; //? 1
@ -83,8 +83,8 @@ void run_current_routine()
//: We'll need to override these later as we change the definition of routine.
//: Important that they return referrences into the routine.
inline size_t& running_at() {
return Current_routine->running_at;
inline size_t& current_step_index() {
return Current_routine->running_step_index;
}
inline string recipe_name() {
@ -96,11 +96,11 @@ inline vector<instruction>& steps() {
}
inline const instruction& current_instruction() {
return Recipe[Current_routine->running_recipe].steps[Current_routine->running_at];
return Recipe[Current_routine->running_recipe].steps[Current_routine->running_step_index];
}
inline bool routine::completed() const {
return Current_routine->running_at >= Recipe[running_recipe].steps.size();
return Current_routine->running_step_index >= Recipe[running_recipe].steps.size();
}
:(before "End Commandline Parsing")

View File

@ -53,8 +53,8 @@ struct routine {
//:: now update routine's helpers
:(replace{} "inline size_t& running_at()")
inline size_t& running_at() {
:(replace{} "inline size_t& current_step_index()")
inline size_t& current_step_index() {
return Current_routine->calls.top().pc;
}
:(replace{} "inline string recipe_name()")
@ -92,12 +92,12 @@ inline bool routine::completed() const {
// when we reach the end of one call, we may reach the end of the one below
// it, and the one below that, and so on
//? trace("foo") << "0: " << pc << " " << &pc; //? 1
while (running_at() >= steps().size()) {
while (current_step_index() >= steps().size()) {
//? trace("foo") << "pop"; //? 1
Current_routine->calls.pop();
if (Current_routine->calls.empty()) return;
// todo: no results returned warning
++running_at();
++current_step_index();
}
//? trace("foo") << "1: " << pc << " " << &pc; //? 1