diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-21 16:57:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-21 16:57:24 -0700 |
commit | b9011f3481c7cb630bdfdf69feee24ddd540af4a (patch) | |
tree | c2db7f6a5a4f7b0e364d47cc602f3452db878591 /cpp | |
parent | 6b6dfb0cc36e9aed46927ea8525937b6454b1df5 (diff) | |
download | mu-b9011f3481c7cb630bdfdf69feee24ddd540af4a.tar.gz |
965
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/.traces/include_nonderef_properties | 36 | ||||
-rw-r--r-- | cpp/019address | 20 |
2 files changed, 52 insertions, 4 deletions
diff --git a/cpp/.traces/include_nonderef_properties b/cpp/.traces/include_nonderef_properties new file mode 100644 index 00000000..6abd913d --- /dev/null +++ b/cpp/.traces/include_nonderef_properties @@ -0,0 +1,36 @@ +parse/0: instruction: 1 +parse/0: ingredient: {name: "2", value: 0, type: 0, properties: [2: literal]} +parse/0: product: {name: "1", value: 0, type: 1, properties: [1: integer]} +parse/0: instruction: 1 +parse/0: ingredient: {name: "34", value: 0, type: 0, properties: [34: literal]} +parse/0: product: {name: "2", value: 0, type: 1, properties: [2: integer]} +parse/0: instruction: 1 +parse/0: ingredient: {name: "35", value: 0, type: 0, properties: [35: literal]} +parse/0: product: {name: "3", value: 0, type: 1, properties: [3: integer]} +parse/0: instruction: 18 +parse/0: ingredient: {name: "1", value: 0, type: 2-4, properties: [1: address:point, deref: , foo: ]} +parse/0: ingredient: {name: "0", value: 0, type: 0, properties: [0: offset]} +parse/0: product: {name: "4", value: 0, type: 1, properties: [4: integer]} +after-brace/0: recipe main +after-brace/0: copy ... +after-brace/0: copy ... +after-brace/0: copy ... +after-brace/0: get ... +run/0: instruction main/0 +run/0: ingredient 0 is 2 +mem/0: storing in location 1 +run/0: instruction main/1 +run/0: ingredient 0 is 34 +mem/0: storing in location 2 +run/0: instruction main/2 +run/0: ingredient 0 is 35 +mem/0: storing in location 3 +run/0: instruction main/3 +run/0: ingredient 0 is 1 +mem/0: location 1 is 2 +run/0: ingredient 1 is 0 +run/0: address to copy is 2 +run/0: its type is 1 +mem/0: location 2 is 34 +run/0: product 0 is 34 +mem/0: storing in location 4 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; |