about summary refs log tree commit diff stats
path: root/cpp/027space
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-28 20:50:23 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-28 20:50:23 -0700
commit75845d2b1276214ce6c3cbc3504e49cb946d29f0 (patch)
treef48226ad77f5cd32469faf6ff6c5d5ae9b747f74 /cpp/027space
parent0ee448dc2bd481bf9ce52dd6843bd00a1e2e6171 (diff)
downloadmu-75845d2b1276214ce6c3cbc3504e49cb946d29f0.tar.gz
991
Diffstat (limited to 'cpp/027space')
-rw-r--r--cpp/027space13
1 files changed, 10 insertions, 3 deletions
diff --git a/cpp/027space b/cpp/027space
index 67092ca0..2fa6f36d 100644
--- a/cpp/027space
+++ b/cpp/027space
@@ -4,11 +4,13 @@
 
 :(scenarios run)
 :(scenario "set_default_space")
+# if default-space is 10, the array of locals begins at location 10
+# and so location 1 is really location 12
 recipe main [
   default-space:address:space <- copy 10:literal
-  1:integer <- copy 12:literal
+  1:integer <- copy 23:literal
 ]
-+mem: storing 12 in location 11
++mem: storing 23 in location 12
 
 :(before "End Call Fields")
 size_t default_space;
@@ -24,7 +26,7 @@ reagent absolutize(reagent x) {
 //?   cout << "not raw: " << x.to_string() << '\n'; //? 1
   assert(x.initialized);
   reagent r = x;
-  r.set_value(r.value + Current_routine.calls.top().default_space);
+  r.set_value(address(r.value, Current_routine.calls.top().default_space));
 //?   cout << "after absolutize: " << r.value << '\n'; //? 1
   if (r.properties.empty())
     r.properties.push_back(pair<string, vector<string> >("", vector<string>()));
@@ -33,6 +35,11 @@ reagent absolutize(reagent x) {
   return r;
 }
 
+int address(int offset, int base) {
+  if (base == 0) return offset;  // raw
+  return base+offset+1;
+}
+
 :(after "void write_memory(reagent x, vector<int> data)")
   if (x.name == "default-space") {
     assert(data.size() == 1);