about summary refs log tree commit diff stats
path: root/cpp/012run
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-19 23:49:13 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-19 23:49:13 -0800
commitb291f85b8d0ece9312b066a84cbeca1b367fe85f (patch)
treee3e443337918a47ac2f3707b1b77957c34a6131d /cpp/012run
parent9dc2948276388d2ca6556f4a8d13d55406775ac7 (diff)
downloadmu-b291f85b8d0ece9312b066a84cbeca1b367fe85f.tar.gz
798 - start of record support
Diffstat (limited to 'cpp/012run')
-rw-r--r--cpp/012run19
1 files changed, 13 insertions, 6 deletions
diff --git a/cpp/012run b/cpp/012run
index acc423a4..a1778705 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -47,16 +47,23 @@ vector<int> read_memory(reagent x) {
     result.push_back(to_int(x.name));
     return result;
   }
-  int val = Memory[to_int(x.name)];
-  trace("mem") << "location " << x.name << " is " << val;
-  result.push_back(val);
+  int base = to_int(x.name);
+  for (size_t offset = 0; offset < Type[x.types[0]].size; ++offset) {
+    int val = Memory[base+offset];
+    trace("mem") << "location " << base+offset << " is " << val;
+    result.push_back(val);
+  }
   return result;
 }
 
 void write_memory(reagent x, vector<int> data) {
-  int dest = to_int(x.name);
-  trace("mem") << "storing in location " << dest;
-  Memory[dest] = data[0];
+  int base = to_int(x.name);
+  size_t size = Type[x.types[0]].size;
+  if (size != data.size()) raise << "size mismatch in storing to " << x.to_string();
+  for (size_t offset = 0; offset < size; ++offset) {
+    trace("mem") << "storing in location " << base+offset;
+    Memory[base+offset] = data[offset];
+  }
 }
 
 :(code)