From 0cc8fa9af894f1d8594173f3083acf5acfbebf3a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 14 Mar 2015 22:33:42 -0700 Subject: 924 --- cpp/.traces/next_ingredient | 6 ++++++ cpp/012run | 3 +-- cpp/020call | 9 ++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cpp/.traces/next_ingredient b/cpp/.traces/next_ingredient index 8ded3d51..1970698a 100644 --- a/cpp/.traces/next_ingredient +++ b/cpp/.traces/next_ingredient @@ -16,3 +16,9 @@ run/0: ingredient 1 is 12 mem/0: location 12 is 2 run/0: product 0 is 3 mem/0: storing in location 13 +run/0: instruction main/1 +run/0: ingredient 0 is 1 +run/0: ingredient 1 is 12 +mem/0: location 12 is 2 +run/0: product 0 is 3 +mem/0: storing in location 13 diff --git a/cpp/012run b/cpp/012run index 0d102660..eec9b61c 100644 --- a/cpp/012run +++ b/cpp/012run @@ -51,8 +51,8 @@ void run(recipe_number r) { void run(routine rr) { // #defines save us the trouble of updating aliases when dependent variables // change. -#define instructions Recipe[rr.calls.top().running_recipe].steps while (!rr.calls.empty()) { + vector& instructions = Recipe[rr.calls.top().running_recipe].steps; while (rr.calls.top().pc >= instructions.size()) { rr.calls.pop(); if (rr.calls.empty()) return; @@ -76,7 +76,6 @@ void run(routine rr) { } ++pc; } -#undef instructions } :(before "End Main") diff --git a/cpp/020call b/cpp/020call index 9aef7931..1b40b1de 100644 --- a/cpp/020call +++ b/cpp/020call @@ -85,12 +85,11 @@ case REPLY: { } rr.calls.pop(); size_t& caller_pc = rr.calls.top().pc; -//? cout << caller_pc << ": " << instructions[caller_pc].products.size() << " <=> " << callee_results.size(); //? 2 - assert(instructions[caller_pc].products.size() <= callee_results.size()); - for (size_t i = 0; i < instructions[caller_pc].products.size(); ++i) { -//? cout << "AAA " << i << '\n'; //? 1 + instruction& caller_instruction = Recipe[rr.calls.top().running_recipe].steps[caller_pc]; + assert(caller_instruction.products.size() <= callee_results.size()); + for (size_t i = 0; i < caller_instruction.products.size(); ++i) { trace("run") << "result " << i << " is " << callee_results[i].size() << "[" << callee_results[i][0] << "...]"; - write_memory(instructions[caller_pc].products[i], callee_results[i]); + write_memory(caller_instruction.products[i], callee_results[i]); } ++caller_pc; break; -- cgit 1.4.1-2-gfad0