From 75845d2b1276214ce6c3cbc3504e49cb946d29f0 Mon Sep 17 00:00:00 2001
From: "Kartik K. Agaram" <vc@akkartik.com>
Date: Sat, 28 Mar 2015 20:50:23 -0700
Subject: 991

---
 cpp/027space | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'cpp/027space')

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);
-- 
cgit 1.4.1-2-gfad0