:(scenario calling_recipe)
def main [
f
]
def f [
3:num <- add 2, 2
]
+mem: storing 4 in location 3
:(scenario return_on_fallthrough)
def main [
f
1:num <- copy 0
2:num <- copy 0
3:num <- copy 0
]
def f [
4:num <- copy 0
5:num <- copy 0
]
+run: f
+run: {4: "number"} <- copy {0: "literal"}
+run: {5: "number"} <- copy {0: "literal"}
+run: {1: "number"} <- copy {0: "literal"}
+run: {2: "number"} <- copy {0: "literal"}
+run: {3: "number"} <- copy {0: "literal"}
:(before "struct routine {")
struct call {
recipe_ordinal running_recipe;
int running_step_index;
call(recipe_ordinal r) {
running_recipe = r;
running_step_index = 0;
}
~call() {
}
};
typedef list<call> call_stack;
:(replace{} "struct routine")
struct routine {
call_stack calls;
routine(recipe_ordinal r);
bool completed() const;
const vector<instruction>& steps() const;
};
:(code)
routine::routine(recipe_ordinal r) {
if (Trace_stream) {
++Trace_stream->callstack_depth;
trace(9999, "trace") << "new routine; incrementing callstack depth to " << Trace_stream->callstack_depth << end();
assert(Trace_stream->callstack_depth < 9000);
}
calls.push_front(call(r));
}
:(code)
call& current_call() {
return Current_routine->calls.front();
}
:(replace{} "int& current_step_index()")
int& current_step_index() {
assert(!Current_routine->calls.empty());
return current_call().running_step_index;
}
:(replace{} "const string& current_recipe_name()")
const string& current_recipe_name() {
assert(!Current_routine->calls.empty());
return get(Recipe, current_call().running_recipe).name;
}
:(replace{} "const recipe& current_recipe()")
const recipe& current_recipe() {
assert