diff options
-rw-r--r-- | cpp/013run | 5 | ||||
-rw-r--r-- | cpp/026new | 8 | ||||
-rw-r--r-- | cpp/027space | 8 | ||||
-rw-r--r-- | cpp/028space_surround | 2 | ||||
-rw-r--r-- | cpp/029string | 6 |
5 files changed, 15 insertions, 14 deletions
diff --git a/cpp/013run b/cpp/013run index 5ba9af70..1606a82d 100644 --- a/cpp/013run +++ b/cpp/013run @@ -27,7 +27,7 @@ struct routine { }; :(before "End Globals") -routine Current_routine(0); +routine* Current_routine = NULL; :(code) void run(recipe_number r) { @@ -35,7 +35,7 @@ void run(recipe_number r) { } void run(routine rr) { - Current_routine = rr; + Current_routine = &rr; while (!done(rr)) { vector<instruction>& instructions = steps(rr); size_t& pc = running_at(rr); @@ -59,6 +59,7 @@ void run(routine rr) { } ++pc; } + Current_routine = NULL; } //: Some helpers. diff --git a/cpp/026new b/cpp/026new index 9c9bbc04..02196c49 100644 --- a/cpp/026new +++ b/cpp/026new @@ -45,7 +45,7 @@ Next_recipe_number++; :(before "End Primitive Recipe Implementations") case NEW: { vector<int> result; - result.push_back(Current_routine.alloc); + result.push_back(Current_routine->alloc); write_memory(instructions[pc].products[0], result); vector<int> types; types.push_back(instructions[pc].ingredients[0].value); @@ -53,12 +53,12 @@ case NEW: { // array vector<int> capacity = read_memory(instructions[pc].ingredients[1]); trace("mem") << "array size is " << capacity[0]; - Memory[Current_routine.alloc] = capacity[0]; - Current_routine.alloc += capacity[0]*size_of(types); + Memory[Current_routine->alloc] = capacity[0]; + Current_routine->alloc += capacity[0]*size_of(types); } else { // scalar - Current_routine.alloc += size_of(types); + Current_routine->alloc += size_of(types); } break; } diff --git a/cpp/027space b/cpp/027space index 9d3ef572..2a845015 100644 --- a/cpp/027space +++ b/cpp/027space @@ -52,7 +52,7 @@ result.properties.push_back(pair<string, vector<string> >("raw", vector<string>( :(code) int space(const reagent& x) { - return Current_routine.calls.top().default_space; + return Current_routine->calls.top().default_space; } int address(int offset, int base) { @@ -67,8 +67,8 @@ int address(int offset, int base) { :(after "void write_memory(reagent x, vector<int> data)") if (x.name == "default-space") { assert(data.size() == 1); - Current_routine.calls.top().default_space = data[0]; -//? cout << "AAA " << Current_routine.calls.top().default_space << '\n'; //? 1 + Current_routine->calls.top().default_space = data[0]; +//? cout << "AAA " << Current_routine->calls.top().default_space << '\n'; //? 1 return; } @@ -82,6 +82,6 @@ recipe main [ :(after "vector<int> read_memory(reagent x)") if (x.name == "default-space") { vector<int> result; - result.push_back(Current_routine.calls.top().default_space); + result.push_back(Current_routine->calls.top().default_space); return result; } diff --git a/cpp/028space_surround b/cpp/028space_surround index 7126911d..dd4fb44f 100644 --- a/cpp/028space_surround +++ b/cpp/028space_surround @@ -27,7 +27,7 @@ recipe main [ :(replace{} "int space(const reagent& x)") int space(const reagent& x) { - return space(x, space_index(x), Current_routine.calls.top().default_space); + return space(x, space_index(x), Current_routine->calls.top().default_space); } int space(const reagent& x, int space_index, int base) { diff --git a/cpp/029string b/cpp/029string index 9a1a094e..320337c4 100644 --- a/cpp/029string +++ b/cpp/029string @@ -58,13 +58,13 @@ Type_number["character"] = Next_type_number++; if (instructions[pc].ingredients[0].properties[0].second[0] == "literal-string") { // allocate an array just large enough for it vector<int> result; - result.push_back(Current_routine.alloc); + result.push_back(Current_routine->alloc); write_memory(instructions[pc].products[0], result); // assume that all characters fit in a single location //? cout << "new string literal: " << instructions[pc].ingredients[0].name << '\n'; //? 1 - Memory[Current_routine.alloc++] = instructions[pc].ingredients[0].name.size(); + Memory[Current_routine->alloc++] = instructions[pc].ingredients[0].name.size(); for (size_t i = 0; i < instructions[pc].ingredients[0].name.size(); ++i) { - Memory[Current_routine.alloc++] = instructions[pc].ingredients[0].name[i]; + Memory[Current_routine->alloc++] = instructions[pc].ingredients[0].name[i]; } // mu strings are not null-terminated in memory break; |