diff options
-rw-r--r-- | 002test.cc | 2 | ||||
-rw-r--r-- | 003trace.cc | 11 | ||||
-rw-r--r-- | 010vm.cc | 2 | ||||
-rw-r--r-- | 011load.cc | 17 | ||||
-rw-r--r-- | 012transform.cc | 2 | ||||
-rw-r--r-- | 013literal_string.cc | 9 | ||||
-rw-r--r-- | 020run.cc | 20 | ||||
-rw-r--r-- | 021arithmetic.cc | 1 | ||||
-rw-r--r-- | 029tools.cc | 1 | ||||
-rw-r--r-- | 030container.cc | 7 | ||||
-rw-r--r-- | 031address.cc | 3 | ||||
-rw-r--r-- | 034call.cc | 1 | ||||
-rw-r--r-- | 040brace.cc | 2 | ||||
-rw-r--r-- | 042name.cc | 2 | ||||
-rw-r--r-- | 043new.cc | 37 | ||||
-rw-r--r-- | 044space.cc | 2 | ||||
-rw-r--r-- | 046closure_name.cc | 2 | ||||
-rw-r--r-- | 050scenario.cc | 17 | ||||
-rw-r--r-- | 052tangle.cc | 4 | ||||
-rw-r--r-- | 060string.mu | 9 | ||||
-rw-r--r-- | 063list.mu | 1 | ||||
-rw-r--r-- | 065duplex_list.mu | 1 | ||||
-rw-r--r-- | 070display.cc | 1 | ||||
-rw-r--r-- | 071print.mu | 8 | ||||
-rw-r--r-- | 075scenario_console.cc | 16 | ||||
-rw-r--r-- | 080trace_browser.cc | 10 | ||||
-rw-r--r-- | 081run_interactive.cc | 4 | ||||
-rw-r--r-- | 082persist.cc | 2 | ||||
-rw-r--r-- | chessboard.mu | 8 | ||||
-rw-r--r-- | display.mu | 1 | ||||
-rw-r--r-- | edit.mu | 83 |
31 files changed, 64 insertions, 222 deletions
diff --git a/002test.cc b/002test.cc index 37698d30..17de608c 100644 --- a/002test.cc +++ b/002test.cc @@ -54,7 +54,7 @@ if (Run_tests) { time_t t; time(&t); cerr << "C tests: " << ctime(&t); for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { -//? cerr << i << '\n'; //? 2 +//? cerr << i << '\n'; run_test(i); } // End Tests diff --git a/003trace.cc b/003trace.cc index a6e262ac..4426bbd3 100644 --- a/003trace.cc +++ b/003trace.cc @@ -83,7 +83,6 @@ :(before "End Tracing") bool Hide_warnings = false; :(before "End Setup") -//? cerr << "AAA setup\n"; //? 2 Hide_warnings = false; :(before "End Types") @@ -136,7 +135,6 @@ struct trace_stream { past_lines.push_back(trace_line(curr_depth, trim(curr_layer), curr_contents)); // preserve indent in contents if (curr_layer == dump_layer || curr_layer == "dump" || dump_layer == "all" || (!Hide_warnings && curr_layer == "warn")) -//? if (dump_layer == "all" && (Current_routine->id == 3 || curr_layer == "schedule")) //? 1 cerr << curr_layer << ": " << curr_contents << '\n'; delete curr_stream; curr_stream = NULL; @@ -190,9 +188,7 @@ struct lease_tracer { lease_tracer() { Trace_stream = new trace_stream; } ~lease_tracer() { if (!Trace_stream) return; // in case tests close Trace_stream -//? cerr << "write to file? " << Trace_file << "$\n"; //? 2 if (!Trace_file.empty()) { -//? cerr << "writing\n"; //? 2 ofstream fout((Trace_dir+Trace_file).c_str()); fout << Trace_stream->readable_contents(""); fout.close(); @@ -204,7 +200,6 @@ struct lease_tracer { #define START_TRACING_UNTIL_END_OF_SCOPE lease_tracer leased_tracer; :(before "End Test Setup") START_TRACING_UNTIL_END_OF_SCOPE -//? Trace_stream->dump_layer = "all"; //? 1 #define CHECK_TRACE_CONTENTS(...) check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) @@ -218,15 +213,12 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte string layer, contents; split_layer_contents(expected_lines.at(curr_expected_line), &layer, &contents); for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -//? cerr << "AAA " << layer << ' ' << p->label << '\n'; //? 1 if (layer != p->label) continue; -//? cerr << "BBB ^" << contents << "$ ^" << p->contents << "$\n"; //? 1 if (contents != trim(p->contents)) continue; -//? cerr << "CCC\n"; //? 1 ++curr_expected_line; while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) ++curr_expected_line; @@ -237,7 +229,6 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte ++Num_failures; cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; DUMP(layer); -//? exit(0); //? 1 Passed = false; return false; } @@ -265,8 +256,6 @@ int trace_count(string layer, string line) { long result = 0; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (layer == p->label) { -//? cerr << "a: " << line << "$\n"; //? 1 -//? cerr << "b: " << trim(p->contents) << "$\n"; //? 1 if (line == "" || line == trim(p->contents)) ++result; } diff --git a/010vm.cc b/010vm.cc index 92e7d14a..c7ac4d0a 100644 --- a/010vm.cc +++ b/010vm.cc @@ -200,7 +200,6 @@ reagent::reagent(string s) :original_string(s), value(0), initialized(false) { if (Type_ordinal.find(type) == Type_ordinal.end() // types can contain integers, like for array sizes && !is_integer(type)) { -//? cerr << type << " is " << Next_type_ordinal << '\n'; //? 1 Type_ordinal[type] = Next_type_ordinal++; } types.push_back(Type_ordinal[type]); @@ -239,7 +238,6 @@ string reagent::to_string() const { } } out << "}"; -//? if (properties.at(0).second.empty()) cerr << out.str(); //? 1 return out.str(); } diff --git a/011load.cc b/011load.cc index d73f1e0f..796a0bc7 100644 --- a/011load.cc +++ b/011load.cc @@ -20,14 +20,12 @@ vector<recipe_ordinal> load(istream& in) { in >> std::noskipws; vector<recipe_ordinal> result; while (!in.eof()) { -//? cerr << "===\n"; //? 1 skip_whitespace_and_comments(in); if (in.eof()) break; string command = next_word(in); // Command Handlers if (command == "recipe") { string recipe_name = next_word(in); -//? cerr << "recipe: " << recipe_name << '\n'; //? 2 if (recipe_name.empty()) raise << "empty recipe name\n" << end(); if (Recipe_ordinal.find(recipe_name) == Recipe_ordinal.end()) { @@ -39,7 +37,6 @@ vector<recipe_ordinal> load(istream& in) { } // todo: save user-defined recipes to mu's memory Recipe[Recipe_ordinal[recipe_name]] = slurp_recipe(in); -//? cerr << Recipe_ordinal[recipe_name] << ": " << recipe_name << '\n'; //? 2 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_ordinal[recipe_name]); @@ -63,7 +60,6 @@ recipe slurp_recipe(istream& in) { instruction curr; while (next_instruction(in, &curr)) { // End Rewrite Instruction(curr) -//? cerr << "instruction: " << curr.to_string() << '\n'; //? 3 result.steps.push_back(curr); } return result; @@ -76,13 +72,11 @@ bool next_instruction(istream& in, instruction* curr) { raise << "0: unbalanced '[' for recipe\n" << end(); return false; } -//? show_rest_of_stream(in); //? 1 skip_whitespace(in); if (in.eof()) { raise << "1: unbalanced '[' for recipe\n" << end(); return false; } -//? show_rest_of_stream(in); //? 1 skip_whitespace_and_comments(in); if (in.eof()) { raise << "2: unbalanced '[' for recipe\n" << end(); @@ -90,20 +84,17 @@ bool next_instruction(istream& in, instruction* curr) { } vector<string> words; -//? show_rest_of_stream(in); //? 1 while (in.peek() != '\n' && !in.eof()) { skip_whitespace(in); if (in.eof()) { raise << "3: unbalanced '[' for recipe\n" << end(); return false; } -//? show_rest_of_stream(in); //? 1 string word = next_word(in); words.push_back(word); skip_whitespace(in); } skip_whitespace_and_comments(in); -//? if (SIZE(words) == 1) cout << words.at(0) << ' ' << SIZE(words.at(0)) << '\n'; //? 1 if (SIZE(words) == 1 && words.at(0) == "]") { return false; // end of recipe } @@ -124,7 +115,6 @@ bool next_instruction(istream& in, instruction* curr) { for (; *p != "<-"; ++p) { if (*p == ",") continue; curr->products.push_back(reagent(*p)); -//? cerr << "product: " << curr->products.back().to_string() << '\n'; //? 1 } ++p; // skip <- } @@ -136,7 +126,6 @@ bool next_instruction(istream& in, instruction* curr) { curr->name = *p; 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_ordinal[*p] == 0) { raise << "Recipe " << *p << " has number 0, which is reserved for IDLE.\n" << end() << end(); @@ -147,7 +136,6 @@ bool next_instruction(istream& in, instruction* curr) { for (; p != words.end(); ++p) { if (*p == ",") continue; curr->ingredients.push_back(reagent(*p)); -//? cerr << "ingredient: " << curr->ingredients.back().to_string() << '\n'; //? 1 } trace("parse") << "instruction: " << curr->name << end(); @@ -165,18 +153,15 @@ bool next_instruction(istream& in, instruction* curr) { } string next_word(istream& in) { -//? cout << "AAA next_word\n"; //? 1 ostringstream out; skip_whitespace(in); slurp_word(in, out); skip_whitespace(in); skip_comment(in); -//? cerr << '^' << out.str() << "$\n"; //? 1 return out.str(); } void slurp_word(istream& in, ostream& out) { -//? cout << "AAA slurp_word\n"; //? 1 char c; if (in.peek() == ',') { in >> c; @@ -184,7 +169,6 @@ void slurp_word(istream& in, ostream& out) { return; } while (in >> c) { -//? cout << c << '\n'; //? 1 if (isspace(c) || c == ',') { in.putback(c); break; @@ -254,7 +238,6 @@ vector<recipe_ordinal> recently_added_recipes; long long int Reserved_for_tests = 1000; :(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 if (recently_added_recipes.at(i) >= Reserved_for_tests) // don't renumber existing recipes, like 'interactive' Recipe_ordinal.erase(Recipe[recently_added_recipes.at(i)].name); Recipe.erase(recently_added_recipes.at(i)); diff --git a/012transform.cc b/012transform.cc index f3c76e38..614e53ed 100644 --- a/012transform.cc +++ b/012transform.cc @@ -15,7 +15,6 @@ vector<transform_fn> Transform; :(code) void transform_all() { -//? cerr << "AAA transform_all\n"; //? 2 for (long long int t = 0; t < SIZE(Transform); ++t) { for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; @@ -29,7 +28,6 @@ void transform_all() { } void parse_int_reagents() { -//? cout << "parse_int_reagents\n"; //? 1 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { recipe& r = p->second; if (r.steps.empty()) continue; diff --git a/013literal_string.cc b/013literal_string.cc index 92dc75ca..60c8f58a 100644 --- a/013literal_string.cc +++ b/013literal_string.cc @@ -26,7 +26,6 @@ Type_ordinal["literal-string"] = 0; string result = slurp_quoted(in); skip_whitespace(in); skip_comment(in); -//? cerr << '^' << result << "$\n"; //? 1 return result; } @@ -48,12 +47,10 @@ bool code_string(istream& in, ostringstream& out) { char c = in.get(); if (!isspace(c)) { in.putback(c); -//? cerr << "code_string: " << out.str() << '\n'; //? 1 return false; } out << c; if (c == '\n') { -//? cerr << "code_string: " << out.str() << '\n'; //? 1 return true; } } @@ -63,18 +60,14 @@ bool code_string(istream& in, ostringstream& out) { // Read a regular string. Regular strings can only contain other regular // strings. void slurp_quoted_comment_oblivious(istream& in, ostringstream& out) { -//? cerr << "comment oblivious\n"; //? 1 int brace_depth = 1; while (!in.eof()) { char c = in.get(); -//? cerr << '%' << (int)c << ' ' << brace_depth << ": " << out.str() << "%$\n"; //? 1 -//? cout << (int)c << ": " << brace_depth << '\n'; //? 2 if (c == '\\') { out << static_cast<char>(in.get()); continue; } out << c; -//? cout << out.str() << "$\n"; //? 1 if (c == '[') ++brace_depth; if (c == ']') --brace_depth; if (brace_depth == 0) break; @@ -87,10 +80,8 @@ void slurp_quoted_comment_oblivious(istream& in, ostringstream& out) { // Read a code string. Code strings can contain either code or regular strings. void slurp_quoted_comment_aware(istream& in, ostringstream& out) { -//? cerr << "comment aware\n"; //? 1 char c; while (in >> c) { -//? cerr << '^' << (int)c << ": " << out.str() << "$\n"; //? 1 if (c == '\\') { out << static_cast<char>(in.get()); continue; diff --git a/020run.cc b/020run.cc index b04fa90a..dd66d8e5 100644 --- a/020run.cc +++ b/020run.cc @@ -60,7 +60,7 @@ void run_current_routine() while (!Current_routine->completed()) // later layers will modify condition { // Running One Instruction -//? Instructions_running[current_recipe_name()]++; //? 1 +//? Instructions_running[current_recipe_name()]++; if (current_instruction().is_label) { ++current_step_index(); continue; } trace(Initial_callstack_depth+Callstack_depth, "run") << current_instruction().to_string() << end(); if (Memory[0] != 0) { @@ -74,8 +74,8 @@ void run_current_routine() if (should_copy_ingredients()) { for (long long int i = 0; i < SIZE(current_instruction().ingredients); ++i) { ingredients.push_back(read_memory(current_instruction().ingredients.at(i))); -//? Locations_read[current_recipe_name()] += SIZE(ingredients.back()); //? 1 -//? Locations_read_by_instruction[current_instruction().name] += SIZE(ingredients.back()); //? 1 +//? Locations_read[current_recipe_name()] += SIZE(ingredients.back()); +//? Locations_read_by_instruction[current_instruction().name] += SIZE(ingredients.back()); } } // Instructions below will write to 'products'. @@ -156,14 +156,14 @@ if (argc > 1) { :(before "End Main") if (!Run_tests) { setup(); -//? Trace_file = "interactive"; //? 3 -//? START_TRACING_UNTIL_END_OF_SCOPE; //? 3 -//? Trace_stream->collect_layers.insert("app"); //? 2 +//? Trace_file = "interactive"; +//? START_TRACING_UNTIL_END_OF_SCOPE; +//? Trace_stream->collect_layers.insert("app"); transform_all(); recipe_ordinal r = Recipe_ordinal[string("main")]; -//? atexit(dump_profile); //? 1 +//? atexit(dump_profile); if (r) run(r); -//? dump_memory(); //? 1 +//? dump_memory(); teardown(); } @@ -217,7 +217,6 @@ load_permanently("core.mu"); :(code) // helper for tests void run(string form) { -//? cerr << form << '\n'; //? 1 vector<recipe_ordinal> tmp = load(form); if (tmp.empty()) return; transform_all(); @@ -227,7 +226,6 @@ void run(string form) { //:: Reading from memory, writing to memory. vector<double> read_memory(reagent x) { -//? cout << "read_memory: " << x.to_string() << '\n'; //? 2 vector<double> result; if (is_literal(x)) { result.push_back(x.value); @@ -272,7 +270,7 @@ long long int size_of(const vector<type_ordinal>& types) { bool size_mismatch(const reagent& x, const vector<double>& data) { if (x.types.empty()) return true; // End size_mismatch(x) Cases -//? if (size_of(x) != SIZE(data)) cerr << size_of(x) << " vs " << SIZE(data) << '\n'; //? 2 +//? if (size_of(x) != SIZE(data)) cerr << size_of(x) << " vs " << SIZE(data) << '\n'; return size_of(x) != SIZE(data); } diff --git a/021arithmetic.cc b/021arithmetic.cc index a29c988c..81cbb544 100644 --- a/021arithmetic.cc +++ b/021arithmetic.cc @@ -7,7 +7,6 @@ Recipe_ordinal["add"] = ADD; :(before "End Primitive Recipe Implementations") case ADD: { double result = 0; -//? if (!tb_is_active()) cerr << ingredients.at(1).at(0) << '\n'; //? 1 for (long long int i = 0; i < SIZE(ingredients); ++i) { if (!scalar(ingredients.at(i))) { raise << current_recipe_name() << ": 'add' requires number ingredients, but got " << current_instruction().ingredients.at(i).original_string << '\n' << end(); diff --git a/029tools.cc b/029tools.cc index 12840d90..b03635b0 100644 --- a/029tools.cc +++ b/029tools.cc @@ -111,7 +111,6 @@ case _START_TRACING: { Trace_stream->dump_layer = "all"; else Trace_stream->dump_layer = current_instruction().ingredients.at(0).name; -//? cout << Trace_stream << ": " << Trace_stream->dump_layer << '\n'; //? 1 break; } diff --git a/030container.cc b/030container.cc index d4712f40..14166047 100644 --- a/030container.cc +++ b/030container.cc @@ -302,9 +302,6 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { skip_whitespace(in); string name = next_word(in); trace("parse") << "reading " << command << ' ' << name << end(); -//? cout << name << '\n'; //? 2 -//? 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++; @@ -328,7 +325,6 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { if (Type_ordinal.find(type_name) == Type_ordinal.end() // types can contain integers, like for array sizes && !is_integer(type_name)) { -//? cerr << type_name << " is " << Next_type_ordinal << '\n'; //? 1 Type_ordinal[type_name] = Next_type_ordinal++; } types.push_back(Type_ordinal[type_name]); @@ -366,7 +362,6 @@ vector<type_ordinal> recently_added_types; 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_ordinal.erase(Type[recently_added_types.at(i)].name); Type.erase(recently_added_types.at(i)); } @@ -382,7 +377,6 @@ while(p != Type_ordinal.end()) { ++p; // now delete current item if necessary if (t >= 1000) { -//? cerr << "AAA " << name << " " << t << '\n'; //? 1 Type_ordinal.erase(name); } } @@ -469,7 +463,6 @@ check_container_field_types(); void check_container_field_types() { 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) { for (long long int j = 0; j < SIZE(info.elements.at(i)); ++j) { if (info.elements.at(i).at(j) == 0) continue; diff --git a/031address.cc b/031address.cc index f0657b98..997e3c65 100644 --- a/031address.cc +++ b/031address.cc @@ -45,16 +45,13 @@ recipe main [ :(code) reagent canonize(reagent x) { if (is_literal(x)) return x; -//? cout << "canonize\n"; //? 1 reagent r = x; -//? cout << x.to_string() << " => " << r.to_string() << '\n'; //? 1 while (has_property(r, "lookup")) r = lookup_memory(r); return r; } reagent lookup_memory(reagent x) { -//? cout << "lookup_memory: " << x.to_string() << "\n"; //? 2 static const type_ordinal ADDRESS = Type_ordinal["address"]; reagent result; if (x.types.empty() || x.types.at(0) != ADDRESS) { diff --git a/034call.cc b/034call.cc index 08eea8c5..4bf7140a 100644 --- a/034call.cc +++ b/034call.cc @@ -125,7 +125,6 @@ inline const vector<instruction>& routine::steps() const { while (current_step_index() >= SIZE(Current_routine->steps())) { // Falling Through End Of Recipe --Callstack_depth; -//? cerr << "reply " << SIZE(Current_routine->calls) << '\n'; //? 2 Current_routine->calls.pop_front(); if (Current_routine->calls.empty()) return; // Complete Call Fallthrough diff --git a/040brace.cc b/040brace.cc index 9615ba58..d674212f 100644 --- a/040brace.cc +++ b/040brace.cc @@ -37,8 +37,6 @@ recipe main [ :(code) void transform_braces(const recipe_ordinal r) { -//? cout << "AAA transform_braces\n"; //? 1 -//? exit(0); //? 1 const int OPEN = 0, CLOSE = 1; // use signed integer for step index because we'll be doing arithmetic on it list<pair<int/*OPEN/CLOSE*/, /*step*/long long int> > braces; diff --git a/042name.cc b/042name.cc index d948ab3b..0a7a316a 100644 --- a/042name.cc +++ b/042name.cc @@ -65,7 +65,6 @@ void transform_names(const recipe_ordinal r) { } bool disqualified(/*mutable*/ reagent& x, const instruction& inst) { -//? cerr << x.to_string() << '\n'; //? 1 if (x.types.empty()) { raise << "missing type in '" << inst.to_string() << "'\n" << end(); return true; @@ -96,7 +95,6 @@ type_ordinal skip_addresses(const vector<type_ordinal>& types) { 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) { if (container.element_names.at(i) == name) return i; } diff --git a/043new.cc b/043new.cc index 42608264..2594dc5d 100644 --- a/043new.cc +++ b/043new.cc @@ -80,8 +80,8 @@ case NEW: { size = size_of(type); } } -//? Total_alloc += size; //? 1 -//? Num_alloc++; //? 1 +//? Total_alloc += size; +//? Num_alloc++; // compute the region of memory to return // really crappy at the moment ensure_space(size); @@ -104,17 +104,17 @@ case NEW: { break; } -//? :(before "End Globals") //? 1 -//? long long int Total_alloc = 0; //? 1 -//? long long int Num_alloc = 0; //? 1 -//? long long int Total_free = 0; //? 1 -//? long long int Num_free = 0; //? 1 -//? :(before "End Setup") //? 1 -//? Total_alloc = Num_alloc = Total_free = Num_free = 0; //? 1 -//? :(before "End Teardown") //? 1 -//? cerr << Total_alloc << "/" << Num_alloc //? 1 -//? << " vs " << Total_free << "/" << Num_free << '\n'; //? 1 -//? cerr << SIZE(Memory) << '\n'; //? 1 +//? :(before "End Globals") +//? long long int Total_alloc = 0; +//? long long int Num_alloc = 0; +//? long long int Total_free = 0; +//? long long int Num_free = 0; +//? :(before "End Setup") +//? Total_alloc = Num_alloc = Total_free = Num_free = 0; +//? :(before "End Teardown") +//? cerr << Total_alloc << "/" << Num_alloc +//? << " vs " << Total_free << "/" << Num_free << '\n'; +//? cerr << SIZE(Memory) << '\n'; :(code) void ensure_space(long long int size) { @@ -236,9 +236,9 @@ case ABANDON: { :(code) void abandon(long long int address, long long int size) { -//? Total_free += size; //? 1 -//? Num_free++; //? 1 -//? cerr << "abandon: " << size << '\n'; //? 2 +//? Total_free += size; +//? Num_free++; +//? cerr << "abandon: " << size << '\n'; // clear memory for (long long int curr = address; curr < address+size; ++curr) Memory[curr] = 0; @@ -328,9 +328,8 @@ if (is_literal(current_instruction().ingredients.at(0)) long long int new_mu_string(const string& contents) { // allocate an array just large enough for it long long int string_length = unicode_length(contents); -//? cout << "string_length is " << string_length << '\n'; //? 1 -//? Total_alloc += string_length+1; //? 1 -//? Num_alloc++; //? 1 +//? Total_alloc += string_length+1; +//? Num_alloc++; ensure_space(string_length+1); // don't forget the extra location for array size // initialize string long long int result = Current_routine->alloc; diff --git a/044space.cc b/044space.cc index 8331dabe..71cd4196 100644 --- a/044space.cc +++ b/044space.cc @@ -49,7 +49,6 @@ default_space = 0; reagent r = absolutize(x); :(code) reagent absolutize(reagent x) { -//? cout << "absolutize " << x.to_string() << '\n'; //? 4 if (is_raw(x) || is_dummy(x)) return x; if (x.name == "default-space") return x; if (!x.initialized) { @@ -203,7 +202,6 @@ long long int space_base(const reagent& x) { long long int address(long long int offset, long long int base) { if (base == 0) return offset; // raw -//? cout << base << '\n'; //? 2 if (offset >= static_cast<long long int>(Memory[base])) { // todo: test raise << "location " << offset << " is out of bounds " << Memory[base] << " at " << base << '\n' << end(); diff --git a/046closure_name.cc b/046closure_name.cc index 35486ed7..eef4753f 100644 --- a/046closure_name.cc +++ b/046closure_name.cc @@ -76,8 +76,6 @@ void collect_surrounding_spaces(const recipe_ordinal r) { :(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")) { if (Name[default_recipe].empty()) raise << "name not found: " << x.name << '\n' << end(); return Name[default_recipe][x.name]; diff --git a/050scenario.cc b/050scenario.cc index e5e0878e..0274fb2e 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -72,10 +72,8 @@ else if (command == "scenario") { :(code) scenario parse_scenario(istream& in) { -//? cerr << "parse scenario\n"; //? 1 scenario result; result.name = next_word(in); -//? cerr << "scenario: " << result.name << '\n'; //? 2 if (Scenario_names.find(result.name) != Scenario_names.end()) raise << "duplicate scenario name: " << result.name << '\n' << end(); Scenario_names.insert(result.name); @@ -87,7 +85,6 @@ scenario parse_scenario(istream& in) { // delete [] delimiters assert(result.to_run.at(0) == '['); result.to_run.erase(0, 1); -//? cerr << (int)result.to_run.at(SIZE(result.to_run)-1) << '\n'; //? 1 assert(result.to_run.at(SIZE(result.to_run)-1) == ']'); result.to_run.erase(SIZE(result.to_run)-1); return result; @@ -113,8 +110,7 @@ scenario foo [ time_t mu_time; time(&mu_time); cerr << "\nMu tests: " << ctime(&mu_time); for (long long int i = 0; i < SIZE(Scenarios); ++i) { -//? cerr << Passed << '\n'; //? 1 -//? cerr << i << ": " << Scenarios.at(i).name << '\n'; //? 7 +//? cerr << i << ": " << Scenarios.at(i).name << '\n'; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; } @@ -135,7 +131,7 @@ const scenario* Current_scenario = NULL; void run_mu_scenario(const scenario& s) { Current_scenario = &s; bool not_already_inside_test = !Trace_stream; -//? cerr << s.name << '\n'; //? 12 +//? cerr << s.name << '\n'; if (not_already_inside_test) { Trace_file = s.name; Trace_stream = new trace_stream; @@ -196,14 +192,11 @@ 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_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]"; -//? Show_rest_of_stream = true; //? 1 vector<recipe_ordinal> tmp_recipe = load(tmp.str()); bind_special_scenario_names(tmp_recipe.at(0)); transform_all(); -//? 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() } @@ -254,7 +247,6 @@ Recipe_ordinal["memory-should-contain"] = MEMORY_SHOULD_CONTAIN; :(before "End Primitive Recipe Implementations") case MEMORY_SHOULD_CONTAIN: { if (!Passed) break; -//? cout << current_instruction().ingredients.at(0).name << '\n'; //? 1 check_memory(current_instruction().ingredients.at(0).name); break; } @@ -424,10 +416,8 @@ case TRACE_SHOULD_CONTAIN: { // simplified version of check_trace_contents() that emits warnings rather // than just printing to stderr bool check_trace(const string& expected) { -//? cerr << "AAA " << expected << '\n'; //? 1 Trace_stream->newline(); vector<trace_line> expected_lines = parse_trace(expected); -//? cerr << "BBB " << SIZE(expected_lines) << '\n'; //? 1 if (expected_lines.empty()) return true; long long int curr_expected_line = 0; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { @@ -436,7 +426,6 @@ bool check_trace(const string& expected) { // match ++curr_expected_line; if (curr_expected_line == SIZE(expected_lines)) { -//? cerr << "ZZZ\n"; //? 1 return true; } } @@ -627,12 +616,10 @@ recipe main [ // just for the scenarios running scenarios in C++ layers void run_mu_scenario(const string& form) { Scenario_names.clear(); -//? cerr << form << '\n'; //? 1 istringstream in(form); in >> std::noskipws; skip_whitespace_and_comments(in); string _scenario = next_word(in); -//? cout << _scenario << '\n'; //? 2 assert(_scenario == "scenario"); scenario s = parse_scenario(in); run_mu_scenario(s); diff --git a/052tangle.cc b/052tangle.cc index 3392acbf..c6e9edbb 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -32,13 +32,11 @@ Fragments_used.clear(); else if (command == "before") { string label = next_word(in); recipe tmp = slurp_recipe(in); -//? cerr << "adding before fragment " << label << '\n'; //? 1 Before_fragments[label].steps.insert(Before_fragments[label].steps.end(), tmp.steps.begin(), tmp.steps.end()); } else if (command == "after") { string label = next_word(in); recipe tmp = slurp_recipe(in); -//? cerr << "adding after fragment " << label << '\n'; //? 1 After_fragments[label].steps.insert(After_fragments[label].steps.begin(), tmp.steps.begin(), tmp.steps.end()); } @@ -72,12 +70,10 @@ void insert_fragments(const recipe_ordinal r) { made_progress = true; Fragments_used.insert(inst.label); if (Before_fragments.find(inst.label) != Before_fragments.end()) { -//? cerr << "loading code before " << inst.label << '\n'; //? 1 result.insert(result.end(), Before_fragments[inst.label].steps.begin(), Before_fragments[inst.label].steps.end()); } result.push_back(inst); if (After_fragments.find(inst.label) != After_fragments.end()) { -//? cerr << "loading code after " << inst.label << '\n'; //? 1 result.insert(result.end(), After_fragments[inst.label].steps.begin(), After_fragments[inst.label].steps.end()); } } diff --git a/060string.mu b/060string.mu index 54995cc4..0a6e2494 100644 --- a/060string.mu +++ b/060string.mu @@ -105,7 +105,6 @@ container buffer [ recipe new-buffer [ local-scope -#? $print default-space:address:array:location, 10/newline result:address:buffer <- new buffer:type len:address:number <- get-address *result, length:offset *len:address:number <- copy 0 @@ -113,7 +112,6 @@ recipe new-buffer [ capacity:number, found?:boolean <- next-ingredient assert found?, [new-buffer must get a capacity argument] *s <- new character:type, capacity -#? $print *s, 10/newline reply result ] @@ -172,10 +170,7 @@ recipe buffer-append [ in <- grow-buffer in } s:address:array:character <- get *in, data:offset -#? $print [array underlying buf: ], s, 10/newline -#? $print [index: ], *len, 10/newline dest:address:character <- index-address *s, *len -#? $print [storing ], c, [ in ], dest, 10/newline *dest <- copy c *len <- add *len, 1 reply in/same-as-ingredient:0 @@ -300,13 +295,11 @@ recipe buffer-to-array [ reply 0 } len:number <- get *in, length:offset -#? $print [size ], len, 10/newline s:address:array:character <- get *in, data:offset # we can't just return s because it is usually the wrong length result:address:array:character <- new character:type, len i:number <- copy 0 { -#? $print i #? 1 done?:boolean <- greater-or-equal i, len break-if done? src:character <- index *s, i @@ -494,7 +487,6 @@ recipe interpolate [ result-len <- subtract result-len, 1 loop } -#? $print tem-len, [ ], $result-len, 10/newline rewind-ingredients _ <- next-ingredient # skip template result:address:array:character <- new character:type, result-len @@ -557,7 +549,6 @@ recipe interpolate [ ] scenario interpolate-works [ -#? dump run #? 1 run [ 1:address:array:character/raw <- new [abc _] 2:address:array:character/raw <- new [def] diff --git a/063list.mu b/063list.mu index 0ae881d4..0c07961d 100644 --- a/063list.mu +++ b/063list.mu @@ -39,7 +39,6 @@ recipe rest [ scenario list-handling [ run [ -#? $start-tracing #? 1 1:address:list <- copy 0 1:address:list <- push 3, 1:address:list 1:address:list <- push 4, 1:address:list diff --git a/065duplex_list.mu b/065duplex_list.mu index 65cb9592..0b0a47c5 100644 --- a/065duplex_list.mu +++ b/065duplex_list.mu @@ -73,7 +73,6 @@ scenario duplex-list-handling [ 4:address:duplex-list <- prev-duplex 4:address:duplex-list 13:number <- first-duplex 4:address:duplex-list 14:boolean <- equal 3:address:duplex-list, 4:address:duplex-list -#? $dump-trace #? 1 ] memory-should-contain [ 0 <- 0 # no modifications to null pointers diff --git a/070display.cc b/070display.cc index 45ddb5e6..2c52534e 100644 --- a/070display.cc +++ b/070display.cc @@ -31,7 +31,6 @@ Recipe_ordinal["close-console"] = CLOSE_CONSOLE; :(before "End Primitive Recipe Implementations") case CLOSE_CONSOLE: { tb_shutdown(); -//? Trace_stream->dump_layer = "all"; //? 1 break; } diff --git a/071print.mu b/071print.mu index 9732ce2f..186f5913 100644 --- a/071print.mu +++ b/071print.mu @@ -122,7 +122,6 @@ recipe print-character [ # special-case: newline { newline?:boolean <- equal c, 10/newline -#? $print c, [ ], newline?, 10/newline break-unless newline? { # unless cursor is already at bottom @@ -159,7 +158,6 @@ recipe print-character [ } reply sc/same-as-ingredient:0 } -#? $print [saving character ], c, [ to fake screen ], cursor, 10/newline cursor:address:screen-cell <- index-address *buf, index cursor-contents:address:character <- get-address *cursor, contents:offset *cursor-contents <- copy c @@ -181,7 +179,6 @@ recipe print-character [ scenario print-character-at-top-left [ run [ -#? $start-tracing #? 3 1:address:screen <- new-fake-screen 3/width, 2/height 1:address:screen <- print-character 1:address:screen, 97 # 'a' 2:address:array:screen-cell <- get *1:address:screen, data:offset @@ -212,7 +209,6 @@ scenario print-character-color [ scenario print-backspace-character [ run [ -#? $start-tracing #? 3 1:address:screen <- new-fake-screen 3/width, 2/height 1:address:screen <- print-character 1:address:screen, 97 # 'a' 1:address:screen <- print-character 1:address:screen, 8 # backspace @@ -271,7 +267,6 @@ scenario print-at-right-margin [ scenario print-newline-character [ run [ -#? $start-tracing #? 3 1:address:screen <- new-fake-screen 3/width, 2/height 1:address:screen <- print-character 1:address:screen, 97 # 'a' 1:address:screen <- print-character 1:address:screen, 10/newline @@ -345,9 +340,7 @@ recipe clear-line [ column:address:number <- get-address *sc, cursor-column:offset original-column:number <- copy *column # space over the entire line -#? $start-tracing #? 1 { -#? $print *column, 10/newline right:number <- subtract width, 1 done?:boolean <- greater-or-equal *column, right break-if done? @@ -398,7 +391,6 @@ recipe move-cursor [ scenario clear-line-erases-printed-characters [ run [ -#? $start-tracing #? 4 1:address:screen <- new-fake-screen 3/width, 2/height # print a character 1:address:screen <- print-character 1:address:screen, 97 # 'a' diff --git a/075scenario_console.cc b/075scenario_console.cc index bf58c46c..8bcab61a 100644 --- a/075scenario_console.cc +++ b/075scenario_console.cc @@ -46,12 +46,10 @@ 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 // create a temporary recipe just for parsing; it won't contain valid instructions istringstream in("[" + current_instruction().ingredients.at(0).name + "]"); recipe r = slurp_recipe(in); long long int num_events = count_events(r); -//? cerr << "fff: " << num_events << '\n'; //? 3 // initialize the events long long int size = num_events*size_of_event() + /*space for length*/1; ensure_space(size); @@ -65,13 +63,11 @@ case ASSUME_CONSOLE: { Memory[Current_routine->alloc+1+/*offset of 'type' in 'mouse-event'*/0] = TB_KEY_MOUSE_LEFT; Memory[Current_routine->alloc+1+/*offset of 'row' in 'mouse-event'*/1] = to_integer(curr.ingredients.at(0).name); Memory[Current_routine->alloc+1+/*offset of 'column' in 'mouse-event'*/2] = to_integer(curr.ingredients.at(1).name); -//? cerr << "AA left click: " << Memory[Current_routine->alloc+2] << ' ' << Memory[Current_routine->alloc+3] << '\n'; //? 1 Current_routine->alloc += size_of_event(); } else if (curr.name == "press") { Memory[Current_routine->alloc] = /*tag for 'keycode' variant of 'event' exclusive-container*/1; Memory[Current_routine->alloc+1] = to_integer(curr.ingredients.at(0).name); -//? cerr << "AA press: " << Memory[Current_routine->alloc+1] << '\n'; //? 3 Current_routine->alloc += size_of_event(); } // End Event Handlers @@ -82,13 +78,11 @@ case ASSUME_CONSOLE: { const char* raw_contents = contents.c_str(); long long int num_keyboard_events = unicode_length(contents); long long int curr = 0; -//? cerr << "AAA: " << num_keyboard_events << '\n'; //? 1 for (long long int i = 0; i < num_keyboard_events; ++i) { Memory[Current_routine->alloc] = /*tag for 'text' variant of 'event' exclusive-container*/0; uint32_t curr_character; assert(curr < SIZE(contents)); tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]); -//? cerr << "AA keyboard: " << curr_character << '\n'; //? 3 Memory[Current_routine->alloc+/*skip exclusive container tag*/1] = curr_character; curr += tb_utf8_char_length(raw_contents[curr]); Current_routine->alloc += size_of_event(); @@ -100,10 +94,7 @@ case ASSUME_CONSOLE: { ensure_space(size_of_events()); Memory[CONSOLE] = Current_routine->alloc; Current_routine->alloc += size_of_events(); -//? cerr << "writing " << event_data_address << " to location " << Memory[CONSOLE]+1 << '\n'; //? 1 Memory[Memory[CONSOLE]+/*offset of 'data' in container 'events'*/1] = event_data_address; -//? cerr << Memory[Memory[CONSOLE]+1] << '\n'; //? 1 -//? cerr << "alloc now " << Current_routine->alloc << '\n'; //? 1 break; } @@ -166,17 +157,13 @@ Recipe_ordinal["replace-in-console"] = REPLACE_IN_CONSOLE; :(before "End Primitive Recipe Implementations") case REPLACE_IN_CONSOLE: { assert(scalar(ingredients.at(0))); -//? cerr << "console: " << Memory[CONSOLE] << '\n'; //? 1 if (!Memory[CONSOLE]) { raise << "console not initialized\n" << end(); break; } long long int console_data = Memory[Memory[CONSOLE]+1]; -//? cerr << "console data starts at " << console_data << '\n'; //? 1 long long int size = Memory[console_data]; // array size -//? cerr << "size of console data is " << size << '\n'; //? 1 for (long long int i = 0, curr = console_data+1; i < size; ++i, curr+=size_of_event()) { -//? cerr << curr << '\n'; //? 1 if (Memory[curr] != /*text*/0) continue; if (Memory[curr+1] != ingredients.at(0).at(0)) continue; for (long long int n = 0; n < size_of_event(); ++n) @@ -190,13 +177,10 @@ long long int count_events(const recipe& r) { long long int result = 0; for (long long int i = 0; i < SIZE(r.steps); ++i) { const instruction& curr = r.steps.at(i); -//? cerr << "aa: " << curr.name << '\n'; //? 3 -//? cerr << "bb: " << curr.ingredients.at(0).name << '\n'; //? 1 if (curr.name == "type") result += unicode_length(curr.ingredients.at(0).name); else result++; -//? cerr << "cc: " << result << '\n'; //? 1 } return result; } diff --git a/080trace_browser.cc b/080trace_browser.cc index 121a8529..f399ae7e 100644 --- a/080trace_browser.cc +++ b/080trace_browser.cc @@ -71,16 +71,12 @@ void start_trace_browser() { } if (key == 'K' || key == TB_KEY_PGUP) { // page-up is more convoluted -//? tb_shutdown(); //? 1 -//? cerr << "page-up: Top_of_screen is currently " << Top_of_screen << '\n'; //? 1 for (int screen_row = tb_height(); screen_row > 0 && Top_of_screen > 0; --screen_row) { --Top_of_screen; if (Top_of_screen <= 0) break; while (Top_of_screen > 0 && Visible.find(Top_of_screen) == Visible.end()) --Top_of_screen; -//? cerr << "now " << Top_of_screen << '\n'; //? 1 } -//? exit(0); //? 1 if (Top_of_screen > 0) refresh_screen_rows(); } @@ -100,10 +96,8 @@ void start_trace_browser() { } if (key == TB_KEY_CARRIAGE_RETURN) { // expand lines under current by one level -//? tb_shutdown(); assert(Trace_index.find(Display_row) != Trace_index.end()); long long int start_index = Trace_index[Display_row]; -//? cerr << "start_index is " << start_index << '\n'; long long int index = 0; // simultaneously compute end_index and min_depth int min_depth = 9999; @@ -114,18 +108,14 @@ void start_trace_browser() { assert(curr_line.depth > Trace_stream->past_lines.at(start_index).depth); if (curr_line.depth < min_depth) min_depth = curr_line.depth; } -//? cerr << "min_depth is " << min_depth << '\n'; long long int end_index = index; -//? cerr << "end_index is " << end_index << '\n'; // mark as visible all intervening indices at min_depth for (index = start_index; index < end_index; ++index) { trace_line& curr_line = Trace_stream->past_lines.at(index); if (curr_line.depth == min_depth) { -//? cerr << "adding " << index << '\n'; Visible.insert(index); } } -//? exit(0); refresh_screen_rows(); } if (key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2) { diff --git a/081run_interactive.cc b/081run_interactive.cc index 411b448a..9c5350e7 100644 --- a/081run_interactive.cc +++ b/081run_interactive.cc @@ -24,7 +24,6 @@ recipe main [ RUN_INTERACTIVE, :(before "End Primitive Recipe Numbers") Recipe_ordinal["run-interactive"] = RUN_INTERACTIVE; -//? cerr << "run-interactive: " << RUN_INTERACTIVE << '\n'; //? 1 :(before "End Primitive Recipe Implementations") case RUN_INTERACTIVE: { if (SIZE(ingredients) != 1) { @@ -294,9 +293,7 @@ long long int stringified_value_of_location(long long int address) { long long int trace_contents(const string& layer) { if (!Trace_stream) return 0; -//? cerr << "trace stream exists\n"; //? 1 if (trace_count(layer) <= 0) return 0; -//? cerr << layer << " has something\n"; //? 1 ostringstream out; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (p->label != layer) continue; @@ -305,7 +302,6 @@ long long int trace_contents(const string& layer) { } string result = out.str(); assert(!result.empty()); -//? cerr << layer << ":\n" << result << "\n--\n"; //? 1 truncate(result); return new_mu_string(result); } diff --git a/082persist.cc b/082persist.cc index 3535e427..9d2a6d63 100644 --- a/082persist.cc +++ b/082persist.cc @@ -35,7 +35,6 @@ case RESTORE: { :(code) string slurp(const string& filename) { -//? cerr << filename << '\n'; //? 1 ostringstream result; ifstream fin(filename.c_str()); fin.peek(); @@ -48,7 +47,6 @@ string slurp(const string& filename) { result << buf; } fin.close(); -//? cerr << "=> " << result.str(); //? 1 return result.str(); } diff --git a/chessboard.mu b/chessboard.mu index ce41a738..a0bdb435 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -155,11 +155,9 @@ recipe print-board [ board:address:array:address:array:character <- next-ingredient row:number <- copy 7 # start printing from the top of the board # print each row -#? $print [printing board to screen ], screen, 10/newline { done?:boolean <- lesser-than row, 0 break-if done? -#? $print [printing rank ], row, 10/newline # print rank number as a legend rank:number <- add row, 1 print-integer screen, rank @@ -182,17 +180,12 @@ recipe print-board [ loop } # print file letters as legend -#? $print [printing legend -#? ] #? 1 s <- new [ +----------------] print-string screen, s screen <- cursor-to-next-line screen -#? screen <- print-character screen, 97 #? 1 s <- new [ a b c d e f g h] screen <- print-string screen, s screen <- cursor-to-next-line screen -#? $print [done printing board -#? ] #? 1 ] # board:address:array:address:array:character <- initial-position @@ -225,7 +218,6 @@ scenario printing-the-board [ run [ 1:address:array:address:array:character/board <- initial-position screen:address <- print-board screen:address, 1:address:array:address:array:character/board -#? $dump-screen #? 1 ] screen-should-contain [ # 012345678901234567890123456789 diff --git a/display.mu b/display.mu index d00163a1..057c7ed1 100644 --- a/display.mu +++ b/display.mu @@ -20,6 +20,5 @@ recipe main [ wait-for-some-interaction move-cursor-up-on-display wait-for-some-interaction -#? $print [aaa] #? 1 close-console ] diff --git a/edit.mu b/edit.mu index 84dffc7b..3a70ffed 100644 --- a/edit.mu +++ b/edit.mu @@ -508,13 +508,12 @@ recipe get-color [ color:number <- next-ingredient c:character <- next-ingredient color-is-white?:boolean <- equal color, 7/white -#? $print [character: ], c, 10/newline #? 1 # if color is white and next character is '#', switch color to blue { break-unless color-is-white? starting-comment?:boolean <- equal c, 35/# break-unless starting-comment? -#? $print [switch color back to blue], 10/newline #? 1 + trace 90, [app], [switch color back to blue] color <- copy 12/lightblue jump +exit:label } @@ -524,7 +523,7 @@ recipe get-color [ break-unless color-is-blue? ending-comment?:boolean <- equal c, 10/newline break-unless ending-comment? -#? $print [switch color back to white], 10/newline #? 1 + trace 90, [app], [switch color back to white] color <- copy 7/white jump +exit:label } @@ -632,7 +631,7 @@ recipe handle-keyboard-event [ { c:address:character <- maybe-convert e, text:variant break-unless c -#? trace 10, [app], [handle-keyboard-event: special character] #? 1 + trace 10, [app], [handle-keyboard-event: special character] # exceptions for special characters go here +handle-special-character # ignore any other special characters @@ -670,11 +669,9 @@ recipe move-cursor-in-editor [ too-far-right?:boolean <- greater-than click-column, right reply-if too-far-right?, 0/false # position cursor -#? trace 1, [print-character], [foo] #? 1 click-row:number <- get t, row:offset click-column:number <- get t, column:offset editor <- snap-cursor screen, editor, click-row, click-column -#? trace 1, [print-character], [foo done] #? 1 # gain focus reply 1/true ] @@ -1572,7 +1569,7 @@ recipe delete-before-cursor [ # if at start of text (before-cursor at § sentinel), return prev:address:duplex-list <- prev-duplex *before-cursor reply-unless prev, editor/same-as-ingredient:0, screen/same-as-ingredient:1, 0/no-more-render -#? trace 10, [app], [delete-before-cursor] #? 1 + trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor remove-duplex *before-cursor @@ -1619,7 +1616,7 @@ recipe move-cursor-coordinates-left [ { at-left-margin?:boolean <- equal *cursor-column, left break-if at-left-margin? -#? trace 10, [app], [decrementing cursor column] #? 1 + trace 10, [app], [decrementing cursor column] *cursor-column <- subtract *cursor-column, 1 reply editor/same-as-ingredient:0, 0/no-more-render } @@ -1641,14 +1638,14 @@ recipe move-cursor-coordinates-left [ previous-character-is-newline?:boolean <- equal previous-character, 10/newline break-unless previous-character-is-newline? # compute length of previous line -#? trace 10, [app], [switching to previous line] #? 1 + trace 10, [app], [switching to previous line] d:address:duplex-list <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d *cursor-column <- add left, end-of-line reply editor/same-as-ingredient:0, go-render? } # case 2: if previous-character was not newline, we're just at a wrapped line -#? trace 10, [app], [wrapping to previous line] #? 1 + trace 10, [app], [wrapping to previous line] right:number <- get *editor, right:offset *cursor-column <- subtract right, 1 # leave room for wrap icon reply editor/same-as-ingredient:0, go-render? @@ -2075,7 +2072,7 @@ after +handle-special-key [ { move-to-previous-character?:boolean <- equal *k, 65515/left-arrow break-unless move-to-previous-character? -#? trace 10, [app], [left arrow] #? 1 + trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) prev:address:duplex-list <- prev-duplex *before-cursor reply-unless prev, screen/same-as-ingredient:0, editor/same-as-ingredient:1, 0/no-more-render @@ -3259,7 +3256,7 @@ d] ] after +scroll-down [ -#? $print [scroll down], 10/newline #? 2 + trace 10, [app], [scroll down] top-of-screen:address:address:duplex-list <- get-address *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset @@ -3561,7 +3558,7 @@ d] ] after +scroll-up [ -#? $print [scroll up], 10/newline #? 1 + trace 10, [app], [scroll up] top-of-screen:address:address:duplex-list <- get-address *editor, top-of-screen:offset *top-of-screen <- before-previous-line *top-of-screen, editor ] @@ -3573,7 +3570,6 @@ recipe before-previous-line [ local-scope curr:address:duplex-list <- next-ingredient c:character <- get *curr, value:offset -#? $print [curr at ], c, 10/newline #? 1 # compute max, number of characters to skip # 1 + len%(width-1) # except rotate second term to vary from 1 to width-1 rather than 0 to width-2 @@ -3583,7 +3579,6 @@ recipe before-previous-line [ max-line-length:number <- subtract right, left, -1/exclusive-right, 1/wrap-icon sentinel:address:duplex-list <- get *editor, data:offset len:number <- previous-line-length curr, sentinel -#? $print [previous line: ], len, 10/newline #? 1 { break-if len # empty line; just skip this newline @@ -3595,11 +3590,9 @@ recipe before-previous-line [ # remainder 0 => scan one width-worth { break-if max -#? $print [remainder 0; scan one width], 10/newline #? 1 max <- copy max-line-length } max <- add max, 1 -#? $print [skipping ], max, [ characters], 10/newline #? 1 count:number <- copy 0 # skip 'max' characters { @@ -4154,7 +4147,6 @@ recipe page-up [ count:number <- copy 0 top-of-screen:address:address:duplex-list <- get-address *editor, top-of-screen:offset { -#? $print [- ], count, [ vs ], max, 10/newline #? 1 done?:boolean <- greater-or-equal count, max break-if done? prev:address:duplex-list <- before-previous-line *top-of-screen, editor @@ -4605,7 +4597,7 @@ recipe resize [ ] scenario point-at-multiple-editors [ - $close-trace + $close-trace # trace too long assume-screen 30/width, 5/height # initialize both halves of screen 1:address:array:character <- new [abc] @@ -4631,7 +4623,7 @@ scenario point-at-multiple-editors [ ] scenario edit-multiple-editors [ - $close-trace + $close-trace # trace too long assume-screen 30/width, 5/height # initialize both halves of screen 1:address:array:character <- new [abc] @@ -4675,7 +4667,7 @@ scenario edit-multiple-editors [ ] scenario multiple-editors-cover-only-their-own-areas [ - $close-trace + $close-trace # trace too long assume-screen 60/width, 10/height run [ 1:address:array:character <- new [abc] @@ -4694,7 +4686,7 @@ scenario multiple-editors-cover-only-their-own-areas [ ] scenario editor-in-focus-keeps-cursor [ - $close-trace + $close-trace # trace too long assume-screen 30/width, 5/height 1:address:array:character <- new [abc] 2:address:array:character <- new [def] @@ -4731,7 +4723,7 @@ scenario editor-in-focus-keeps-cursor [ ] scenario backspace-in-sandbox-editor-joins-lines [ - $close-trace + $close-trace # trace too long assume-screen 30/width, 5/height # initialize sandbox side with two lines 1:address:array:character <- new [] @@ -4870,15 +4862,11 @@ recipe update-cursor [ sandbox-in-focus?:boolean <- next-ingredient { break-if sandbox-in-focus? -#? $print [recipes in focus -#? ] #? 1 cursor-row:number <- get *recipes, cursor-row:offset cursor-column:number <- get *recipes, cursor-column:offset } { break-unless sandbox-in-focus? -#? $print [sandboxes in focus -#? ] #? 1 cursor-row:number <- get *current-sandbox, cursor-row:offset cursor-column:number <- get *current-sandbox, cursor-column:offset } @@ -4913,7 +4901,7 @@ after +global-type [ # ctrl-x - maximize/unmaximize the side with focus scenario maximize-side [ - $close-trace + $close-trace # trace too long assume-screen 30/width, 5/height # initialize both halves of screen 1:address:array:character <- new [abc] @@ -5047,7 +5035,7 @@ container sandbox-data [ ] scenario run-and-show-results [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 15/height # recipe editor is empty 1:address:array:character <- new [] @@ -5304,7 +5292,6 @@ recipe render-sandboxes [ { break-if sandbox-warnings break-unless empty-screen? -#? $print [display response from ], row, 10/newline #? 1 *response-starting-row <- add row, 1 +render-sandbox-response row, screen <- render-string screen, sandbox-response, left, right, 245/grey, row @@ -5422,7 +5409,7 @@ recipe render-screen [ ] scenario run-updates-results [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) 1:address:array:character <- new [ @@ -5475,7 +5462,7 @@ z:number <- add 2, 2 ] scenario run-instruction-and-print-warnings [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 10/height # left editor is empty 1:address:array:character <- new [] @@ -5532,7 +5519,7 @@ scenario run-instruction-and-print-warnings [ ] scenario run-instruction-and-print-warnings-only-once [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 10/height # left editor is empty 1:address:array:character <- new [] @@ -5561,7 +5548,7 @@ scenario run-instruction-and-print-warnings-only-once [ ] scenario run-instruction-manages-screen-per-sandbox [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 20/height # left editor is empty 1:address:array:character <- new [] @@ -5594,7 +5581,7 @@ scenario run-instruction-manages-screen-per-sandbox [ ] scenario sandbox-with-print-can-be-edited [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 20/height # left editor is empty 1:address:array:character <- new [] @@ -5640,7 +5627,7 @@ scenario sandbox-with-print-can-be-edited [ ] scenario sandbox-can-handle-infinite-loop [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 20/height # left editor is empty 1:address:array:character <- new [recipe foo [ @@ -5711,7 +5698,7 @@ scenario editor-provides-edited-contents [ ## editing sandboxes after they've been created scenario clicking-on-a-sandbox-moves-it-to-editor [ - $close-trace + $close-trace # trace too long assume-screen 40/width, 10/height # basic recipe 1:address:array:character <- new [ @@ -5820,7 +5807,7 @@ recipe extract-sandbox [ ## deleting sandboxes scenario deleting-sandboxes [ - $close-trace # trace too long for github + $close-trace # trace too long assume-screen 100/width, 15/height 1:address:array:character <- new [] 2:address:array:character <- new [] @@ -5890,7 +5877,6 @@ after +global-touch [ { was-delete?:boolean <- delete-sandbox *t, env break-unless was-delete? -#? trace 10, [app], [delete clicked] #? 1 hide-screen screen screen <- render-sandbox-side screen, env screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? @@ -5933,7 +5919,7 @@ recipe delete-sandbox [ ## clicking on sandbox results to 'fix' them and turn sandboxes into tests scenario sandbox-click-on-result-toggles-color-to-green [ - $close-trace + $close-trace # trace too long assume-screen 40/width, 10/height # basic recipe 1:address:array:character <- new [ @@ -6108,7 +6094,7 @@ after +render-sandbox-response [ ## clicking on the code typed into a sandbox toggles its trace scenario sandbox-click-on-code-toggles-app-trace [ - $close-trace + $close-trace # trace too long assume-screen 40/width, 10/height # basic recipe 1:address:array:character <- new [ @@ -6181,7 +6167,7 @@ recipe foo [ ] scenario sandbox-shows-app-trace-and-result [ - $close-trace + $close-trace # trace too long assume-screen 40/width, 10/height # basic recipe 1:address:array:character <- new [ @@ -6295,7 +6281,6 @@ after +render-sandbox-results [ break-unless display-trace? sandbox-trace:address:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on -#? $print [display trace from ], row, 10/newline #? 1 row, screen <- render-string, screen, sandbox-trace, left, right, 245/grey, row row <- subtract row, 1 # trim the trailing newline that's always present } @@ -6304,7 +6289,7 @@ after +render-sandbox-results [ ## handling malformed programs scenario run-shows-warnings-in-get [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 15/height 1:address:array:character <- new [ recipe foo [ @@ -6340,7 +6325,7 @@ recipe foo [ ] scenario run-shows-missing-type-warnings [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 15/height 1:address:array:character <- new [ recipe foo [ @@ -6367,7 +6352,7 @@ recipe foo [ ] scenario run-shows-unbalanced-bracket-warnings [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 15/height # recipe is incomplete (unbalanced '[') 1:address:array:character <- new [ @@ -6396,7 +6381,7 @@ recipe foo « ] scenario run-shows-get-on-non-container-warnings [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 15/height 1:address:array:character <- new [ recipe foo [ @@ -6425,7 +6410,7 @@ recipe foo [ ] scenario run-shows-non-literal-get-argument-warnings [ - $close-trace + $close-trace # trace too long assume-screen 100/width, 15/height 1:address:array:character <- new [ recipe foo [ @@ -6457,7 +6442,7 @@ recipe foo [ ] scenario run-shows-warnings-everytime [ - $close-trace + $close-trace # trace too long # try to run a file with an error assume-screen 100/width, 15/height 1:address:array:character <- new [ |