diff options
-rw-r--r-- | 010vm.cc | 60 | ||||
-rw-r--r-- | 011load.cc | 40 | ||||
-rw-r--r-- | 012transform.cc | 8 | ||||
-rw-r--r-- | 013literal_string.cc | 2 | ||||
-rw-r--r-- | 020run.cc | 12 | ||||
-rw-r--r-- | 021arithmetic.cc | 10 | ||||
-rw-r--r-- | 022boolean.cc | 6 | ||||
-rw-r--r-- | 023jump.cc | 8 | ||||
-rw-r--r-- | 024compare.cc | 10 | ||||
-rw-r--r-- | 025trace.cc | 4 | ||||
-rw-r--r-- | 026assert.cc | 2 | ||||
-rw-r--r-- | 027debug.cc | 14 | ||||
-rw-r--r-- | 030container.cc | 72 | ||||
-rw-r--r-- | 031address.cc | 2 | ||||
-rw-r--r-- | 032array.cc | 24 | ||||
-rw-r--r-- | 033exclusive_container.cc | 14 | ||||
-rw-r--r-- | 034call.cc | 8 | ||||
-rw-r--r-- | 035call_ingredient.cc | 6 | ||||
-rw-r--r-- | 036call_reply.cc | 10 | ||||
-rw-r--r-- | 037recipe.cc | 10 | ||||
-rw-r--r-- | 038scheduler.cc | 18 | ||||
-rw-r--r-- | 039wait.cc | 6 | ||||
-rw-r--r-- | 040brace.cc | 50 | ||||
-rw-r--r-- | 041name.cc | 28 | ||||
-rw-r--r-- | 042new.cc | 16 | ||||
-rw-r--r-- | 043space.cc | 4 | ||||
-rw-r--r-- | 045closure_name.cc | 28 | ||||
-rw-r--r-- | 046tangle.cc | 2 | ||||
-rw-r--r-- | 047jump_label.cc | 16 | ||||
-rw-r--r-- | 049continuation.cc | 12 | ||||
-rw-r--r-- | 050scenario.cc | 18 | ||||
-rw-r--r-- | 064random.cc | 6 | ||||
-rw-r--r-- | 070display.cc | 38 | ||||
-rw-r--r-- | 072scenario_screen.cc | 22 | ||||
-rw-r--r-- | 075scenario_console.cc | 14 | ||||
-rw-r--r-- | 080trace_browser.cc | 2 | ||||
-rw-r--r-- | 081run_interactive.cc | 22 |
37 files changed, 312 insertions, 312 deletions
diff --git a/010vm.cc b/010vm.cc index ea0d6632..a4014f6d 100644 --- a/010vm.cc +++ b/010vm.cc @@ -1,10 +1,10 @@ :(after "Types") // A program is a book of 'recipes' (functions) -typedef long long int recipe_number; +typedef long long int recipe_ordinal; :(before "End Globals") -map<string, recipe_number> Recipe_number; -map<recipe_number, recipe> Recipe; -recipe_number Next_recipe_number = 1; +map<string, recipe_ordinal> Recipe_ordinal; +map<recipe_ordinal, recipe> Recipe; +recipe_ordinal Next_recipe_ordinal = 1; :(before "End Types") // Recipes are lists of instructions. To run a recipe, the computer runs its @@ -25,7 +25,7 @@ struct instruction { bool is_label; string label; // only if is_label string name; // only if !is_label - recipe_number operation; // Recipe_number[name] + recipe_ordinal operation; // Recipe_ordinal[name] vector<reagent> ingredients; // only if !is_label vector<reagent> products; // only if !is_label instruction(); @@ -44,7 +44,7 @@ struct reagent { string name; double value; bool initialized; - vector<type_number> types; + vector<type_ordinal> types; reagent(string s); reagent(); void set_value(double v) { value = v; initialized = true; } @@ -71,29 +71,29 @@ Memory.clear(); // Unlike most computers today, mu stores types in a single big table, shared // by all the mu programs on the computer. This is useful in providing a // seamless experience to help understand arbitrary mu programs. -typedef long long int type_number; +typedef long long int type_ordinal; :(before "End Globals") -map<string, type_number> Type_number; -map<type_number, type_info> Type; -type_number Next_type_number = 1; +map<string, type_ordinal> Type_ordinal; +map<type_ordinal, type_info> Type; +type_ordinal Next_type_ordinal = 1; :(code) void setup_types() { - Type.clear(); Type_number.clear(); - Type_number["literal"] = 0; - Next_type_number = 1; + Type.clear(); Type_ordinal.clear(); + Type_ordinal["literal"] = 0; + Next_type_ordinal = 1; // Mu Types Initialization - type_number number = Type_number["number"] = Next_type_number++; - Type_number["location"] = Type_number["number"]; // wildcard type: either a pointer or a scalar + type_ordinal number = Type_ordinal["number"] = Next_type_ordinal++; + Type_ordinal["location"] = Type_ordinal["number"]; // wildcard type: either a pointer or a scalar Type[number].name = "number"; - type_number address = Type_number["address"] = Next_type_number++; + type_ordinal address = Type_ordinal["address"] = Next_type_ordinal++; Type[address].name = "address"; - type_number boolean = Type_number["boolean"] = Next_type_number++; + type_ordinal boolean = Type_ordinal["boolean"] = Next_type_ordinal++; Type[boolean].name = "boolean"; - type_number character = Type_number["character"] = Next_type_number++; + type_ordinal character = Type_ordinal["character"] = Next_type_ordinal++; Type[character].name = "character"; // Array types are a special modifier to any other type. For example, // array:number or array:address:boolean. - type_number array = Type_number["array"] = Next_type_number++; + type_ordinal array = Type_ordinal["array"] = Next_type_ordinal++; Type[array].name = "array"; // End Mu Types Initialization } @@ -121,7 +121,7 @@ struct type_info { string name; kind_of_type kind; long long int size; // only if type is not primitive; primitives and addresses have size 1 (except arrays are dynamic) - vector<vector<type_number> > elements; + vector<vector<type_ordinal> > elements; vector<string> element_names; // End type_info Fields type_info() :kind(primitive), size(0) {} @@ -139,10 +139,10 @@ enum primitive_recipes { //: recipes there are only codes, no entries in the book, because mu just knows //: what to do for them. void setup_recipes() { - Recipe.clear(); Recipe_number.clear(); - Recipe_number["idle"] = IDLE; + Recipe.clear(); Recipe_ordinal.clear(); + Recipe_ordinal["idle"] = IDLE; // Primitive Recipe Numbers - Recipe_number["copy"] = COPY; + Recipe_ordinal["copy"] = COPY; // End Primitive Recipe Numbers } //: We could just reset the recipe table after every test, but that gets slow @@ -152,12 +152,12 @@ void setup_recipes() { :(before "End One-time Setup") setup_recipes(); assert(MAX_PRIMITIVE_RECIPES < 100); // level 0 is primitives; until 99 -Next_recipe_number = 100; +Next_recipe_ordinal = 100; // End Load Recipes :(before "End Test Run Initialization") -assert(Next_recipe_number < 1000); // recipes being tested didn't overflow into test space +assert(Next_recipe_ordinal < 1000); // recipes being tested didn't overflow into test space :(before "End Setup") -Next_recipe_number = 1000; // consistent new numbers for each test +Next_recipe_ordinal = 1000; // consistent new numbers for each test @@ -185,11 +185,11 @@ reagent::reagent(string s) :original_string(s), value(0), initialized(false) { name = properties.at(0).first; for (long long int i = 0; i < SIZE(properties.at(0).second); ++i) { string type = properties.at(0).second.at(i); - if (Type_number.find(type) == Type_number.end()) { -//? cerr << type << " is " << Next_type_number << '\n'; //? 1 - Type_number[type] = Next_type_number++; + if (Type_ordinal.find(type) == Type_ordinal.end()) { +//? cerr << type << " is " << Next_type_ordinal << '\n'; //? 1 + Type_ordinal[type] = Next_type_ordinal++; } - types.push_back(Type_number[type]); + types.push_back(Type_ordinal[type]); } if (name == "_" && types.empty()) { types.push_back(0); diff --git a/011load.cc b/011load.cc index 35a5daac..6216c7be 100644 --- a/011load.cc +++ b/011load.cc @@ -10,15 +10,15 @@ recipe main [ +parse: product: {name: "1", properties: ["1": "number"]} :(code) -vector<recipe_number> load(string form) { +vector<recipe_ordinal> load(string form) { istringstream in(form); in >> std::noskipws; return load(in); } -vector<recipe_number> load(istream& in) { +vector<recipe_ordinal> load(istream& in) { in >> std::noskipws; - vector<recipe_number> result; + vector<recipe_ordinal> result; while (!in.eof()) { //? cerr << "===\n"; //? 1 skip_whitespace_and_comments(in); @@ -30,20 +30,20 @@ vector<recipe_number> load(istream& in) { //? cerr << "recipe: " << recipe_name << '\n'; //? 1 if (recipe_name.empty()) raise << "empty recipe name\n"; - if (Recipe_number.find(recipe_name) == Recipe_number.end()) { - Recipe_number[recipe_name] = Next_recipe_number++; + if (Recipe_ordinal.find(recipe_name) == Recipe_ordinal.end()) { + Recipe_ordinal[recipe_name] = Next_recipe_ordinal++; } - if (Recipe.find(Recipe_number[recipe_name]) != Recipe.end()) { - raise << "redefining recipe " << Recipe[Recipe_number[recipe_name]].name << "\n"; - Recipe.erase(Recipe_number[recipe_name]); + if (Recipe.find(Recipe_ordinal[recipe_name]) != Recipe.end()) { + raise << "redefining recipe " << Recipe[Recipe_ordinal[recipe_name]].name << "\n"; + Recipe.erase(Recipe_ordinal[recipe_name]); } // todo: save user-defined recipes to mu's memory - Recipe[Recipe_number[recipe_name]] = slurp_recipe(in); -//? cerr << Recipe_number[recipe_name] << ": " << recipe_name << '\n'; //? 1 - Recipe[Recipe_number[recipe_name]].name = recipe_name; + Recipe[Recipe_ordinal[recipe_name]] = slurp_recipe(in); +//? cerr << Recipe_ordinal[recipe_name] << ": " << recipe_name << '\n'; //? 1 + Recipe[Recipe_ordinal[recipe_name]].name = recipe_name; // track added recipes because we may need to undo them in tests; see below - recently_added_recipes.push_back(Recipe_number[recipe_name]); - result.push_back(Recipe_number[recipe_name]); + recently_added_recipes.push_back(Recipe_ordinal[recipe_name]); + result.push_back(Recipe_ordinal[recipe_name]); } // End Command Handlers else { @@ -116,14 +116,14 @@ bool next_instruction(istream& in, instruction* curr) { if (p == words.end()) raise << "instruction prematurely ended with '<-'\n" << die(); curr->name = *p; - if (Recipe_number.find(*p) == Recipe_number.end()) { - Recipe_number[*p] = Next_recipe_number++; -//? cout << "AAA: " << *p << " is now " << Recipe_number[*p] << '\n'; //? 1 + if (Recipe_ordinal.find(*p) == Recipe_ordinal.end()) { + Recipe_ordinal[*p] = Next_recipe_ordinal++; +//? cout << "AAA: " << *p << " is now " << Recipe_ordinal[*p] << '\n'; //? 1 } - if (Recipe_number[*p] == 0) { + if (Recipe_ordinal[*p] == 0) { raise << "Recipe " << *p << " has number 0, which is reserved for IDLE.\n" << die(); } - curr->operation = Recipe_number[*p]; ++p; + curr->operation = Recipe_ordinal[*p]; ++p; for (; p != words.end(); ++p) { if (*p == ",") continue; @@ -214,11 +214,11 @@ void show_rest_of_stream(istream& in) { //: Have tests clean up any recipes they added. :(before "End Globals") -vector<recipe_number> recently_added_recipes; +vector<recipe_ordinal> recently_added_recipes; :(before "End Setup") for (long long int i = 0; i < SIZE(recently_added_recipes); ++i) { //? cout << "AAA clearing " << Recipe[recently_added_recipes.at(i)].name << '\n'; //? 2 - Recipe_number.erase(Recipe[recently_added_recipes.at(i)].name); + Recipe_ordinal.erase(Recipe[recently_added_recipes.at(i)].name); Recipe.erase(recently_added_recipes.at(i)); } // Clear Other State For recently_added_recipes diff --git a/012transform.cc b/012transform.cc index 1a7415c8..f3c76e38 100644 --- a/012transform.cc +++ b/012transform.cc @@ -8,7 +8,7 @@ long long int transformed_until; recipe() :transformed_until(-1) {} :(before "End Types") -typedef void (*transform_fn)(recipe_number); +typedef void (*transform_fn)(recipe_ordinal); :(before "End Globals") vector<transform_fn> Transform; @@ -17,11 +17,11 @@ vector<transform_fn> Transform; void transform_all() { //? cerr << "AAA transform_all\n"; //? 2 for (long long int t = 0; t < SIZE(Transform); ++t) { - for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + 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; - (*Transform.at(t))(/*recipe_number*/p->first); + (*Transform.at(t))(/*recipe_ordinal*/p->first); r.transformed_until = t; } } @@ -30,7 +30,7 @@ void transform_all() { void parse_int_reagents() { //? cout << "parse_int_reagents\n"; //? 1 - for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; for (long long int index = 0; index < SIZE(r.steps); ++index) { diff --git a/013literal_string.cc b/013literal_string.cc index f8445c26..0d4e3573 100644 --- a/013literal_string.cc +++ b/013literal_string.cc @@ -19,7 +19,7 @@ recipe main [ +parse: ingredient: {name: "abc:def/ghi", properties: [_: "literal-string"]} :(before "End Mu Types Initialization") -Type_number["literal-string"] = 0; +Type_ordinal["literal-string"] = 0; :(after "string next_word(istream& in)") if (in.peek() == '[') { diff --git a/020run.cc b/020run.cc index cecfd7b0..44f8667b 100644 --- a/020run.cc +++ b/020run.cc @@ -36,9 +36,9 @@ recipe main [ // Book-keeping while running a recipe. //: Later layers will change this. struct routine { - recipe_number running_recipe; + recipe_ordinal running_recipe; long long int running_step_index; - routine(recipe_number r) :running_recipe(r), running_step_index(0) {} + routine(recipe_ordinal r) :running_recipe(r), running_step_index(0) {} bool completed() const; }; @@ -46,7 +46,7 @@ struct routine { routine* Current_routine = NULL; :(code) -void run(recipe_number r) { +void run(recipe_ordinal r) { routine rr(r); Current_routine = &rr; run_current_routine(); @@ -132,7 +132,7 @@ if (!Run_tests) { START_TRACING_UNTIL_END_OF_SCOPE; //? Trace_stream->dump_layer = "all"; //? 2 transform_all(); - recipe_number r = Recipe_number[string("main")]; + recipe_ordinal r = Recipe_ordinal[string("main")]; //? Trace_stream->dump_layer = "all"; //? 1 if (r) run(r); //? dump_memory(); //? 1 @@ -167,7 +167,7 @@ load_permanently("core.mu"); void run(string form) { //? cerr << "AAA 2\n"; //? 2 //? cerr << form << '\n'; //? 1 - vector<recipe_number> tmp = load(form); + vector<recipe_ordinal> tmp = load(form); if (tmp.empty()) return; transform_all(); //? cerr << "AAA 3\n"; //? 2 @@ -211,7 +211,7 @@ void write_memory(reagent x, vector<double> data) { long long int size_of(const reagent& r) { return size_of(r.types); } -long long int size_of(const vector<type_number>& types) { +long long int size_of(const vector<type_ordinal>& types) { // End size_of(types) Cases return 1; } diff --git a/021arithmetic.cc b/021arithmetic.cc index 147fd8bd..7d68f266 100644 --- a/021arithmetic.cc +++ b/021arithmetic.cc @@ -3,7 +3,7 @@ :(before "End Primitive Recipe Declarations") ADD, :(before "End Primitive Recipe Numbers") -Recipe_number["add"] = ADD; +Recipe_ordinal["add"] = ADD; :(before "End Primitive Recipe Implementations") case ADD: { double result = 0; @@ -39,7 +39,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") SUBTRACT, :(before "End Primitive Recipe Numbers") -Recipe_number["subtract"] = SUBTRACT; +Recipe_ordinal["subtract"] = SUBTRACT; :(before "End Primitive Recipe Implementations") case SUBTRACT: { assert(scalar(ingredients.at(0))); @@ -76,7 +76,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") MULTIPLY, :(before "End Primitive Recipe Numbers") -Recipe_number["multiply"] = MULTIPLY; +Recipe_ordinal["multiply"] = MULTIPLY; :(before "End Primitive Recipe Implementations") case MULTIPLY: { double result = 1; @@ -112,7 +112,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") DIVIDE, :(before "End Primitive Recipe Numbers") -Recipe_number["divide"] = DIVIDE; +Recipe_ordinal["divide"] = DIVIDE; :(before "End Primitive Recipe Implementations") case DIVIDE: { assert(scalar(ingredients.at(0))); @@ -151,7 +151,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") DIVIDE_WITH_REMAINDER, :(before "End Primitive Recipe Numbers") -Recipe_number["divide-with-remainder"] = DIVIDE_WITH_REMAINDER; +Recipe_ordinal["divide-with-remainder"] = DIVIDE_WITH_REMAINDER; :(before "End Primitive Recipe Implementations") case DIVIDE_WITH_REMAINDER: { long long int quotient = ingredients.at(0).at(0) / ingredients.at(1).at(0); diff --git a/022boolean.cc b/022boolean.cc index 8570d643..86b2f16d 100644 --- a/022boolean.cc +++ b/022boolean.cc @@ -3,7 +3,7 @@ :(before "End Primitive Recipe Declarations") AND, :(before "End Primitive Recipe Numbers") -Recipe_number["and"] = AND; +Recipe_ordinal["and"] = AND; :(before "End Primitive Recipe Implementations") case AND: { bool result = true; @@ -45,7 +45,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") OR, :(before "End Primitive Recipe Numbers") -Recipe_number["or"] = OR; +Recipe_ordinal["or"] = OR; :(before "End Primitive Recipe Implementations") case OR: { bool result = false; @@ -87,7 +87,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") NOT, :(before "End Primitive Recipe Numbers") -Recipe_number["not"] = NOT; +Recipe_ordinal["not"] = NOT; :(before "End Primitive Recipe Implementations") case NOT: { products.resize(ingredients.size()); diff --git a/023jump.cc b/023jump.cc index daa5e5e0..f53f3079 100644 --- a/023jump.cc +++ b/023jump.cc @@ -13,7 +13,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") JUMP, :(before "End Primitive Recipe Numbers") -Recipe_number["jump"] = JUMP; +Recipe_ordinal["jump"] = JUMP; :(before "End Primitive Recipe Implementations") case JUMP: { assert(current_instruction().ingredients.at(0).initialized); @@ -26,7 +26,7 @@ case JUMP: { //: special type to designate jump targets :(before "End Mu Types Initialization") -Type_number["offset"] = 0; +Type_ordinal["offset"] = 0; :(scenario jump_backward) recipe main [ @@ -42,7 +42,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") JUMP_IF, :(before "End Primitive Recipe Numbers") -Recipe_number["jump-if"] = JUMP_IF; +Recipe_ordinal["jump-if"] = JUMP_IF; :(before "End Primitive Recipe Implementations") case JUMP_IF: { assert(current_instruction().ingredients.at(1).initialized); @@ -81,7 +81,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") JUMP_UNLESS, :(before "End Primitive Recipe Numbers") -Recipe_number["jump-unless"] = JUMP_UNLESS; +Recipe_ordinal["jump-unless"] = JUMP_UNLESS; :(before "End Primitive Recipe Implementations") case JUMP_UNLESS: { assert(current_instruction().ingredients.at(1).initialized); diff --git a/024compare.cc b/024compare.cc index c86184b5..c037c381 100644 --- a/024compare.cc +++ b/024compare.cc @@ -3,7 +3,7 @@ :(before "End Primitive Recipe Declarations") EQUAL, :(before "End Primitive Recipe Numbers") -Recipe_number["equal"] = EQUAL; +Recipe_ordinal["equal"] = EQUAL; :(before "End Primitive Recipe Implementations") case EQUAL: { vector<double>& exemplar = ingredients.at(0); @@ -54,7 +54,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") GREATER_THAN, :(before "End Primitive Recipe Numbers") -Recipe_number["greater-than"] = GREATER_THAN; +Recipe_ordinal["greater-than"] = GREATER_THAN; :(before "End Primitive Recipe Implementations") case GREATER_THAN: { bool result = true; @@ -102,7 +102,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") LESSER_THAN, :(before "End Primitive Recipe Numbers") -Recipe_number["lesser-than"] = LESSER_THAN; +Recipe_ordinal["lesser-than"] = LESSER_THAN; :(before "End Primitive Recipe Implementations") case LESSER_THAN: { bool result = true; @@ -150,7 +150,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") GREATER_OR_EQUAL, :(before "End Primitive Recipe Numbers") -Recipe_number["greater-or-equal"] = GREATER_OR_EQUAL; +Recipe_ordinal["greater-or-equal"] = GREATER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case GREATER_OR_EQUAL: { bool result = true; @@ -206,7 +206,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") LESSER_OR_EQUAL, :(before "End Primitive Recipe Numbers") -Recipe_number["lesser-or-equal"] = LESSER_OR_EQUAL; +Recipe_ordinal["lesser-or-equal"] = LESSER_OR_EQUAL; :(before "End Primitive Recipe Implementations") case LESSER_OR_EQUAL: { bool result = true; diff --git a/025trace.cc b/025trace.cc index 6052f526..71a113ba 100644 --- a/025trace.cc +++ b/025trace.cc @@ -9,7 +9,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") TRACE, :(before "End Primitive Recipe Numbers") -Recipe_number["trace"] = TRACE; +Recipe_ordinal["trace"] = TRACE; :(before "End Primitive Recipe Implementations") case TRACE: { assert(is_literal(current_instruction().ingredients.at(0))); @@ -23,7 +23,7 @@ case TRACE: { :(before "End Primitive Recipe Declarations") HIDE_WARNINGS, :(before "End Primitive Recipe Numbers") -Recipe_number["hide-warnings"] = HIDE_WARNINGS; +Recipe_ordinal["hide-warnings"] = HIDE_WARNINGS; :(before "End Primitive Recipe Implementations") case HIDE_WARNINGS: { Hide_warnings = true; diff --git a/026assert.cc b/026assert.cc index 557bb780..f864d43e 100644 --- a/026assert.cc +++ b/026assert.cc @@ -8,7 +8,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") ASSERT, :(before "End Primitive Recipe Numbers") -Recipe_number["assert"] = ASSERT; +Recipe_ordinal["assert"] = ASSERT; :(before "End Primitive Recipe Implementations") case ASSERT: { assert(SIZE(ingredients) == 2); diff --git a/027debug.cc b/027debug.cc index 36215244..a855aad8 100644 --- a/027debug.cc +++ b/027debug.cc @@ -3,7 +3,7 @@ :(before "End Primitive Recipe Declarations") _PRINT, :(before "End Primitive Recipe Numbers") -Recipe_number["$print"] = _PRINT; +Recipe_ordinal["$print"] = _PRINT; :(before "End Primitive Recipe Implementations") case _PRINT: { for (long long int i = 0; i < SIZE(ingredients); ++i) { @@ -25,7 +25,7 @@ case _PRINT: { :(before "End Primitive Recipe Declarations") _START_TRACING, :(before "End Primitive Recipe Numbers") -Recipe_number["$start-tracing"] = _START_TRACING; +Recipe_ordinal["$start-tracing"] = _START_TRACING; :(before "End Primitive Recipe Implementations") case _START_TRACING: { if (current_instruction().ingredients.empty()) @@ -39,7 +39,7 @@ case _START_TRACING: { :(before "End Primitive Recipe Declarations") _STOP_TRACING, :(before "End Primitive Recipe Numbers") -Recipe_number["$stop-tracing"] = _STOP_TRACING; +Recipe_ordinal["$stop-tracing"] = _STOP_TRACING; :(before "End Primitive Recipe Implementations") case _STOP_TRACING: { Trace_stream->dump_layer = ""; @@ -49,7 +49,7 @@ case _STOP_TRACING: { :(before "End Primitive Recipe Declarations") _CLOSE_TRACE, :(before "End Primitive Recipe Numbers") -Recipe_number["$close-trace"] = _CLOSE_TRACE; +Recipe_ordinal["$close-trace"] = _CLOSE_TRACE; :(before "End Primitive Recipe Implementations") case _CLOSE_TRACE: { if (Trace_stream) { @@ -62,7 +62,7 @@ case _CLOSE_TRACE: { :(before "End Primitive Recipe Declarations") _EXIT, :(before "End Primitive Recipe Numbers") -Recipe_number["$exit"] = _EXIT; +Recipe_ordinal["$exit"] = _EXIT; :(before "End Primitive Recipe Implementations") case _EXIT: { exit(0); @@ -72,7 +72,7 @@ case _EXIT: { :(before "End Primitive Recipe Declarations") _DUMP_TRACE, :(before "End Primitive Recipe Numbers") -Recipe_number["$dump-trace"] = _DUMP_TRACE; +Recipe_ordinal["$dump-trace"] = _DUMP_TRACE; :(before "End Primitive Recipe Implementations") case _DUMP_TRACE: { DUMP(""); @@ -82,7 +82,7 @@ case _DUMP_TRACE: { :(before "End Primitive Recipe Declarations") _DUMP_MEMORY, :(before "End Primitive Recipe Numbers") -Recipe_number["$dump-memory"] = _DUMP_MEMORY; +Recipe_ordinal["$dump-memory"] = _DUMP_MEMORY; :(before "End Primitive Recipe Implementations") case _DUMP_MEMORY: { dump_memory(); diff --git a/030container.cc b/030container.cc index 6ee9fcd7..a679626e 100644 --- a/030container.cc +++ b/030container.cc @@ -2,11 +2,11 @@ :(before "End Mu Types Initialization") //: We'll use this container as a running example, with two number elements. -type_number point = Type_number["point"] = Next_type_number++; +type_ordinal point = Type_ordinal["point"] = Next_type_ordinal++; Type[point].size = 2; Type[point].kind = container; Type[point].name = "point"; -vector<type_number> i; +vector<type_ordinal> i; i.push_back(number); Type[point].elements.push_back(i); Type[point].elements.push_back(i); @@ -29,14 +29,14 @@ recipe main [ :(before "End Mu Types Initialization") // A more complex container, containing another container as one of its // elements. -type_number point_number = Type_number["point-number"] = Next_type_number++; +type_ordinal point_number = Type_ordinal["point-number"] = Next_type_ordinal++; Type[point_number].size = 2; Type[point_number].kind = container; Type[point_number].name = "point-number"; -vector<type_number> p2; +vector<type_ordinal> p2; p2.push_back(point); Type[point_number].elements.push_back(p2); -vector<type_number> i2; +vector<type_ordinal> i2; i2.push_back(number); Type[point_number].elements.push_back(i2); @@ -101,12 +101,12 @@ recipe main [ :(before "End Primitive Recipe Declarations") GET, :(before "End Primitive Recipe Numbers") -Recipe_number["get"] = GET; +Recipe_ordinal["get"] = GET; :(before "End Primitive Recipe Implementations") case GET: { reagent base = current_instruction().ingredients.at(0); long long int base_address = base.value; - type_number base_type = base.types.at(0); + type_ordinal base_type = base.types.at(0); if (Type[base_type].kind != container) raise << "'get' on a non-container in " << current_recipe_name () << ": " << current_instruction().to_string() << '\n' << die(); assert(is_literal(current_instruction().ingredients.at(1))); @@ -119,7 +119,7 @@ case GET: { trace(Primitive_recipe_depth, "run") << "address to copy is " << src; assert(Type[base_type].kind == container); assert(SIZE(Type[base_type].elements) > offset); - type_number src_type = Type[base_type].elements.at(offset).at(0); + type_ordinal src_type = Type[base_type].elements.at(offset).at(0); trace(Primitive_recipe_depth, "run") << "its type is " << Type[src_type].name; reagent tmp; tmp.set_value(src); @@ -150,12 +150,12 @@ recipe main [ :(before "End Primitive Recipe Declarations") GET_ADDRESS, :(before "End Primitive Recipe Numbers") -Recipe_number["get-address"] = GET_ADDRESS; +Recipe_ordinal["get-address"] = GET_ADDRESS; :(before "End Primitive Recipe Implementations") case GET_ADDRESS: { reagent base = current_instruction().ingredients.at(0); long long int base_address = base.value; - type_number base_type = base.types.at(0); + type_ordinal base_type = base.types.at(0); if (Type[base_type].kind != container) raise << "'get' on a non-container in " << current_recipe_name () << ": " << current_instruction().to_string() << '\n' << die(); assert(is_literal(current_instruction().ingredients.at(1))); @@ -215,16 +215,16 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { string name = next_word(in); trace("parse") << "reading " << command << ' ' << name; //? cout << name << '\n'; //? 2 -//? if (Type_number.find(name) != Type_number.end()) //? 1 -//? cerr << Type_number[name] << '\n'; //? 1 - if (Type_number.find(name) == Type_number.end() - || Type_number[name] == 0) { - Type_number[name] = Next_type_number++; +//? if (Type_ordinal.find(name) != Type_ordinal.end()) //? 1 +//? cerr << Type_ordinal[name] << '\n'; //? 1 + if (Type_ordinal.find(name) == Type_ordinal.end() + || Type_ordinal[name] == 0) { + Type_ordinal[name] = Next_type_ordinal++; } - trace("parse") << "type number: " << Type_number[name]; + trace("parse") << "type number: " << Type_ordinal[name]; skip_bracket(in, "'container' must begin with '['"); - type_info& t = Type[Type_number[name]]; - recently_added_types.push_back(Type_number[name]); + type_info& t = Type[Type_ordinal[name]]; + recently_added_types.push_back(Type_ordinal[name]); t.name = name; t.kind = kind; while (!in.eof()) { @@ -234,14 +234,14 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { istringstream inner(element); t.element_names.push_back(slurp_until(inner, ':')); trace("parse") << " element name: " << t.element_names.back(); - vector<type_number> types; + vector<type_ordinal> types; while (!inner.eof()) { string type_name = slurp_until(inner, ':'); - if (Type_number.find(type_name) == Type_number.end()) { -//? cerr << type_name << " is " << Next_type_number << '\n'; //? 1 - Type_number[type_name] = Next_type_number++; + if (Type_ordinal.find(type_name) == Type_ordinal.end()) { +//? cerr << type_name << " is " << Next_type_ordinal << '\n'; //? 1 + Type_ordinal[type_name] = Next_type_ordinal++; } - types.push_back(Type_number[type_name]); + types.push_back(Type_ordinal[type_name]); trace("parse") << " type: " << types.back(); } t.elements.push_back(types); @@ -252,38 +252,38 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { //: ensure types created in one scenario don't leak outside it. :(before "End Globals") -vector<type_number> recently_added_types; +vector<type_ordinal> recently_added_types; :(before "End load_permanently") //: for non-tests recently_added_types.clear(); :(before "End Setup") //: for tests for (long long int i = 0; i < SIZE(recently_added_types); ++i) { //? cout << "erasing " << Type[recently_added_types.at(i)].name << '\n'; //? 1 - Type_number.erase(Type[recently_added_types.at(i)].name); + Type_ordinal.erase(Type[recently_added_types.at(i)].name); Type.erase(recently_added_types.at(i)); } recently_added_types.clear(); // delete recent type references -// can't rely on recently_added_types to cleanup Type_number, because of deliberately misbehaving tests with references to undefined types -map<string, type_number>::iterator p = Type_number.begin(); -while(p != Type_number.end()) { +// can't rely on recently_added_types to cleanup Type_ordinal, because of deliberately misbehaving tests with references to undefined types +map<string, type_ordinal>::iterator p = Type_ordinal.begin(); +while(p != Type_ordinal.end()) { // save current item string name = p->first; - type_number t = p->second; + type_ordinal t = p->second; // increment iterator ++p; // now delete current item if necessary if (t >= 1000) { //? cerr << "AAA " << name << " " << t << '\n'; //? 1 - Type_number.erase(name); + Type_ordinal.erase(name); } } //: lastly, ensure scenarios are consistent by always starting them at the //: same type number. -Next_type_number = 1000; +Next_type_ordinal = 1000; :(before "End Test Run Initialization") -assert(Next_type_number < 1000); +assert(Next_type_ordinal < 1000); :(before "End Setup") -Next_type_number = 1000; +Next_type_ordinal = 1000; //:: Allow container definitions anywhere in the codebase, but warn if you //:: can't find a definition. @@ -314,7 +314,7 @@ $warn: 0 Transform.push_back(check_invalid_types); :(code) -void check_invalid_types(const recipe_number r) { +void check_invalid_types(const recipe_ordinal r) { for (long long int index = 0; index < SIZE(Recipe[r].steps); ++index) { const instruction& inst = Recipe[r].steps.at(index); for (long long int i = 0; i < SIZE(inst.ingredients); ++i) { @@ -359,7 +359,7 @@ check_container_field_types(); :(code) void check_container_field_types() { - for (map<type_number, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { + for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { const type_info& info = p->second; //? cerr << "checking " << p->first << '\n'; //? 1 for (long long int i = 0; i < SIZE(info.elements); ++i) { @@ -377,7 +377,7 @@ void check_container_field_types() { :(before "End Primitive Recipe Declarations") MERGE, :(before "End Primitive Recipe Numbers") -Recipe_number["merge"] = MERGE; +Recipe_ordinal["merge"] = MERGE; :(before "End Primitive Recipe Implementations") case MERGE: { products.resize(1); diff --git a/031address.cc b/031address.cc index a42965fe..9c63ebe3 100644 --- a/031address.cc +++ b/031address.cc @@ -38,7 +38,7 @@ reagent canonize(reagent x) { reagent deref(reagent x) { //? cout << "deref: " << x.to_string() << "\n"; //? 2 - static const type_number ADDRESS = Type_number["address"]; + static const type_ordinal ADDRESS = Type_ordinal["address"]; reagent result; assert(x.types.at(0) == ADDRESS); diff --git a/032array.cc b/032array.cc index 1ca54ef0..3afb11a4 100644 --- a/032array.cc +++ b/032array.cc @@ -39,9 +39,9 @@ recipe main [ //: disable the size mismatch check since the destination array need not be initialized :(after "bool size_mismatch(const reagent& x, const vector<double>& data)") -if (x.types.at(0) == Type_number["array"]) return false; +if (x.types.at(0) == Type_ordinal["array"]) return false; :(after "long long int size_of(const reagent& r)") - if (r.types.at(0) == Type_number["array"]) { + if (r.types.at(0) == Type_ordinal["array"]) { assert(SIZE(r.types) > 1); // skip the 'array' type to get at the element type return 1 + Memory[r.value]*size_of(array_element(r.types)); @@ -73,18 +73,18 @@ recipe main [ :(before "End Primitive Recipe Declarations") INDEX, :(before "End Primitive Recipe Numbers") -Recipe_number["index"] = INDEX; +Recipe_ordinal["index"] = INDEX; :(before "End Primitive Recipe Implementations") case INDEX: { //? if (Trace_stream) Trace_stream->dump_layer = "run"; //? 1 reagent base = canonize(current_instruction().ingredients.at(0)); //? trace(Primitive_recipe_depth, "run") << "ingredient 0 after canonize: " << base.to_string(); //? 1 long long int base_address = base.value; - assert(base.types.at(0) == Type_number["array"]); + assert(base.types.at(0) == Type_ordinal["array"]); reagent offset = canonize(current_instruction().ingredients.at(1)); //? trace(Primitive_recipe_depth, "run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1 vector<double> offset_val(read_memory(offset)); - vector<type_number> element_type = array_element(base.types); + vector<type_ordinal> element_type = array_element(base.types); //? trace(Primitive_recipe_depth, "run") << "offset: " << offset_val.at(0); //? 1 //? trace(Primitive_recipe_depth, "run") << "size of elements: " << size_of(element_type); //? 1 long long int src = base_address + 1 + offset_val.at(0)*size_of(element_type); @@ -98,8 +98,8 @@ case INDEX: { } :(code) -vector<type_number> array_element(const vector<type_number>& types) { - return vector<type_number>(++types.begin(), types.end()); +vector<type_ordinal> array_element(const vector<type_ordinal>& types) { + return vector<type_ordinal>(++types.begin(), types.end()); } :(scenario index_address) @@ -128,15 +128,15 @@ recipe main [ :(before "End Primitive Recipe Declarations") INDEX_ADDRESS, :(before "End Primitive Recipe Numbers") -Recipe_number["index-address"] = INDEX_ADDRESS; +Recipe_ordinal["index-address"] = INDEX_ADDRESS; :(before "End Primitive Recipe Implementations") case INDEX_ADDRESS: { reagent base = canonize(current_instruction().ingredients.at(0)); long long int base_address = base.value; - assert(base.types.at(0) == Type_number["array"]); + assert(base.types.at(0) == Type_ordinal["array"]); reagent offset = canonize(current_instruction().ingredients.at(1)); vector<double> offset_val(read_memory(offset)); - vector<type_number> element_type = array_element(base.types); + vector<type_ordinal> element_type = array_element(base.types); long long int result = base_address + 1 + offset_val.at(0)*size_of(element_type); products.resize(1); products.at(0).push_back(result); @@ -158,11 +158,11 @@ recipe main [ :(before "End Primitive Recipe Declarations") LENGTH, :(before "End Primitive Recipe Numbers") -Recipe_number["length"] = LENGTH; +Recipe_ordinal["length"] = LENGTH; :(before "End Primitive Recipe Implementations") case LENGTH: { reagent x = canonize(current_instruction().ingredients.at(0)); - if (x.types.at(0) != Type_number["array"]) { + if (x.types.at(0) != Type_ordinal["array"]) { raise << "tried to calculate length of non-array " << x.to_string() << '\n'; break; } diff --git a/033exclusive_container.cc b/033exclusive_container.cc index 08aaf3f7..b1600032 100644 --- a/033exclusive_container.cc +++ b/033exclusive_container.cc @@ -7,16 +7,16 @@ :(before "End Mu Types Initialization") //: We'll use this container as a running example, with two number elements. { -type_number tmp = Type_number["number-or-point"] = Next_type_number++; +type_ordinal tmp = Type_ordinal["number-or-point"] = Next_type_ordinal++; Type[tmp].size = 2; Type[tmp].kind = exclusive_container; Type[tmp].name = "number-or-point"; //? cout << tmp << ": " << SIZE(Type[tmp].elements) << '\n'; //? 1 -vector<type_number> t1; +vector<type_ordinal> t1; t1.push_back(number); Type[tmp].elements.push_back(t1); //? cout << SIZE(Type[tmp].elements) << '\n'; //? 1 -vector<type_number> t2; +vector<type_ordinal> t2; t2.push_back(point); Type[tmp].elements.push_back(t2); //? cout << SIZE(Type[tmp].elements) << '\n'; //? 1 @@ -45,7 +45,7 @@ if (t.kind == exclusive_container) { // size of an exclusive container is the size of its largest variant // (So like containers, it can't contain arrays.) //? cout << "--- " << types.at(0) << ' ' << t.size << '\n'; //? 1 -//? cout << "point: " << Type_number["point"] << " " << Type[Type_number["point"]].name << " " << Type[Type_number["point"]].size << '\n'; //? 1 +//? cout << "point: " << Type_ordinal["point"] << " " << Type[Type_ordinal["point"]].name << " " << Type[Type_ordinal["point"]].size << '\n'; //? 1 //? cout << t.name << ' ' << t.size << ' ' << SIZE(t.elements) << '\n'; //? 1 long long int result = 0; for (long long int i = 0; i < t.size; ++i) { @@ -65,7 +65,7 @@ if (t.kind == exclusive_container) { //: 'maybe-convert' requires a literal in ingredient 1. We'll use a synonym //: called 'variant'. :(before "End Mu Types Initialization") -Type_number["variant"] = 0; +Type_ordinal["variant"] = 0; :(scenario maybe_convert) recipe main [ @@ -88,12 +88,12 @@ recipe main [ :(before "End Primitive Recipe Declarations") MAYBE_CONVERT, :(before "End Primitive Recipe Numbers") -Recipe_number["maybe-convert"] = MAYBE_CONVERT; +Recipe_ordinal["maybe-convert"] = MAYBE_CONVERT; :(before "End Primitive Recipe Implementations") case MAYBE_CONVERT: { reagent base = canonize(current_instruction().ingredients.at(0)); long long int base_address = base.value; - type_number base_type = base.types.at(0); + type_ordinal base_type = base.types.at(0); assert(Type[base_type].kind == exclusive_container); assert(is_literal(current_instruction().ingredients.at(1))); long long int tag = current_instruction().ingredients.at(1).value; diff --git a/034call.cc b/034call.cc index f36f987e..4c368bbf 100644 --- a/034call.cc +++ b/034call.cc @@ -34,10 +34,10 @@ recipe f [ // recipe. When that finishes, we continue this one where we left off. // This requires maintaining a 'stack' of interrupted recipes or 'calls'. struct call { - recipe_number running_recipe; + recipe_ordinal running_recipe; long long int running_step_index; // End call Fields - call(recipe_number r) { + call(recipe_ordinal r) { running_recipe = r; running_step_index = 0; // End call Constructor @@ -49,12 +49,12 @@ typedef list<call> call_stack; struct routine { call_stack calls; // End routine Fields - routine(recipe_number r); + routine(recipe_ordinal r); bool completed() const; const vector<instruction>& steps() const; }; :(code) -routine::routine(recipe_number r) { +routine::routine(recipe_ordinal r) { calls.push_front(call(r)); // End routine Constructor } diff --git a/035call_ingredient.cc b/035call_ingredient.cc index 9e355eb1..fa8e012e 100644 --- a/035call_ingredient.cc +++ b/035call_ingredient.cc @@ -34,7 +34,7 @@ for (long long int i = 0; i < SIZE(ingredients); ++i) { :(before "End Primitive Recipe Declarations") NEXT_INGREDIENT, :(before "End Primitive Recipe Numbers") -Recipe_number["next-ingredient"] = NEXT_INGREDIENT; +Recipe_ordinal["next-ingredient"] = NEXT_INGREDIENT; :(before "End Primitive Recipe Implementations") case NEXT_INGREDIENT: { assert(!Current_routine->calls.empty()); @@ -71,7 +71,7 @@ recipe f [ :(before "End Primitive Recipe Declarations") REWIND_INGREDIENTS, :(before "End Primitive Recipe Numbers") -Recipe_number["rewind-ingredients"] = REWIND_INGREDIENTS; +Recipe_ordinal["rewind-ingredients"] = REWIND_INGREDIENTS; :(before "End Primitive Recipe Implementations") case REWIND_INGREDIENTS: { Current_routine->calls.front().next_ingredient_to_process = 0; @@ -92,7 +92,7 @@ recipe f [ :(before "End Primitive Recipe Declarations") INGREDIENT, :(before "End Primitive Recipe Numbers") -Recipe_number["ingredient"] = INGREDIENT; +Recipe_ordinal["ingredient"] = INGREDIENT; :(before "End Primitive Recipe Implementations") case INGREDIENT: { assert(is_literal(current_instruction().ingredients.at(0))); diff --git a/036call_reply.cc b/036call_reply.cc index 8c69fa3f..d6bec0e6 100644 --- a/036call_reply.cc +++ b/036call_reply.cc @@ -15,7 +15,7 @@ recipe f [ :(before "End Primitive Recipe Declarations") REPLY, :(before "End Primitive Recipe Numbers") -Recipe_number["reply"] = REPLY; +Recipe_ordinal["reply"] = REPLY; :(before "End Primitive Recipe Implementations") case REPLY: { const instruction& reply_inst = current_instruction(); // save pointer into recipe before pop @@ -125,7 +125,7 @@ recipe test1 [ // ``` if (curr.name == "reply-if") { assert(curr.products.empty()); - curr.operation = Recipe_number["jump-unless"]; + curr.operation = Recipe_ordinal["jump-unless"]; curr.name = "jump-unless"; vector<reagent> results; copy(++curr.ingredients.begin(), curr.ingredients.end(), inserter(results, results.end())); @@ -133,7 +133,7 @@ if (curr.name == "reply-if") { curr.ingredients.push_back(reagent("1:offset")); result.steps.push_back(curr); curr.clear(); - curr.operation = Recipe_number["reply"]; + curr.operation = Recipe_ordinal["reply"]; curr.name = "reply"; curr.ingredients.swap(results); } @@ -144,7 +144,7 @@ if (curr.name == "reply-if") { // ``` if (curr.name == "reply-unless") { assert(curr.products.empty()); - curr.operation = Recipe_number["jump-if"]; + curr.operation = Recipe_ordinal["jump-if"]; curr.name = "jump-if"; vector<reagent> results; copy(++curr.ingredients.begin(), curr.ingredients.end(), inserter(results, results.end())); @@ -152,7 +152,7 @@ if (curr.name == "reply-unless") { curr.ingredients.push_back(reagent("1:offset")); result.steps.push_back(curr); curr.clear(); - curr.operation = Recipe_number["reply"]; + curr.operation = Recipe_ordinal["reply"]; curr.name = "reply"; curr.ingredients.swap(results); } diff --git a/037recipe.cc b/037recipe.cc index 6eccb8ee..2331ce9d 100644 --- a/037recipe.cc +++ b/037recipe.cc @@ -25,20 +25,20 @@ recipe f [ #? ? :(before "End Mu Types Initialization") -Type_number["recipe"] = 0; -type_number recipe_number = Type_number["recipe-number"] = Next_type_number++; -Type[recipe_number].name = "recipe-number"; +Type_ordinal["recipe"] = 0; +type_ordinal recipe_ordinal = Type_ordinal["recipe-number"] = Next_type_ordinal++; +Type[recipe_ordinal].name = "recipe-number"; :(before "End Reagent-parsing Exceptions") if (r.properties.at(0).second.at(0) == "recipe") { - r.set_value(Recipe_number[r.name]); + r.set_value(Recipe_ordinal[r.name]); return; } :(before "End Primitive Recipe Declarations") CALL, :(before "End Primitive Recipe Numbers") -Recipe_number["call"] = CALL; +Recipe_ordinal["call"] = CALL; :(before "End Primitive Recipe Implementations") case CALL: { assert(scalar(ingredients.at(0))); diff --git a/038scheduler.cc b/038scheduler.cc index 160753d4..2f53e884 100644 --- a/038scheduler.cc +++ b/038scheduler.cc @@ -45,8 +45,8 @@ long long int Scheduling_interval = 500; :(before "End Setup") Scheduling_interval = 500; Routines.clear(); -:(replace{} "void run(recipe_number r)") -void run(recipe_number r) { +:(replace{} "void run(recipe_ordinal r)") +void run(recipe_ordinal r) { //? cerr << "AAA 4\n"; //? 1 Routines.push_back(new routine(r)); //? cerr << "AAA " << Routines.size() << " routines\n"; //? 1 @@ -137,7 +137,7 @@ parent_index = -1; :(before "End Primitive Recipe Declarations") START_RUNNING, :(before "End Primitive Recipe Numbers") -Recipe_number["start-running"] = START_RUNNING; +Recipe_ordinal["start-running"] = START_RUNNING; :(before "End Primitive Recipe Implementations") case START_RUNNING: { routine* new_routine = new routine(ingredients.at(0).at(0)); @@ -211,8 +211,8 @@ recipe f2 [ //: this scenario will require some careful setup in escaped C++ //: (straining our tangle capabilities to near-breaking point) :(scenario scheduler_skips_completed_routines) -% recipe_number f1 = load("recipe f1 [\n1:number <- copy 0:literal\n]").front(); -% recipe_number f2 = load("recipe f2 [\n2:number <- copy 0:literal\n]").front(); +% recipe_ordinal f1 = load("recipe f1 [\n1:number <- copy 0:literal\n]").front(); +% recipe_ordinal f2 = load("recipe f2 [\n2:number <- copy 0:literal\n]").front(); % Routines.push_back(new routine(f1)); // f1 meant to run % Routines.push_back(new routine(f2)); % Routines.back()->state = COMPLETED; // f2 not meant to run @@ -301,7 +301,7 @@ recipe f2 [ :(before "End Primitive Recipe Declarations") ROUTINE_STATE, :(before "End Primitive Recipe Numbers") -Recipe_number["routine-state"] = ROUTINE_STATE; +Recipe_ordinal["routine-state"] = ROUTINE_STATE; :(before "End Primitive Recipe Implementations") case ROUTINE_STATE: { assert(scalar(ingredients.at(0))); @@ -323,7 +323,7 @@ case ROUTINE_STATE: { :(before "End Primitive Recipe Declarations") RESTART, :(before "End Primitive Recipe Numbers") -Recipe_number["restart"] = RESTART; +Recipe_ordinal["restart"] = RESTART; :(before "End Primitive Recipe Implementations") case RESTART: { assert(scalar(ingredients.at(0))); @@ -340,7 +340,7 @@ case RESTART: { :(before "End Primitive Recipe Declarations") STOP, :(before "End Primitive Recipe Numbers") -Recipe_number["stop"] = STOP; +Recipe_ordinal["stop"] = STOP; :(before "End Primitive Recipe Implementations") case STOP: { assert(scalar(ingredients.at(0))); @@ -357,7 +357,7 @@ case STOP: { :(before "End Primitive Recipe Declarations") _DUMP_ROUTINES, :(before "End Primitive Recipe Numbers") -Recipe_number["$dump-routines"] = _DUMP_ROUTINES; +Recipe_ordinal["$dump-routines"] = _DUMP_ROUTINES; :(before "End Primitive Recipe Implementations") case _DUMP_ROUTINES: { for (long long int i = 0; i < SIZE(Routines); ++i) { diff --git a/039wait.cc b/039wait.cc index 01237863..cbfb4664 100644 --- a/039wait.cc +++ b/039wait.cc @@ -33,7 +33,7 @@ waiting_on_location = old_value_of_waiting_location = 0; :(before "End Primitive Recipe Declarations") WAIT_FOR_LOCATION, :(before "End Primitive Recipe Numbers") -Recipe_number["wait-for-location"] = WAIT_FOR_LOCATION; +Recipe_ordinal["wait-for-location"] = WAIT_FOR_LOCATION; :(before "End Primitive Recipe Implementations") case WAIT_FOR_LOCATION: { reagent loc = canonize(current_instruction().ingredients.at(0)); @@ -93,7 +93,7 @@ waiting_on_routine = 0; :(before "End Primitive Recipe Declarations") WAIT_FOR_ROUTINE, :(before "End Primitive Recipe Numbers") -Recipe_number["wait-for-routine"] = WAIT_FOR_ROUTINE; +Recipe_ordinal["wait-for-routine"] = WAIT_FOR_ROUTINE; :(before "End Primitive Recipe Implementations") case WAIT_FOR_ROUTINE: { Current_routine->state = WAITING; @@ -124,7 +124,7 @@ for (long long int i = 0; i < SIZE(Routines); ++i) { :(before "End Primitive Recipe Declarations") SWITCH, :(before "End Primitive Recipe Numbers") -Recipe_number["switch"] = SWITCH; +Recipe_ordinal["switch"] = SWITCH; :(before "End Primitive Recipe Implementations") case SWITCH: { long long int id = some_other_running_routine(); diff --git a/040brace.cc b/040brace.cc index 6dd3d4c3..c111769b 100644 --- a/040brace.cc +++ b/040brace.cc @@ -36,7 +36,7 @@ recipe main [ Transform.push_back(transform_braces); :(code) -void transform_braces(const recipe_number r) { +void transform_braces(const recipe_ordinal r) { //? cout << "AAA transform_braces\n"; //? 1 //? exit(0); //? 1 const int OPEN = 0, CLOSE = 1; @@ -63,8 +63,8 @@ void transform_braces(const recipe_number r) { else if (inst.label == "}") open_braces.pop(); else if (inst.is_label) ; // do nothing - else if (inst.operation == Recipe_number["loop"]) { - inst.operation = Recipe_number["jump"]; + else if (inst.operation == Recipe_ordinal["loop"]) { + inst.operation = Recipe_ordinal["jump"]; if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(0).name << ":offset"; @@ -72,15 +72,15 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(open_braces.top()-index); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump " << ing.value << ":offset"; trace("after-brace") << index << ": " << ing.to_string(); trace("after-brace") << index << ": " << Recipe[r].steps.at(index).ingredients.at(0).to_string(); } } - else if (inst.operation == Recipe_number["break"]) { - inst.operation = Recipe_number["jump"]; + else if (inst.operation == Recipe_ordinal["break"]) { + inst.operation = Recipe_ordinal["jump"]; if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(0).name << ":offset"; @@ -88,13 +88,13 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(matching_brace(open_braces.top(), braces) - index - 1); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump " << ing.value << ":offset"; } } - else if (inst.operation == Recipe_number["loop-if"]) { - inst.operation = Recipe_number["jump-if"]; + else if (inst.operation == Recipe_ordinal["loop-if"]) { + inst.operation = Recipe_ordinal["jump-if"]; if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset"; @@ -102,13 +102,13 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(open_braces.top()-index); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump-if " << inst.ingredients.at(0).name << ", " << ing.value << ":offset"; } } - else if (inst.operation == Recipe_number["break-if"]) { - inst.operation = Recipe_number["jump-if"]; + else if (inst.operation == Recipe_ordinal["break-if"]) { + inst.operation = Recipe_ordinal["jump-if"]; if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset"; @@ -116,13 +116,13 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(matching_brace(open_braces.top(), braces) - index - 1); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump-if " << inst.ingredients.at(0).name << ", " << ing.value << ":offset"; } } - else if (inst.operation == Recipe_number["loop-unless"]) { - inst.operation = Recipe_number["jump-unless"]; + else if (inst.operation == Recipe_ordinal["loop-unless"]) { + inst.operation = Recipe_ordinal["jump-unless"]; if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset"; @@ -130,14 +130,14 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(open_braces.top()-index); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump-unless " << inst.ingredients.at(0).name << ", " << ing.value << ":offset"; } } - else if (inst.operation == Recipe_number["break-unless"]) { + else if (inst.operation == Recipe_ordinal["break-unless"]) { //? cout << "AAA break-unless\n"; //? 1 - inst.operation = Recipe_number["jump-unless"]; + inst.operation = Recipe_ordinal["jump-unless"]; if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { // explicit target; a later phase will handle it trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset"; @@ -145,7 +145,7 @@ void transform_braces(const recipe_number r) { else { reagent ing; ing.set_value(matching_brace(open_braces.top(), braces) - index - 1); - ing.types.push_back(Type_number["offset"]); + ing.types.push_back(Type_ordinal["offset"]); inst.ingredients.push_back(ing); trace("after-brace") << "jump-unless " << inst.ingredients.at(0).name << ", " << ing.value << ":offset"; } @@ -186,12 +186,12 @@ LOOP, LOOP_IF, LOOP_UNLESS, :(before "End Primitive Recipe Numbers") -Recipe_number["break"] = BREAK; -Recipe_number["break-if"] = BREAK_IF; -Recipe_number["break-unless"] = BREAK_UNLESS; -Recipe_number["loop"] = LOOP; -Recipe_number["loop-if"] = LOOP_IF; -Recipe_number["loop-unless"] = LOOP_UNLESS; +Recipe_ordinal["break"] = BREAK; +Recipe_ordinal["break-if"] = BREAK_IF; +Recipe_ordinal["break-unless"] = BREAK_UNLESS; +Recipe_ordinal["loop"] = LOOP; +Recipe_ordinal["loop-if"] = LOOP_IF; +Recipe_ordinal["loop-unless"] = LOOP_UNLESS; :(scenario loop) recipe main [ diff --git a/041name.cc b/041name.cc index eccc7b27..ccf4a353 100644 --- a/041name.cc +++ b/041name.cc @@ -20,18 +20,18 @@ recipe main [ Transform.push_back(transform_names); :(before "End Globals") -map<recipe_number, map<string, long long int> > Name; +map<recipe_ordinal, map<string, long long int> > Name; :(after "Clear Other State For recently_added_recipes") for (long long int i = 0; i < SIZE(recently_added_recipes); ++i) { Name.erase(recently_added_recipes.at(i)); } :(code) -void transform_names(const recipe_number r) { +void transform_names(const recipe_ordinal r) { bool names_used = false; bool numeric_locations_used = false; map<string, long long int>& names = Name[r]; - map<string, vector<type_number> > metadata; + map<string, vector<type_ordinal> > metadata; // store the indices 'used' so far in the map long long int& curr_idx = names[""]; ++curr_idx; // avoid using index 0, benign skip in some other cases @@ -62,11 +62,11 @@ void transform_names(const recipe_number r) { inst.products.at(out).set_value(lookup_name(inst.products.at(out), r)); } } - if (names_used && numeric_locations_used && r != Recipe_number["interactive"]) + if (names_used && numeric_locations_used && r != Recipe_ordinal["interactive"]) raise << "mixing variable names and numeric addresses in " << Recipe[r].name << '\n'; } -void check_metadata(map<string, vector<type_number> >& metadata, const reagent& x, const recipe_number r) { +void check_metadata(map<string, vector<type_ordinal> >& metadata, const reagent& x, const recipe_ordinal r) { if (is_literal(x)) return; if (is_raw(x)) return; // if you use raw locations you're probably doing something unsafe @@ -94,19 +94,19 @@ bool already_transformed(const reagent& r, const map<string, long long int>& nam return names.find(r.name) != names.end(); } -long long int lookup_name(const reagent& r, const recipe_number default_recipe) { +long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe) { return Name[default_recipe][r.name]; } -type_number skip_addresses(const vector<type_number>& types) { +type_ordinal skip_addresses(const vector<type_ordinal>& types) { for (long long int i = 0; i < SIZE(types); ++i) { - if (types.at(i) != Type_number["address"]) return types.at(i); + if (types.at(i) != Type_ordinal["address"]) return types.at(i); } raise << "expected a container" << '\n' << die(); return -1; } -int find_element_name(const type_number t, const string& name) { +int find_element_name(const type_ordinal t, const string& name) { const type_info& container = Type[t]; //? cout << "looking for element " << name << " in type " << container.name << " with " << SIZE(container.element_names) << " elements\n"; //? 1 for (long long int i = 0; i < SIZE(container.element_names); ++i) { @@ -215,8 +215,8 @@ recipe main [ :(after "Per-recipe Transforms") // replace element names of containers with offsets -if (inst.operation == Recipe_number["get"] - || inst.operation == Recipe_number["get-address"]) { +if (inst.operation == Recipe_ordinal["get"] + || inst.operation == Recipe_ordinal["get-address"]) { // at least 2 args, and second arg is offset assert(SIZE(inst.ingredients) >= 2); //? cout << inst.ingredients.at(1).to_string() << '\n'; //? 1 @@ -224,7 +224,7 @@ if (inst.operation == Recipe_number["get"] raise << inst.to_string() << ": expected literal; got " << inst.ingredients.at(1).to_string() << '\n' << die(); if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be a container, we don't have to canonize - type_number base_type = skip_addresses(inst.ingredients.at(0).types); + type_ordinal base_type = skip_addresses(inst.ingredients.at(0).types); inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name)); trace("name") << "element " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " is at offset " << inst.ingredients.at(1).value; } @@ -255,13 +255,13 @@ recipe main [ :(after "Per-recipe Transforms") // convert variant names of exclusive containers -if (inst.operation == Recipe_number["maybe-convert"]) { +if (inst.operation == Recipe_ordinal["maybe-convert"]) { // at least 2 args, and second arg is offset assert(SIZE(inst.ingredients) >= 2); assert(is_literal(inst.ingredients.at(1))); if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) { // since first non-address in base type must be an exclusive container, we don't have to canonize - type_number base_type = skip_addresses(inst.ingredients.at(0).types); + type_ordinal base_type = skip_addresses(inst.ingredients.at(0).types); inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name)); trace("name") << "variant " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " has tag " << inst.ingredients.at(1).value; } diff --git a/042new.cc b/042new.cc index 0e685095..59337300 100644 --- a/042new.cc +++ b/042new.cc @@ -28,10 +28,10 @@ trace(Primitive_recipe_depth, "new") << "routine allocated memory from " << allo //:: First handle 'type' operands. :(before "End Mu Types Initialization") -Type_number["type"] = 0; +Type_ordinal["type"] = 0; :(after "Per-recipe Transforms") -// replace type names with type_numbers -if (inst.operation == Recipe_number["new"]) { +// replace type names with type_ordinals +if (inst.operation == Recipe_ordinal["new"]) { // End NEW Transform Special-cases // first arg must be of type 'type' assert(SIZE(inst.ingredients) >= 1); @@ -39,10 +39,10 @@ if (inst.operation == Recipe_number["new"]) { raise << "expected literal, got " << inst.ingredients.at(0).to_string() << '\n' << die(); if (inst.ingredients.at(0).properties.at(0).second.at(0) != "type") raise << "tried to allocate non-type " << inst.ingredients.at(0).to_string() << " in recipe " << Recipe[r].name << '\n' << die(); - if (Type_number.find(inst.ingredients.at(0).name) == Type_number.end()) + if (Type_ordinal.find(inst.ingredients.at(0).name) == Type_ordinal.end()) raise << "unknown type " << inst.ingredients.at(0).name << " in recipe " << Recipe[r].name << '\n' << die(); -//? cerr << "type " << inst.ingredients.at(0).name << " => " << Type_number[inst.ingredients.at(0).name] << '\n'; //? 1 - inst.ingredients.at(0).set_value(Type_number[inst.ingredients.at(0).name]); +//? cerr << "type " << inst.ingredients.at(0).name << " => " << Type_ordinal[inst.ingredients.at(0).name] << '\n'; //? 1 + inst.ingredients.at(0).set_value(Type_ordinal[inst.ingredients.at(0).name]); trace(Primitive_recipe_depth, "new") << inst.ingredients.at(0).name << " -> " << inst.ingredients.at(0).name; end_new_transform:; } @@ -53,14 +53,14 @@ if (inst.operation == Recipe_number["new"]) { :(before "End Primitive Recipe Declarations") NEW, :(before "End Primitive Recipe Numbers") -Recipe_number["new"] = NEW; +Recipe_ordinal["new"] = NEW; :(before "End Primitive Recipe Implementations") case NEW: { // compute the space we need long long int size = 0; long long int array_length = 0; { - vector<type_number> type; + vector<type_ordinal> type; assert(is_literal(current_instruction().ingredients.at(0))); type.push_back(current_instruction().ingredients.at(0).value); //? trace(Primitive_recipe_depth, "mem") << "type " << current_instruction().ingredients.at(0).to_string() << ' ' << type.size() << ' ' << type.back() << " has size " << size_of(type); //? 1 diff --git a/043space.cc b/043space.cc index 52c92f87..e32fbceb 100644 --- a/043space.cc +++ b/043space.cc @@ -49,8 +49,8 @@ default_space = 0; reagent r = absolutize(x); :(code) reagent absolutize(reagent x) { -//? if (Recipe_number.find("increment-counter") != Recipe_number.end()) //? 1 -//? cout << "AAA " << "increment-counter/2: " << Recipe[Recipe_number["increment-counter"]].steps.at(2).products.at(0).to_string() << '\n'; //? 1 +//? if (Recipe_ordinal.find("increment-counter") != Recipe_ordinal.end()) //? 1 +//? cout << "AAA " << "increment-counter/2: " << Recipe[Recipe_ordinal["increment-counter"]].steps.at(2).products.at(0).to_string() << '\n'; //? 1 //? cout << "absolutize " << x.to_string() << '\n'; //? 4 //? cout << is_raw(x) << '\n'; //? 1 if (is_raw(x) || is_dummy(x)) return x; diff --git a/045closure_name.cc b/045closure_name.cc index 6ae48847..a9a7575c 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -35,13 +35,13 @@ recipe increment-counter [ //: surrounding space of each recipe. This must happen before transform_names. :(before "End Globals") -map<recipe_number, recipe_number> Surrounding_space; +map<recipe_ordinal, recipe_ordinal> Surrounding_space; :(after "int main") Transform.push_back(collect_surrounding_spaces); :(code) -void collect_surrounding_spaces(const recipe_number r) { +void collect_surrounding_spaces(const recipe_ordinal r) { for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { const instruction& inst = Recipe[r].steps.at(i); if (inst.is_label) continue; @@ -49,9 +49,9 @@ void collect_surrounding_spaces(const recipe_number r) { if (is_literal(inst.products.at(j))) continue; if (inst.products.at(j).name != "0") continue; if (SIZE(inst.products.at(j).types) != 3 - || inst.products.at(j).types.at(0) != Type_number["address"] - || inst.products.at(j).types.at(1) != Type_number["array"] - || inst.products.at(j).types.at(2) != Type_number["location"]) { + || inst.products.at(j).types.at(0) != Type_ordinal["address"] + || inst.products.at(j).types.at(1) != Type_ordinal["array"] + || inst.products.at(j).types.at(2) != Type_ordinal["location"]) { raise << "slot 0 should always have type address:array:location, but is " << inst.products.at(j).to_string() << '\n'; continue; } @@ -61,12 +61,12 @@ void collect_surrounding_spaces(const recipe_number r) { if (SIZE(s) > 1) raise << "slot 0 should have a single value in /names, got " << inst.products.at(j).to_string() << '\n'; string surrounding_recipe_name = s.at(0); if (Surrounding_space.find(r) != Surrounding_space.end() - && Surrounding_space[r] != Recipe_number[surrounding_recipe_name]) { + && Surrounding_space[r] != Recipe_ordinal[surrounding_recipe_name]) { raise << "recipe " << Recipe[r].name << " can have only one 'surrounding' recipe but has " << Recipe[Surrounding_space[r]].name << " and " << surrounding_recipe_name << '\n'; continue; } trace("name") << "recipe " << Recipe[r].name << " is surrounded by " << surrounding_recipe_name; - Surrounding_space[r] = Recipe_number[surrounding_recipe_name]; + Surrounding_space[r] = Recipe_ordinal[surrounding_recipe_name]; } } } @@ -74,8 +74,8 @@ void collect_surrounding_spaces(const recipe_number r) { //: Once surrounding spaces are available, transform_names uses them to handle //: /space properties. -:(replace{} "long long int lookup_name(const reagent& r, const recipe_number default_recipe)") -long long int lookup_name(const reagent& x, const recipe_number default_recipe) { +:(replace{} "long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe)") +long long int lookup_name(const reagent& x, const recipe_ordinal default_recipe) { //? cout << "AAA " << default_recipe << " " << Recipe[default_recipe].name << '\n'; //? 2 //? cout << "AAA " << x.to_string() << '\n'; //? 1 if (!has_property(x, "space")) { @@ -86,15 +86,15 @@ long long int lookup_name(const reagent& x, const recipe_number default_recipe) if (SIZE(p) != 1) raise << "/space property should have exactly one (non-negative integer) value\n"; long long int n = to_integer(p.at(0)); assert(n >= 0); - recipe_number surrounding_recipe = lookup_surrounding_recipe(default_recipe, n); - set<recipe_number> done; - vector<recipe_number> path; + recipe_ordinal surrounding_recipe = lookup_surrounding_recipe(default_recipe, n); + set<recipe_ordinal> done; + vector<recipe_ordinal> path; return lookup_name(x, surrounding_recipe, done, path); } // If the recipe we need to lookup this name in doesn't have names done yet, // recursively call transform_names on it. -long long int lookup_name(const reagent& x, const recipe_number r, set<recipe_number>& done, vector<recipe_number>& path) { +long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) { if (!Name[r].empty()) return Name[r][x.name]; if (done.find(r) != done.end()) { raise << "can't compute address of " << x.to_string() << " because "; @@ -111,7 +111,7 @@ long long int lookup_name(const reagent& x, const recipe_number r, set<recipe_nu return Name[r][x.name]; } -recipe_number lookup_surrounding_recipe(const recipe_number r, long long int n) { +recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n) { if (n == 0) return r; if (Surrounding_space.find(r) == Surrounding_space.end()) { raise << "don't know surrounding recipe of " << Recipe[r].name << '\n'; diff --git a/046tangle.cc b/046tangle.cc index 2b650e3d..0c4129f0 100644 --- a/046tangle.cc +++ b/046tangle.cc @@ -44,7 +44,7 @@ else if (command == "after") { Transform.push_back(insert_fragments); :(code) -void insert_fragments(const recipe_number r) { +void insert_fragments(const recipe_ordinal r) { // Copy into a new vector because insertions invalidate iterators. // But this way we can't insert into labels created inside before/after. vector<instruction> result; diff --git a/047jump_label.cc b/047jump_label.cc index ca7f868c..dca2e37a 100644 --- a/047jump_label.cc +++ b/047jump_label.cc @@ -11,13 +11,13 @@ recipe main [ -mem: storing 0 in location 1 :(before "End Mu Types Initialization") -Type_number["label"] = 0; +Type_ordinal["label"] = 0; :(after "int main") Transform.push_back(transform_labels); :(code) -void transform_labels(const recipe_number r) { +void transform_labels(const recipe_ordinal r) { map<string, long long int> offset; for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { const instruction& inst = Recipe[r].steps.at(i); @@ -25,19 +25,19 @@ void transform_labels(const recipe_number r) { } for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { instruction& inst = Recipe[r].steps.at(i); - if (inst.operation == Recipe_number["jump"]) { + if (inst.operation == Recipe_ordinal["jump"]) { //? cerr << inst.to_string() << '\n'; //? 1 replace_offset(inst.ingredients.at(0), offset, i, r); } - if (inst.operation == Recipe_number["jump-if"] || inst.operation == Recipe_number["jump-unless"]) { + if (inst.operation == Recipe_ordinal["jump-if"] || inst.operation == Recipe_ordinal["jump-unless"]) { replace_offset(inst.ingredients.at(1), offset, i, r); } - if ((inst.operation == Recipe_number["loop"] || inst.operation == Recipe_number["break"]) + if ((inst.operation == Recipe_ordinal["loop"] || inst.operation == Recipe_ordinal["break"]) && SIZE(inst.ingredients) == 1) { replace_offset(inst.ingredients.at(0), offset, i, r); } - if ((inst.operation == Recipe_number["loop-if"] || inst.operation == Recipe_number["loop-unless"] - || inst.operation == Recipe_number["break-if"] || inst.operation == Recipe_number["break-unless"]) + if ((inst.operation == Recipe_ordinal["loop-if"] || inst.operation == Recipe_ordinal["loop-unless"] + || inst.operation == Recipe_ordinal["break-if"] || inst.operation == Recipe_ordinal["break-unless"]) && SIZE(inst.ingredients) == 2) { replace_offset(inst.ingredients.at(1), offset, i, r); } @@ -45,7 +45,7 @@ void transform_labels(const recipe_number r) { } :(code) -void replace_offset(reagent& x, /*const*/ map<string, long long int>& offset, const long long int current_offset, const recipe_number r) { +void replace_offset(reagent& x, /*const*/ map<string, long long int>& offset, const long long int current_offset, const recipe_ordinal r) { //? cerr << "AAA " << x.to_string() << '\n'; //? 1 assert(is_literal(x)); //? cerr << "BBB " << x.to_string() << '\n'; //? 1 diff --git a/049continuation.cc b/049continuation.cc index 4e0dd0e0..c292f44b 100644 --- a/049continuation.cc +++ b/049continuation.cc @@ -14,13 +14,13 @@ Continuation.clear(); Next_continuation_id = 0; :(before "End Mu Types Initialization") -type_number continuation = Type_number["continuation"] = Next_type_number++; +type_ordinal continuation = Type_ordinal["continuation"] = Next_type_ordinal++; Type[continuation].name = "continuation"; :(before "End Primitive Recipe Declarations") CURRENT_CONTINUATION, :(before "End Primitive Recipe Numbers") -Recipe_number["current-continuation"] = CURRENT_CONTINUATION; +Recipe_ordinal["current-continuation"] = CURRENT_CONTINUATION; :(before "End Primitive Recipe Implementations") case CURRENT_CONTINUATION: { // copy the current call stack @@ -37,7 +37,7 @@ case CURRENT_CONTINUATION: { :(before "End Primitive Recipe Declarations") CONTINUE_FROM, :(before "End Primitive Recipe Numbers") -Recipe_number["continue-from"] = CONTINUE_FROM; +Recipe_ordinal["continue-from"] = CONTINUE_FROM; :(before "End Primitive Recipe Implementations") case CONTINUE_FROM: { assert(scalar(ingredients.at(0))); @@ -165,11 +165,11 @@ is_reset = false; :(before "End Primitive Recipe Declarations") CREATE_DELIMITED_CONTINUATION, :(before "End Primitive Recipe Numbers") -Recipe_number["create-delimited-continuation"] = CREATE_DELIMITED_CONTINUATION; +Recipe_ordinal["create-delimited-continuation"] = CREATE_DELIMITED_CONTINUATION; :(before "End Primitive Recipe Implementations") case CREATE_DELIMITED_CONTINUATION: { Current_routine->calls.front().is_reset = true; - Current_routine->calls.push_front(call(Recipe_number[current_instruction().ingredients.at(0).name])); + Current_routine->calls.push_front(call(Recipe_ordinal[current_instruction().ingredients.at(0).name])); ingredients.erase(ingredients.begin()); // drop the callee goto complete_call; } @@ -187,7 +187,7 @@ Next_delimited_continuation_id = 0; :(before "End Primitive Recipe Declarations") REPLY_DELIMITED_CONTINUATION, :(before "End Primitive Recipe Numbers") -Recipe_number["reply-delimited-continuation"] = REPLY_DELIMITED_CONTINUATION; +Recipe_ordinal["reply-delimited-continuation"] = REPLY_DELIMITED_CONTINUATION; :(before "End Primitive Recipe Implementations") case REPLY_DELIMITED_CONTINUATION: { // first clear any existing ingredients, to isolate the creation of the diff --git a/050scenario.cc b/050scenario.cc index 5010aa86..836ff9f8 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -139,7 +139,7 @@ void run_mu_scenario(const scenario& s) { setup(); } assert(Routines.empty()); - vector<recipe_number> tmp = load("recipe "+s.name+" [ "+s.to_run+" ]"); + vector<recipe_ordinal> tmp = load("recipe "+s.name+" [ "+s.to_run+" ]"); bind_special_scenario_names(tmp.at(0)); transform_all(); run(tmp.front()); @@ -173,17 +173,17 @@ recipe main [ :(before "End Primitive Recipe Declarations") RUN, :(before "End Primitive Recipe Numbers") -Recipe_number["run"] = RUN; +Recipe_ordinal["run"] = RUN; :(before "End Primitive Recipe Implementations") case RUN: { //? cout << "recipe " << current_instruction().ingredients.at(0).name << '\n'; //? 1 ostringstream tmp; - tmp << "recipe run" << Next_recipe_number << " [ " << current_instruction().ingredients.at(0).name << " ]"; + tmp << "recipe run" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]"; //? Show_rest_of_stream = true; //? 1 - vector<recipe_number> tmp_recipe = load(tmp.str()); + vector<recipe_ordinal> tmp_recipe = load(tmp.str()); bind_special_scenario_names(tmp_recipe.at(0)); transform_all(); -//? cout << tmp_recipe.at(0) << ' ' << Recipe_number["main"] << '\n'; //? 1 +//? cout << tmp_recipe.at(0) << ' ' << Recipe_ordinal["main"] << '\n'; //? 1 Current_routine->calls.push_front(call(tmp_recipe.at(0))); continue; // not done with caller; don't increment current_step_index() } @@ -191,7 +191,7 @@ case RUN: { // Some variables for fake resources always get special addresses in // scenarios. :(code) -void bind_special_scenario_names(recipe_number r) { +void bind_special_scenario_names(recipe_ordinal r) { // Special Scenario Variable Names(r) // End Special Scenario Variable Names(r) } @@ -224,7 +224,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") MEMORY_SHOULD_CONTAIN, :(before "End Primitive Recipe Numbers") -Recipe_number["memory-should-contain"] = MEMORY_SHOULD_CONTAIN; +Recipe_ordinal["memory-should-contain"] = MEMORY_SHOULD_CONTAIN; :(before "End Primitive Recipe Implementations") case MEMORY_SHOULD_CONTAIN: { if (!Passed) break; @@ -387,7 +387,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") TRACE_SHOULD_CONTAIN, :(before "End Primitive Recipe Numbers") -Recipe_number["trace-should-contain"] = TRACE_SHOULD_CONTAIN; +Recipe_ordinal["trace-should-contain"] = TRACE_SHOULD_CONTAIN; :(before "End Primitive Recipe Implementations") case TRACE_SHOULD_CONTAIN: { if (!Passed) break; @@ -479,7 +479,7 @@ recipe main [ :(before "End Primitive Recipe Declarations") TRACE_SHOULD_NOT_CONTAIN, :(before "End Primitive Recipe Numbers") -Recipe_number["trace-should-not-contain"] = TRACE_SHOULD_NOT_CONTAIN; +Recipe_ordinal["trace-should-not-contain"] = TRACE_SHOULD_NOT_CONTAIN; :(before "End Primitive Recipe Implementations") case TRACE_SHOULD_NOT_CONTAIN: { if (!Passed) break; diff --git a/064random.cc b/064random.cc index 0180dfae..05fa2863 100644 --- a/064random.cc +++ b/064random.cc @@ -1,7 +1,7 @@ :(before "End Primitive Recipe Declarations") RANDOM, :(before "End Primitive Recipe Numbers") -Recipe_number["random"] = RANDOM; +Recipe_ordinal["random"] = RANDOM; :(before "End Primitive Recipe Implementations") case RANDOM: { // todo: limited range of numbers, might be imperfectly random @@ -14,7 +14,7 @@ case RANDOM: { :(before "End Primitive Recipe Declarations") MAKE_RANDOM_NONDETERMINISTIC, :(before "End Primitive Recipe Numbers") -Recipe_number["make-random-nondeterministic"] = MAKE_RANDOM_NONDETERMINISTIC; +Recipe_ordinal["make-random-nondeterministic"] = MAKE_RANDOM_NONDETERMINISTIC; :(before "End Primitive Recipe Implementations") case MAKE_RANDOM_NONDETERMINISTIC: { srand(time(NULL)); @@ -24,7 +24,7 @@ case MAKE_RANDOM_NONDETERMINISTIC: { :(before "End Primitive Recipe Declarations") ROUND, :(before "End Primitive Recipe Numbers") -Recipe_number["round"] = ROUND; +Recipe_ordinal["round"] = ROUND; :(before "End Primitive Recipe Implementations") case ROUND: { assert(scalar(ingredients.at(0))); diff --git a/070display.cc b/070display.cc index 477552a0..a926c1ae 100644 --- a/070display.cc +++ b/070display.cc @@ -13,7 +13,7 @@ bool Autodisplay = true; :(before "End Primitive Recipe Declarations") OPEN_CONSOLE, :(before "End Primitive Recipe Numbers") -Recipe_number["open-console"] = OPEN_CONSOLE; +Recipe_ordinal["open-console"] = OPEN_CONSOLE; //? cerr << "open-console: " << OPEN_CONSOLE << '\n'; //? 1 :(before "End Primitive Recipe Implementations") case OPEN_CONSOLE: { @@ -25,7 +25,7 @@ case OPEN_CONSOLE: { :(before "End Primitive Recipe Declarations") CLOSE_CONSOLE, :(before "End Primitive Recipe Numbers") -Recipe_number["close-console"] = CLOSE_CONSOLE; +Recipe_ordinal["close-console"] = CLOSE_CONSOLE; :(before "End Primitive Recipe Implementations") case CLOSE_CONSOLE: { tb_shutdown(); @@ -39,7 +39,7 @@ tb_shutdown(); :(before "End Primitive Recipe Declarations") CLEAR_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["clear-display"] = CLEAR_DISPLAY; +Recipe_ordinal["clear-display"] = CLEAR_DISPLAY; :(before "End Primitive Recipe Implementations") case CLEAR_DISPLAY: { tb_clear(); @@ -50,7 +50,7 @@ case CLEAR_DISPLAY: { :(before "End Primitive Recipe Declarations") CLEAR_LINE_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY; +Recipe_ordinal["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case CLEAR_LINE_ON_DISPLAY: { long long int width = tb_width(); @@ -65,7 +65,7 @@ case CLEAR_LINE_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") PRINT_CHARACTER_TO_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY; +Recipe_ordinal["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY; :(before "End Primitive Recipe Implementations") case PRINT_CHARACTER_TO_DISPLAY: { int h=tb_height(), w=tb_width(); @@ -114,7 +114,7 @@ case PRINT_CHARACTER_TO_DISPLAY: { :(before "End Primitive Recipe Declarations") CURSOR_POSITION_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY; +Recipe_ordinal["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case CURSOR_POSITION_ON_DISPLAY: { products.resize(2); @@ -126,7 +126,7 @@ case CURSOR_POSITION_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") MOVE_CURSOR_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY; +Recipe_ordinal["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_ON_DISPLAY: { assert(scalar(ingredients.at(0))); @@ -141,7 +141,7 @@ case MOVE_CURSOR_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") MOVE_CURSOR_DOWN_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["move-cursor-down-on-display"] = MOVE_CURSOR_DOWN_ON_DISPLAY; +Recipe_ordinal["move-cursor-down-on-display"] = MOVE_CURSOR_DOWN_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_DOWN_ON_DISPLAY: { int h=tb_height(); @@ -157,7 +157,7 @@ case MOVE_CURSOR_DOWN_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") MOVE_CURSOR_UP_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["move-cursor-up-on-display"] = MOVE_CURSOR_UP_ON_DISPLAY; +Recipe_ordinal["move-cursor-up-on-display"] = MOVE_CURSOR_UP_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_UP_ON_DISPLAY: { if (Display_row > 0) { @@ -171,7 +171,7 @@ case MOVE_CURSOR_UP_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") MOVE_CURSOR_RIGHT_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["move-cursor-right-on-display"] = MOVE_CURSOR_RIGHT_ON_DISPLAY; +Recipe_ordinal["move-cursor-right-on-display"] = MOVE_CURSOR_RIGHT_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_RIGHT_ON_DISPLAY: { int w=tb_width(); @@ -187,7 +187,7 @@ case MOVE_CURSOR_RIGHT_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") MOVE_CURSOR_LEFT_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["move-cursor-left-on-display"] = MOVE_CURSOR_LEFT_ON_DISPLAY; +Recipe_ordinal["move-cursor-left-on-display"] = MOVE_CURSOR_LEFT_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case MOVE_CURSOR_LEFT_ON_DISPLAY: { if (Display_column > 0) { @@ -201,7 +201,7 @@ case MOVE_CURSOR_LEFT_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") DISPLAY_WIDTH, :(before "End Primitive Recipe Numbers") -Recipe_number["display-width"] = DISPLAY_WIDTH; +Recipe_ordinal["display-width"] = DISPLAY_WIDTH; :(before "End Primitive Recipe Implementations") case DISPLAY_WIDTH: { products.resize(1); @@ -212,7 +212,7 @@ case DISPLAY_WIDTH: { :(before "End Primitive Recipe Declarations") DISPLAY_HEIGHT, :(before "End Primitive Recipe Numbers") -Recipe_number["display-height"] = DISPLAY_HEIGHT; +Recipe_ordinal["display-height"] = DISPLAY_HEIGHT; :(before "End Primitive Recipe Implementations") case DISPLAY_HEIGHT: { products.resize(1); @@ -223,7 +223,7 @@ case DISPLAY_HEIGHT: { :(before "End Primitive Recipe Declarations") HIDE_CURSOR_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["hide-cursor-on-display"] = HIDE_CURSOR_ON_DISPLAY; +Recipe_ordinal["hide-cursor-on-display"] = HIDE_CURSOR_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case HIDE_CURSOR_ON_DISPLAY: { tb_set_cursor(TB_HIDE_CURSOR, TB_HIDE_CURSOR); @@ -233,7 +233,7 @@ case HIDE_CURSOR_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") SHOW_CURSOR_ON_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["show-cursor-on-display"] = SHOW_CURSOR_ON_DISPLAY; +Recipe_ordinal["show-cursor-on-display"] = SHOW_CURSOR_ON_DISPLAY; :(before "End Primitive Recipe Implementations") case SHOW_CURSOR_ON_DISPLAY: { tb_set_cursor(Display_row, Display_column); @@ -243,7 +243,7 @@ case SHOW_CURSOR_ON_DISPLAY: { :(before "End Primitive Recipe Declarations") HIDE_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["hide-display"] = HIDE_DISPLAY; +Recipe_ordinal["hide-display"] = HIDE_DISPLAY; :(before "End Primitive Recipe Implementations") case HIDE_DISPLAY: { Autodisplay = false; @@ -253,7 +253,7 @@ case HIDE_DISPLAY: { :(before "End Primitive Recipe Declarations") SHOW_DISPLAY, :(before "End Primitive Recipe Numbers") -Recipe_number["show-display"] = SHOW_DISPLAY; +Recipe_ordinal["show-display"] = SHOW_DISPLAY; :(before "End Primitive Recipe Implementations") case SHOW_DISPLAY: { Autodisplay = true; @@ -266,7 +266,7 @@ case SHOW_DISPLAY: { :(before "End Primitive Recipe Declarations") WAIT_FOR_SOME_INTERACTION, :(before "End Primitive Recipe Numbers") -Recipe_number["wait-for-some-interaction"] = WAIT_FOR_SOME_INTERACTION; +Recipe_ordinal["wait-for-some-interaction"] = WAIT_FOR_SOME_INTERACTION; :(before "End Primitive Recipe Implementations") case WAIT_FOR_SOME_INTERACTION: { tb_event event; @@ -277,7 +277,7 @@ case WAIT_FOR_SOME_INTERACTION: { :(before "End Primitive Recipe Declarations") CHECK_FOR_INTERACTION, :(before "End Primitive Recipe Numbers") -Recipe_number["check-for-interaction"] = CHECK_FOR_INTERACTION; +Recipe_ordinal["check-for-interaction"] = CHECK_FOR_INTERACTION; :(before "End Primitive Recipe Implementations") case CHECK_FOR_INTERACTION: { products.resize(2); // result and status diff --git a/072scenario_screen.cc b/072scenario_screen.cc index 25298629..14ac3a36 100644 --- a/072scenario_screen.cc +++ b/072scenario_screen.cc @@ -143,21 +143,21 @@ Name[r]["screen"] = SCREEN; // `screen:address <- new-fake-screen width, height` //? cout << "before: " << curr.to_string() << '\n'; //? 1 if (curr.name == "assume-screen") { - curr.operation = Recipe_number["new-fake-screen"]; + curr.operation = Recipe_ordinal["new-fake-screen"]; curr.name = "new-fake-screen"; assert(curr.operation); assert(curr.products.empty()); curr.products.push_back(reagent("screen:address")); curr.products.at(0).set_value(SCREEN); //? cout << "after: " << curr.to_string() << '\n'; //? 1 -//? cout << "AAA " << Recipe_number["new-fake-screen"] << '\n'; //? 1 +//? cout << "AAA " << Recipe_ordinal["new-fake-screen"] << '\n'; //? 1 } //: screen-should-contain is a regular instruction :(before "End Primitive Recipe Declarations") SCREEN_SHOULD_CONTAIN, :(before "End Primitive Recipe Numbers") -Recipe_number["screen-should-contain"] = SCREEN_SHOULD_CONTAIN; +Recipe_ordinal["screen-should-contain"] = SCREEN_SHOULD_CONTAIN; :(before "End Primitive Recipe Implementations") case SCREEN_SHOULD_CONTAIN: { if (!Passed) break; @@ -168,7 +168,7 @@ case SCREEN_SHOULD_CONTAIN: { :(before "End Primitive Recipe Declarations") SCREEN_SHOULD_CONTAIN_IN_COLOR, :(before "End Primitive Recipe Numbers") -Recipe_number["screen-should-contain-in-color"] = SCREEN_SHOULD_CONTAIN_IN_COLOR; +Recipe_ordinal["screen-should-contain-in-color"] = SCREEN_SHOULD_CONTAIN_IN_COLOR; :(before "End Primitive Recipe Implementations") case SCREEN_SHOULD_CONTAIN_IN_COLOR: { if (!Passed) break; @@ -196,13 +196,13 @@ void check_screen(const string& expected_contents, const int color) { //? cerr << "Checking screen for color " << color << "\n"; //? 2 assert(!Current_routine->calls.front().default_space); // not supported long long int screen_location = Memory[SCREEN]; - int data_offset = find_element_name(Type_number["screen"], "data"); + int data_offset = find_element_name(Type_ordinal["screen"], "data"); assert(data_offset >= 0); long long int screen_data_location = screen_location+data_offset; // type: address:array:character long long int screen_data_start = Memory[screen_data_location]; // type: array:character - int width_offset = find_element_name(Type_number["screen"], "num-columns"); + int width_offset = find_element_name(Type_ordinal["screen"], "num-columns"); long long int screen_width = Memory[screen_location+width_offset]; - int height_offset = find_element_name(Type_number["screen"], "num-rows"); + int height_offset = find_element_name(Type_ordinal["screen"], "num-rows"); long long int screen_height = Memory[screen_location+height_offset]; raw_string_stream cursor(expected_contents); // todo: too-long expected_contents should fail @@ -319,7 +319,7 @@ void raw_string_stream::skip_whitespace_and_comments() { :(before "End Primitive Recipe Declarations") _DUMP_SCREEN, :(before "End Primitive Recipe Numbers") -Recipe_number["$dump-screen"] = _DUMP_SCREEN; +Recipe_ordinal["$dump-screen"] = _DUMP_SCREEN; :(before "End Primitive Recipe Implementations") case _DUMP_SCREEN: { dump_screen(); @@ -330,11 +330,11 @@ case _DUMP_SCREEN: { void dump_screen() { assert(!Current_routine->calls.front().default_space); // not supported long long int screen_location = Memory[SCREEN]; - int width_offset = find_element_name(Type_number["screen"], "num-columns"); + int width_offset = find_element_name(Type_ordinal["screen"], "num-columns"); long long int screen_width = Memory[screen_location+width_offset]; - int height_offset = find_element_name(Type_number["screen"], "num-rows"); + int height_offset = find_element_name(Type_ordinal["screen"], "num-rows"); long long int screen_height = Memory[screen_location+height_offset]; - int data_offset = find_element_name(Type_number["screen"], "data"); + int data_offset = find_element_name(Type_ordinal["screen"], "data"); assert(data_offset >= 0); long long int screen_data_location = screen_location+data_offset; // type: address:array:character long long int screen_data_start = Memory[screen_data_location]; // type: array:character diff --git a/075scenario_console.cc b/075scenario_console.cc index 427906e9..c5946617 100644 --- a/075scenario_console.cc +++ b/075scenario_console.cc @@ -43,7 +43,7 @@ if (s == "console") return true; :(before "End Primitive Recipe Declarations") ASSUME_CONSOLE, :(before "End Primitive Recipe Numbers") -Recipe_number["assume-console"] = ASSUME_CONSOLE; +Recipe_ordinal["assume-console"] = ASSUME_CONSOLE; :(before "End Primitive Recipe Implementations") case ASSUME_CONSOLE: { //? cerr << "aaa: " << current_instruction().ingredients.at(0).name << '\n'; //? 2 @@ -162,7 +162,7 @@ scenario events-in-scenario [ :(before "End Primitive Recipe Declarations") REPLACE_IN_CONSOLE, :(before "End Primitive Recipe Numbers") -Recipe_number["replace-in-console"] = REPLACE_IN_CONSOLE; +Recipe_ordinal["replace-in-console"] = REPLACE_IN_CONSOLE; :(before "End Primitive Recipe Implementations") case REPLACE_IN_CONSOLE: { assert(scalar(ingredients.at(0))); @@ -203,8 +203,8 @@ long long int size_of_event() { // memoize result if already computed static long long int result = 0; if (result) return result; - vector<type_number> type; - type.push_back(Type_number["event"]); + vector<type_ordinal> type; + type.push_back(Type_ordinal["event"]); result = size_of(type); return result; } @@ -213,9 +213,9 @@ long long int size_of_events() { // memoize result if already computed static long long int result = 0; if (result) return result; - vector<type_number> type; - assert(Type_number["console"]); - type.push_back(Type_number["console"]); + vector<type_ordinal> type; + assert(Type_ordinal["console"]); + type.push_back(Type_ordinal["console"]); result = size_of(type); return result; } diff --git a/080trace_browser.cc b/080trace_browser.cc index 69d68792..931a9d86 100644 --- a/080trace_browser.cc +++ b/080trace_browser.cc @@ -1,7 +1,7 @@ :(before "End Primitive Recipe Declarations") _BROWSE_TRACE, :(before "End Primitive Recipe Numbers") -Recipe_number["$browse-trace"] = _BROWSE_TRACE; +Recipe_ordinal["$browse-trace"] = _BROWSE_TRACE; :(before "End Primitive Recipe Implementations") case _BROWSE_TRACE: { start_trace_browser(); diff --git a/081run_interactive.cc b/081run_interactive.cc index 95a40533..5f38ad60 100644 --- a/081run_interactive.cc +++ b/081run_interactive.cc @@ -3,7 +3,7 @@ :(before "End Primitive Recipe Declarations") RUN_INTERACTIVE, :(before "End Primitive Recipe Numbers") -Recipe_number["run-interactive"] = RUN_INTERACTIVE; +Recipe_ordinal["run-interactive"] = RUN_INTERACTIVE; //? cerr << "run-interactive: " << RUN_INTERACTIVE << '\n'; //? 1 :(before "End Primitive Recipe Implementations") case RUN_INTERACTIVE: { @@ -35,8 +35,8 @@ void run_interactive(long long int address) { } //? cerr << size << ' ' << Memory[address+size] << '\n'; //? 1 assert(Memory[address+size] == 10); // skip the newline - if (Recipe_number.find("interactive") == Recipe_number.end()) - Recipe_number["interactive"] = Next_recipe_number++; + if (Recipe_ordinal.find("interactive") == Recipe_ordinal.end()) + Recipe_ordinal["interactive"] = Next_recipe_ordinal++; string command = trim(strip_comments(tmp.str())); if (command.empty()) { ++current_step_index(); @@ -48,8 +48,8 @@ void run_interactive(long long int address) { return; } //? exit(0); //? 1 - if (Name[Recipe_number["interactive"]].find(command) != Name[Recipe_number["interactive"]].end()) { - print_value_of_location_as_response(Name[Recipe_number["interactive"]][command]); + if (Name[Recipe_ordinal["interactive"]].find(command) != Name[Recipe_ordinal["interactive"]].end()) { + print_value_of_location_as_response(Name[Recipe_ordinal["interactive"]][command]); ++current_step_index(); return; } @@ -57,15 +57,15 @@ void run_interactive(long long int address) { //? cerr << command; //? 1 //? exit(0); //? 1 //? cerr << "AAA 1\n"; //? 1 - Recipe.erase(Recipe_number["interactive"]); + Recipe.erase(Recipe_ordinal["interactive"]); // call run(string) but without the scheduling //? cerr << ("recipe interactive [\n"+command+"\n]\n"); //? 1 load("recipe interactive [\n"+command+"\n]\n"); transform_all(); -//? cerr << "names: " << Name[Recipe_number["interactive"]].size() << "; "; //? 1 -//? cerr << "steps: " << Recipe[Recipe_number["interactive"]].steps.size() << "; "; //? 1 -//? cerr << "interactive transformed_until: " << Recipe[Recipe_number["interactive"]].transformed_until << '\n'; //? 1 - Current_routine->calls.push_front(call(Recipe_number["interactive"])); +//? cerr << "names: " << Name[Recipe_ordinal["interactive"]].size() << "; "; //? 1 +//? cerr << "steps: " << Recipe[Recipe_ordinal["interactive"]].steps.size() << "; "; //? 1 +//? cerr << "interactive transformed_until: " << Recipe[Recipe_ordinal["interactive"]].transformed_until << '\n'; //? 1 + Current_routine->calls.push_front(call(Recipe_ordinal["interactive"])); } string strip_comments(string in) { @@ -114,7 +114,7 @@ void print_value_of_location_as_response(long long int address) { :(before "End Primitive Recipe Declarations") _RUN_DEPTH, :(before "End Primitive Recipe Numbers") -Recipe_number["$run-depth"] = _RUN_DEPTH; +Recipe_ordinal["$run-depth"] = _RUN_DEPTH; :(before "End Primitive Recipe Implementations") case _RUN_DEPTH: { cerr << Current_routine->calls.size(); |