about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-02 10:30:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-02 10:30:27 -0700
commitfc9dc705462d0714ca9110dfd2f1fe058c915d9e (patch)
tree225bc560f05b4a2b061240c5e23e5c1c8333dba5
parentf652431d44a1fecf2ba778cf2d59f8ec650fcd68 (diff)
downloadmu-fc9dc705462d0714ca9110dfd2f1fe058c915d9e.tar.gz
1002
-rw-r--r--cpp/.traces/new_array1
-rw-r--r--cpp/026new6
2 files changed, 7 insertions, 0 deletions
diff --git a/cpp/.traces/new_array b/cpp/.traces/new_array
index 6070d166..803f2c6e 100644
--- a/cpp/.traces/new_array
+++ b/cpp/.traces/new_array
@@ -17,6 +17,7 @@ after-brace/0: new ...
 after-brace/0: subtract ...
 run/0: instruction main/0
 mem/0: storing 1000 in location 1
+mem/0: array size is 5
 run/0: instruction main/1
 mem/0: storing 1005 in location 2
 run/0: instruction main/2
diff --git a/cpp/026new b/cpp/026new
index 1991be5b..e541d923 100644
--- a/cpp/026new
+++ b/cpp/026new
@@ -52,6 +52,8 @@ case NEW: {
   if (instructions[pc].ingredients.size() > 1) {
     // array
     vector<int> capacity = read_memory(instructions[pc].ingredients[1]);
+    trace("mem") << "array size is " << capacity[0];
+    Memory[Current_routine.alloc] = capacity[0];
     Current_routine.alloc += capacity[0]*size_of(types);
   }
   else {
@@ -67,4 +69,8 @@ recipe main [
   2:address:integer/raw <- new integer:type
   3:integer/raw <- subtract 2:address:integer/raw, 1:address:array:integer/raw
 ]
++run: instruction main/0
++mem: array size is 5
++run: instruction main/1
++run: instruction main/2
 +mem: storing 5 in location 3