diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-19 20:38:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-19 20:38:09 -0700 |
commit | 4be9a93be91b4d301aa8679af5ebcba82ff2049d (patch) | |
tree | 681b3a19635dca4b35de567835749c5ae9ee5135 | |
parent | 4b72aa8ba510376d5ed2576e328972433213058c (diff) | |
download | mu-4be9a93be91b4d301aa8679af5ebcba82ff2049d.tar.gz |
1103
-rw-r--r-- | cpp/.traces/next_ingredient_missing | 11 | ||||
-rw-r--r-- | cpp/036call_ingredient | 21 |
2 files changed, 32 insertions, 0 deletions
diff --git a/cpp/.traces/next_ingredient_missing b/cpp/.traces/next_ingredient_missing new file mode 100644 index 00000000..07d681ca --- /dev/null +++ b/cpp/.traces/next_ingredient_missing @@ -0,0 +1,11 @@ +parse/0: instruction: 1001 +parse/0: instruction: 25 +parse/0: product: {name: "_", value: 0, type: 0, properties: ["_": "dummy"]} +parse/0: product: {name: "12", value: 0, type: 1, properties: ["12": "integer"]} +after-brace/0: recipe f +after-brace/0: next-ingredient ... +after-brace/0: recipe main +after-brace/0: f ... +run/0: instruction main/0 +run/0: instruction f/0 +mem/0: storing 0 in location 12 diff --git a/cpp/036call_ingredient b/cpp/036call_ingredient index 9b85aa55..9f156d65 100644 --- a/cpp/036call_ingredient +++ b/cpp/036call_ingredient @@ -13,6 +13,15 @@ recipe f [ +mem: location 12 is 2 +mem: storing 3 in location 13 +:(scenario "next_ingredient_missing") +recipe main [ + f +] +recipe f [ + _, 12:integer <- next-ingredient +] ++mem: storing 0 in location 12 + :(before "End call Fields") vector<vector<int> > ingredient_atoms; size_t next_ingredient_to_process; @@ -37,7 +46,19 @@ case NEXT_INGREDIENT: { << rr.calls.top().ingredient_atoms[rr.calls.top().next_ingredient_to_process][0]; write_memory(instructions[pc].products[0], rr.calls.top().ingredient_atoms[rr.calls.top().next_ingredient_to_process]); + if (instructions[pc].products.size() > 1) { + vector<int> ingredient_exists; + ingredient_exists.push_back(1); + write_memory(instructions[pc].products[1], ingredient_exists); + } ++rr.calls.top().next_ingredient_to_process; } + else { + if (instructions[pc].products.size() > 1) { + vector<int> no_ingredient; + no_ingredient.push_back(0); + write_memory(instructions[pc].products[1], no_ingredient); + } + } break; } |