about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-21 14:39:00 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-21 14:39:00 -0800
commitd672cdfc6c89b1306af9a967d551dbc016948965 (patch)
tree9ea2aca23ce4456846bc7f794290d3654ee9e694
parent986eebffcfbc896449a0d61c395b714bab59c5f0 (diff)
downloadmu-d672cdfc6c89b1306af9a967d551dbc016948965.tar.gz
808
-rw-r--r--cpp/.traces/store_indirect13
-rw-r--r--cpp/018address11
2 files changed, 24 insertions, 0 deletions
diff --git a/cpp/.traces/store_indirect b/cpp/.traces/store_indirect
new file mode 100644
index 00000000..259685d1
--- /dev/null
+++ b/cpp/.traces/store_indirect
@@ -0,0 +1,13 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "2", type: 0}
+parse/0:   product: {name: "1", type: 2-1}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "34", type: 0}
+parse/0:   product: {name: "1", type: 2-1, property: deref:}
+run/0: instruction 0
+run/0: ingredient 0 is 2
+mem/0: storing in location 1
+run/0: instruction 1
+run/0: ingredient 0 is 34
+mem/0: location 1 is 2
+mem/0: storing in location 2
diff --git a/cpp/018address b/cpp/018address
index 4a5bcd51..33f62fc9 100644
--- a/cpp/018address
+++ b/cpp/018address
@@ -28,8 +28,19 @@ vector<int> read_memory(reagent x) {
   return result;
 }
 
+:(scenario "store_indirect")
+# similarly, write to addresses pointing at other locations using the 'deref' property
+recipe main [
+  1:address:integer <- copy 2:literal
+  1:address:integer/deref <- copy 34:literal
+]
++run: instruction 1
++mem: location 1 is 2
++mem: storing in location 2
+
 :(replace{} "void write_memory(reagent x, vector<int> data)")
 void write_memory(reagent x, vector<int> data) {
+  x = canonize(x);
   int base = to_int(x.name);
   size_t size = size_of(x.types[0]);
   if (size != data.size()) raise << "size mismatch in storing to " << x.to_string();