diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-10-28 06:27:01 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-10-28 06:27:01 -0700 |
commit | 67573caf07392a89df841ef47cc98e5b91a13205 (patch) | |
tree | 82698363791699f96fbfb6fd6a9e9749996476f4 | |
parent | 5810092d53f44e639c7bfd4e62d1960c323dcb6f (diff) | |
download | mu-67573caf07392a89df841ef47cc98e5b91a13205.tar.gz |
2297
-rw-r--r-- | 034call.cc | 11 | ||||
-rw-r--r-- | 035call_ingredient.cc | 20 | ||||
-rw-r--r-- | 043new.cc | 2 | ||||
-rw-r--r-- | 044space.cc | 10 | ||||
-rw-r--r-- | 045space_surround.cc | 2 | ||||
-rw-r--r-- | 072scenario_screen.cc | 4 |
6 files changed, 27 insertions, 22 deletions
diff --git a/034call.cc b/034call.cc index 87d0d601..f33e6053 100644 --- a/034call.cc +++ b/034call.cc @@ -64,22 +64,27 @@ routine::routine(recipe_ordinal r) { // End routine Constructor } +:(code) +inline call& current_call() { + return Current_routine->calls.front(); +} + //:: now update routine's helpers :(replace{} "inline long long int& current_step_index()") inline long long int& current_step_index() { assert(!Current_routine->calls.empty()); - return Current_routine->calls.front().running_step_index; + return current_call().running_step_index; } :(replace{} "inline const string& current_recipe_name()") inline const string& current_recipe_name() { assert(!Current_routine->calls.empty()); - return Recipe[Current_routine->calls.front().running_recipe].name; + return Recipe[current_call().running_recipe].name; } :(replace{} "inline const instruction& current_instruction()") inline const instruction& current_instruction() { assert(!Current_routine->calls.empty()); - return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index); + return Recipe[current_call().running_recipe].steps.at(current_call().running_step_index); } :(after "Defined Recipe Checks") diff --git a/035call_ingredient.cc b/035call_ingredient.cc index 01036728..41e7811b 100644 --- a/035call_ingredient.cc +++ b/035call_ingredient.cc @@ -29,8 +29,8 @@ next_ingredient_to_process = 0; :(before "End Call Housekeeping") for (long long int i = 0; i < SIZE(ingredients); ++i) { - Current_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i)); - Current_routine->calls.front().ingredient_types.push_back(call_instruction.ingredients.at(i).type); + current_call().ingredient_atoms.push_back(ingredients.at(i)); + current_call().ingredient_types.push_back(call_instruction.ingredients.at(i).type); } :(before "End Primitive Recipe Declarations") @@ -48,12 +48,12 @@ case NEXT_INGREDIENT: { :(before "End Primitive Recipe Implementations") case NEXT_INGREDIENT: { assert(!Current_routine->calls.empty()); - if (Current_routine->calls.front().next_ingredient_to_process < SIZE(Current_routine->calls.front().ingredient_atoms)) { + if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) { products.push_back( - Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process)); + current_call().ingredient_atoms.at(current_call().next_ingredient_to_process)); assert(SIZE(products) == 1); products.resize(2); // push a new vector products.at(1).push_back(1); - ++Current_routine->calls.front().next_ingredient_to_process; + ++current_call().next_ingredient_to_process; } else { if (SIZE(current_instruction().products) < 2) @@ -105,7 +105,7 @@ case REWIND_INGREDIENTS: { } :(before "End Primitive Recipe Implementations") case REWIND_INGREDIENTS: { - Current_routine->calls.front().next_ingredient_to_process = 0; + current_call().next_ingredient_to_process = 0; break; } @@ -138,13 +138,13 @@ case INGREDIENT: { } :(before "End Primitive Recipe Implementations") case INGREDIENT: { - if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(Current_routine->calls.front().ingredient_atoms)) { - Current_routine->calls.front().next_ingredient_to_process = ingredients.at(0).at(0); + if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) { + current_call().next_ingredient_to_process = ingredients.at(0).at(0); products.push_back( - Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process)); + current_call().ingredient_atoms.at(current_call().next_ingredient_to_process)); assert(SIZE(products) == 1); products.resize(2); // push a new vector products.at(1).push_back(1); - ++Current_routine->calls.front().next_ingredient_to_process; + ++current_call().next_ingredient_to_process; } else { if (SIZE(current_instruction().products) > 1) { diff --git a/043new.cc b/043new.cc index 34ccf18b..4604a4fa 100644 --- a/043new.cc +++ b/043new.cc @@ -367,7 +367,7 @@ Current_routine = main_routine; for (long long int i = 1; i < argc; ++i) { vector<double> arg; arg.push_back(new_mu_string(argv[i])); - Current_routine->calls.front().ingredient_atoms.push_back(arg); + current_call().ingredient_atoms.push_back(arg); } //: stash recognizes strings diff --git a/044space.cc b/044space.cc index 598c8847..57faa054 100644 --- a/044space.cc +++ b/044space.cc @@ -174,7 +174,7 @@ void try_reclaim_locals() { if (Recipe[r].steps.empty()) return; const instruction& inst = Recipe[r].steps.at(0); if (inst.name != "local-scope") return; - abandon(Current_routine->calls.front().default_space, + abandon(current_call().default_space, /*array length*/1+/*number-of-locals*/Name[r][""]); } @@ -192,8 +192,8 @@ void rewrite_default_space_instruction(instruction& curr) { //:: helpers :(code) -long long int space_base(const reagent& x) { - return Current_routine->calls.front().default_space; +long long int space_base(const reagent& x) { // temporary + return current_call().default_space; } long long int address(long long int offset, long long int base) { @@ -217,7 +217,7 @@ long long int address(long long int offset, long long int base) { || x.type->right->right->right) { raise_error << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); } - Current_routine->calls.front().default_space = data.at(0); + current_call().default_space = data.at(0); return; } @@ -231,6 +231,6 @@ recipe main [ :(after "vector<double> read_memory(reagent x)") if (x.name == "default-space") { vector<double> result; - result.push_back(Current_routine->calls.front().default_space); + result.push_back(current_call().default_space); return result; } diff --git a/045space_surround.cc b/045space_surround.cc index b55c5e04..880c350e 100644 --- a/045space_surround.cc +++ b/045space_surround.cc @@ -27,7 +27,7 @@ recipe main [ :(replace{} "long long int space_base(const reagent& x)") long long int space_base(const reagent& x) { - return space_base(x, space_index(x), Current_routine->calls.front().default_space); + return space_base(x, space_index(x), current_call().default_space); } long long int space_base(const reagent& x, long long int space_index, long long int base) { diff --git a/072scenario_screen.cc b/072scenario_screen.cc index 4ecbbd4d..ed2ddad3 100644 --- a/072scenario_screen.cc +++ b/072scenario_screen.cc @@ -197,7 +197,7 @@ struct raw_string_stream { :(code) void check_screen(const string& expected_contents, const int color) { - assert(!Current_routine->calls.front().default_space); // not supported + assert(!current_call().default_space); // not supported long long int screen_location = Memory[SCREEN]; int data_offset = find_element_name(Type_ordinal["screen"], "data", ""); assert(data_offset >= 0); @@ -332,7 +332,7 @@ case _DUMP_SCREEN: { :(code) void dump_screen() { - assert(!Current_routine->calls.front().default_space); // not supported + assert(!current_call().default_space); // not supported long long int screen_location = Memory[SCREEN]; int width_offset = find_element_name(Type_ordinal["screen"], "num-columns", ""); long long int screen_width = Memory[screen_location+width_offset]; |