about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/.traces/deref_sidesteps_default_space37
-rw-r--r--cpp/027space19
2 files changed, 55 insertions, 1 deletions
diff --git a/cpp/.traces/deref_sidesteps_default_space b/cpp/.traces/deref_sidesteps_default_space
new file mode 100644
index 00000000..9c7205ab
--- /dev/null
+++ b/cpp/.traces/deref_sidesteps_default_space
@@ -0,0 +1,37 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "34", value: 0, type: 0, properties: ["34": "literal"]}
+parse/0:   product: {name: "7", value: 0, type: 1, properties: ["7": "integer"]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "5", value: 0, type: 0, properties: ["5": "literal"]}
+parse/0:   product: {name: "10", value: 0, type: 1, properties: ["10": "integer"]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "10", value: 0, type: 0, properties: ["10": "literal"]}
+parse/0:   product: {name: "default-space", value: 0, type: 2-0, properties: ["default-space": "address":"space"]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "7", value: 0, type: 0, properties: ["7": "literal"]}
+parse/0:   product: {name: "1", value: 0, type: 2-1, properties: ["1": "address":"integer"]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "1", value: 0, type: 2-1, properties: ["1": "address":"integer", "deref": ]}
+parse/0:   product: {name: "8", value: 0, type: 1, properties: ["8": "integer", "raw": ]}
+after-brace/0: recipe main
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+run/0: instruction main/0
+run/0: ingredient 0 is 34
+mem/0: storing 34 in location 7
+run/0: instruction main/1
+run/0: ingredient 0 is 5
+mem/0: storing 5 in location 10
+run/0: instruction main/2
+run/0: ingredient 0 is 10
+run/0: instruction main/3
+run/0: ingredient 0 is 7
+mem/0: storing 7 in location 12
+run/0: instruction main/4
+run/0: ingredient 0 is 1
+mem/0: location 12 is 7
+mem/0: location 7 is 34
+mem/0: storing 34 in location 8
diff --git a/cpp/027space b/cpp/027space
index 07ac5aa6..fed15bf6 100644
--- a/cpp/027space
+++ b/cpp/027space
@@ -13,6 +13,19 @@ recipe main [
 ]
 +mem: storing 23 in location 12
 
+:(scenario "deref_sidesteps_default_space")
+recipe main [
+  # pretend pointer from outside
+  7:integer <- copy 34:literal
+  # pretend array
+  10:integer <- copy 5:literal
+  # actual start of this function
+  default-space:address:space <- copy 10:literal
+  1:address:integer <- copy 7:literal
+  8:integer/raw <- copy 1:address:integer/deref
+]
++mem: storing 34 in location 8
+
 :(before "End Call Fields")
 size_t default_space;
 :(replace "call(recipe_number r) :running_recipe(r)")
@@ -22,7 +35,8 @@ call(recipe_number r) :running_recipe(r), pc(0), next_ingredient_to_process(0),
 reagent r = absolutize(x);
 :(code)
 reagent absolutize(reagent x) {
-//?   cout << "absolutize " << x.to_string() << '\n'; //? 1
+//?   cout << "absolutize " << x.to_string() << '\n'; //? 2
+//?   cout << is_raw(x) << '\n'; //? 1
   if (is_raw(x) || is_dummy(x)) return x;
 //?   cout << "not raw: " << x.to_string() << '\n'; //? 1
   assert(x.initialized);
@@ -33,7 +47,10 @@ reagent absolutize(reagent x) {
   assert(is_raw(r));
   return r;
 }
+:(before "return result" following "reagent deref(reagent x)")
+result.properties.push_back(pair<string, vector<string> >("raw", vector<string>()));
 
+:(code)
 int space(const reagent& x) {
   return Current_routine.calls.top().default_space;
 }