diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 20:07:17 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-24 20:16:21 -0700 |
commit | dcfca05e08744270b3145f7906c5cd46485a4b52 (patch) | |
tree | 673e8715688bdc3990bbfe9077158e764690ec01 /cpp/035call | |
parent | 69e14325e3eaa3722766bb9706d7da5862b6ea26 (diff) | |
download | mu-dcfca05e08744270b3145f7906c5cd46485a4b52.tar.gz |
1171
Chip away at eliminating that 'pc' reference by first throwing out the most common expression that uses it: instructions[pc].
Diffstat (limited to 'cpp/035call')
-rw-r--r-- | cpp/035call | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cpp/035call b/cpp/035call index c7052e62..799cb739 100644 --- a/cpp/035call +++ b/cpp/035call @@ -65,15 +65,19 @@ inline string recipe_name() { inline vector<instruction>& steps() { return Recipe[Current_routine->calls.top().running_recipe].steps; } +:(replace{} "inline const instruction& current_instruction()") +inline const instruction& current_instruction() { + return Recipe[Current_routine->calls.top().running_recipe].steps[Current_routine->calls.top().pc]; +} :(replace{} "default:" following "End Primitive Recipe Implementations") default: { // not a primitive; try to look up the book of recipes - if (Recipe.find(instructions[pc].operation) == Recipe.end()) { - raise << "undefined operation " << instructions[pc].operation << ": " << instructions[pc].name << '\n'; + if (Recipe.find(current_instruction().operation) == Recipe.end()) { + raise << "undefined operation " << current_instruction().operation << ": " << current_instruction().name << '\n'; break; } - Current_routine->calls.push(call(instructions[pc].operation)); + Current_routine->calls.push(call(current_instruction().operation)); continue; // not done with caller; don't increment pc } |