about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-28 19:20:58 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-28 19:20:58 -0700
commitd39883ec7eaa17a3efafeff86ee3f0d75e4d0ebf (patch)
treef8430a788ea15a4dfd6b76b33a6df740749f62b1 /cpp
parentf1a3be1c542120b01fd8273aabf8a674530df981 (diff)
downloadmu-d39883ec7eaa17a3efafeff86ee3f0d75e4d0ebf.tar.gz
989
Diffstat (limited to 'cpp')
-rw-r--r--cpp/.traces/index_indirect50
-rw-r--r--cpp/020array12
2 files changed, 62 insertions, 0 deletions
diff --git a/cpp/.traces/index_indirect b/cpp/.traces/index_indirect
new file mode 100644
index 00000000..784daf9a
--- /dev/null
+++ b/cpp/.traces/index_indirect
@@ -0,0 +1,50 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "3", value: 0, type: 0, properties: [3: literal]}
+parse/0:   product: {name: "1", value: 0, type: 1, properties: [1: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "14", value: 0, type: 0, properties: [14: literal]}
+parse/0:   product: {name: "2", value: 0, type: 1, properties: [2: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "15", value: 0, type: 0, properties: [15: literal]}
+parse/0:   product: {name: "3", value: 0, type: 1, properties: [3: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "16", value: 0, type: 0, properties: [16: literal]}
+parse/0:   product: {name: "4", value: 0, type: 1, properties: [4: integer]}
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: [1: literal]}
+parse/0:   product: {name: "5", value: 0, type: 2-4-1, properties: [5: address:array:integer]}
+parse/0: instruction: 20
+parse/0:   ingredient: {name: "5", value: 0, type: 2-4-1, properties: [5: address:array:integer, deref: ]}
+parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: [1: literal]}
+parse/0:   product: {name: "6", value: 0, type: 1, properties: [6: integer]}
+after-brace/0: recipe main
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: copy ...
+after-brace/0: index ...
+run/0: instruction main/0
+run/0: ingredient 0 is 3
+mem/0: storing 3 in location 1
+run/0: instruction main/1
+run/0: ingredient 0 is 14
+mem/0: storing 14 in location 2
+run/0: instruction main/2
+run/0: ingredient 0 is 15
+mem/0: storing 15 in location 3
+run/0: instruction main/3
+run/0: ingredient 0 is 16
+mem/0: storing 16 in location 4
+run/0: instruction main/4
+run/0: ingredient 0 is 1
+mem/0: storing 1 in location 5
+run/0: instruction main/5
+run/0: ingredient 0 is 5
+mem/0: location 5 is 1
+run/0: ingredient 1 is 1
+run/0: address to copy is 3
+run/0: its type is 1
+mem/0: location 3 is 15
+run/0: product 0 is 15
+mem/0: storing 15 in location 6
diff --git a/cpp/020array b/cpp/020array
index f6f2c0c5..bfa2b4ac 100644
--- a/cpp/020array
+++ b/cpp/020array
@@ -122,3 +122,15 @@ case INDEX_ADDRESS: {
   write_memory(instructions[pc].products[0], result);
   break;
 }
+
+:(scenario "index_indirect")
+recipe main [
+  1:integer <- copy 3:literal
+  2:integer <- copy 14:literal
+  3:integer <- copy 15:literal
+  4:integer <- copy 16:literal
+  5:address:array:integer <- copy 1:literal
+  6:integer <- index 5:address:array:integer/deref, 1:literal
+]
++run: instruction main/5
++mem: storing 15 in location 6