From c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 25 May 2015 22:27:19 -0700 Subject: 1459 --- html/020run.cc.html | 64 ++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) (limited to 'html/020run.cc.html') diff --git a/html/020run.cc.html b/html/020run.cc.html index 246ca3eb..3ebdbf88 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -2,7 +2,7 @@ -~/Desktop/s/mu/020run.cc +020run.cc @@ -49,8 +49,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } recipe main [ 1:number <- copy 23:literal ] -+run: instruction main/0 -+run: ingredient 0 is 23 ++run: 1:number <- copy 23:literal +mem: storing 23 in location 1 :(scenario copy) @@ -58,8 +57,7 @@ recipe main [ 1:number <- copy 23:literal 2:number <- copy 1:number ] -+run: instruction main/1 -+run: ingredient 0 is 1 ++run: 2:number <- copy 1:number +mem: location 1 is 23 +mem: storing 23 in location 2 @@ -67,8 +65,6 @@ recipe main [ recipe main [ 1:number, 2:number <- copy 23:literal, 24:literal ] -+run: ingredient 0 is 23 -+run: ingredient 1 is 24 +mem: storing 23 in location 1 +mem: storing 24 in location 2 @@ -77,7 +73,7 @@ recipe main [ //: Later layers will change this. struct routine { recipe_number running_recipe; - index_t running_step_index; + long long int running_step_index; routine(recipe_number r) :running_recipe(r), running_step_index(0) {} bool completed() const; }; @@ -98,21 +94,18 @@ void run_current_routine() { // Running One Instruction. if (current_instruction().is_label) { ++current_step_index(); continue; } - trace("run") << "instruction " << current_recipe_name() << '/' << current_step_index(); - trace("run") << current_instruction().to_string(); + trace(Initial_callstack_depth+Callstack_depth, "run") << current_instruction().to_string(); assert(Memory[0] == 0); // Read all ingredients from memory. // Each ingredient loads a vector of values rather than a single value; mu // permits operating on reagents spanning multiple locations. vector<vector<double> > ingredients; - for (index_t i = 0; i < current_instruction().ingredients.size(); ++i) { - trace("run") << "ingredient " << i << " is " << current_instruction().ingredients.at(i).name; + for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) { ingredients.push_back(read_memory(current_instruction().ingredients.at(i))); } // Instructions below will write to 'products' or to 'instruction_counter'. vector<vector<double> > products; - index_t instruction_counter = current_step_index(); -//? cout << "AAA: " << current_instruction().to_string() << '\n'; //? 1 + long long int instruction_counter = current_step_index(); switch (current_instruction().operation) { // Primitive Recipe Implementations case COPY: { @@ -124,17 +117,12 @@ void run_current_routine() cout << "not a primitive op: " << current_instruction().operation << '\n'; } } -//? cout << "BBB: " << current_instruction().to_string() << '\n'; //? 1 - if (products.size() < current_instruction().products.size()) + if (SIZE(products) < SIZE(current_instruction().products)) raise << "failed to write to all products! " << current_instruction().to_string(); -//? cout << "CCC: " << current_instruction().to_string() << '\n'; //? 1 - for (index_t i = 0; i < current_instruction().products.size(); ++i) { - trace("run") << "product " << i << " is " << current_instruction().products.at(i).name; + for (long long int i = 0; i < SIZE(current_instruction().products); ++i) { write_memory(current_instruction().products.at(i), products.at(i)); } -//? cout << "DDD: " << current_instruction().to_string() << '\n'; //? 1 current_step_index() = instruction_counter+1; -//? cerr << "screen: " << Memory[SCREEN] << '\n'; //? 1 } stop_running_current_routine:; } @@ -143,7 +131,7 @@ void run_current_routine() //: We'll need to override these later as we change the definition of routine. //: Important that they return referrences into the routine. -inline index_t& current_step_index() { +inline long long int& current_step_index() { return Current_routine->running_step_index; } @@ -156,7 +144,7 @@ inline const instruction& current_instruction()} inline bool routine::completed() const { - return running_step_index >= Recipe[running_recipe].steps.size(); + return running_step_index >= SIZE(Recipe[running_recipe].steps); } :(before "End Commandline Parsing") @@ -222,11 +210,11 @@ vector<double> read_memory(reagent x.push_back(x.value); return result; } - index_t base = x.value; - size_t size = size_of(x); - for (index_t offset = 0; offset < size; ++offset) { + long long int base = x.value; + long long int size = size_of(x); + for (long long int offset = 0; offset < size; ++offset) { double val = Memory[base+offset]; - trace("mem") << "location " << base+offset << " is " << val; + trace(Primitive_recipe_depth, "mem") << "location " << base+offset << " is " << val; result.push_back(val); } return result; @@ -234,20 +222,20 @@ vector<double> read_memory(reagent x(reagent x, vector<double> data) { if (is_dummy(x)) return; - index_t base = x.value; - if (size_of(x) != data.size()) + long long int base = x.value; + if (size_of(x) != SIZE(data)) raise << "size mismatch in storing to " << x.to_string() << '\n'; - for (index_t offset = 0; offset < data.size(); ++offset) { - trace("mem") << "storing " << data.at(offset) << " in location " << base+offset; + for (long long int offset = 0; offset < SIZE(data); ++offset) { + trace(Primitive_recipe_depth, "mem") << "storing " << data.at(offset) << " in location " << base+offset; Memory[base+offset] = data.at(offset); } } :(code) -size_t size_of(const reagent& r) { +long long int size_of(const reagent& r) { return size_of(r.types); } -size_t size_of(const vector<type_number>& types) { +long long int size_of(const vector<type_number>& types) { // End size_of(types) Cases return 1; } @@ -257,7 +245,7 @@ bool is_dummy(const reagent& x} bool isa_literal(const reagent& r) { - return r.types.size() == 1 && r.types.at(0) == 0; + return SIZE(r.types) == 1 && r.types.at(0) == 0; } :(scenario run_label) @@ -266,15 +254,15 @@ recipe main [ 1:number <- copy 23:literal 2:number <- copy 1:number ] -+run: instruction main/1 -+run: instruction main/2 --run: instruction main/0 ++run: 1:number <- copy 23:literal ++run: 2:number <- copy 1:number +-run: +foo :(scenario run_dummy) recipe main [ _ <- copy 0:literal ] -+run: instruction main/0 ++run: _ <- copy 0:literal -- cgit 1.4.1-2-gfad0