diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-11-01 02:46:41 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-11-01 02:46:41 -0700 |
commit | aae198a93b03ca53a0eb2a661c0a8cc47780573f (patch) | |
tree | 77d8365b53ec06ba8b410dd0b3661c19c82eb745 /026call.cc | |
parent | aa68aeb34e2476af8bfea8ba11e08e3d5f1d19f1 (diff) | |
download | mu-aae198a93b03ca53a0eb2a661c0a8cc47780573f.tar.gz |
4099
Generalize commit 4089 to arbitrary closures, and not just the current 'space' or call frame. Now we should be treating spaces just like any other data structure, and reclaiming all addresses inside them when we need to. The cost: all spaces must now specify what recipe generated them (so they know how to interpret the array of locations) using the /names property. We can probably make this ergonomic with a little 'type inference'. But at least things are safe now.
Diffstat (limited to '026call.cc')
-rw-r--r-- | 026call.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/026call.cc b/026call.cc index a82917f1..6b7a14f7 100644 --- a/026call.cc +++ b/026call.cc @@ -69,6 +69,8 @@ routine::routine(recipe_ordinal r) { //:: now update routine's helpers +//: macro versions for a slight speedup + :(delete{} "int& current_step_index()") :(delete{} "recipe_ordinal currently_running_recipe()") :(delete{} "const string& current_recipe_name()") @@ -84,6 +86,51 @@ routine::routine(recipe_ordinal r) { #define to_instruction(call) get(Recipe, (call).running_recipe).steps.at((call).running_step_index) #define current_instruction() to_instruction(current_call()) +//: function versions for debugging + +:(code) +//? :(before "End Globals") +//? bool Foo2 = false; +//? :(code) +//? call& current_call() { +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return Current_routine->calls.front(); +//? } +//? :(replace{} "int& current_step_index()") +//? int& current_step_index() { +//? assert(!Current_routine->calls.empty()); +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return current_call().running_step_index; +//? } +//? :(replace{} "recipe_ordinal currently_running_recipe()") +//? recipe_ordinal currently_running_recipe() { +//? assert(!Current_routine->calls.empty()); +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return current_call().running_recipe; +//? } +//? :(replace{} "const string& current_recipe_name()") +//? const string& current_recipe_name() { +//? assert(!Current_routine->calls.empty()); +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return get(Recipe, current_call().running_recipe).name; +//? } +//? :(replace{} "const recipe& current_recipe()") +//? const recipe& current_recipe() { +//? assert(!Current_routine->calls.empty()); +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return get(Recipe, current_call().running_recipe); +//? } +//? :(replace{} "const instruction& current_instruction()") +//? const instruction& current_instruction() { +//? assert(!Current_routine->calls.empty()); +//? if (Foo2) cerr << __FUNCTION__ << '\n'; +//? return to_instruction(current_call()); +//? } +//? :(code) +//? const instruction& to_instruction(const call& call) { +//? return get(Recipe, call.running_recipe).steps.at(call.running_step_index); +//? } + :(after "Defined Recipe Checks") // not a primitive; check that it's present in the book of recipes if (!contains_key(Recipe, inst.operation)) { |