From dcfca05e08744270b3145f7906c5cd46485a4b52 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 24 Apr 2015 20:07:17 -0700 Subject: 1171 Chip away at eliminating that 'pc' reference by first throwing out the most common expression that uses it: instructions[pc]. --- cpp/035call | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cpp/035call') 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& 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 } -- cgit 1.4.1-2-gfad0