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 15:43:58 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-19 15:43:58 -0800
commita26cc359953a5f15280ecd6c647b74a06f00ed0f (patch)
tree69b582052580ff7be0ff855d93d82260a365b566 /cpp/012run
parentf4b6b2c2876bb29c01bfd95f55347e7d74222974 (diff)
downloadmu-a26cc359953a5f15280ecd6c647b74a06f00ed0f.tar.gz
785
Diffstat (limited to 'cpp/012run')
-rw-r--r--cpp/012run18
1 files changed, 17 insertions, 1 deletions
diff --git a/cpp/012run b/cpp/012run
index 9696da43..2b14fd4b 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -7,6 +7,16 @@ recipe main [
 +run: ingredient 0 is 23
 +mem: storing in location 1
 
+:(scenario copy)
+recipe main [
+  1:integer <- copy 23:literal
+  2:integer <- copy 1:integer
+]
++run: instruction 1
++mem: location 1 is 23
++run: ingredient 0 is 23
++mem: storing in location 2
+
 :(code)
 void run(string form) {
   run(add_recipe(form));
@@ -33,7 +43,13 @@ void run(recipe_number r) {
 
 vector<int> read_memory(reagent x) {
   vector<int> result;
-  result.push_back(to_int(x.name));
+  if (x.types[0] == 0) {  // literal
+    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);
   return result;
 }