about summary refs log tree commit diff stats
path: root/cpp/020array
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-25 19:06:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-25 19:47:17 -0700
commite853b94e93f0a525c857eff97b5ed3d7e9fecdac (patch)
treea91449a1497a7cbb3433cb41d8d10c966a0c809e /cpp/020array
parent6de26237ff5c596084caea6e0a9158c22692f566 (diff)
downloadmu-e853b94e93f0a525c857eff97b5ed3d7e9fecdac.tar.gz
971
Diffstat (limited to 'cpp/020array')
-rw-r--r--cpp/020array14
1 files changed, 10 insertions, 4 deletions
diff --git a/cpp/020array b/cpp/020array
index 4ee04e98..aafeacf8 100644
--- a/cpp/020array
+++ b/cpp/020array
@@ -32,8 +32,9 @@ recipe main [
 if (t.is_array) {
   int base = r.value;
   if (Memory[base] == 0) return 0;
-  reagent x(t.element[0]);
+  reagent x;
   x.set_value(base+1);
+  x.types.push_back(t.element[0]);
   return 1 + Memory[base]*size_of(x);
 }
 
@@ -53,12 +54,15 @@ case INDEX: {
   assert(Type[base_type].is_array);
   trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
   size_t offset = instructions[pc].ingredients[1].value;
-  int src = base_address + 1 + offset*size_of(reagent(Type[base_type].element[0]));
+  reagent elem;
+  elem.types.push_back(Type[base_type].element[0]);
+  int src = base_address + 1 + offset*size_of(elem);
   trace("run") << "address to copy is " << src;
   int src_type = Type[base_type].element[0];
   trace("run") << "its type is " << src_type;
-  reagent tmp(src_type);
+  reagent tmp;
   tmp.set_value(src);
+  tmp.types.push_back(src_type);
   vector<int> result(read_memory(tmp));
   trace("run") << "product 0 is " << result[0];
   write_memory(instructions[pc].products[0], result);
@@ -98,7 +102,9 @@ case INDEX_ADDRESS: {
   assert(Type[base_type].is_array);
   trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
   size_t offset = instructions[pc].ingredients[1].value;
-  int src = base_address + 1 + offset*size_of(reagent(Type[base_type].element[0]));
+  reagent elem;
+  elem.types.push_back(Type[base_type].element[0]);
+  int src = base_address + 1 + offset*size_of(elem);
   trace("run") << "address to copy is " << src;
   vector<int> result;
   result.push_back(src);