about summary refs log tree commit diff stats
path: root/cpp/019address
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-21 16:57:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-21 16:57:24 -0700
commitb9011f3481c7cb630bdfdf69feee24ddd540af4a (patch)
treec2db7f6a5a4f7b0e364d47cc602f3452db878591 /cpp/019address
parent6b6dfb0cc36e9aed46927ea8525937b6454b1df5 (diff)
downloadmu-b9011f3481c7cb630bdfdf69feee24ddd540af4a.tar.gz
965
Diffstat (limited to 'cpp/019address')
-rw-r--r--cpp/019address20
1 files changed, 16 insertions, 4 deletions
diff --git a/cpp/019address b/cpp/019address
index 540f18e6..623d5aaa 100644
--- a/cpp/019address
+++ b/cpp/019address
@@ -56,6 +56,7 @@ void write_memory(reagent x, vector<int> data) {
 
 :(code)
 reagent canonize(reagent x) {
+//?   cout << "canonize\n"; //? 1
   reagent r = x;
   while (has_property(r, "deref"))
     r = deref(r);
@@ -70,6 +71,7 @@ bool has_property(reagent x, string name) {
 }
 
 reagent deref(reagent x) {
+//?   cout << "deref\n"; //? 1
   reagent result("");
   assert(x.types[0] == 2);  // address
 
@@ -83,14 +85,12 @@ reagent deref(reagent x) {
   // drop-one 'deref'
   int i = 0;
   int len = x.properties.size();
-  while (true) {
-    assert(i < len);
+  for (i = 0; i < len; ++i) {
     if (x.properties[i].first == "deref") break;
     result.properties.push_back(x.properties[i]);
-    ++i;
   }
   ++i;  // skip first deref
-  while (i < len) {
+  for (; i < len; ++i) {
     result.properties.push_back(x.properties[i]);
   }
   return result;
@@ -109,6 +109,18 @@ recipe main [
 +run: product 0 is 34
 +mem: storing in location 4
 
+:(scenario "include_nonderef_properties")
+recipe main [
+  1:integer <- copy 2:literal
+  2:integer <- copy 34:literal
+  3:integer <- copy 35:literal
+  4:integer <- get 1:address:point/deref/foo, 0:offset
+]
++run: instruction main/3
++run: address to copy is 2
++run: product 0 is 34
++mem: storing in location 4
+
 :(replace{} "case GET:")
 case GET: {
   trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name;