about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-20 20:22:13 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-20 20:22:13 -0800
commiteaa75c87c5b9ffb34ebd8c2ea0f1682dfcad336a (patch)
tree354f3e966bcb5ebc5326b6fe7a12a1312aaebdd3
parent916ae8f5d64995f786ea5610affdd004258e8eb9 (diff)
downloadmu-eaa75c87c5b9ffb34ebd8c2ea0f1682dfcad336a.tar.gz
800
-rw-r--r--cpp/012run8
-rw-r--r--cpp/017and-record7
2 files changed, 7 insertions, 8 deletions
diff --git a/cpp/012run b/cpp/012run
index 5d0e28cf..63ffdff1 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -59,7 +59,7 @@ vector<int> read_memory(reagent x) {
 
 void write_memory(reagent x, vector<int> data) {
   int base = to_int(x.name);
-  size_t size = Type[x.types[0]].size;
+  size_t size = size_of(x.types[0]);
   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;
@@ -74,3 +74,9 @@ int to_int(string n) {
   assert(*end == '\0');
   return result;
 }
+
+int size_of(type_number x) {
+  type_info t = Type[x];
+  if (!t.is_record && !t.is_array) return t.size;
+  return t.size;  // TODO
+}
diff --git a/cpp/017and-record b/cpp/017and-record
index b4026e10..94febae0 100644
--- a/cpp/017and-record
+++ b/cpp/017and-record
@@ -74,10 +74,3 @@ recipe main [
 +mem: location 13 is 0
 +run: product 0 is 0
 +mem: storing in location 15
-
-:(code)
-int size_of(type_number x) {
-  type_info t = Type[x];
-  if (!t.is_record && !t.is_array) return t.size;
-  return t.size;  // TODO
-}