From beea7ce25cfe42c363259705a6b5741ad47484ab Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 22 Oct 2016 04:04:46 -0700 Subject: 3543 --- html/000organization.cc.html | 2 +- html/001help.cc.html | 2 +- html/002test.cc.html | 5 ++-- html/003trace.cc.html | 6 +---- html/010vm.cc.html | 2 +- html/011load.cc.html | 23 +++++++++++++--- html/012transform.cc.html | 2 +- html/013update_operation.cc.html | 2 +- html/014literal_string.cc.html | 2 +- html/015literal_noninteger.cc.html | 2 +- html/016dilated_reagent.cc.html | 23 +++++++++++++--- html/017parse_tree.cc.html | 25 +++++++++++++---- html/018type_abbreviations.cc.html | 2 +- html/020run.cc.html | 2 +- html/021check_instruction.cc.html | 2 +- html/022arithmetic.cc.html | 2 +- html/023boolean.cc.html | 2 +- html/024jump.cc.html | 2 +- html/025compare.cc.html | 2 +- html/026call.cc.html | 2 +- html/027call_ingredient.cc.html | 6 ++--- html/028call_reply.cc.html | 2 +- html/029tools.cc.html | 2 +- html/030container.cc.html | 12 ++++++++- html/031merge.cc.html | 2 +- html/032array.cc.html | 2 +- html/033exclusive_container.cc.html | 2 +- html/034address.cc.html | 2 +- html/035lookup.cc.html | 2 +- html/036refcount.cc.html | 2 +- html/037abandon.cc.html | 2 +- html/038new_text.cc.html | 2 +- html/039location_array.cc.html | 2 +- html/040brace.cc.html | 2 +- html/041jump_target.cc.html | 2 +- html/042name.cc.html | 2 +- html/043space.cc.html | 2 +- html/044space_surround.cc.html | 2 +- html/045closure_name.cc.html | 2 +- html/046global.cc.html | 2 +- html/047check_type_by_name.cc.html | 2 +- html/050scenario.cc.html | 42 ++++++++++++++++++++++++----- html/052tangle.cc.html | 12 ++++++++- html/053recipe_header.cc.html | 16 ++++++++--- html/054static_dispatch.cc.html | 2 +- html/055shape_shifting_container.cc.html | 2 +- html/056shape_shifting_recipe.cc.html | 2 +- html/057immutable.cc.html | 2 +- html/058to_text.cc.html | 2 +- html/060rewrite_literal_string.cc.html | 2 +- html/062convert_ingredients_to_text.cc.html | 2 +- html/067random.cc.html | 6 ++++- html/068random.mu.html | 19 +++++++++++++ html/069hash.cc.html | 2 +- html/071recipe.cc.html | 8 +++--- html/072scheduler.cc.html | 27 ++++++++++++++----- html/073wait.cc.html | 10 +++---- html/074deep_copy.cc.html | 2 +- html/075channel.mu.html | 16 ++++++++++- html/080display.cc.html | 2 +- html/082scenario_screen.cc.html | 6 ++--- html/085scenario_console.cc.html | 2 +- html/087file.cc.html | 2 +- html/089scenario_filesystem.cc.html | 17 +++++++++++- html/091socket.cc.html | 2 +- html/092socket.mu.html | 4 +-- html/100trace_browser.cc.html | 2 +- html/101run_sandboxed.cc.html | 2 +- html/102persist.cc.html | 2 +- html/http-client.mu.html | 6 ++--- html/http-server.mu.html | 10 +------ html/lambda-to-mu.mu.html | 6 ++--- 72 files changed, 278 insertions(+), 127 deletions(-) diff --git a/html/000organization.cc.html b/html/000organization.cc.html index d074f97e..a94eb30c 100644 --- a/html/000organization.cc.html +++ b/html/000organization.cc.html @@ -16,7 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Delimiter { color: #800080; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } --> diff --git a/html/001help.cc.html b/html/001help.cc.html index 1ad1ee68..0b857932 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -18,7 +18,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } .CommentedCode { color: #6c6c6c; } diff --git a/html/002test.cc.html b/html/002test.cc.html index bca0201f..b66c4cea 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } .CommentedCode { color: #6c6c6c; } @@ -58,7 +58,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color :(before "End Includes") #define CHECK(X) \ if (Passed && !(X)) { \ - ++Num_failures; \ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << '\n'; \ Passed = false; \ return; /* Currently we stop at the very first failure. */ \ @@ -66,7 +65,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color #define CHECK_EQ(X, Y) \ if (Passed && (X) != (Y)) { \ - ++Num_failures; \ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << " == " << #Y << '\n'; \ cerr << " got " << (X) << '\n'; /* BEWARE: multiple eval */ \ Passed = false; \ @@ -116,6 +114,7 @@ Passed = true; // End Test Teardown teardown(); if (Passed) cerr << '.'; + else ++Num_failures; } bool is_integer(const string& s) { diff --git a/html/003trace.cc.html b/html/003trace.cc.html index d4618fb9..a4e56ca8 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } --> @@ -211,7 +211,6 @@ trace_stream* Trace_stream = NULL:(before "End Test Teardown") if (Passed && !Hide_errors && trace_count("error") > 0) { Passed = false; - ++Num_failures; } :(before "End Types") @@ -253,7 +252,6 @@ START_TRACING_UNTIL_END_OF_SCOPE #define CHECK_TRACE_CONTAINS_ERROR() CHECK(trace_count("error") > 0) #define CHECK_TRACE_DOESNT_CONTAIN_ERROR() \ if (Passed && trace_count("error") > 0) { \ - ++Num_failures; \ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \ DUMP("error"); \ Passed = false; \ @@ -262,7 +260,6 @@ START_TRACING_UNTIL_END_OF_SCOPE #define CHECK_TRACE_COUNT(label, count) \ if (Passed && trace_count(label) != (count)) { \ - ++Num_failures; \ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \ cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \ DUMP(label); \ @@ -293,7 +290,6 @@ START_TRACING_UNTIL_END_OF_SCOPE split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); } - ++Num_failures; if (line_exists_anywhere(label, contents)) { cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; DUMP(""); diff --git a/html/010vm.cc.html b/html/010vm.cc.html index c6da65ae..acfb4e10 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -19,7 +19,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } .CommentedCode { color: #6c6c6c; } diff --git a/html/011load.cc.html b/html/011load.cc.html index a80dce11..0d208739 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -62,6 +62,10 @@ vector<recipe_ordinal> load(istream& in skip_whitespace_and_comments(in); if (!has_data(in)) break; string command = next_word(in); + if (command.empty()) { + assert(!has_data(in)); + break; + } // Command Handlers if (command == "recipe" || command == "def") { recipe_ordinal r = slurp_recipe(in); @@ -86,6 +90,11 @@ vector<recipe_ordinal> load(istream& in int slurp_recipe(istream& in) { recipe result; result.name = next_word(in); + if (result.name.empty()) { + assert(!has_data(in)); + raise << "file ended with 'recipe'\n" << end(); + return -1; + } // End Load Recipe Name skip_whitespace_but_not_newline(in); // End Recipe Refinements @@ -125,7 +134,7 @@ vector<recipe_ordinal> load(istream& in curr->clear(); skip_whitespace_and_comments(in); if (!has_data(in)) { - raise << "0: unbalanced '[' for recipe\n" << end(); + raise << "incomplete recipe at end of file (0)\n" << end(); return false; } @@ -133,10 +142,15 @@ vector<recipe_ordinal> load(istream& in while (has_data(in) && in.peek() != '\n') { skip_whitespace_but_not_newline(in); if (!has_data(in)) { - raise << "1: unbalanced '[' for recipe\n" << end(); + raise << "incomplete recipe at end of file (1)\n" << end(); return false; } string word = next_word(in); + if (word.empty()) { + assert(!has_data(in)); + raise << "incomplete recipe at end of file (2)\n" << end(); + return false; + } words.push_back(word); skip_whitespace_but_not_newline(in); } @@ -149,7 +163,7 @@ vector<recipe_ordinal> load(istream& in curr->label = words.at(0); trace(9993, "parse") << "label: " << curr->label << end(); if (!has_data(in)) { - raise << "7: unbalanced '[' for recipe\n" << end(); + raise << "incomplete recipe at end of file (3)\n" << end(); return false; } return true; @@ -185,6 +199,7 @@ vector<recipe_ordinal> load(istream& in return true; } +// can return empty string -- only if `in` has no more data string next_word(istream& in) { skip_whitespace_but_not_newline(in); // End next_word Special-cases diff --git a/html/012transform.cc.html b/html/012transform.cc.html index 31993361..100c0205 100644 --- a/html/012transform.cc.html +++ b/html/012transform.cc.html @@ -16,7 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/013update_operation.cc.html b/html/013update_operation.cc.html index 48dd882e..b8259ed3 100644 --- a/html/013update_operation.cc.html +++ b/html/013update_operation.cc.html @@ -19,7 +19,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .cSpecial { color: #008000; } .CommentedCode { color: #6c6c6c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index c19da0af..9d772d06 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/015literal_noninteger.cc.html b/html/015literal_noninteger.cc.html index dd45673a..43bb4cd8 100644 --- a/html/015literal_noninteger.cc.html +++ b/html/015literal_noninteger.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/016dilated_reagent.cc.html b/html/016dilated_reagent.cc.html index 65d8ba2e..5705bbfc 100644 --- a/html/016dilated_reagent.cc.html +++ b/html/016dilated_reagent.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } .PreProc { color: #800080; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -144,7 +144,13 @@ string slurp_balanced_bracket(istream& inreturn; } { - string_tree* type_names = new string_tree(next_word(in)); + string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete dilated reagent at end of file (0)\n" << end(); + return; + } + string_tree* type_names = new string_tree(s); // End Parsing Dilated Reagent Type Property(type_names) type = new_type_tree(type_names); delete type_names; @@ -153,7 +159,13 @@ string slurp_balanced_bracket(istream& in(in); if (key.empty()) continue; if (key == "}") continue; - string_tree* value = new string_tree(next_word(in)); + string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete dilated reagent at end of file (1)\n" << end(); + return; + } + string_tree* value = new string_tree(s); // End Parsing Dilated Reagent Property(value) properties.push_back(pair<string, string_tree*>(key, value)); } @@ -163,6 +175,11 @@ string slurp_balanced_bracket(istream& in:(code) string slurp_key(istream& in) { string result = next_word(in); + if (result.empty()) { + assert(!has_data(in)); + raise << "incomplete dilated reagent at end of file (2)\n" << end(); + return result; + } while (!result.empty() && *result.rbegin() == ':') strip_last(result); while (isspace(in.peek()) || in.peek() == ':') diff --git a/html/017parse_tree.cc.html b/html/017parse_tree.cc.html index 0ff64fb1..6ffd509d 100644 --- a/html/017parse_tree.cc.html +++ b/html/017parse_tree.cc.html @@ -14,6 +14,7 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } +.cSpecial { color: #008000; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } @@ -21,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -81,7 +82,13 @@ string_tree* parse_string_tree(istream& inreturn NULL; } if (in.peek() != '(') { - string_tree* result = new string_tree(next_word(in)); + string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete string tree at end of file (0)\n" << end(); + return NULL; + } + string_tree* result = new string_tree(s); return result; } in.get(); // skip '(' @@ -92,10 +99,18 @@ string_tree* parse_string_tree(istream& in(has_data(in)); if (in.peek() == ')') break; *curr = new string_tree(NULL, NULL); - if (in.peek() == '(') + if (in.peek() == '(') { (*curr)->left = parse_string_tree(in); - else - (*curr)->left = new string_tree(next_word(in)); + } + else { + string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete string tree at end of file (1)\n" << end(); + return NULL; + } + (*curr)->left = new string_tree(s); + } curr = &(*curr)->right; } in.get(); // skip ')' diff --git a/html/018type_abbreviations.cc.html b/html/018type_abbreviations.cc.html index c0325c4d..b2550ec5 100644 --- a/html/018type_abbreviations.cc.html +++ b/html/018type_abbreviations.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Constant { color: #00a0a0; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/020run.cc.html b/html/020run.cc.html index 437285aa..e138ac60 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -24,7 +24,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .PreProc { color: #800080; } --> diff --git a/html/021check_instruction.cc.html b/html/021check_instruction.cc.html index c6bd2575..d9f01d9b 100644 --- a/html/021check_instruction.cc.html +++ b/html/021check_instruction.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index 89d4d36e..3b0a9cac 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } --> diff --git a/html/023boolean.cc.html b/html/023boolean.cc.html index d079cf29..b0b9f772 100644 --- a/html/023boolean.cc.html +++ b/html/023boolean.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/024jump.cc.html b/html/024jump.cc.html index 077373b7..6ec34b93 100644 --- a/html/024jump.cc.html +++ b/html/024jump.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/025compare.cc.html b/html/025compare.cc.html index c2be1759..ad45045d 100644 --- a/html/025compare.cc.html +++ b/html/025compare.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/026call.cc.html b/html/026call.cc.html index 4afc0186..6f21f765 100644 --- a/html/026call.cc.html +++ b/html/026call.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/027call_ingredient.cc.html b/html/027call_ingredient.cc.html index 7aa1cd97..2b15f95b 100644 --- a/html/027call_ingredient.cc.html +++ b/html/027call_ingredient.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -112,9 +112,7 @@ put(Recipe_ordinal,if (current_instruction().products.empty()) break; products.resize(2); // pad the first product with sufficient zeros to match its type - int size = size_of(current_instruction().products.at(0)); - for (int i = 0; i < size; ++i) - products.at(0).push_back(0); + products.at(0).resize(size_of(current_instruction().products.at(0))); products.at(1).push_back(0); } break; diff --git a/html/028call_reply.cc.html b/html/028call_reply.cc.html index 867180e0..f764d5db 100644 --- a/html/028call_reply.cc.html +++ b/html/028call_reply.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/029tools.cc.html b/html/029tools.cc.html index 7af3acb9..5c9ba6b9 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .cSpecial { color: #008000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/030container.cc.html b/html/030container.cc.html index abddc0aa..644f031e 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -24,7 +24,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -759,6 +759,11 @@ Num_calls_to_transform_all_at_first_definition = -1void insert_container(const string& command, kind_of_type kind, istream& in) { skip_whitespace_but_not_newline(in); string name = next_word(in); + if (name.empty()) { + assert(!has_data(in)); + raise << "incomplete container definition at end of file (0)\n" << end(); + return; + } // End container Name Refinements trace(9991, "parse") << "--- defining " << command << ' ' << name << end(); if (!contains_key(Type_ordinal, name) @@ -782,6 +787,11 @@ Num_calls_to_transform_all_at_first_definition = -1while (has_data(in)) { skip_whitespace_and_comments(in); string element = next_word(in); + if (element.empty()) { + assert(!has_data(in)); + raise << "incomplete container definition at end of file (1)\n" << end(); + return; + } if (element == "]") break; if (in.peek() != '\n') { raise << command << " '" << name << "' contains multiple elements on a single line. Containers and exclusive containers must only contain elements, one to a line, no code.\n" << end(); diff --git a/html/031merge.cc.html b/html/031merge.cc.html index 6b39e164..f26edc7e 100644 --- a/html/031merge.cc.html +++ b/html/031merge.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } .Constant { color: #00a0a0; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/032array.cc.html b/html/032array.cc.html index ecd99f8b..3d92149f 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index 1f8849e3..bb1ebd85 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/034address.cc.html b/html/034address.cc.html index d27f79e9..6ddedbe8 100644 --- a/html/034address.cc.html +++ b/html/034address.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/035lookup.cc.html b/html/035lookup.cc.html index 22b62af4..c654b1f0 100644 --- a/html/035lookup.cc.html +++ b/html/035lookup.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/036refcount.cc.html b/html/036refcount.cc.html index 7edfe3f9..e9970c4b 100644 --- a/html/036refcount.cc.html +++ b/html/036refcount.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .SalientComment { color: #00ffff; } --> diff --git a/html/037abandon.cc.html b/html/037abandon.cc.html index b3f955ff..e73ca70d 100644 --- a/html/037abandon.cc.html +++ b/html/037abandon.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/038new_text.cc.html b/html/038new_text.cc.html index 4c3a8461..d7ed1415 100644 --- a/html/038new_text.cc.html +++ b/html/038new_text.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/039location_array.cc.html b/html/039location_array.cc.html index 94aec343..f9504a09 100644 --- a/html/039location_array.cc.html +++ b/html/039location_array.cc.html @@ -16,7 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .cSpecial { color: #008000; } .Delimiter { color: #800080; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } --> diff --git a/html/040brace.cc.html b/html/040brace.cc.html index 2ef1dfb1..405c2d57 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/041jump_target.cc.html b/html/041jump_target.cc.html index d0b2b3aa..8904671c 100644 --- a/html/041jump_target.cc.html +++ b/html/041jump_target.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/042name.cc.html b/html/042name.cc.html index bcb4993e..9fe6b220 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/043space.cc.html b/html/043space.cc.html index 95448e34..be17cf77 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -24,7 +24,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index bc05a6d5..2a246ae6 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/045closure_name.cc.html b/html/045closure_name.cc.html index cb7cf32a..5876b712 100644 --- a/html/045closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/046global.cc.html b/html/046global.cc.html index 4bae44f9..df109cd5 100644 --- a/html/046global.cc.html +++ b/html/046global.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/047check_type_by_name.cc.html b/html/047check_type_by_name.cc.html index db280f49..e769674e 100644 --- a/html/047check_type_by_name.cc.html +++ b/html/047check_type_by_name.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 274d846f..337bf0a7 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -25,7 +25,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -117,6 +117,11 @@ vector<scenario> Scenarios; scenario parse_scenario(istream& in) { scenario result; result.name = next_word(in); + if (result.name.empty()) { + assert(!has_data(in)); + raise << "incomplete scenario at end of file\n" << end(); + return result; + } skip_whitespace_and_comments(in); if (in.peek() != '[') { raise << "Expected '[' after scenario '" << result.name << "'\n" << end(); @@ -217,11 +222,9 @@ Hide_missing_default_space_errors = false(tmp.at(0)); transform_all(); run(tmp.front()); - if (!Hide_errors && trace_count("error") > 0) - Passed = false; // End Mu Test Teardown - if (!Passed) - ++Num_failures; + if (!Hide_errors && trace_count("error") > 0 && !Scenario_testing_scenario) + Passed = false; if (not_already_inside_test && Trace_stream) { teardown(); if (Save_trace) { @@ -370,6 +373,11 @@ put(Recipe_ordinal,(in); if (!has_data(in)) break; string lhs = next_word(in); + if (lhs.empty()) { + assert(!has_data(in)); + raise << "incomplete 'memory-should-contain' block at end of file (0)\n" << end(); + return; + } if (!is_integer(lhs)) { check_type(lhs, in); continue; @@ -379,6 +387,11 @@ put(Recipe_ordinal,; in >> _assign; assert(_assign == "<-"); skip_whitespace_and_comments(in); string rhs = next_word(in); + if (rhs.empty()) { + assert(!has_data(in)); + raise << "incomplete 'memory-should-contain' block at end of file (1)\n" << end(); + return; + } if (!is_integer(rhs) && !is_noninteger(rhs)) { if (Current_scenario && !Scenario_testing_scenario) // genuine test in a mu file @@ -415,9 +428,19 @@ put(Recipe_ordinal,.set_value(to_integer(x.name)); skip_whitespace_and_comments(in); string _assign = next_word(in); + if (_assign.empty()) { + assert(!has_data(in)); + raise << "incomplete 'memory-should-contain' block at end of file (2)\n" << end(); + return; + } assert(_assign == "<-"); skip_whitespace_and_comments(in); string literal = next_word(in); + if (literal.empty()) { + assert(!has_data(in)); + raise << "incomplete 'memory-should-contain' block at end of file (3)\n" << end(); + return; + } int address = x.value; // exclude quoting brackets assert(*literal.begin() == '['); literal.erase(literal.begin()); @@ -572,7 +595,7 @@ put(Recipe_ordinal,"in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end(); if (!Hide_errors) DUMP(expected_lines.at(curr_expected_line).label); - Passed = false; + if (!Scenario_testing_scenario) Passed = false; } vector<trace_line> parse_trace(const string& expected) { @@ -660,7 +683,7 @@ put(Recipe_ordinal,for (int i = 0; i < SIZE(lines); ++i) { if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) { raise << "unexpected [" << lines.at(i).contents << "] in trace with label '" << lines.at(i).label << "'\n" << end(); - Passed = false; + if (!Scenario_testing_scenario) Passed = false; return false; } } @@ -791,6 +814,11 @@ is_autogenerated = false;< in >> std::noskipws; skip_whitespace_and_comments(in); string _scenario = next_word(in); + if (_scenario.empty()) { + assert(!has_data(in)); + raise << "no scenario in string passed into run_mu_scenario()\n" << end(); + return; + } assert(_scenario == "scenario"); scenario s = parse_scenario(in); run_mu_scenario(s); diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html index a589bff5..498d1c2e 100644 --- a/html/052tangle.cc.html +++ b/html/052tangle.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -70,6 +70,11 @@ Fragments_used.clear();:(before "End Command Handlers") else if (command == "before") { string label = next_word(in); + if (label.empty()) { + assert(!has_data(in)); + raise << "incomplete 'before' block at end of file\n" << end(); + return result; + } recipe tmp; slurp_body(in, tmp); if (is_waypoint(label)) @@ -80,6 +85,11 @@ Fragments_used.clear();} else if (command == "after") { string label = next_word(in); + if (label.empty()) { + assert(!has_data(in)); + raise << "incomplete 'after' block at end of file\n" << end(); + return result; + } recipe tmp; slurp_body(in, tmp); if (is_waypoint(label)) diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index 5e9a957c..cce0a02f 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } .SalientComment { color: #00ffff; } @@ -71,6 +71,11 @@ has_header = false; result.has_header = true; while (has_data(in) && in.peek() != '[' && in.peek() != '\n') { string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete recipe header at end of file (0)\n" << end(); + return; + } if (s == "<-") raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end(); if (s == "->") break; @@ -80,6 +85,11 @@ has_header = false; } while (has_data(in) && in.peek() != '[' && in.peek() != '\n') { string s = next_word(in); + if (s.empty()) { + assert(!has_data(in)); + raise << "incomplete recipe header at end of file (1)\n" << end(); + return; + } result.products.push_back(reagent(s)); trace(9999, "parse") << "header product: " << result.products.back().original_string << end(); skip_whitespace_but_not_newline(in); @@ -242,9 +252,7 @@ put(Recipe_ordinal,else { products.resize(2); // pad the first product with sufficient zeros to match its type - int size = size_of(current_instruction().products.at(0)); - for (int i = 0; i < size; ++i) - products.at(0).push_back(0); + products.at(0).resize(size_of(current_instruction().products.at(0))); products.at(1).push_back(0); } break; diff --git a/html/054static_dispatch.cc.html b/html/054static_dispatch.cc.html index 32548869..5b3c52b9 100644 --- a/html/054static_dispatch.cc.html +++ b/html/054static_dispatch.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index a0c82477..7721fc45 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .CommentedCode { color: #6c6c6c; } .Constant { color: #00a0a0; } diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index aa527a1d..f5ea7e02 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -24,7 +24,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .PreProc { color: #800080; } --> diff --git a/html/057immutable.cc.html b/html/057immutable.cc.html index 5cb35f7b..366589f3 100644 --- a/html/057immutable.cc.html +++ b/html/057immutable.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/058to_text.cc.html b/html/058to_text.cc.html index 33fb6060..3f4efc85 100644 --- a/html/058to_text.cc.html +++ b/html/058to_text.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/060rewrite_literal_string.cc.html b/html/060rewrite_literal_string.cc.html index 04e4965c..9e6b1cf1 100644 --- a/html/060rewrite_literal_string.cc.html +++ b/html/060rewrite_literal_string.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/062convert_ingredients_to_text.cc.html b/html/062convert_ingredients_to_text.cc.html index 8653cbf6..05f4a760 100644 --- a/html/062convert_ingredients_to_text.cc.html +++ b/html/062convert_ingredients_to_text.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/067random.cc.html b/html/067random.cc.html index 6eaca039..963db65a 100644 --- a/html/067random.cc.html +++ b/html/067random.cc.html @@ -16,7 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> @@ -59,6 +59,10 @@ put(Recipe_ordinal,(time(NULL)); break; } + +// undo non-determinism in later tests +:(before "End Setup") +srand(0); diff --git a/html/068random.mu.html b/html/068random.mu.html index 52707f10..20b26659 100644 --- a/html/068random.mu.html +++ b/html/068random.mu.html @@ -86,6 +86,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 8 <- 1 # end of stream ] ] + +def random-in-range generator:&:stream:num, start:num, end:num -> result:num, fail?:bool, generator:&:stream:num [ + local-scope + load-ingredients + result, fail?, generator <- random generator + return-if fail? + delta:num <- subtract end, start + _, result <- divide-with-remainder result, delta + result <- add result, start +] + +scenario random-in-range [ + local-scope + source:&:stream:num <- assume-random-numbers 91 + 1:num/raw <- random-in-range source, 40, 50 + memory-should-contain [ + 1 <- 41 + ] +] diff --git a/html/069hash.cc.html b/html/069hash.cc.html index b86928bb..d0dd445c 100644 --- a/html/069hash.cc.html +++ b/html/069hash.cc.html @@ -20,7 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } .CommentedCode { color: #6c6c6c; } diff --git a/html/071recipe.cc.html b/html/071recipe.cc.html index d4476afb..51073ad2 100644 --- a/html/071recipe.cc.html +++ b/html/071recipe.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -150,10 +150,12 @@ put(Recipe_ordinal,(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end(); break; } - const instruction& caller_instruction = current_instruction(); + instruction/*copy*/ call_instruction = current_instruction(); + call_instruction.operation = ingredients.at(0).at(0); + call_instruction.ingredients.erase(call_instruction.ingredients.begin()); Current_routine->calls.push_front(call(ingredients.at(0).at(0))); ingredients.erase(ingredients.begin()); // drop the callee - finish_call_housekeeping(caller_instruction, ingredients); + finish_call_housekeeping(call_instruction, ingredients); continue; } diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 720b8473..3eac3e1b 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -316,6 +316,23 @@ increment_any_refcounts(ingredientreturn false; } +// ensure this works with indirect calls using 'call' as well +:(scenario start_running_immediately_updates_refcounts_of_ingredients_of_indirect_calls) +% Scheduling_interval = 1; +def main [ + local-scope + n:&:num <- new number:type + *n <- copy 34 + call f1, n + 1:num/raw <- copy *n +] +def f1 n:&:num [ + local-scope + load-ingredients +] +# check that n wasn't reclaimed when f1 returned ++mem: storing 34 in location 1 + :(scenario next_ingredient_never_leaks_refcounts) def create-space n:&:num -> default-space:space [ default-space <- new location:type, 2 @@ -565,15 +582,11 @@ DISCONTINUED, } :(before "End Test Teardown") -if (Passed && any_routines_with_error()) { - Passed = false; +if (Passed && any_routines_with_error()) raise << "some routines died with errors\n" << end(); -} :(before "End Mu Test Teardown") -if (Passed && any_routines_with_error()) { - Passed = false; +if (Passed && any_routines_with_error()) raise << Current_scenario->name << ": some routines died with errors\n" << end(); -} :(code) bool any_routines_with_error() { diff --git a/html/073wait.cc.html b/html/073wait.cc.html index b5339856..321b73c3 100644 --- a/html/073wait.cc.html +++ b/html/073wait.cc.html @@ -23,7 +23,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> @@ -70,20 +70,16 @@ WAITING, waiting_on_location = 0; :(before "End Mu Test Teardown") -if (Passed && any_routines_waiting()) { - Passed = false; +if (Passed && any_routines_waiting()) raise << Current_scenario->name << ": deadlock!\n" << end(); -} :(before "End Run Routine") if (any_routines_waiting()) { raise << "deadlock!\n" << end(); dump_waiting_routines(); } :(before "End Test Teardown") -if (Passed && any_routines_with_error()) { - Passed = false; +if (Passed && any_routines_with_error()) raise << "some routines died with errors\n" << end(); -} :(code) bool any_routines_waiting() { for (int i = 0; i < SIZE(Routines); ++i) { diff --git a/html/074deep_copy.cc.html b/html/074deep_copy.cc.html index 1509dab3..9be9b2e4 100644 --- a/html/074deep_copy.cc.html +++ b/html/074deep_copy.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muData { color: #ffff00; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/075channel.mu.html b/html/075channel.mu.html index 862329f8..eda9e8da 100644 --- a/html/075channel.mu.html +++ b/html/075channel.mu.html @@ -412,7 +412,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result <- length *q ] -# helper for channels of characters in particular +## helpers for channels of characters in particular + def buffer-lines in:&:source:char, buffered-out:&:sink:char -> buffered-out:&:sink:char, in:&:source:char [ local-scope load-ingredients @@ -511,6 +512,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color test: reached end ] ] + +def drain source:&:source:char -> result:text, source:&:source:char [ + local-scope + load-ingredients + buf:&:buffer <- new-buffer 30 + { + c:char, done?:bool <- read source + break-if done? + buf <- append buf, c + loop + } + result <- buffer-to-array buf +] diff --git a/html/080display.cc.html b/html/080display.cc.html index 0523bbf3..6de5c230 100644 --- a/html/080display.cc.html +++ b/html/080display.cc.html @@ -18,7 +18,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } --> diff --git a/html/082scenario_screen.cc.html b/html/082scenario_screen.cc.html index 40636764..ede1e5f8 100644 --- a/html/082scenario_screen.cc.html +++ b/html/082scenario_screen.cc.html @@ -21,7 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .muRecipe { color: #ff8700; } --> @@ -304,7 +304,7 @@ put(Recipe_ordinal,if (cursor.at_end()) break; if (cursor.get() != '.') { raise << Current_scenario->name << ": each row of the expected screen should start with a '.'\n" << end(); - Passed = false; + if (!Scenario_testing_scenario) Passed = false; return; } for (int column = 0; column < screen_width; ++column, addr+= /*size of screen-cell*/2) { @@ -360,7 +360,7 @@ put(Recipe_ordinal,} if (cursor.get() != '.') { raise << Current_scenario->name << ": row " << row << " of the expected screen is too long\n" << end(); - Passed = false; + if (!Scenario_testing_scenario) Passed = false; return; } } diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html index e6c70135..91f5aab2 100644 --- a/html/085scenario_console.cc.html +++ b/html/085scenario_console.cc.html @@ -19,7 +19,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/087file.cc.html b/html/087file.cc.html index 192db668..1fd4af3a 100644 --- a/html/087file.cc.html +++ b/html/087file.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } --> diff --git a/html/089scenario_filesystem.cc.html b/html/089scenario_filesystem.cc.html index 8d42226c..7fa10101 100644 --- a/html/089scenario_filesystem.cc.html +++ b/html/089scenario_filesystem.cc.html @@ -19,7 +19,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> @@ -149,6 +149,11 @@ put(Recipe_ordinal,(in); if (!has_data(in)) break; string filename = next_word(in); + if (filename.empty()) { + assert(!has_data(in)); + raise << "incomplete 'resources' block at end of file (0)\n" << end(); + return; + } if (*filename.begin() != '[') { raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end(); break; @@ -164,6 +169,11 @@ put(Recipe_ordinal,break; } string arrow = next_word(in); + if (arrow.empty()) { + assert(!has_data(in)); + raise << "incomplete 'resources' block at end of file (1)\n" << end(); + return; + } if (arrow != "<-") { raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end(); break; @@ -173,6 +183,11 @@ put(Recipe_ordinal,break; } string contents = next_word(in); + if (contents.empty()) { + assert(!has_data(in)); + raise << "incomplete 'resources' block at end of file (2)\n" << end(); + return; + } if (*contents.begin() != '[') { raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end(); break; diff --git a/html/091socket.cc.html b/html/091socket.cc.html index 9dadf48c..2d5f54f1 100644 --- a/html/091socket.cc.html +++ b/html/091socket.cc.html @@ -16,7 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .cSpecial { color: #008000; } .Delimiter { color: #800080; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } .Comment { color: #9090ff; } diff --git a/html/092socket.mu.html b/html/092socket.mu.html index 062217fe..186c7c3b 100644 --- a/html/092socket.mu.html +++ b/html/092socket.mu.html @@ -196,11 +196,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color put-index *new-port-connections, len, *new-port-connection ] -def receive-from-socket session:num, sink:&:sink:char -> sink:&:sink:char [ +def receive-from-socket socket:num, sink:&:sink:char -> sink:&:sink:char [ local-scope load-ingredients { - req:text, eof?:bool <- $read-from-socket session, 4096/bytes + req:text, eof?:bool <- $read-from-socket socket, 4096/bytes bytes-read:num <- length *req i:num <- copy 0 { diff --git a/html/100trace_browser.cc.html b/html/100trace_browser.cc.html index a2aee17e..1b357983 100644 --- a/html/100trace_browser.cc.html +++ b/html/100trace_browser.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index f2883e6f..dc606ed0 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -22,7 +22,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Special { color: #c00000; } .traceContains { color: #008000; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } --> diff --git a/html/102persist.cc.html b/html/102persist.cc.html index 76437a6d..c0d8ca78 100644 --- a/html/102persist.cc.html +++ b/html/102persist.cc.html @@ -17,7 +17,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +.Identifier { color: #ecf32c; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> diff --git a/html/http-client.mu.html b/html/http-client.mu.html index bd5520c3..96e87f5c 100644 --- a/html/http-client.mu.html +++ b/html/http-client.mu.html @@ -37,17 +37,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color local-scope google:&:source:char <- start-reading-from-network 0/real-resources, [google.com], [/] n:num <- copy 0 - b:&:buffer <- new-buffer 30 + buf:&:buffer <- new-buffer 30 { c:char, done?:bool <- read google break-if done? n <- add n, 1 - b <- append b, c + buf <- append buf, c #? trunc?:bool <- greater-or-equal n, 10000 #? loop-unless trunc? loop } - result:text <- buffer-to-array b + result:text <- buffer-to-array buf open-console len:num <- length *result print 0/real-screen, result diff --git a/html/http-server.mu.html b/html/http-server.mu.html index d09f4f87..cdc4d661 100644 --- a/html/http-server.mu.html +++ b/html/http-server.mu.html @@ -13,7 +13,6 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } -.Delimiter { color: #800080; } .muControl { color: #c0a020; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } @@ -47,14 +46,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color session:num <- $accept socket contents:&:source:char, sink:&:sink:char <- new-channel 30 sink <- start-running receive-from-socket session, sink - buf:&:buffer <- new-buffer 30 - { - c:char, done?:bool, contents <- read contents - break-if done? - buf <- append buf, c - loop - } - socket-text:text <- buffer-to-array buf + query:text <- drain contents $print [Done reading from socket.], 10/newline write-to-socket session, [HTTP/1.0 200 OK Content-type: text/plain diff --git a/html/lambda-to-mu.mu.html b/html/lambda-to-mu.mu.html index 52100115..46788657 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda-to-mu.mu.html @@ -222,7 +222,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { break-if pair? # atom - b:&:buffer <- new-buffer 30 + buf:&:buffer <- new-buffer 30 { done?:bool <- end-of-stream? in break-if done? @@ -233,10 +233,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color done? <- space? c break-if done? c <- read in - b <- append b, c + buf <- append buf, c loop } - s:text <- buffer-to-array b + s:text <- buffer-to-array buf out <- new-atom s } { -- cgit 1.4.1-2-gfad0