diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-05-28 14:28:07 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-05-28 23:00:47 -0700 |
commit | 5987486862b8c989452bc62d359168a5686b462e (patch) | |
tree | 4b8aa541eb7bbf614619d49723ddea6198163689 /071recipe.cc | |
parent | ec7c8c8b7434f498098c6b3417bb9c47d5b12881 (diff) | |
download | mu-5987486862b8c989452bc62d359168a5686b462e.tar.gz |
3887 - clean up early exits in interpreter loop
It's always confusing when `break` refers to a `switch` but `continue` refers to the loop around the `switch`. But we've done ugly things like this and `goto` for expedience. However, we're starting to run into cases where we now need to insert code at every `continue` or `continue`-mimicking `goto` inside the core interpreter loop. Better to make the loop single-entry-single-exit. Common things to run after every instruction will now happen inside the `finish_instruction` function rather than at the `finish_instruction` label.
Diffstat (limited to '071recipe.cc')
-rw-r--r-- | 071recipe.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/071recipe.cc b/071recipe.cc index 1a145ed6..c44d3127 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -114,13 +114,17 @@ case CALL: { raise << maybe(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end(); break; } - instruction/*copy*/ call_instruction = current_instruction(); + const call& caller_frame = current_call(); + instruction/*copy*/ call_instruction = to_instruction(caller_frame); call_instruction.operation = ingredients.at(0).at(0); call_instruction.ingredients.erase(call_instruction.ingredients.begin()); Current_routine->calls.push_front(call(ingredients.at(0).at(0))); ingredients.erase(ingredients.begin()); // drop the callee finish_call_housekeeping(call_instruction, ingredients); - continue; + // not done with caller + write_products = false; + fall_through_to_next_instruction = false; + break; } //:: check types for 'call' instructions |