diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-10-29 11:56:10 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-10-29 11:56:10 -0700 |
commit | dd2e01e43e971c9325b343fa3e554097e829c508 (patch) | |
tree | 6c101a638967fc7120b9e421cf63837f1c9b6c86 | |
parent | b2ec0969e9f7ef7c3267545efbed907c15084695 (diff) | |
download | mu-dd2e01e43e971c9325b343fa3e554097e829c508.tar.gz |
2311
-rw-r--r-- | 012transform.cc | 4 | ||||
-rw-r--r-- | 030container.cc | 16 | ||||
-rw-r--r-- | 032array.cc | 2 | ||||
-rw-r--r-- | 033exclusive_container.cc | 2 | ||||
-rw-r--r-- | 034call.cc | 6 | ||||
-rw-r--r-- | 036call_reply.cc | 2 | ||||
-rw-r--r-- | 038scheduler.cc | 4 | ||||
-rw-r--r-- | 039wait.cc | 4 | ||||
-rw-r--r-- | 040brace.cc | 110 | ||||
-rw-r--r-- | 042name.cc | 13 | ||||
-rw-r--r-- | 043new.cc | 2 |
11 files changed, 85 insertions, 80 deletions
diff --git a/012transform.cc b/012transform.cc index 59af0e22..72f0cb0b 100644 --- a/012transform.cc +++ b/012transform.cc @@ -15,11 +15,14 @@ vector<transform_fn> Transform; :(code) void transform_all() { + trace(9990, "transform") << "=== transform_all()" << end(); for (long long int t = 0; t < SIZE(Transform); ++t) { +//? cerr << "transform " << t << '\n'; for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; if (r.transformed_until != t-1) continue; +//? cerr << " recipe " << r.name << '\n'; (*Transform.at(t))(/*recipe_ordinal*/p->first); r.transformed_until = t; } @@ -29,6 +32,7 @@ void transform_all() { } void parse_int_reagents() { + trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end(); for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; diff --git a/030container.cc b/030container.cc index de83c739..17e018f7 100644 --- a/030container.cc +++ b/030container.cc @@ -347,7 +347,7 @@ container foo [ x:number y:number ] -+parse: reading container foo ++parse: --- defining container foo +parse: element name: x +parse: type: 1 +parse: element name: y @@ -363,13 +363,13 @@ container bar [ x:number y:number ] -+parse: reading container foo ++parse: --- defining container foo +parse: type number: 1000 +parse: element name: x +parse: type: 1 +parse: element name: y +parse: type: 1001 -+parse: reading container bar ++parse: --- defining container bar +parse: type number: 1001 :(before "End Command Handlers") @@ -381,12 +381,12 @@ else if (command == "container") { void insert_container(const string& command, kind_of_type kind, istream& in) { skip_whitespace(in); string name = next_word(in); - trace("parse") << "reading " << command << ' ' << name << end(); + trace(9991, "parse") << "--- defining " << command << ' ' << name << end(); if (Type_ordinal.find(name) == Type_ordinal.end() || Type_ordinal[name] == 0) { Type_ordinal[name] = Next_type_ordinal++; } - trace("parse") << "type number: " << Type_ordinal[name] << end(); + trace(9999, "parse") << "type number: " << Type_ordinal[name] << end(); skip_bracket(in, "'container' must begin with '['"); type_info& info = Type[Type_ordinal[name]]; recently_added_types.push_back(Type_ordinal[name]); @@ -399,7 +399,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { // End insert_container Special Definitions(element) istringstream inner(element); info.element_names.push_back(slurp_until(inner, ':')); - trace("parse") << " element name: " << info.element_names.back() << end(); + trace(9993, "parse") << " element name: " << info.element_names.back() << end(); type_tree* new_type = NULL; type_tree** curr_type = &new_type; vector<type_ordinal> types; @@ -412,7 +412,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { Type_ordinal[type_name] = Next_type_ordinal++; } *curr_type = new type_tree(Type_ordinal[type_name]); - trace("parse") << " type: " << Type_ordinal[type_name] << end(); + trace(9993, "parse") << " type: " << Type_ordinal[type_name] << end(); curr_type = &(*curr_type)->right; } info.elements.push_back(new_type); @@ -545,7 +545,7 @@ container foo [ # ']' in comment y:number ] -+parse: reading container foo ++parse: --- defining container foo +parse: element name: x +parse: type: 1 +parse: element name: y diff --git a/032array.cc b/032array.cc index 32a8f544..b9a8bc9a 100644 --- a/032array.cc +++ b/032array.cc @@ -53,7 +53,7 @@ case CREATE_ARRAY: { // initialize array size, so that size_of will work Memory[base_address] = array_size; // in array elements long long int size = size_of(product); // in locations - trace("run") << "creating array of size " << size << '\n' << end(); + trace(9998, "run") << "creating array of size " << size << '\n' << end(); // initialize array for (long long int i = 1; i <= size_of(product); ++i) { Memory[base_address+i] = 0; diff --git a/033exclusive_container.cc b/033exclusive_container.cc index 1d1e28a0..ac7bcfd4 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -124,7 +124,7 @@ exclusive-container foo [ x:number y:number ] -+parse: reading exclusive-container foo ++parse: --- defining exclusive-container foo +parse: element name: x +parse: type: 1 +parse: element name: y diff --git a/034call.cc b/034call.cc index df358e6e..b6793c72 100644 --- a/034call.cc +++ b/034call.cc @@ -60,7 +60,7 @@ struct routine { routine::routine(recipe_ordinal r) { if (Trace_stream) { ++Trace_stream->callstack_depth; - trace("trace") << "new routine; incrementing callstack depth to " << Trace_stream->callstack_depth << end(); + trace(9999, "trace") << "new routine; incrementing callstack depth to " << Trace_stream->callstack_depth << end(); assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion } calls.push_front(call(r)); @@ -111,7 +111,7 @@ default: { // not a primitive; look up the book of recipes if (Trace_stream) { ++Trace_stream->callstack_depth; - trace("trace") << "incrementing callstack depth to " << Trace_stream->callstack_depth << end(); + trace(9999, "trace") << "incrementing callstack depth to " << Trace_stream->callstack_depth << end(); assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion } Current_routine->calls.push_front(call(current_instruction().operation)); @@ -151,7 +151,7 @@ inline const vector<instruction>& routine::steps() const { while (current_step_index() >= SIZE(Current_routine->steps())) { // Falling Through End Of Recipe if (Trace_stream) { - trace("trace") << "fall-through: exiting " << current_recipe_name() << "; decrementing callstack depth from " << Trace_stream->callstack_depth << end(); + trace(9999, "trace") << "fall-through: exiting " << current_recipe_name() << "; decrementing callstack depth from " << Trace_stream->callstack_depth << end(); --Trace_stream->callstack_depth; assert(Trace_stream->callstack_depth >= 0); } diff --git a/036call_reply.cc b/036call_reply.cc index 4f96a38b..60261c7a 100644 --- a/036call_reply.cc +++ b/036call_reply.cc @@ -26,7 +26,7 @@ case REPLY: { const instruction& reply_inst = current_instruction(); // save pointer into recipe before pop const string& callee = current_recipe_name(); if (Trace_stream) { - trace("trace") << "reply: decrementing callstack depth from " << Trace_stream->callstack_depth << end(); + trace(9999, "trace") << "reply: decrementing callstack depth from " << Trace_stream->callstack_depth << end(); --Trace_stream->callstack_depth; assert(Trace_stream->callstack_depth >= 0); } diff --git a/038scheduler.cc b/038scheduler.cc index d02aa43e..1b482fc5 100644 --- a/038scheduler.cc +++ b/038scheduler.cc @@ -58,7 +58,7 @@ void run(routine* rr) { skip_to_next_routine(); assert(Current_routine); assert(Current_routine->state == RUNNING); - trace("schedule") << current_routine_label() << end(); + trace(9990, "schedule") << current_routine_label() << end(); run_current_routine(Scheduling_interval); // Scheduler State Transitions if (Current_routine->completed()) @@ -460,7 +460,7 @@ DISCONTINUED, :(before "End Scheduler State Transitions") if (Current_routine->limit >= 0) { if (Current_routine->limit <= Scheduling_interval) { - trace("schedule") << "discontinuing routine " << Current_routine->id << end(); + trace(9999, "schedule") << "discontinuing routine " << Current_routine->id << end(); Current_routine->state = DISCONTINUED; Current_routine->limit = 0; } diff --git a/039wait.cc b/039wait.cc index bdb81651..081e28be 100644 --- a/039wait.cc +++ b/039wait.cc @@ -56,7 +56,7 @@ for (long long int i = 0; i < SIZE(Routines); ++i) { if (Routines.at(i)->state != WAITING) continue; if (Routines.at(i)->waiting_on_location && Memory[Routines.at(i)->waiting_on_location] != Routines.at(i)->old_value_of_waiting_location) { - trace("schedule") << "waking up routine\n" << end(); + trace(9999, "schedule") << "waking up routine\n" << end(); Routines.at(i)->state = RUNNING; Routines.at(i)->waiting_on_location = Routines.at(i)->old_value_of_waiting_location = 0; } @@ -128,7 +128,7 @@ for (long long int i = 0; i < SIZE(Routines); ++i) { assert(id != Routines.at(i)->id); // routine can't wait on itself for (long long int j = 0; j < SIZE(Routines); ++j) { if (Routines.at(j)->id == id && Routines.at(j)->state != RUNNING) { - trace("schedule") << "waking up routine " << Routines.at(i)->id << end(); + trace(9999, "schedule") << "waking up routine " << Routines.at(i)->id << end(); Routines.at(i)->state = RUNNING; Routines.at(i)->waiting_on_routine = 0; } diff --git a/040brace.cc b/040brace.cc index 3a95e9f6..aae9f3d7 100644 --- a/040brace.cc +++ b/040brace.cc @@ -27,9 +27,9 @@ recipe main [ 1:number <- copy 0 } ] -+after-brace: recipe main -+after-brace: jump 1:offset -+after-brace: copy ... ++transform: --- transform braces for recipe main ++transform: jump 1:offset ++transform: copy ... //: one-time setup :(after "int main") @@ -40,19 +40,19 @@ void transform_braces(const recipe_ordinal r) { const int OPEN = 0, CLOSE = 1; // use signed integer for step index because we'll be doing arithmetic on it list<pair<int/*OPEN/CLOSE*/, /*step*/long long int> > braces; + trace(9991, "transform") << "--- transform braces for recipe " << Recipe[r].name << end(); for (long long int index = 0; index < SIZE(Recipe[r].steps); ++index) { const instruction& inst = Recipe[r].steps.at(index); if (inst.label == "{") { - trace("brace") << maybe(Recipe[r].name) << "push (open, " << index << ")" << end(); + trace(9993, "transform") << maybe(Recipe[r].name) << "push (open, " << index << ")" << end(); braces.push_back(pair<int,long long int>(OPEN, index)); } if (inst.label == "}") { - trace("brace") << "push (close, " << index << ")" << end(); + trace(9993, "transform") << "push (close, " << index << ")" << end(); braces.push_back(pair<int,long long int>(CLOSE, index)); } } stack</*step*/long long int> open_braces; - trace("after-brace") << "recipe " << Recipe[r].name << end(); for (long long int index = 0; index < SIZE(Recipe[r].steps); ++index) { instruction& inst = Recipe[r].steps.at(index); if (inst.label == "{") { @@ -70,7 +70,7 @@ void transform_braces(const recipe_ordinal r) { && inst.operation != Recipe_ordinal["break"] && inst.operation != Recipe_ordinal["break-if"] && inst.operation != Recipe_ordinal["break-unless"]) { - trace("after-brace") << inst.name << " ..." << end(); + trace(9991, "transform") << inst.name << " ..." << end(); continue; } // check for errors @@ -91,14 +91,14 @@ void transform_braces(const recipe_ordinal r) { if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { // conditional branches check arg 1 if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { - trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset" << end(); + trace(9991, "transform") << "jump " << inst.ingredients.at(1).name << ":offset" << end(); continue; } } else { // unconditional branches check arg 0 if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) { - trace("after-brace") << "jump " << inst.ingredients.at(0).name << ":offset" << end(); + trace(9991, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end(); continue; } } @@ -115,11 +115,11 @@ void transform_braces(const recipe_ordinal r) { inst.ingredients.push_back(target); // log computed target if (inst.name.find("-if") != string::npos) - trace("after-brace") << "jump-if " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); + trace(9991, "transform") << "jump-if " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); else if (inst.name.find("-unless") != string::npos) - trace("after-brace") << "jump-unless " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); + trace(9991, "transform") << "jump-unless " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); else - trace("after-brace") << "jump " << no_scientific(target.value) << ":offset" << end(); + trace(9991, "transform") << "jump " << no_scientific(target.value) << ":offset" << end(); } } @@ -169,11 +169,11 @@ recipe main [ loop } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... -+after-brace: copy ... -+after-brace: jump -2:offset ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... ++transform: copy ... ++transform: jump -2:offset :(scenario break_empty_block) recipe main [ @@ -182,9 +182,9 @@ recipe main [ break } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: jump 0:offset ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: jump 0:offset :(scenario break_cascading) recipe main [ @@ -196,10 +196,10 @@ recipe main [ break } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: jump 0:offset -+after-brace: jump 0:offset ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: jump 0:offset ++transform: jump 0:offset :(scenario break_cascading_2) recipe main [ @@ -213,12 +213,12 @@ recipe main [ break } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... -+after-brace: jump 1:offset -+after-brace: copy ... -+after-brace: jump 0:offset ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... ++transform: jump 1:offset ++transform: copy ... ++transform: jump 0:offset :(scenario break_if) recipe main [ @@ -232,12 +232,12 @@ recipe main [ break } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... -+after-brace: jump-if 2, 1:offset -+after-brace: copy ... -+after-brace: jump 0:offset ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... ++transform: jump-if 2, 1:offset ++transform: copy ... ++transform: jump 0:offset :(scenario break_nested) recipe main [ @@ -251,7 +251,7 @@ recipe main [ 4:number <- copy 0 } ] -+after-brace: jump 4:offset ++transform: jump 4:offset :(scenario break_nested_degenerate) recipe main [ @@ -264,7 +264,7 @@ recipe main [ 4:number <- copy 0 } ] -+after-brace: jump 3:offset ++transform: jump 3:offset :(scenario break_nested_degenerate_2) recipe main [ @@ -276,7 +276,7 @@ recipe main [ } } ] -+after-brace: jump 2:offset ++transform: jump 2:offset :(scenario break_label) % Hide_errors = true; @@ -286,7 +286,7 @@ recipe main [ break +foo:offset } ] -+after-brace: jump +foo:offset ++transform: jump +foo:offset :(scenario break_unless) recipe main [ @@ -297,11 +297,11 @@ recipe main [ 3:number <- copy 0 } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... -+after-brace: jump-unless 2, 1:offset -+after-brace: copy ... ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... ++transform: jump-unless 2, 1:offset ++transform: copy ... :(scenario loop_unless) recipe main [ @@ -312,11 +312,11 @@ recipe main [ 3:number <- copy 0 } ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... -+after-brace: jump-unless 2, -1:offset -+after-brace: copy ... ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... ++transform: jump-unless 2, -1:offset ++transform: copy ... :(scenario loop_nested) recipe main [ @@ -330,8 +330,8 @@ recipe main [ 5:number <- copy 0 } ] -+after-brace: recipe main -+after-brace: jump-if 4, -5:offset ++transform: --- transform braces for recipe main ++transform: jump-if 4, -5:offset :(scenario loop_label) recipe main [ @@ -339,9 +339,9 @@ recipe main [ +foo 2:number <- copy 0 ] -+after-brace: recipe main -+after-brace: copy ... -+after-brace: copy ... ++transform: --- transform braces for recipe main ++transform: copy ... ++transform: copy ... //: test how things actually run :(scenarios run) diff --git a/042name.cc b/042name.cc index 7850d57f..6022fd93 100644 --- a/042name.cc +++ b/042name.cc @@ -30,6 +30,7 @@ for (long long int i = 0; i < SIZE(recently_added_recipes); ++i) { :(code) void transform_names(const recipe_ordinal r) { + trace(9991, "transform") << "--- transform names for recipe " << Recipe[r].name << end(); bool names_used = false; bool numeric_locations_used = false; map<string, long long int>& names = Name[r]; @@ -38,7 +39,7 @@ void transform_names(const recipe_ordinal r) { ++curr_idx; // avoid using index 0, benign skip in some other cases for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { instruction& inst = Recipe[r].steps.at(i); - // Per-recipe Transforms + // End transform_names(inst) Special-cases // map names to addresses for (long long int in = 0; in < SIZE(inst.ingredients); ++in) { if (is_numeric_location(inst.ingredients.at(in))) numeric_locations_used = true; @@ -54,7 +55,7 @@ void transform_names(const recipe_ordinal r) { if (is_named_location(inst.products.at(out))) names_used = true; if (disqualified(inst.products.at(out), inst, Recipe[r].name)) continue; if (names.find(inst.products.at(out).name) == names.end()) { - trace("name") << "assign " << inst.products.at(out).name << " " << curr_idx << end(); + trace(9993, "name") << "assign " << inst.products.at(out).name << " " << curr_idx << end(); names[inst.products.at(out).name] = curr_idx; curr_idx += size_of(inst.products.at(out)); } @@ -190,7 +191,7 @@ recipe main [ +name: element y of type point is at offset 1 +name: element x of type point is at offset 0 -:(after "Per-recipe Transforms") +:(before "End transform_names(inst) Special-cases") // replace element names of containers with offsets if (inst.operation == Recipe_ordinal["get"] || inst.operation == Recipe_ordinal["get-address"]) { @@ -204,7 +205,7 @@ if (inst.operation == Recipe_ordinal["get"] // since first non-address in base type must be a container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, Recipe[r].name); inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, Recipe[r].name)); - trace("name") << "element " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); + trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); } } @@ -231,7 +232,7 @@ recipe main [ +name: variant p of type number-or-point has tag 1 +mem: storing 13 in location 20 -:(after "Per-recipe Transforms") +:(before "End transform_names(inst) Special-cases") // convert variant names of exclusive containers if (inst.operation == Recipe_ordinal["maybe-convert"]) { if (SIZE(inst.ingredients) != 2) { @@ -243,6 +244,6 @@ if (inst.operation == Recipe_ordinal["maybe-convert"]) { // since first non-address in base type must be an exclusive container, we don't have to canonize type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type, Recipe[r].name); inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, Recipe[r].name)); - trace("name") << "variant " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); + trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); } } diff --git a/043new.cc b/043new.cc index 4604a4fa..05c64009 100644 --- a/043new.cc +++ b/043new.cc @@ -28,7 +28,7 @@ trace(Primitive_recipe_depth, "new") << "routine allocated memory from " << allo :(before "End Mu Types Initialization") Type_ordinal["type"] = 0; -:(after "Per-recipe Transforms") +:(before "End transform_names(inst) Special-cases") // replace type names with type_ordinals if (inst.operation == Recipe_ordinal["new"]) { // End NEW Transform Special-cases |