From 65361948ca7975553757a0e0df4ac7352413044c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 14 May 2015 16:04:45 -0700 Subject: 1376 - update github docs --- html/072scenario_screen.cc.html | 68 +++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) (limited to 'html/072scenario_screen.cc.html') diff --git a/html/072scenario_screen.cc.html b/html/072scenario_screen.cc.html index d5426460..79cc6044 100644 --- a/html/072scenario_screen.cc.html +++ b/html/072scenario_screen.cc.html @@ -2,7 +2,7 @@ -Mu - 072scenario_screen.cc +~/Desktop/s/mu/072scenario_screen.cc @@ -83,14 +83,14 @@ assert(Next_predefined_global_for_scenarios < // There's a restriction on the number of variables 'run' can use, so that // it can avoid colliding with the dynamic allocator in case it doesn't // initialize a default-space. -assert(Name[tmp_recipe[0]][""] < Max_variables_in_scenarios); +assert(Name[tmp_recipe.at(0)][""] < Max_variables_in_scenarios); :(before "End Globals") // Scenario Globals. const size_t SCREEN = Next_predefined_global_for_scenarios++; // End Scenario Globals. :(before "End Predefined Scenario Locals In Run") -Name[tmp_recipe[0]]["screen"] = SCREEN; +Name[tmp_recipe.at(0)]["screen"] = SCREEN; :(before "End Rewrite Instruction(curr)") // rewrite `assume-screen width, height` to @@ -100,7 +100,7 @@ if (curr.name == < curr.operation = Recipe_number["init-fake-screen"]; assert(curr.products.empty()); curr.products.push_back(reagent("screen:address")); - curr.products[0].set_value(SCREEN); + curr.products.at(0).set_value(SCREEN); //? cout << "after: " << curr.to_string() << '\n'; //? 1 //? cout << "AAA " << Recipe_number["init-fake-screen"] << '\n'; //? 1 } @@ -113,13 +113,14 @@ Recipe_number["screen-should-contain"] = :(before "End Primitive Recipe Implementations") case SCREEN_SHOULD_CONTAIN: { //? cout << "AAA\n"; //? 1 - check_screen(current_instruction().ingredients[0].name); + check_screen(current_instruction().ingredients.at(0).name); break; } :(code) void check_screen(const string& contents) { - assert(!Current_routine->calls.top().default_space); // not supported +//? cerr << "Checking screen\n"; //? 1 + assert(!Current_routine->calls.front().default_space); // not supported index_t screen_location = Memory[SCREEN]; int data_offset = find_element_name(Type_number["screen"], "data"); assert(data_offset >= 0); @@ -151,15 +152,62 @@ void check_screen(const string& contents; // now skip length for (index_t i = 0; i < expected_contents.size(); ++i) { trace("run") << "checking location " << screen_data_start+i; - if ((!Memory[screen_data_start+i] && !isspace(expected_contents[i])) // uninitialized memory => spaces - || (Memory[screen_data_start+i] && Memory[screen_data_start+i] != expected_contents[i])) { +//? cerr << "comparing " << i/screen_width << ", " << i%screen_width << ": " << Memory[screen_data_start+i] << " vs " << (int)expected_contents.at(i) << '\n'; //? 1 + if ((!Memory[screen_data_start+i] && !isspace(expected_contents.at(i))) // uninitialized memory => spaces + || (Memory[screen_data_start+i] && Memory[screen_data_start+i] != expected_contents.at(i))) { //? cerr << "CCC " << Trace_stream << " " << Hide_warnings << '\n'; //? 1 - raise << "expected screen location (" << i/screen_width << ", " << i%screen_width << ") to contain '" << expected_contents[i] << "' instead of '" << static_cast<char>(Memory[screen_data_start+i]) << "'\n"; - Passed = false; + if (Current_scenario && !Hide_warnings) { + // genuine test in a mu file + raise << "\nF - " << Current_scenario->name << ": expected screen location (" << i/screen_width << ", " << i%screen_width << ") to contain '" << expected_contents.at(i) << "' instead of '" << static_cast<char>(Memory[screen_data_start+i]) << "'\n"; + dump_screen(); + } + else { + // just testing check_screen + raise << "expected screen location (" << i/screen_width << ", " << i%screen_width << ") to contain '" << expected_contents.at(i) << "' instead of '" << static_cast<char>(Memory[screen_data_start+i]) << "'\n"; + } + if (!Hide_warnings) { + Passed = false; + ++Num_failures; + } return; } } } + +:(before "End Primitive Recipe Declarations") +_DUMP_SCREEN, +:(before "End Primitive Recipe Numbers") +Recipe_number["$dump-screen"] = _DUMP_SCREEN; +:(before "End Primitive Recipe Implementations") +case _DUMP_SCREEN: { + dump_screen(); + break; +} + +:(code) +void dump_screen() { + assert(!Current_routine->calls.front().default_space); // not supported + index_t screen_location = Memory[SCREEN]; + int width_offset = find_element_name(Type_number["screen"], "num-columns"); + size_t screen_width = Memory[screen_location+width_offset]; + int height_offset = find_element_name(Type_number["screen"], "num-rows"); + size_t screen_height = Memory[screen_location+height_offset]; + int data_offset = find_element_name(Type_number["screen"], "data"); + assert(data_offset >= 0); + index_t screen_data_location = screen_location+data_offset; // type: address:array:character + index_t screen_data_start = Memory[screen_data_location]; // type: array:character +//? cerr << "data start: " << screen_data_start << '\n'; //? 1 + assert(Memory[screen_data_start] == screen_width*screen_height); + index_t curr = screen_data_start+1; // skip length + for (index_t row = 0; row < screen_height; ++row) { +//? cerr << curr << ":\n"; //? 1 + for (index_t col = 0; col < screen_width; ++col) { + cerr << static_cast<char>(Memory[curr]); + ++curr; + } + cerr << '\n'; + } +} -- cgit 1.4.1-2-gfad0