From fd7d8138a4ff5515f9b79c584a98d5c26d8ddb8a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 2 Mar 2017 05:48:01 -0800 Subject: 3750 --- 003trace.cc | 32 +- html/001help.cc.html | 16 +- html/002test.cc.html | 2 +- html/003trace.cc.html | 738 ++++++++++++++-------------- html/003trace.test.cc.html | 88 ++-- html/010vm.cc.html | 4 +- html/011load.cc.html | 52 +- html/012transform.cc.html | 8 +- html/013update_operation.cc.html | 4 +- html/014literal_string.cc.html | 4 +- html/015literal_noninteger.cc.html | 4 +- html/016dilated_reagent.cc.html | 16 +- html/017parse_tree.cc.html | 4 +- html/018type_abbreviations.cc.html | 28 +- html/020run.cc.html | 38 +- html/021check_instruction.cc.html | 10 +- html/022arithmetic.cc.html | 106 ++-- html/023boolean.cc.html | 18 +- html/024jump.cc.html | 26 +- html/025compare.cc.html | 68 +-- html/026call.cc.html | 10 +- html/027call_ingredient.cc.html | 12 +- html/028call_return.cc.html | 20 +- html/029tools.cc.html | 28 +- html/030container.cc.html | 82 ++-- html/031merge.cc.html | 24 +- html/032array.cc.html | 64 +-- html/033exclusive_container.cc.html | 32 +- html/034address.cc.html | 34 +- html/035lookup.cc.html | 26 +- html/036refcount.cc.html | 40 +- html/037abandon.cc.html | 12 +- html/038new_text.cc.html | 18 +- html/039location_array.cc.html | 2 +- html/040brace.cc.html | 32 +- html/041jump_target.cc.html | 12 +- html/042name.cc.html | 26 +- html/043space.cc.html | 24 +- html/044space_surround.cc.html | 2 +- html/045closure_name.cc.html | 30 +- html/046global.cc.html | 6 +- html/047check_type_by_name.cc.html | 18 +- html/050scenario.cc.html | 126 ++--- html/052tangle.cc.html | 34 +- html/053recipe_header.cc.html | 60 +-- html/054static_dispatch.cc.html | 46 +- html/055shape_shifting_container.cc.html | 28 +- html/056shape_shifting_recipe.cc.html | 62 +-- html/057immutable.cc.html | 32 +- html/058to_text.cc.html | 2 +- html/060rewrite_literal_string.cc.html | 4 +- html/062convert_ingredients_to_text.cc.html | 10 +- html/069hash.cc.html | 12 +- html/071recipe.cc.html | 22 +- html/072scheduler.cc.html | 32 +- html/073wait.cc.html | 68 +-- html/074deep_copy.cc.html | 36 +- html/080display.cc.html | 26 +- html/082scenario_screen.cc.html | 30 +- html/085scenario_console.cc.html | 18 +- html/087file.cc.html | 58 +-- html/089scenario_filesystem.cc.html | 44 +- html/091socket.cc.html | 62 +-- html/100trace_browser.cc.html | 4 +- html/101run_sandboxed.cc.html | 22 +- 65 files changed, 1321 insertions(+), 1337 deletions(-) diff --git a/003trace.cc b/003trace.cc index acdb79f1..7b046f89 100644 --- a/003trace.cc +++ b/003trace.cc @@ -13,36 +13,28 @@ //: longer valid. In both cases you end up having to reorganize code as well as //: tests, an error-prone activity. //: -//: This file tries to fix this problem by supporting domain-driven testing. -//: We try to focus on the domain of inputs the program should work on. All -//: tests invoke the program in a single way: by calling run() with different -//: inputs. The program operates on the input and logs _facts_ it deduces to a -//: trace: +//: In response, this layer introduces the notion of *domain-driven* testing. +//: We focus on the domain of inputs the whole program needs to handle rather +//: than the correctness of individual functions. All tests invoke the program +//: in a single way: by calling run() with some input. As the program operates +//: on the input, it traces out a list of _facts_ deduced about the domain: //: trace("label") << "fact 1: " << val; //: -//: The tests check for facts: +//: Tests can now check these facts: //: :(scenario foo) //: 34 # call run() with this input -//: +label: fact 1: 34 # trace should have logged this at the end -//: -label: fact 1: 35 # trace should never contain such a line +//: +label: fact 1: 34 # 'run' should have deduced this fact +//: -label: fact 1: 35 # the trace should not contain such a fact //: //: Since we never call anything but the run() function directly, we never have //: to rewrite the tests when we reorganize the internals of the program. We //: just have to make sure our rewrite deduces the same facts about the domain, //: and that's something we're going to have to do anyway. //: -//: To avoid the combinatorial explosion of integration tests, each layer logs -//: facts to the trace with a common label. Tests in that layer focus on the -//: same label. In essence, validating the facts logged with a specific label -//: is identical to calling some internal subsystem directly. -//: -//: Traces interact salubriously with layers. Thanks to our ordering -//: directives, each layer can contain its own tests. They may rely on other -//: layers, but when a test fails it's usually due to breakage in the same -//: layer. When multiple tests fail, it's usually useful to debug the very -//: first test to fail. This is in contrast with the traditional organization -//: of code, where changes can cause breakages in faraway subsystems, and -//: picking the right test to debug can be an important skill to pick up. +//: To avoid the combinatorial explosion of integration tests, each layer +//: mainly logs facts to the trace with a common *label*. All tests in a layer +//: tend to check facts with this label. Validating the facts logged with a +//: specific label is like calling functions of that layer directly. //: //: To build robust tests, trace facts about your domain rather than details of //: how you computed them. diff --git a/html/001help.cc.html b/html/001help.cc.html index 201d24ea..61af7f42 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -79,7 +79,7 @@ if ('onhashchange' in window) { 18 << "Examples:\n" 19 << " To load files and run 'main':\n" 20 << " mu file1.mu file2.mu ...\n" - 21 << " To run 'main' and dump a trace of all operations at the end:\n" + 21 << " To run 'main' and dump a trace of all operations at the end:\n" 22 << " mu --trace file1.mu file2.mu ...\n" 23 << " To run all tests:\n" 24 << " mu test\n" @@ -87,7 +87,7 @@ if ('onhashchange' in window) { 26 << " mu test file1.mu file2.mu ...\n" 27 << " To run a single Mu scenario:\n" 28 << " mu test file1.mu file2.mu ... scenario\n" - 29 << " To run a single Mu scenario and dump a trace at the end:\n" + 29 << " To run a single Mu scenario and dump a trace at the end:\n" 30 << " mu --trace test file1.mu file2.mu ... scenario\n" 31 << " To load files and run only the tests in explicitly loaded files (for apps):\n" 32 << " mu --test-only-app test file1.mu file2.mu ...\n" @@ -98,7 +98,7 @@ if ('onhashchange' in window) { 37 << " To pass ingredients to a mu program, provide them after '--':\n" 38 << " mu file_or_dir1 file_or_dir2 ... -- ingredient1 ingredient2 ...\n" 39 << "\n" - 40 << " To browse a trace generated by a previous run:\n" + 40 << " To browse a trace generated by a previous run:\n" 41 << " mu browse-trace file\n" 42 ; 43 return 0; @@ -134,9 +134,9 @@ if ('onhashchange' in window) { 73 74 bool starts_with(const string& s, const string& pat) { 75 string::const_iterator a=s.begin(), b=pat.begin(); - 76 for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) + 76 for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) 77 if (*a != *b) return false; - 78 return b == pat.end(); + 78 return b == pat.end(); 79 } 80 81 //: I'll throw some style conventions here for want of a better place for them. @@ -268,12 +268,12 @@ if ('onhashchange' in window) { 207 // from http://stackoverflow.com/questions/152643/idiomatic-c-for-reading-from-a-const-map 208 template<typename T> typename T::mapped_type& get(T& map, typename T::key_type const& key) { 209 typename T::iterator iter(map.find(key)); -210 assert(iter != map.end()); +210 assert(iter != map.end()); 211 return iter->second; 212 } 213 template<typename T> typename T::mapped_type const& get(const T& map, typename T::key_type const& key) { 214 typename T::const_iterator iter(map.find(key)); -215 assert(iter != map.end()); +215 assert(iter != map.end()); 216 return iter->second; 217 } 218 template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) { @@ -281,7 +281,7 @@ if ('onhashchange' in window) { 220 return map[key]; 221 } 222 template<typename T> bool contains_key(T& map, typename T::key_type const& key) { -223 return map.find(key) != map.end(); +223 return map.find(key) != map.end(); 224 } 225 template<typename T> typename T::mapped_type& get_or_insert(T& map, typename T::key_type const& key) { 226 return map[key]; diff --git a/html/002test.cc.html b/html/002test.cc.html index f91d0c39..3e69cef1 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -150,7 +150,7 @@ if ('onhashchange' in window) { 90 } 91 92 int to_integer(string n) { - 93 char* end = NULL; + 93 char* end = NULL; 94 // safe because string.c_str() is guaranteed to be null-terminated 95 int result = strtoll(n.c_str(), &end, /*any base*/0); 96 if (*end != '\0') cerr << "tried to convert " << n << " to number\n"; diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 069cc057..b1999eb4 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -72,400 +72,392 @@ if ('onhashchange' in window) { 13 //: longer valid. In both cases you end up having to reorganize code as well as 14 //: tests, an error-prone activity. 15 //: - 16 //: This file tries to fix this problem by supporting domain-driven testing. - 17 //: We try to focus on the domain of inputs the program should work on. All - 18 //: tests invoke the program in a single way: by calling run() with different - 19 //: inputs. The program operates on the input and logs _facts_ it deduces to a - 20 //: trace: + 16 //: In response, this layer introduces the notion of *domain-driven* testing. + 17 //: We focus on the domain of inputs the whole program needs to handle rather + 18 //: than the correctness of individual functions. All tests invoke the program + 19 //: in a single way: by calling run() with some input. As the program operates + 20 //: on the input, it traces out a list of _facts_ deduced about the domain: 21 //: trace("label") << "fact 1: " << val; 22 //: - 23 //: The tests check for facts: + 23 //: Tests can now check these facts: 24 //: :(scenario foo) 25 //: 34 # call run() with this input - 26 //: +label: fact 1: 34 # trace should have logged this at the end - 27 //: -label: fact 1: 35 # trace should never contain such a line + 26 //: +label: fact 1: 34 # 'run' should have deduced this fact + 27 //: -label: fact 1: 35 # the trace should not contain such a fact 28 //: 29 //: Since we never call anything but the run() function directly, we never have 30 //: to rewrite the tests when we reorganize the internals of the program. We 31 //: just have to make sure our rewrite deduces the same facts about the domain, 32 //: and that's something we're going to have to do anyway. 33 //: - 34 //: To avoid the combinatorial explosion of integration tests, each layer logs - 35 //: facts to the trace with a common label. Tests in that layer focus on the - 36 //: same label. In essence, validating the facts logged with a specific label - 37 //: is identical to calling some internal subsystem directly. + 34 //: To avoid the combinatorial explosion of integration tests, each layer + 35 //: mainly logs facts to the trace with a common *label*. All tests in a layer + 36 //: tend to check facts with this label. Validating the facts logged with a + 37 //: specific label is like calling functions of that layer directly. 38 //: - 39 //: Traces interact salubriously with layers. Thanks to our ordering - 40 //: directives, each layer can contain its own tests. They may rely on other - 41 //: layers, but when a test fails it's usually due to breakage in the same - 42 //: layer. When multiple tests fail, it's usually useful to debug the very - 43 //: first test to fail. This is in contrast with the traditional organization - 44 //: of code, where changes can cause breakages in faraway subsystems, and - 45 //: picking the right test to debug can be an important skill to pick up. - 46 //: - 47 //: To build robust tests, trace facts about your domain rather than details of - 48 //: how you computed them. - 49 //: - 50 //: More details: http://akkartik.name/blog/tracing-tests - 51 //: - 52 //: --- - 53 //: - 54 //: Between layers and domain-driven testing, programming starts to look like a - 55 //: fundamentally different activity. Instead of a) superficial, b) local rules - 56 //: on c) code [like say http://blog.bbv.ch/2013/06/05/clean-code-cheat-sheet], - 57 //: we allow programmers to engage with the a) deep, b) global structure of the - 58 //: c) domain. If you can systematically track discontinuities in the domain, - 59 //: you don't care if the code used gotos as long as it passed the tests. If - 60 //: tests become more robust to run it becomes easier to try out radically - 61 //: different implementations for the same program. If code is super-easy to - 62 //: rewrite, it becomes less important what indentation style it uses, or that - 63 //: the objects are appropriately encapsulated, or that the functions are - 64 //: referentially transparent. + 39 //: To build robust tests, trace facts about your domain rather than details of + 40 //: how you computed them. + 41 //: + 42 //: More details: http://akkartik.name/blog/tracing-tests + 43 //: + 44 //: --- + 45 //: + 46 //: Between layers and domain-driven testing, programming starts to look like a + 47 //: fundamentally different activity. Instead of a) superficial, b) local rules + 48 //: on c) code [like say http://blog.bbv.ch/2013/06/05/clean-code-cheat-sheet], + 49 //: we allow programmers to engage with the a) deep, b) global structure of the + 50 //: c) domain. If you can systematically track discontinuities in the domain, + 51 //: you don't care if the code used gotos as long as it passed the tests. If + 52 //: tests become more robust to run it becomes easier to try out radically + 53 //: different implementations for the same program. If code is super-easy to + 54 //: rewrite, it becomes less important what indentation style it uses, or that + 55 //: the objects are appropriately encapsulated, or that the functions are + 56 //: referentially transparent. + 57 //: + 58 //: Instead of plumbing, programming becomes building and gradually refining a + 59 //: map of the environment the program must operate under. Whether a program is + 60 //: 'correct' at a given point in time is a red herring; what matters is + 61 //: avoiding regression by monotonically nailing down the more 'eventful' parts + 62 //: of the terrain. It helps readers new and old, and rewards curiosity, to + 63 //: organize large programs in self-similar hierarchies of example scenarios + 64 //: colocated with the code that makes them work. 65 //: - 66 //: Instead of plumbing, programming becomes building and gradually refining a - 67 //: map of the environment the program must operate under. Whether a program is - 68 //: 'correct' at a given point in time is a red herring; what matters is - 69 //: avoiding regression by monotonically nailing down the more 'eventful' parts - 70 //: of the terrain. It helps readers new and old, and rewards curiosity, to - 71 //: organize large programs in self-similar hierarchies of example scenarios - 72 //: colocated with the code that makes them work. - 73 //: - 74 //: "Programming properly should be regarded as an activity by which - 75 //: programmers form a mental model, rather than as production of a program." - 76 //: -- Peter Naur (http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22) - 77 - 78 :(before "End Types") - 79 struct trace_line { - 80 int depth; // optional field just to help browse traces later - 81 string label; - 82 string contents; - 83 trace_line(string l, string c) :depth(0), label(l), contents(c) {} - 84 trace_line(int d, string l, string c) :depth(d), label(l), contents(c) {} - 85 }; - 86 - 87 :(before "End Globals") - 88 bool Hide_errors = false; - 89 bool Dump_trace = false; - 90 string Dump_label = ""; - 91 :(before "End Setup") - 92 Hide_errors = false; - 93 Dump_trace = false; - 94 Dump_label = ""; + 66 //: "Programming properly should be regarded as an activity by which + 67 //: programmers form a mental model, rather than as production of a program." + 68 //: -- Peter Naur (http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22) + 69 + 70 :(before "End Types") + 71 struct trace_line { + 72 int depth; // optional field just to help browse traces later + 73 string label; + 74 string contents; + 75 trace_line(string l, string c) :depth(0), label(l), contents(c) {} + 76 trace_line(int d, string l, string c) :depth(d), label(l), contents(c) {} + 77 }; + 78 + 79 :(before "End Globals") + 80 bool Hide_errors = false; + 81 bool Dump_trace = false; + 82 string Dump_label = ""; + 83 :(before "End Setup") + 84 Hide_errors = false; + 85 Dump_trace = false; + 86 Dump_label = ""; + 87 + 88 :(before "End Types") + 89 // Pre-define some global constants that trace_stream needs to know about. + 90 // Since they're in the Types section, they'll be included in any cleaved + 91 // compilation units. So no extern linkage. + 92 const int Max_depth = 9999; + 93 const int Error_depth = 0; // definitely always print errors + 94 const int App_depth = 2; // temporarily where all Mu code will trace to 95 - 96 :(before "End Types") - 97 // Pre-define some global constants that trace_stream needs to know about. - 98 // Since they're in the Types section, they'll be included in any cleaved - 99 // compilation units. So no extern linkage. -100 const int Max_depth = 9999; -101 const int Error_depth = 0; // definitely always print errors -102 const int App_depth = 2; // temporarily where all Mu code will trace to -103 -104 struct trace_stream { -105 vector<trace_line> past_lines; -106 // accumulator for current line -107 ostringstream* curr_stream; -108 string curr_label; -109 int curr_depth; -110 int callstack_depth; -111 int collect_depth; -112 ofstream null_stream; // never opens a file, so writes silently fail -113 trace_stream() :curr_stream(NULL), curr_depth(Max_depth), callstack_depth(0), collect_depth(Max_depth) {} -114 ~trace_stream() { if (curr_stream) delete curr_stream; } -115 -116 ostream& stream(string label) { -117 return stream(Max_depth, label); + 96 struct trace_stream { + 97 vector<trace_line> past_lines; + 98 // accumulator for current line + 99 ostringstream* curr_stream; +100 string curr_label; +101 int curr_depth; +102 int callstack_depth; +103 int collect_depth; +104 ofstream null_stream; // never opens a file, so writes silently fail +105 trace_stream() :curr_stream(NULL), curr_depth(Max_depth), callstack_depth(0), collect_depth(Max_depth) {} +106 ~trace_stream() { if (curr_stream) delete curr_stream; } +107 +108 ostream& stream(string label) { +109 return stream(Max_depth, label); +110 } +111 +112 ostream& stream(int depth, string label) { +113 if (depth > collect_depth) return null_stream; +114 curr_stream = new ostringstream; +115 curr_label = label; +116 curr_depth = depth; +117 return *curr_stream; 118 } 119 -120 ostream& stream(int depth, string label) { -121 if (depth > collect_depth) return null_stream; -122 curr_stream = new ostringstream; -123 curr_label = label; -124 curr_depth = depth; -125 return *curr_stream; -126 } -127 -128 // be sure to call this before messing with curr_stream or curr_label -129 void newline(); -130 // useful for debugging -131 string readable_contents(string label); // empty label = show everything -132 }; -133 -134 :(code) -135 void trace_stream::newline() { -136 if (!curr_stream) return; -137 string curr_contents = curr_stream->str(); -138 if (!curr_contents.empty()) { -139 past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents)); // preserve indent in contents -140 if ((!Hide_errors && curr_label == "error") -141 || Dump_trace -142 || (!Dump_label.empty() && curr_label == Dump_label)) -143 cerr << curr_label << ": " << curr_contents << '\n'; -144 } -145 delete curr_stream; -146 curr_stream = NULL; -147 curr_label.clear(); -148 curr_depth = Max_depth; -149 } -150 -151 string trace_stream::readable_contents(string label) { -152 ostringstream output; -153 label = trim(label); -154 for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) -155 if (label.empty() || label == p->label) { -156 output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n'; -157 } -158 return output.str(); -159 } -160 -161 :(before "End Globals") -162 trace_stream* Trace_stream = NULL; -163 int Trace_errors = 0; // used only when Trace_stream is NULL -164 -165 :(before "End Includes") -166 #define CLEAR_TRACE delete Trace_stream, Trace_stream = new trace_stream; -167 -168 // Top-level helper. IMPORTANT: can't nest -169 #define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) -170 -171 // Just for debugging; 'git log' should never show any calls to 'dbg'. -172 #define dbg trace(0, "a") -173 #define DUMP(label) if (Trace_stream) cerr << Trace_stream->readable_contents(label); -174 -175 // Errors are a special layer. -176 #define raise (!Trace_stream ? (tb_shutdown(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error")) -177 // If we aren't yet sure how to deal with some corner case, use assert_for_now -178 // to indicate that it isn't an inviolable invariant. -179 #define assert_for_now assert -180 -181 // Inside tests, fail any tests that displayed (unexpected) errors. -182 // Expected errors in tests should always be hidden and silently checked for. -183 :(before "End Test Teardown") -184 if (Passed && !Hide_errors && trace_contains_errors()) { -185 Passed = false; -186 } -187 :(code) -188 bool trace_contains_errors() { -189 return Trace_errors > 0 || trace_count("error") > 0; +120 // be sure to call this before messing with curr_stream or curr_label +121 void newline(); +122 // useful for debugging +123 string readable_contents(string label); // empty label = show everything +124 }; +125 +126 :(code) +127 void trace_stream::newline() { +128 if (!curr_stream) return; +129 string curr_contents = curr_stream->str(); +130 if (!curr_contents.empty()) { +131 past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents)); // preserve indent in contents +132 if ((!Hide_errors && curr_label == "error") +133 || Dump_trace +134 || (!Dump_label.empty() && curr_label == Dump_label)) +135 cerr << curr_label << ": " << curr_contents << '\n'; +136 } +137 delete curr_stream; +138 curr_stream = NULL; +139 curr_label.clear(); +140 curr_depth = Max_depth; +141 } +142 +143 string trace_stream::readable_contents(string label) { +144 ostringstream output; +145 label = trim(label); +146 for (vector<trace_line>::iterator p = past_lines.begin(); p != past_lines.end(); ++p) +147 if (label.empty() || label == p->label) { +148 output << std::setw(4) << p->depth << ' ' << p->label << ": " << p->contents << '\n'; +149 } +150 return output.str(); +151 } +152 +153 :(before "End Globals") +154 trace_stream* Trace_stream = NULL; +155 int Trace_errors = 0; // used only when Trace_stream is NULL +156 +157 :(before "End Includes") +158 #define CLEAR_TRACE delete Trace_stream, Trace_stream = new trace_stream; +159 +160 // Top-level helper. IMPORTANT: can't nest +161 #define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) +162 +163 // Just for debugging; 'git log' should never show any calls to 'dbg'. +164 #define dbg trace(0, "a") +165 #define DUMP(label) if (Trace_stream) cerr << Trace_stream->readable_contents(label); +166 +167 // Errors are a special layer. +168 #define raise (!Trace_stream ? (tb_shutdown(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error")) +169 // If we aren't yet sure how to deal with some corner case, use assert_for_now +170 // to indicate that it isn't an inviolable invariant. +171 #define assert_for_now assert +172 +173 // Inside tests, fail any tests that displayed (unexpected) errors. +174 // Expected errors in tests should always be hidden and silently checked for. +175 :(before "End Test Teardown") +176 if (Passed && !Hide_errors && trace_contains_errors()) { +177 Passed = false; +178 } +179 :(code) +180 bool trace_contains_errors() { +181 return Trace_errors > 0 || trace_count("error") > 0; +182 } +183 +184 :(before "End Types") +185 struct end {}; +186 :(code) +187 ostream& operator<<(ostream& os, unused end) { +188 if (Trace_stream) Trace_stream->newline(); +189 return os; 190 } 191 -192 :(before "End Types") -193 struct end {}; -194 :(code) -195 ostream& operator<<(ostream& os, unused end) { -196 if (Trace_stream) Trace_stream->newline(); -197 return os; -198 } -199 -200 :(before "End Globals") -201 bool Save_trace = false; -202 -203 // Trace_stream is a resource, lease_tracer uses RAII to manage it. -204 :(before "End Types") -205 struct lease_tracer { -206 lease_tracer(); -207 ~lease_tracer(); -208 }; -209 :(code) -210 lease_tracer::lease_tracer() { Trace_stream = new trace_stream; } -211 lease_tracer::~lease_tracer() { -212 if (!Trace_stream) return; // in case tests close Trace_stream -213 if (Save_trace) { -214 ofstream fout("last_trace"); -215 fout << Trace_stream->readable_contents(""); -216 fout.close(); -217 } -218 delete Trace_stream, Trace_stream = NULL; -219 } -220 :(before "End Includes") -221 #define START_TRACING_UNTIL_END_OF_SCOPE lease_tracer leased_tracer; -222 :(before "End Test Setup") -223 START_TRACING_UNTIL_END_OF_SCOPE -224 -225 :(before "End Includes") -226 #define CHECK_TRACE_CONTENTS(...) check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) -227 -228 #define CHECK_TRACE_CONTAINS_ERRORS() CHECK(trace_contains_errors()) -229 #define CHECK_TRACE_DOESNT_CONTAIN_ERRORS() \ -230 if (Passed && trace_contains_errors()) { \ -231 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \ -232 DUMP("error"); \ -233 Passed = false; \ -234 return; \ -235 } -236 -237 #define CHECK_TRACE_COUNT(label, count) \ -238 if (Passed && trace_count(label) != (count)) { \ -239 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \ -240 cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \ -241 DUMP(label); \ -242 Passed = false; \ -243 return; /* Currently we stop at the very first failure. */ \ -244 } -245 -246 #define CHECK_TRACE_DOESNT_CONTAIN(...) CHECK(trace_doesnt_contain(__VA_ARGS__)) -247 -248 :(code) -249 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) { -250 if (!Passed) return false; -251 if (!Trace_stream) return false; -252 vector<string> expected_lines = split(expected, "^D"); -253 int curr_expected_line = 0; -254 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) -255 ++curr_expected_line; -256 if (curr_expected_line == SIZE(expected_lines)) return true; -257 string label, contents; -258 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); -259 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -260 if (label != p->label) continue; -261 if (contents != trim(p->contents)) continue; -262 ++curr_expected_line; -263 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) -264 ++curr_expected_line; -265 if (curr_expected_line == SIZE(expected_lines)) return true; -266 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); -267 } -268 -269 if (line_exists_anywhere(label, contents)) { -270 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; -271 DUMP(""); -272 } -273 else { -274 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; -275 DUMP(label); -276 } -277 Passed = false; -278 return false; -279 } -280 -281 void split_label_contents(const string& s, string* label, string* contents) { -282 static const string delim(": "); -283 size_t pos = s.find(delim); -284 if (pos == string::npos) { -285 *label = ""; -286 *contents = trim(s); -287 } -288 else { -289 *label = trim(s.substr(0, pos)); -290 *contents = trim(s.substr(pos+SIZE(delim))); -291 } +192 :(before "End Globals") +193 bool Save_trace = false; +194 +195 // Trace_stream is a resource, lease_tracer uses RAII to manage it. +196 :(before "End Types") +197 struct lease_tracer { +198 lease_tracer(); +199 ~lease_tracer(); +200 }; +201 :(code) +202 lease_tracer::lease_tracer() { Trace_stream = new trace_stream; } +203 lease_tracer::~lease_tracer() { +204 if (!Trace_stream) return; // in case tests close Trace_stream +205 if (Save_trace) { +206 ofstream fout("last_trace"); +207 fout << Trace_stream->readable_contents(""); +208 fout.close(); +209 } +210 delete Trace_stream, Trace_stream = NULL; +211 } +212 :(before "End Includes") +213 #define START_TRACING_UNTIL_END_OF_SCOPE lease_tracer leased_tracer; +214 :(before "End Test Setup") +215 START_TRACING_UNTIL_END_OF_SCOPE +216 +217 :(before "End Includes") +218 #define CHECK_TRACE_CONTENTS(...) check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) +219 +220 #define CHECK_TRACE_CONTAINS_ERRORS() CHECK(trace_contains_errors()) +221 #define CHECK_TRACE_DOESNT_CONTAIN_ERRORS() \ +222 if (Passed && trace_contains_errors()) { \ +223 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \ +224 DUMP("error"); \ +225 Passed = false; \ +226 return; \ +227 } +228 +229 #define CHECK_TRACE_COUNT(label, count) \ +230 if (Passed && trace_count(label) != (count)) { \ +231 cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \ +232 cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \ +233 DUMP(label); \ +234 Passed = false; \ +235 return; /* Currently we stop at the very first failure. */ \ +236 } +237 +238 #define CHECK_TRACE_DOESNT_CONTAIN(...) CHECK(trace_doesnt_contain(__VA_ARGS__)) +239 +240 :(code) +241 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) { +242 if (!Passed) return false; +243 if (!Trace_stream) return false; +244 vector<string> expected_lines = split(expected, "^D"); +245 int curr_expected_line = 0; +246 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) +247 ++curr_expected_line; +248 if (curr_expected_line == SIZE(expected_lines)) return true; +249 string label, contents; +250 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); +251 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +252 if (label != p->label) continue; +253 if (contents != trim(p->contents)) continue; +254 ++curr_expected_line; +255 while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) +256 ++curr_expected_line; +257 if (curr_expected_line == SIZE(expected_lines)) return true; +258 split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); +259 } +260 +261 if (line_exists_anywhere(label, contents)) { +262 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; +263 DUMP(""); +264 } +265 else { +266 cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; +267 DUMP(label); +268 } +269 Passed = false; +270 return false; +271 } +272 +273 void split_label_contents(const string& s, string* label, string* contents) { +274 static const string delim(": "); +275 size_t pos = s.find(delim); +276 if (pos == string::npos) { +277 *label = ""; +278 *contents = trim(s); +279 } +280 else { +281 *label = trim(s.substr(0, pos)); +282 *contents = trim(s.substr(pos+SIZE(delim))); +283 } +284 } +285 +286 bool line_exists_anywhere(const string& label, const string& contents) { +287 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +288 if (label != p->label) continue; +289 if (contents == trim(p->contents)) return true; +290 } +291 return false; 292 } 293 -294 bool line_exists_anywhere(const string& label, const string& contents) { -295 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -296 if (label != p->label) continue; -297 if (contents == trim(p->contents)) return true; -298 } -299 return false; -300 } -301 -302 int trace_count(string label) { -303 return trace_count(label, ""); -304 } -305 -306 int trace_count(string label, string line) { -307 if (!Trace_stream) return 0; -308 long result = 0; -309 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -310 if (label == p->label) { -311 if (line == "" || trim(line) == trim(p->contents)) -312 ++result; -313 } -314 } -315 return result; -316 } -317 -318 int trace_count_prefix(string label, string prefix) { -319 if (!Trace_stream) return 0; -320 long result = 0; -321 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -322 if (label == p->label) { -323 if (starts_with(trim(p->contents), trim(prefix))) -324 ++result; -325 } -326 } -327 return result; -328 } -329 -330 bool trace_doesnt_contain(string label, string line) { -331 return trace_count(label, line) == 0; -332 } -333 -334 bool trace_doesnt_contain(string expected) { -335 vector<string> tmp = split_first(expected, ": "); -336 return trace_doesnt_contain(tmp.at(0), tmp.at(1)); -337 } -338 -339 vector<string> split(string s, string delim) { -340 vector<string> result; -341 size_t begin=0, end=s.find(delim); -342 while (true) { -343 if (end == string::npos) { -344 result.push_back(string(s, begin, string::npos)); -345 break; -346 } -347 result.push_back(string(s, begin, end-begin)); -348 begin = end+SIZE(delim); -349 end = s.find(delim, begin); -350 } -351 return result; -352 } -353 -354 vector<string> split_first(string s, string delim) { -355 vector<string> result; -356 size_t end=s.find(delim); -357 result.push_back(string(s, 0, end)); -358 if (end != string::npos) -359 result.push_back(string(s, end+SIZE(delim), string::npos)); -360 return result; -361 } -362 -363 string trim(const string& s) { -364 string::const_iterator first = s.begin(); -365 while (first != s.end() && isspace(*first)) -366 ++first; -367 if (first == s.end()) return ""; -368 -369 string::const_iterator last = --s.end(); -370 while (last != s.begin() && isspace(*last)) -371 --last; -372 ++last; -373 return string(first, last); -374 } -375 -376 :(before "End Includes") -377 #include <vector> -378 using std::vector; -379 #include <list> -380 using std::list; -381 #include <map> -382 using std::map; -383 #include <set> -384 using std::set; -385 #include <algorithm> +294 int trace_count(string label) { +295 return trace_count(label, ""); +296 } +297 +298 int trace_count(string label, string line) { +299 if (!Trace_stream) return 0; +300 long result = 0; +301 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +302 if (label == p->label) { +303 if (line == "" || trim(line) == trim(p->contents)) +304 ++result; +305 } +306 } +307 return result; +308 } +309 +310 int trace_count_prefix(string label, string prefix) { +311 if (!Trace_stream) return 0; +312 long result = 0; +313 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +314 if (label == p->label) { +315 if (starts_with(trim(p->contents), trim(prefix))) +316 ++result; +317 } +318 } +319 return result; +320 } +321 +322 bool trace_doesnt_contain(string label, string line) { +323 return trace_count(label, line) == 0; +324 } +325 +326 bool trace_doesnt_contain(string expected) { +327 vector<string> tmp = split_first(expected, ": "); +328 return trace_doesnt_contain(tmp.at(0), tmp.at(1)); +329 } +330 +331 vector<string> split(string s, string delim) { +332 vector<string> result; +333 size_t begin=0, end=s.find(delim); +334 while (true) { +335 if (end == string::npos) { +336 result.push_back(string(s, begin, string::npos)); +337 break; +338 } +339 result.push_back(string(s, begin, end-begin)); +340 begin = end+SIZE(delim); +341 end = s.find(delim, begin); +342 } +343 return result; +344 } +345 +346 vector<string> split_first(string s, string delim) { +347 vector<string> result; +348 size_t end=s.find(delim); +349 result.push_back(string(s, 0, end)); +350 if (end != string::npos) +351 result.push_back(string(s, end+SIZE(delim), string::npos)); +352 return result; +353 } +354 +355 string trim(const string& s) { +356 string::const_iterator first = s.begin(); +357 while (first != s.end() && isspace(*first)) +358 ++first; +359 if (first == s.end()) return ""; +360 +361 string::const_iterator last = --s.end(); +362 while (last != s.begin() && isspace(*last)) +363 --last; +364 ++last; +365 return string(first, last); +366 } +367 +368 :(before "End Includes") +369 #include <vector> +370 using std::vector; +371 #include <list> +372 using std::list; +373 #include <map> +374 using std::map; +375 #include <set> +376 using std::set; +377 #include <algorithm> +378 +379 #include <sstream> +380 using std::istringstream; +381 using std::ostringstream; +382 +383 #include <fstream> +384 using std::ifstream; +385 using std::ofstream; 386 -387 #include <sstream> -388 using std::istringstream; -389 using std::ostringstream; -390 -391 #include <fstream> -392 using std::ifstream; -393 using std::ofstream; -394 -395 #include "termbox/termbox.h" -396 -397 :(before "End Globals") -398 //: In future layers we'll use the depth field as follows: +387 #include "termbox/termbox.h" +388 +389 :(before "End Globals") +390 //: In future layers we'll use the depth field as follows: +391 //: +392 //: Errors will be depth 0. +393 //: Mu 'applications' will be able to use depths 1-100 as they like. +394 //: Primitive statements will occupy 101-9989 +395 extern const int Initial_callstack_depth = 101; +396 extern const int Max_callstack_depth = 9989; +397 //: Finally, details of primitive Mu statements will occupy depth 9990-9999 +398 //: (more on that later as well) 399 //: -400 //: Errors will be depth 0. -401 //: Mu 'applications' will be able to use depths 1-100 as they like. -402 //: Primitive statements will occupy 101-9989 -403 extern const int Initial_callstack_depth = 101; -404 extern const int Max_callstack_depth = 9989; -405 //: Finally, details of primitive Mu statements will occupy depth 9990-9999 -406 //: (more on that later as well) -407 //: -408 //: This framework should help us hide some details at each level, mixing -409 //: static ideas like layers with the dynamic notion of call-stack depth. +400 //: This framework should help us hide some details at each level, mixing +401 //: static ideas like layers with the dynamic notion of call-stack depth. diff --git a/html/003trace.test.cc.html b/html/003trace.test.cc.html index 3e1e2d3d..efd93367 100644 --- a/html/003trace.test.cc.html +++ b/html/003trace.test.cc.html @@ -56,66 +56,66 @@ if ('onhashchange' in window) {
   1 void test_trace_check_compares() {
-  2   trace("test layer") << "foo" << end();
-  3   CHECK_TRACE_CONTENTS("test layer: foo");
+  2   trace("test layer") << "foo" << end();
+  3   CHECK_TRACE_CONTENTS("test layer: foo");
   4 }
   5 
   6 void test_trace_check_ignores_other_layers() {
-  7   trace("test layer 1") << "foo" << end();
-  8   trace("test layer 2") << "bar" << end();
-  9   CHECK_TRACE_CONTENTS("test layer 1: foo");
- 10   CHECK_TRACE_DOESNT_CONTAIN("test layer 2: foo");
+  7   trace("test layer 1") << "foo" << end();
+  8   trace("test layer 2") << "bar" << end();
+  9   CHECK_TRACE_CONTENTS("test layer 1: foo");
+ 10   CHECK_TRACE_DOESNT_CONTAIN("test layer 2: foo");
  11 }
  12 
  13 void test_trace_check_ignores_leading_whitespace() {
- 14   trace("test layer 1") << " foo" << end();
+ 14   trace("test layer 1") << " foo" << end();
  15   CHECK_EQ(trace_count("test layer 1", /*too little whitespace*/"foo"), 1);
  16   CHECK_EQ(trace_count("test layer 1", /*too much whitespace*/"  foo"), 1);
  17 }
  18 
  19 void test_trace_check_ignores_other_lines() {
- 20   trace("test layer 1") << "foo" << end();
- 21   trace("test layer 1") << "bar" << end();
- 22   CHECK_TRACE_CONTENTS("test layer 1: foo");
+ 20   trace("test layer 1") << "foo" << end();
+ 21   trace("test layer 1") << "bar" << end();
+ 22   CHECK_TRACE_CONTENTS("test layer 1: foo");
  23 }
  24 
  25 void test_trace_check_ignores_other_lines2() {
- 26   trace("test layer 1") << "foo" << end();
- 27   trace("test layer 1") << "bar" << end();
- 28   CHECK_TRACE_CONTENTS("test layer 1: bar");
+ 26   trace("test layer 1") << "foo" << end();
+ 27   trace("test layer 1") << "bar" << end();
+ 28   CHECK_TRACE_CONTENTS("test layer 1: bar");
  29 }
  30 
  31 void test_trace_ignores_trailing_whitespace() {
- 32   trace("test layer 1") << "foo\n" << end();
- 33   CHECK_TRACE_CONTENTS("test layer 1: foo");
+ 32   trace("test layer 1") << "foo\n" << end();
+ 33   CHECK_TRACE_CONTENTS("test layer 1: foo");
  34 }
  35 
  36 void test_trace_ignores_trailing_whitespace2() {
- 37   trace("test layer 1") << "foo " << end();
- 38   CHECK_TRACE_CONTENTS("test layer 1: foo");
+ 37   trace("test layer 1") << "foo " << end();
+ 38   CHECK_TRACE_CONTENTS("test layer 1: foo");
  39 }
  40 
  41 void test_trace_orders_across_layers() {
- 42   trace("test layer 1") << "foo" << end();
- 43   trace("test layer 2") << "bar" << end();
- 44   trace("test layer 1") << "qux" << end();
- 45   CHECK_TRACE_CONTENTS("test layer 1: foo^Dtest layer 2: bar^Dtest layer 1: qux^D");
+ 42   trace("test layer 1") << "foo" << end();
+ 43   trace("test layer 2") << "bar" << end();
+ 44   trace("test layer 1") << "qux" << end();
+ 45   CHECK_TRACE_CONTENTS("test layer 1: foo^Dtest layer 2: bar^Dtest layer 1: qux^D");
  46 }
  47 
  48 void test_trace_supports_count() {
- 49   trace("test layer 1") << "foo" << end();
- 50   trace("test layer 1") << "foo" << end();
+ 49   trace("test layer 1") << "foo" << end();
+ 50   trace("test layer 1") << "foo" << end();
  51   CHECK_EQ(trace_count("test layer 1", "foo"), 2);
  52 }
  53 
  54 void test_trace_supports_count2() {
- 55   trace("test layer 1") << "foo" << end();
- 56   trace("test layer 1") << "bar" << end();
+ 55   trace("test layer 1") << "foo" << end();
+ 56   trace("test layer 1") << "bar" << end();
  57   CHECK_EQ(trace_count("test layer 1"), 2);
  58 }
  59 
  60 void test_trace_count_ignores_trailing_whitespace() {
- 61   trace("test layer 1") << "foo\n" << end();
+ 61   trace("test layer 1") << "foo\n" << end();
  62   CHECK_EQ(trace_count("test layer 1", "foo"), 1);
  63 }
  64 
@@ -130,26 +130,26 @@ if ('onhashchange' in window) {
  73 // can't check trace because trace methods call 'split'
  74 
  75 void test_split_returns_at_least_one_elem() {
- 76   vector<string> result = split("", ",");
+ 76   vector<string> result = split("", ",");
  77   CHECK_EQ(result.size(), 1);
  78   CHECK_EQ(result.at(0), "");
  79 }
  80 
  81 void test_split_returns_entire_input_when_no_delim() {
- 82   vector<string> result = split("abc", ",");
+ 82   vector<string> result = split("abc", ",");
  83   CHECK_EQ(result.size(), 1);
  84   CHECK_EQ(result.at(0), "abc");
  85 }
  86 
  87 void test_split_works() {
- 88   vector<string> result = split("abc,def", ",");
+ 88   vector<string> result = split("abc,def", ",");
  89   CHECK_EQ(result.size(), 2);
  90   CHECK_EQ(result.at(0), "abc");
  91   CHECK_EQ(result.at(1), "def");
  92 }
  93 
  94 void test_split_works2() {
- 95   vector<string> result = split("abc,def,ghi", ",");
+ 95   vector<string> result = split("abc,def,ghi", ",");
  96   CHECK_EQ(result.size(), 3);
  97   CHECK_EQ(result.at(0), "abc");
  98   CHECK_EQ(result.at(1), "def");
@@ -157,7 +157,7 @@ if ('onhashchange' in window) {
 100 }
 101 
 102 void test_split_handles_multichar_delim() {
-103   vector<string> result = split("abc,,def,,ghi", ",,");
+103   vector<string> result = split("abc,,def,,ghi", ",,");
 104   CHECK_EQ(result.size(), 3);
 105   CHECK_EQ(result.at(0), "abc");
 106   CHECK_EQ(result.at(1), "def");
@@ -165,19 +165,19 @@ if ('onhashchange' in window) {
 108 }
 109 
 110 void test_trim() {
-111   CHECK_EQ(trim(""), "");
-112   CHECK_EQ(trim(" "), "");
-113   CHECK_EQ(trim("  "), "");
-114   CHECK_EQ(trim("a"), "a");
-115   CHECK_EQ(trim(" a"), "a");
-116   CHECK_EQ(trim("  a"), "a");
-117   CHECK_EQ(trim("  ab"), "ab");
-118   CHECK_EQ(trim("a "), "a");
-119   CHECK_EQ(trim("a  "), "a");
-120   CHECK_EQ(trim("ab  "), "ab");
-121   CHECK_EQ(trim(" a "), "a");
-122   CHECK_EQ(trim("  a  "), "a");
-123   CHECK_EQ(trim("  ab  "), "ab");
+111   CHECK_EQ(trim(""), "");
+112   CHECK_EQ(trim(" "), "");
+113   CHECK_EQ(trim("  "), "");
+114   CHECK_EQ(trim("a"), "a");
+115   CHECK_EQ(trim(" a"), "a");
+116   CHECK_EQ(trim("  a"), "a");
+117   CHECK_EQ(trim("  ab"), "ab");
+118   CHECK_EQ(trim("a "), "a");
+119   CHECK_EQ(trim("a  "), "a");
+120   CHECK_EQ(trim("ab  "), "ab");
+121   CHECK_EQ(trim(" a "), "a");
+122   CHECK_EQ(trim("  a  "), "a");
+123   CHECK_EQ(trim("  ab  "), "ab");
 124 }
 
diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 7a54fad4..25bdf097 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -209,7 +209,7 @@ if ('onhashchange' in window) { 147 // End Mu Types Initialization 148 } 149 void teardown_types() { -150 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { +150 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { 151 for (int i = 0; i < SIZE(p->second.elements); ++i) 152 p->second.elements.clear(); 153 } @@ -645,7 +645,7 @@ if ('onhashchange' in window) { 583 } 584 585 void dump_memory() { -586 for (map<int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) { +586 for (map<int, double>::iterator p = Memory.begin(); p != Memory.end(); ++p) { 587 cout << p->first << ": " << no_scientific(p->second) << '\n'; 588 } 589 } diff --git a/html/011load.cc.html b/html/011load.cc.html index e718060e..5aeeb12e 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -105,7 +105,7 @@ if ('onhashchange' in window) { 43 } 44 // End Command Handlers 45 else { - 46 raise << "unknown top-level command: " << command << '\n' << end(); + 46 raise << "unknown top-level command: " << command << '\n' << end(); 47 } 48 } 49 return result; @@ -117,21 +117,21 @@ if ('onhashchange' in window) { 55 result.name = next_word(in); 56 if (result.name.empty()) { 57 assert(!has_data(in)); - 58 raise << "file ended with 'recipe'\n" << end(); + 58 raise << "file ended with 'recipe'\n" << end(); 59 return -1; 60 } 61 // End Load Recipe Name 62 skip_whitespace_but_not_newline(in); 63 // End Recipe Refinements 64 if (result.name.empty()) - 65 raise << "empty result.name\n" << end(); - 66 trace(9991, "parse") << "--- defining " << result.name << end(); + 65 raise << "empty result.name\n" << end(); + 66 trace(9991, "parse") << "--- defining " << result.name << end(); 67 if (!contains_key(Recipe_ordinal, result.name)) 68 put(Recipe_ordinal, result.name, Next_recipe_ordinal++); - 69 if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) { - 70 trace(9991, "parse") << "already exists" << end(); + 69 if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) { + 70 trace(9991, "parse") << "already exists" << end(); 71 if (should_check_for_redefine(result.name)) - 72 raise << "redefining recipe " << result.name << "\n" << end(); + 72 raise << "redefining recipe " << result.name << "\n" << end(); 73 Recipe.erase(get(Recipe_ordinal, result.name)); 74 } 75 slurp_body(in, result); @@ -144,13 +144,13 @@ if ('onhashchange' in window) { 82 in >> std::noskipws; 83 skip_whitespace_but_not_newline(in); 84 if (in.get() != '[') - 85 raise << result.name << ": recipe body must begin with '['\n" << end(); + 85 raise << result.name << ": recipe body must begin with '['\n" << end(); 86 skip_whitespace_and_comments(in); // permit trailing comment after '[' 87 instruction curr; 88 while (next_instruction(in, &curr)) { 89 curr.original_string = to_original_string(curr); 90 // End Rewrite Instruction(curr, recipe result) - 91 trace(9992, "load") << "after rewriting: " << to_string(curr) << end(); + 91 trace(9992, "load") << "after rewriting: " << to_string(curr) << end(); 92 if (!curr.is_empty()) result.steps.push_back(curr); 93 } 94 } @@ -159,7 +159,7 @@ if ('onhashchange' in window) { 97 curr->clear(); 98 skip_whitespace_and_comments(in); 99 if (!has_data(in)) { -100 raise << "incomplete recipe at end of file (0)\n" << end(); +100 raise << "incomplete recipe at end of file (0)\n" << end(); 101 return false; 102 } 103 @@ -167,13 +167,13 @@ if ('onhashchange' in window) { 105 while (has_data(in) && in.peek() != '\n') { 106 skip_whitespace_but_not_newline(in); 107 if (!has_data(in)) { -108 raise << "incomplete recipe at end of file (1)\n" << end(); +108 raise << "incomplete recipe at end of file (1)\n" << end(); 109 return false; 110 } 111 string word = next_word(in); 112 if (word.empty()) { 113 assert(!has_data(in)); -114 raise << "incomplete recipe at end of file (2)\n" << end(); +114 raise << "incomplete recipe at end of file (2)\n" << end(); 115 return false; 116 } 117 words.push_back(word); @@ -186,39 +186,39 @@ if ('onhashchange' in window) { 124 if (SIZE(words) == 1 && is_label_word(words.at(0))) { 125 curr->is_label = true; 126 curr->label = words.at(0); -127 trace(9993, "parse") << "label: " << curr->label << end(); +127 trace(9993, "parse") << "label: " << curr->label << end(); 128 if (!has_data(in)) { -129 raise << "incomplete recipe at end of file (3)\n" << end(); +129 raise << "incomplete recipe at end of file (3)\n" << end(); 130 return false; 131 } 132 return true; 133 } 134 135 vector<string>::iterator p = words.begin(); -136 if (find(words.begin(), words.end(), "<-") != words.end()) { +136 if (find(words.begin(), words.end(), "<-") != words.end()) { 137 for (; *p != "<-"; ++p) 138 curr->products.push_back(reagent(*p)); 139 ++p; // skip <- 140 } 141 -142 if (p == words.end()) { -143 raise << "instruction prematurely ended with '<-'\n" << end(); +142 if (p == words.end()) { +143 raise << "instruction prematurely ended with '<-'\n" << end(); 144 return false; 145 } 146 curr->name = *p; ++p; 147 // curr->operation will be set at transform time 148 -149 for (; p != words.end(); ++p) +149 for (; p != words.end(); ++p) 150 curr->ingredients.push_back(reagent(*p)); 151 -152 trace(9993, "parse") << "instruction: " << curr->name << end(); -153 trace(9993, "parse") << " number of ingredients: " << SIZE(curr->ingredients) << end(); -154 for (vector<reagent>::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) -155 trace(9993, "parse") << " ingredient: " << to_string(*p) << end(); -156 for (vector<reagent>::iterator p = curr->products.begin(); p != curr->products.end(); ++p) -157 trace(9993, "parse") << " product: " << to_string(*p) << end(); +152 trace(9993, "parse") << "instruction: " << curr->name << end(); +153 trace(9993, "parse") << " number of ingredients: " << SIZE(curr->ingredients) << end(); +154 for (vector<reagent>::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) +155 trace(9993, "parse") << " ingredient: " << to_string(*p) << end(); +156 for (vector<reagent>::iterator p = curr->products.begin(); p != curr->products.end(); ++p) +157 trace(9993, "parse") << " product: " << to_string(*p) << end(); 158 if (!has_data(in)) { -159 raise << "9: unbalanced '[' for recipe\n" << end(); +159 raise << "9: unbalanced '[' for recipe\n" << end(); 160 return false; 161 } 162 // End next_instruction(curr) @@ -234,7 +234,7 @@ if ('onhashchange' in window) { 172 skip_whitespace_and_comments_but_not_newline(in); 173 string result = out.str(); 174 if (result != "[" && ends_with(result, '[')) -175 raise << "insert a space before '[' in '" << result << "'\n" << end(); +175 raise << "insert a space before '[' in '" << result << "'\n" << end(); 176 return result; 177 } 178 diff --git a/html/012transform.cc.html b/html/012transform.cc.html index d8e1dd2c..6323c53f 100644 --- a/html/012transform.cc.html +++ b/html/012transform.cc.html @@ -101,9 +101,9 @@ if ('onhashchange' in window) { 44 } 45 46 void transform_all() { - 47 trace(9990, "transform") << "=== transform_all()" << end(); + 47 trace(9990, "transform") << "=== transform_all()" << end(); 48 for (int t = 0; t < SIZE(Transform); ++t) { - 49 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + 49 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { 50 recipe& r = p->second; 51 if (r.transformed_until != t-1) continue; 52 // End Transform Checks @@ -128,8 +128,8 @@ if ('onhashchange' in window) { 71 72 :(code) 73 void parse_int_reagents() { - 74 trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end(); - 75 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { + 74 trace(9991, "transform") << "--- parsing any uninitialized reagents as integers" << end(); + 75 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { 76 recipe& r = p->second; 77 if (r.steps.empty()) continue; 78 for (int index = 0; index < SIZE(r.steps); ++index) { diff --git a/html/013update_operation.cc.html b/html/013update_operation.cc.html index 454a500b..06afb9ae 100644 --- a/html/013update_operation.cc.html +++ b/html/013update_operation.cc.html @@ -68,14 +68,14 @@ if ('onhashchange' in window) { 6 7 :(code) 8 void update_instruction_operations(const recipe_ordinal r) { - 9 trace(9991, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end(); + 9 trace(9991, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end(); 10 recipe& caller = get(Recipe, r); 11 //? cerr << "--- compute instruction operations for recipe " << caller.name << '\n'; 12 for (int index = 0; index < SIZE(caller.steps); ++index) { 13 instruction& inst = caller.steps.at(index); 14 if (inst.is_label) continue; 15 if (!contains_key(Recipe_ordinal, inst.name)) { -16 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe\n" << end(); +16 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe\n" << end(); 17 continue; 18 } 19 inst.operation = get(Recipe_ordinal, inst.name); diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 8a182fd0..30b36230 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -134,7 +134,7 @@ if ('onhashchange' in window) { 73 if (brace_depth == 0) break; 74 } 75 if (!has_data(in) && brace_depth > 0) { - 76 raise << "unbalanced '['\n" << end(); + 76 raise << "unbalanced '['\n" << end(); 77 out.clear(); 78 } 79 } @@ -161,7 +161,7 @@ if ('onhashchange' in window) { 100 out << c; 101 if (c == ']') return; 102 } -103 raise << "unbalanced '['\n" << end(); +103 raise << "unbalanced '['\n" << end(); 104 out.clear(); 105 } 106 diff --git a/html/015literal_noninteger.cc.html b/html/015literal_noninteger.cc.html index ecd41cea..773772ee 100644 --- a/html/015literal_noninteger.cc.html +++ b/html/015literal_noninteger.cc.html @@ -81,11 +81,11 @@ if ('onhashchange' in window) { 20 return s.find_first_not_of("0123456789-.") == string::npos // no other characters 21 && s.find_first_of("0123456789") != string::npos // at least one digit 22 && s.find('-', 1) == string::npos // '-' only at first position -23 && std::count(s.begin(), s.end(), '.') == 1; // exactly one decimal point +23 && std::count(s.begin(), s.end(), '.') == 1; // exactly one decimal point 24 } 25 26 double to_double(string n) { -27 char* end = NULL; +27 char* end = NULL; 28 // safe because string.c_str() is guaranteed to be null-terminated 29 double result = strtod(n.c_str(), &end); 30 assert(*end == '\0'); diff --git a/html/016dilated_reagent.cc.html b/html/016dilated_reagent.cc.html index b5f43dc9..2a7764cd 100644 --- a/html/016dilated_reagent.cc.html +++ b/html/016dilated_reagent.cc.html @@ -125,7 +125,7 @@ if ('onhashchange' in window) { 62 if (c == '(') open_brackets.push_back(c); 63 if (c == ')') { 64 if (open_brackets.empty() || open_brackets.back() != '(') { - 65 raise << "unbalanced ')'\n" << end(); + 65 raise << "unbalanced ')'\n" << end(); 66 continue; 67 } 68 assert(open_brackets.back() == '('); @@ -134,7 +134,7 @@ if ('onhashchange' in window) { 71 if (c == '[') open_brackets.push_back(c); 72 if (c == ']') { 73 if (open_brackets.empty() || open_brackets.back() != '[') { - 74 raise << "unbalanced ']'\n" << end(); + 74 raise << "unbalanced ']'\n" << end(); 75 continue; 76 } 77 open_brackets.pop_back(); @@ -142,7 +142,7 @@ if ('onhashchange' in window) { 79 if (c == '{') open_brackets.push_back(c); 80 if (c == '}') { 81 if (open_brackets.empty() || open_brackets.back() != '{') { - 82 raise << "unbalanced '}'\n" << end(); + 82 raise << "unbalanced '}'\n" << end(); 83 continue; 84 } 85 open_brackets.pop_back(); @@ -162,18 +162,18 @@ if ('onhashchange' in window) { 99 in.get(); // skip '{' 100 name = slurp_key(in); 101 if (name.empty()) { -102 raise << "invalid reagent '" << s << "' without a name\n" << end(); +102 raise << "invalid reagent '" << s << "' without a name\n" << end(); 103 return; 104 } 105 if (name == "}") { -106 raise << "invalid empty reagent '" << s << "'\n" << end(); +106 raise << "invalid empty reagent '" << s << "'\n" << end(); 107 return; 108 } 109 { 110 string s = next_word(in); 111 if (s.empty()) { 112 assert(!has_data(in)); -113 raise << "incomplete dilated reagent at end of file (0)\n" << end(); +113 raise << "incomplete dilated reagent at end of file (0)\n" << end(); 114 return; 115 } 116 string_tree* type_names = new string_tree(s); @@ -188,7 +188,7 @@ if ('onhashchange' in window) { 125 string s = next_word(in); 126 if (s.empty()) { 127 assert(!has_data(in)); -128 raise << "incomplete dilated reagent at end of file (1)\n" << end(); +128 raise << "incomplete dilated reagent at end of file (1)\n" << end(); 129 return; 130 } 131 string_tree* value = new string_tree(s); @@ -203,7 +203,7 @@ if ('onhashchange' in window) { 140 string result = next_word(in); 141 if (result.empty()) { 142 assert(!has_data(in)); -143 raise << "incomplete dilated reagent at end of file (2)\n" << end(); +143 raise << "incomplete dilated reagent at end of file (2)\n" << end(); 144 return result; 145 } 146 while (!result.empty() && *result.rbegin() == ':') diff --git a/html/017parse_tree.cc.html b/html/017parse_tree.cc.html index 1c9ebf22..7ee73d4f 100644 --- a/html/017parse_tree.cc.html +++ b/html/017parse_tree.cc.html @@ -110,7 +110,7 @@ if ('onhashchange' in window) { 48 string s = next_word(in); 49 if (s.empty()) { 50 assert(!has_data(in)); - 51 raise << "incomplete string tree at end of file (0)\n" << end(); + 51 raise << "incomplete string tree at end of file (0)\n" << end(); 52 return NULL; 53 } 54 string_tree* result = new string_tree(s); @@ -131,7 +131,7 @@ if ('onhashchange' in window) { 69 string s = next_word(in); 70 if (s.empty()) { 71 assert(!has_data(in)); - 72 raise << "incomplete string tree at end of file (1)\n" << end(); + 72 raise << "incomplete string tree at end of file (1)\n" << end(); 73 return NULL; 74 } 75 (*curr)->left = new string_tree(s); diff --git a/html/018type_abbreviations.cc.html b/html/018type_abbreviations.cc.html index 2195c88e..c5b4978b 100644 --- a/html/018type_abbreviations.cc.html +++ b/html/018type_abbreviations.cc.html @@ -86,34 +86,34 @@ if ('onhashchange' in window) { 23 string new_type_name = next_word(in); 24 assert(has_data(in) || !new_type_name.empty()); 25 if (!has_data(in) || new_type_name.empty()) { - 26 raise << "incomplete 'type' statement; must be of the form 'type <new type name> = <type expression>'\n" << end(); + 26 raise << "incomplete 'type' statement; must be of the form 'type <new type name> = <type expression>'\n" << end(); 27 return; 28 } 29 string arrow = next_word(in); 30 assert(has_data(in) || !arrow.empty()); 31 if (arrow.empty()) { - 32 raise << "incomplete 'type' statement 'type " << new_type_name << "'\n" << end(); + 32 raise << "incomplete 'type' statement 'type " << new_type_name << "'\n" << end(); 33 return; 34 } 35 if (arrow != "=") { - 36 raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); + 36 raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); 37 return; 38 } 39 if (!has_data(in)) { - 40 raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); + 40 raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); 41 return; 42 } 43 string old = next_word(in); 44 if (old.empty()) { - 45 raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); - 46 raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); + 45 raise << "incomplete 'type' statement 'type " << new_type_name << " ='\n" << end(); + 46 raise << "'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type " << new_type_name << ' ' << arrow << "'\n" << end(); 47 return; 48 } 49 if (contains_key(Type_abbreviations, new_type_name)) { - 50 raise << "'type' conflict: '" << new_type_name << "' defined as both '" << names_to_string_without_quotes(get(Type_abbreviations, new_type_name)) << "' and '" << old << "'\n" << end(); + 50 raise << "'type' conflict: '" << new_type_name << "' defined as both '" << names_to_string_without_quotes(get(Type_abbreviations, new_type_name)) << "' and '" << old << "'\n" << end(); 51 return; 52 } - 53 trace(9990, "type") << "alias " << new_type_name << " = " << old << end(); + 53 trace(9990, "type") << "alias " << new_type_name << " = " << old << end(); 54 type_tree* old_type = new_type_tree(old); 55 put(Type_abbreviations, new_type_name, old_type); 56 } @@ -170,7 +170,7 @@ if ('onhashchange' in window) { 107 atexit(clear_type_abbreviations); 108 :(code) 109 void restore_type_abbreviations() { -110 for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { +110 for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) { 111 if (!contains_key(Type_abbreviations_snapshot, p->first)) 112 delete p->second; 113 } @@ -178,7 +178,7 @@ if ('onhashchange' in window) { 115 Type_abbreviations = Type_abbreviations_snapshot; 116 } 117 void clear_type_abbreviations() { -118 for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) +118 for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) 119 delete p->second; 120 Type_abbreviations.clear(); 121 } @@ -231,17 +231,17 @@ if ('onhashchange' in window) { 168 } 169 170 void expand_type_abbreviations(const recipe& caller) { -171 trace(9991, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end(); +171 trace(9991, "transform") << "--- expand type abbreviations in recipe '" << caller.name << "'" << end(); 172 for (int i = 0; i < SIZE(caller.steps); ++i) { 173 const instruction& inst = caller.steps.at(i); -174 trace(9991, "transform") << "instruction '" << inst.original_string << end(); +174 trace(9991, "transform") << "instruction '" << inst.original_string << end(); 175 for (long int i = 0; i < SIZE(inst.ingredients); ++i) { 176 expand_type_abbreviations(inst.ingredients.at(i).type); -177 trace(9992, "transform") << "ingredient type after expanding abbreviations: " << names_to_string(inst.ingredients.at(i).type) << end(); +177 trace(9992, "transform") << "ingredient type after expanding abbreviations: " << names_to_string(inst.ingredients.at(i).type) << end(); 178 } 179 for (long int i = 0; i < SIZE(inst.products); ++i) { 180 expand_type_abbreviations(inst.products.at(i).type); -181 trace(9992, "transform") << "product type after expanding abbreviations: " << names_to_string(inst.products.at(i).type) << end(); +181 trace(9992, "transform") << "product type after expanding abbreviations: " << names_to_string(inst.products.at(i).type) << end(); 182 } 183 } 184 // End Expand Type Abbreviations(caller) diff --git a/html/020run.cc.html b/html/020run.cc.html index 93b6ee3c..92a67ea1 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -131,9 +131,9 @@ if ('onhashchange' in window) { 66 while (should_continue_running(Current_routine)) { // beware: may modify Current_routine 67 // Running One Instruction 68 if (current_instruction().is_label) { ++current_step_index(); continue; } - 69 trace(Initial_callstack_depth + Trace_stream->callstack_depth, "run") << to_string(current_instruction()) << end(); + 69 trace(Initial_callstack_depth + Trace_stream->callstack_depth, "run") << to_string(current_instruction()) << end(); 70 if (get_or_insert(Memory, 0) != 0) { - 71 raise << "something wrote to location 0; this should never happen\n" << end(); + 71 raise << "something wrote to location 0; this should never happen\n" << end(); 72 put(Memory, 0, 0); 73 } 74 // read all ingredients from memory, each potentially spanning multiple locations @@ -147,7 +147,7 @@ if ('onhashchange' in window) { 82 switch (current_instruction().operation) { 83 // Primitive Recipe Implementations 84 case COPY: { - 85 copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); + 85 copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); 86 break; 87 } 88 // End Primitive Recipe Implementations @@ -157,7 +157,7 @@ if ('onhashchange' in window) { 92 } 93 // Write Products of Instruction 94 if (SIZE(products) < SIZE(current_instruction().products)) { - 95 raise << SIZE(products) << " vs " << SIZE(current_instruction().products) << ": failed to write to all products! " << to_original_string(current_instruction()) << '\n' << end(); + 95 raise << SIZE(products) << " vs " << SIZE(current_instruction().products) << ": failed to write to all products! " << to_original_string(current_instruction()) << '\n' << end(); 96 } 97 else { 98 for (int i = 0; i < SIZE(current_instruction().products); ++i) @@ -249,7 +249,7 @@ if ('onhashchange' in window) { 184 transform_all(); 185 //? DUMP(""); 186 //? exit(0); -187 if (trace_contains_errors()) return 1; +187 if (trace_contains_errors()) return 1; 188 save_snapshots(); 189 190 //: Step 3: if we aren't running tests, locate a recipe called 'main' and @@ -262,7 +262,7 @@ if ('onhashchange' in window) { 197 Trace_stream = new trace_stream; 198 Save_trace = true; 199 } -200 trace(2, "run") << "=== Starting to run" << end(); +200 trace(2, "run") << "=== Starting to run" << end(); 201 assert(Num_calls_to_transform_all == 1); 202 run_main(argc, argv); 203 teardown(); @@ -284,15 +284,15 @@ if ('onhashchange' in window) { 219 220 :(code) 221 void dump_profile() { -222 for (map<string, int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { +222 for (map<string, int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) { 223 cerr << p->first << ": " << p->second << '\n'; 224 } 225 cerr << "== locations read\n"; -226 for (map<string, int>::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { +226 for (map<string, int>::iterator p = Locations_read.begin(); p != Locations_read.end(); ++p) { 227 cerr << p->first << ": " << p->second << '\n'; 228 } 229 cerr << "== locations read by instruction\n"; -230 for (map<string, int>::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { +230 for (map<string, int>::iterator p = Locations_read_by_instruction.begin(); p != Locations_read_by_instruction.end(); ++p) { 231 cerr << p->first << ": " << p->second << '\n'; 232 } 233 } @@ -303,7 +303,7 @@ if ('onhashchange' in window) { 238 void cleanup_main() { 239 if (Save_trace && Trace_stream) { 240 ofstream fout("interactive"); -241 fout << Trace_stream->readable_contents(""); +241 fout << Trace_stream->readable_contents(""); 242 fout.close(); 243 } 244 if (Trace_stream) delete Trace_stream, Trace_stream = NULL; @@ -319,10 +319,10 @@ if ('onhashchange' in window) { 254 } 255 ifstream fin(filename.c_str()); 256 if (!fin) { -257 cerr << "no such file '" << filename << "'\n" << end(); // don't raise, just warn. just in case it's just a name for a scenario to run. +257 cerr << "no such file '" << filename << "'\n" << end(); // don't raise, just warn. just in case it's just a name for a scenario to run. 258 return; 259 } -260 trace(9990, "load") << "=== " << filename << end(); +260 trace(9990, "load") << "=== " << filename << end(); 261 load(fin); 262 fin.close(); 263 } @@ -363,7 +363,7 @@ if ('onhashchange' in window) { 298 int size = size_of(x); 299 for (int offset = 0; offset < size; ++offset) { 300 double val = get_or_insert(Memory, x.value+offset); -301 trace(9999, "mem") << "location " << x.value+offset << " is " << no_scientific(val) << end(); +301 trace(9999, "mem") << "location " << x.value+offset << " is " << no_scientific(val) << end(); 302 result.push_back(val); 303 } 304 return result; @@ -373,24 +373,24 @@ if ('onhashchange' in window) { 308 assert(Current_routine); // run-time only 309 // Begin Preprocess write_memory(x, data) 310 if (!x.type) { -311 raise << "can't write to '" << to_string(x) << "'; no type\n" << end(); +311 raise << "can't write to '" << to_string(x) << "'; no type\n" << end(); 312 return; 313 } 314 if (is_dummy(x)) return; 315 if (is_literal(x)) return; 316 // End Preprocess write_memory(x, data) 317 if (x.value == 0) { -318 raise << "can't write to location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +318 raise << "can't write to location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 319 return; 320 } 321 if (size_mismatch(x, data)) { -322 raise << maybe(current_recipe_name()) << "size mismatch in storing to '" << x.original_string << "' (" << size_of(x) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end(); +322 raise << maybe(current_recipe_name()) << "size mismatch in storing to '" << x.original_string << "' (" << size_of(x) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end(); 323 return; 324 } 325 // End write_memory(x) Special-cases 326 for (int offset = 0; offset < SIZE(data); ++offset) { 327 assert(x.value+offset > 0); -328 trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end(); +328 trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end(); 329 put(Memory, x.value+offset, data.at(offset)); 330 } 331 } @@ -410,7 +410,7 @@ if ('onhashchange' in window) { 345 } 346 else { 347 if (!type->left->atom) { -348 raise << "invalid type " << to_string(type) << '\n' << end(); +348 raise << "invalid type " << to_string(type) << '\n' << end(); 349 return 0; 350 } 351 if (type->left->value == get(Type_ordinal, "address")) return 1; @@ -448,7 +448,7 @@ if ('onhashchange' in window) { 383 vector<recipe_ordinal> tmp = load(form); 384 transform_all(); 385 if (tmp.empty()) return; -386 if (trace_contains_errors()) return; +386 if (trace_contains_errors()) return; 387 // if a test defines main, it probably wants to start there regardless of 388 // definition order 389 if (contains_key(Recipe, get(Recipe_ordinal, "main"))) diff --git a/html/021check_instruction.cc.html b/html/021check_instruction.cc.html index e399cd2c..d9a0c06d 100644 --- a/html/021check_instruction.cc.html +++ b/html/021check_instruction.cc.html @@ -74,7 +74,7 @@ if ('onhashchange' in window) { 13 14 :(code) 15 void check_instruction(const recipe_ordinal r) { - 16 trace(9991, "transform") << "--- perform checks for recipe " << get(Recipe, r).name << end(); + 16 trace(9991, "transform") << "--- perform checks for recipe " << get(Recipe, r).name << end(); 17 map<string, vector<type_ordinal> > metadata; 18 for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { 19 instruction& inst = get(Recipe, r).steps.at(i); @@ -83,12 +83,12 @@ if ('onhashchange' in window) { 22 // Primitive Recipe Checks 23 case COPY: { 24 if (SIZE(inst.products) != SIZE(inst.ingredients)) { - 25 raise << maybe(get(Recipe, r).name) << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); + 25 raise << maybe(get(Recipe, r).name) << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); 26 break; 27 } 28 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 29 if (!types_coercible(inst.products.at(i), inst.ingredients.at(i))) { - 30 raise << maybe(get(Recipe, r).name) << "can't copy '" << inst.ingredients.at(i).original_string << "' to '" << inst.products.at(i).original_string << "'; types don't match\n" << end(); + 30 raise << maybe(get(Recipe, r).name) << "can't copy '" << inst.ingredients.at(i).original_string << "' to '" << inst.products.at(i).original_string << "'; types don't match\n" << end(); 31 goto finish_checking_instruction; 32 } 33 } @@ -236,7 +236,7 @@ if ('onhashchange' in window) { 175 if (is_literal(type)) return false; 176 if (type->atom) return false; 177 if (!type->left->atom) { -178 raise << "invalid type " << to_string(type) << '\n' << end(); +178 raise << "invalid type " << to_string(type) << '\n' << end(); 179 return false; 180 } 181 return type->left->value == get(Type_ordinal, "array"); @@ -251,7 +251,7 @@ if ('onhashchange' in window) { 190 if (is_literal(type)) return false; 191 if (type->atom) return false; 192 if (!type->left->atom) { -193 raise << "invalid type " << to_string(type) << '\n' << end(); +193 raise << "invalid type " << to_string(type) << '\n' << end(); 194 return false; 195 } 196 return type->left->value == get(Type_ordinal, "address"); diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index 0203dde2..4c483ad9 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -71,16 +71,16 @@ if ('onhashchange' in window) { 9 // primary goal of these checks is to forbid address arithmetic 10 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 11 if (!is_mu_number(inst.ingredients.at(i))) { - 12 raise << maybe(get(Recipe, r).name) << "'add' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); + 12 raise << maybe(get(Recipe, r).name) << "'add' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 13 goto finish_checking_instruction; 14 } 15 } 16 if (SIZE(inst.products) > 1) { - 17 raise << maybe(get(Recipe, r).name) << "'add' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 17 raise << maybe(get(Recipe, r).name) << "'add' yields exactly one product in '" << inst.original_string << "'\n" << end(); 18 break; 19 } 20 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { - 21 raise << maybe(get(Recipe, r).name) << "'add' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 21 raise << maybe(get(Recipe, r).name) << "'add' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 22 break; 23 } 24 break; @@ -137,22 +137,22 @@ if ('onhashchange' in window) { 75 :(before "End Primitive Recipe Checks") 76 case SUBTRACT: { 77 if (inst.ingredients.empty()) { - 78 raise << maybe(get(Recipe, r).name) << "'subtract' has no ingredients\n" << end(); + 78 raise << maybe(get(Recipe, r).name) << "'subtract' has no ingredients\n" << end(); 79 break; 80 } 81 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 82 if (is_raw(inst.ingredients.at(i))) continue; // permit address offset computations in tests 83 if (!is_mu_number(inst.ingredients.at(i))) { - 84 raise << maybe(get(Recipe, r).name) << "'subtract' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); + 84 raise << maybe(get(Recipe, r).name) << "'subtract' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 85 goto finish_checking_instruction; 86 } 87 } 88 if (SIZE(inst.products) > 1) { - 89 raise << maybe(get(Recipe, r).name) << "'subtract' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 89 raise << maybe(get(Recipe, r).name) << "'subtract' yields exactly one product in '" << inst.original_string << "'\n" << end(); 90 break; 91 } 92 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { - 93 raise << maybe(get(Recipe, r).name) << "'subtract' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 93 raise << maybe(get(Recipe, r).name) << "'subtract' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 94 break; 95 } 96 break; @@ -199,16 +199,16 @@ if ('onhashchange' in window) { 137 case MULTIPLY: { 138 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 139 if (!is_mu_number(inst.ingredients.at(i))) { -140 raise << maybe(get(Recipe, r).name) << "'multiply' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +140 raise << maybe(get(Recipe, r).name) << "'multiply' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 141 goto finish_checking_instruction; 142 } 143 } 144 if (SIZE(inst.products) > 1) { -145 raise << maybe(get(Recipe, r).name) << "'multiply' yields exactly one product in '" << inst.original_string << "'\n" << end(); +145 raise << maybe(get(Recipe, r).name) << "'multiply' yields exactly one product in '" << inst.original_string << "'\n" << end(); 146 break; 147 } 148 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -149 raise << maybe(get(Recipe, r).name) << "'multiply' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +149 raise << maybe(get(Recipe, r).name) << "'multiply' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 150 break; 151 } 152 break; @@ -251,21 +251,21 @@ if ('onhashchange' in window) { 189 :(before "End Primitive Recipe Checks") 190 case DIVIDE: { 191 if (inst.ingredients.empty()) { -192 raise << maybe(get(Recipe, r).name) << "'divide' has no ingredients\n" << end(); +192 raise << maybe(get(Recipe, r).name) << "'divide' has no ingredients\n" << end(); 193 break; 194 } 195 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 196 if (!is_mu_number(inst.ingredients.at(i))) { -197 raise << maybe(get(Recipe, r).name) << "'divide' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +197 raise << maybe(get(Recipe, r).name) << "'divide' requires number ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 198 goto finish_checking_instruction; 199 } 200 } 201 if (SIZE(inst.products) > 1) { -202 raise << maybe(get(Recipe, r).name) << "'divide' yields exactly one product in '" << inst.original_string << "'\n" << end(); +202 raise << maybe(get(Recipe, r).name) << "'divide' yields exactly one product in '" << inst.original_string << "'\n" << end(); 203 break; 204 } 205 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -206 raise << maybe(get(Recipe, r).name) << "'divide' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +206 raise << maybe(get(Recipe, r).name) << "'divide' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 207 break; 208 } 209 break; @@ -309,20 +309,20 @@ if ('onhashchange' in window) { 247 :(before "End Primitive Recipe Checks") 248 case DIVIDE_WITH_REMAINDER: { 249 if (SIZE(inst.ingredients) != 2) { -250 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +250 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 251 break; 252 } 253 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -254 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +254 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 255 break; 256 } 257 if (SIZE(inst.products) > 2) { -258 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' yields two products in '" << inst.original_string << "'\n" << end(); +258 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' yields two products in '" << inst.original_string << "'\n" << end(); 259 break; 260 } 261 for (int i = 0; i < SIZE(inst.products); ++i) { 262 if (!is_dummy(inst.products.at(i)) && !is_mu_number(inst.products.at(i))) { -263 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' should yield a number, but got '" << inst.products.at(i).original_string << "'\n" << end(); +263 raise << maybe(get(Recipe, r).name) << "'divide-with-remainder' should yield a number, but got '" << inst.products.at(i).original_string << "'\n" << end(); 264 goto finish_checking_instruction; 265 } 266 } @@ -335,7 +335,7 @@ if ('onhashchange' in window) { 273 long long int a = static_cast<long long int>(ingredients.at(0).at(0)); 274 long long int b = static_cast<long long int>(ingredients.at(1).at(0)); 275 if (b == 0) { -276 raise << maybe(current_recipe_name()) << "divide by zero in '" << to_original_string(current_instruction()) << "'\n" << end(); +276 raise << maybe(current_recipe_name()) << "divide by zero in '" << to_original_string(current_instruction()) << "'\n" << end(); 277 products.resize(2); 278 products.at(0).push_back(0); 279 products.at(1).push_back(0); @@ -393,19 +393,19 @@ if ('onhashchange' in window) { 331 :(before "End Primitive Recipe Checks") 332 case SHIFT_LEFT: { 333 if (SIZE(inst.ingredients) != 2) { -334 raise << maybe(get(Recipe, r).name) << "'shift-left' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +334 raise << maybe(get(Recipe, r).name) << "'shift-left' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 335 break; 336 } 337 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -338 raise << maybe(get(Recipe, r).name) << "'shift-left' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +338 raise << maybe(get(Recipe, r).name) << "'shift-left' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 339 break; 340 } 341 if (SIZE(inst.products) > 1) { -342 raise << maybe(get(Recipe, r).name) << "'shift-left' yields one product in '" << inst.original_string << "'\n" << end(); +342 raise << maybe(get(Recipe, r).name) << "'shift-left' yields one product in '" << inst.original_string << "'\n" << end(); 343 break; 344 } 345 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -346 raise << maybe(get(Recipe, r).name) << "'shift-left' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +346 raise << maybe(get(Recipe, r).name) << "'shift-left' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 347 goto finish_checking_instruction; 348 } 349 break; @@ -417,7 +417,7 @@ if ('onhashchange' in window) { 355 int b = static_cast<int>(ingredients.at(1).at(0)); 356 products.resize(1); 357 if (b < 0) { -358 raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end(); +358 raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end(); 359 products.at(0).push_back(0); 360 break; 361 } @@ -464,19 +464,19 @@ if ('onhashchange' in window) { 402 :(before "End Primitive Recipe Checks") 403 case SHIFT_RIGHT: { 404 if (SIZE(inst.ingredients) != 2) { -405 raise << maybe(get(Recipe, r).name) << "'shift-right' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +405 raise << maybe(get(Recipe, r).name) << "'shift-right' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 406 break; 407 } 408 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -409 raise << maybe(get(Recipe, r).name) << "'shift-right' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +409 raise << maybe(get(Recipe, r).name) << "'shift-right' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 410 break; 411 } 412 if (SIZE(inst.products) > 1) { -413 raise << maybe(get(Recipe, r).name) << "'shift-right' yields one product in '" << inst.original_string << "'\n" << end(); +413 raise << maybe(get(Recipe, r).name) << "'shift-right' yields one product in '" << inst.original_string << "'\n" << end(); 414 break; 415 } 416 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -417 raise << maybe(get(Recipe, r).name) << "'shift-right' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +417 raise << maybe(get(Recipe, r).name) << "'shift-right' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 418 goto finish_checking_instruction; 419 } 420 break; @@ -488,7 +488,7 @@ if ('onhashchange' in window) { 426 int b = static_cast<int>(ingredients.at(1).at(0)); 427 products.resize(1); 428 if (b < 0) { -429 raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end(); +429 raise << maybe(current_recipe_name()) << "second ingredient can't be negative in '" << to_original_string(current_instruction()) << "'\n" << end(); 430 products.at(0).push_back(0); 431 break; 432 } @@ -535,19 +535,19 @@ if ('onhashchange' in window) { 473 :(before "End Primitive Recipe Checks") 474 case AND_BITS: { 475 if (SIZE(inst.ingredients) != 2) { -476 raise << maybe(get(Recipe, r).name) << "'and-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +476 raise << maybe(get(Recipe, r).name) << "'and-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 477 break; 478 } 479 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -480 raise << maybe(get(Recipe, r).name) << "'and-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +480 raise << maybe(get(Recipe, r).name) << "'and-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 481 break; 482 } 483 if (SIZE(inst.products) > 1) { -484 raise << maybe(get(Recipe, r).name) << "'and-bits' yields one product in '" << inst.original_string << "'\n" << end(); +484 raise << maybe(get(Recipe, r).name) << "'and-bits' yields one product in '" << inst.original_string << "'\n" << end(); 485 break; 486 } 487 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -488 raise << maybe(get(Recipe, r).name) << "'and-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +488 raise << maybe(get(Recipe, r).name) << "'and-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 489 goto finish_checking_instruction; 490 } 491 break; @@ -593,19 +593,19 @@ if ('onhashchange' in window) { 531 :(before "End Primitive Recipe Checks") 532 case OR_BITS: { 533 if (SIZE(inst.ingredients) != 2) { -534 raise << maybe(get(Recipe, r).name) << "'or-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +534 raise << maybe(get(Recipe, r).name) << "'or-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 535 break; 536 } 537 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -538 raise << maybe(get(Recipe, r).name) << "'or-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +538 raise << maybe(get(Recipe, r).name) << "'or-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 539 break; 540 } 541 if (SIZE(inst.products) > 1) { -542 raise << maybe(get(Recipe, r).name) << "'or-bits' yields one product in '" << inst.original_string << "'\n" << end(); +542 raise << maybe(get(Recipe, r).name) << "'or-bits' yields one product in '" << inst.original_string << "'\n" << end(); 543 break; 544 } 545 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -546 raise << maybe(get(Recipe, r).name) << "'or-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +546 raise << maybe(get(Recipe, r).name) << "'or-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 547 goto finish_checking_instruction; 548 } 549 break; @@ -645,19 +645,19 @@ if ('onhashchange' in window) { 583 :(before "End Primitive Recipe Checks") 584 case XOR_BITS: { 585 if (SIZE(inst.ingredients) != 2) { -586 raise << maybe(get(Recipe, r).name) << "'xor-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +586 raise << maybe(get(Recipe, r).name) << "'xor-bits' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 587 break; 588 } 589 if (!is_mu_number(inst.ingredients.at(0)) || !is_mu_number(inst.ingredients.at(1))) { -590 raise << maybe(get(Recipe, r).name) << "'xor-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); +590 raise << maybe(get(Recipe, r).name) << "'xor-bits' requires number ingredients, but got '" << inst.original_string << "'\n" << end(); 591 break; 592 } 593 if (SIZE(inst.products) > 1) { -594 raise << maybe(get(Recipe, r).name) << "'xor-bits' yields one product in '" << inst.original_string << "'\n" << end(); +594 raise << maybe(get(Recipe, r).name) << "'xor-bits' yields one product in '" << inst.original_string << "'\n" << end(); 595 break; 596 } 597 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -598 raise << maybe(get(Recipe, r).name) << "'xor-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +598 raise << maybe(get(Recipe, r).name) << "'xor-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 599 goto finish_checking_instruction; 600 } 601 break; @@ -697,19 +697,19 @@ if ('onhashchange' in window) { 635 :(before "End Primitive Recipe Checks") 636 case FLIP_BITS: { 637 if (SIZE(inst.ingredients) != 1) { -638 raise << maybe(get(Recipe, r).name) << "'flip-bits' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +638 raise << maybe(get(Recipe, r).name) << "'flip-bits' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 639 break; 640 } 641 if (!is_mu_number(inst.ingredients.at(0))) { -642 raise << maybe(get(Recipe, r).name) << "'flip-bits' requires a number ingredient, but got '" << inst.original_string << "'\n" << end(); +642 raise << maybe(get(Recipe, r).name) << "'flip-bits' requires a number ingredient, but got '" << inst.original_string << "'\n" << end(); 643 break; 644 } 645 if (SIZE(inst.products) > 1) { -646 raise << maybe(get(Recipe, r).name) << "'flip-bits' yields one product in '" << inst.original_string << "'\n" << end(); +646 raise << maybe(get(Recipe, r).name) << "'flip-bits' yields one product in '" << inst.original_string << "'\n" << end(); 647 break; 648 } 649 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -650 raise << maybe(get(Recipe, r).name) << "'flip-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +650 raise << maybe(get(Recipe, r).name) << "'flip-bits' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 651 goto finish_checking_instruction; 652 } 653 break; @@ -754,11 +754,11 @@ if ('onhashchange' in window) { 692 :(before "End Primitive Recipe Checks") 693 case ROUND: { 694 if (SIZE(inst.ingredients) != 1) { -695 raise << maybe(get(Recipe, r).name) << "'round' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +695 raise << maybe(get(Recipe, r).name) << "'round' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 696 break; 697 } 698 if (!is_mu_number(inst.ingredients.at(0))) { -699 raise << maybe(get(Recipe, r).name) << "first ingredient of 'round' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +699 raise << maybe(get(Recipe, r).name) << "first ingredient of 'round' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 700 break; 701 } 702 break; @@ -795,11 +795,11 @@ if ('onhashchange' in window) { 733 :(before "End Primitive Recipe Checks") 734 case TRUNCATE: { 735 if (SIZE(inst.ingredients) != 1) { -736 raise << maybe(get(Recipe, r).name) << "'truncate' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +736 raise << maybe(get(Recipe, r).name) << "'truncate' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 737 break; 738 } 739 if (!is_mu_number(inst.ingredients.at(0))) { -740 raise << maybe(get(Recipe, r).name) << "first ingredient of 'truncate' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +740 raise << maybe(get(Recipe, r).name) << "first ingredient of 'truncate' should be a number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 741 break; 742 } 743 break; @@ -830,19 +830,19 @@ if ('onhashchange' in window) { 768 :(before "End Primitive Recipe Checks") 769 case CHARACTER_TO_CODE: { 770 if (SIZE(inst.ingredients) != 1) { -771 raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +771 raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 772 break; 773 } 774 if (!is_mu_character(inst.ingredients.at(0))) { -775 raise << maybe(get(Recipe, r).name) << "first ingredient of 'character-to-code' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +775 raise << maybe(get(Recipe, r).name) << "first ingredient of 'character-to-code' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 776 break; 777 } 778 if (SIZE(inst.products) != 1) { -779 raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); +779 raise << maybe(get(Recipe, r).name) << "'character-to-code' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 780 break; 781 } 782 if (!is_mu_number(inst.products.at(0))) { -783 raise << maybe(get(Recipe, r).name) << "first product of 'character-to-code' should be a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +783 raise << maybe(get(Recipe, r).name) << "first product of 'character-to-code' should be a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 784 break; 785 } 786 break; diff --git a/html/023boolean.cc.html b/html/023boolean.cc.html index 06f948c3..3ee18571 100644 --- a/html/023boolean.cc.html +++ b/html/023boolean.cc.html @@ -69,16 +69,16 @@ if ('onhashchange' in window) { 8 case AND: { 9 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 10 if (!is_mu_scalar(inst.ingredients.at(i))) { - 11 raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); + 11 raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 12 goto finish_checking_instruction; 13 } 14 } 15 if (SIZE(inst.products) > 1) { - 16 raise << maybe(get(Recipe, r).name) << "'and' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 16 raise << maybe(get(Recipe, r).name) << "'and' yields exactly one product in '" << inst.original_string << "'\n" << end(); 17 break; 18 } 19 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { - 20 raise << maybe(get(Recipe, r).name) << "'and' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 20 raise << maybe(get(Recipe, r).name) << "'and' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 21 break; 22 } 23 break; @@ -127,16 +127,16 @@ if ('onhashchange' in window) { 66 case OR: { 67 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 68 if (!is_mu_scalar(inst.ingredients.at(i))) { - 69 raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); + 69 raise << maybe(get(Recipe, r).name) << "'and' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 70 goto finish_checking_instruction; 71 } 72 } 73 if (SIZE(inst.products) > 1) { - 74 raise << maybe(get(Recipe, r).name) << "'or' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 74 raise << maybe(get(Recipe, r).name) << "'or' yields exactly one product in '" << inst.original_string << "'\n" << end(); 75 break; 76 } 77 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { - 78 raise << maybe(get(Recipe, r).name) << "'or' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 78 raise << maybe(get(Recipe, r).name) << "'or' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 79 break; 80 } 81 break; @@ -184,19 +184,19 @@ if ('onhashchange' in window) { 123 :(before "End Primitive Recipe Checks") 124 case NOT: { 125 if (SIZE(inst.products) != SIZE(inst.ingredients)) { -126 raise << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); +126 raise << "ingredients and products should match in '" << inst.original_string << "'\n" << end(); 127 break; 128 } 129 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 130 if (!is_mu_scalar(inst.ingredients.at(i))) { -131 raise << maybe(get(Recipe, r).name) << "'not' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +131 raise << maybe(get(Recipe, r).name) << "'not' requires boolean ingredients, but got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 132 goto finish_checking_instruction; 133 } 134 } 135 for (int i = 0; i < SIZE(inst.products); ++i) { 136 if (is_dummy(inst.products.at(i))) continue; 137 if (!is_mu_boolean(inst.products.at(i))) { -138 raise << maybe(get(Recipe, r).name) << "'not' should yield a boolean, but got '" << inst.products.at(i).original_string << "'\n" << end(); +138 raise << maybe(get(Recipe, r).name) << "'not' should yield a boolean, but got '" << inst.products.at(i).original_string << "'\n" << end(); 139 goto finish_checking_instruction; 140 } 141 } diff --git a/html/024jump.cc.html b/html/024jump.cc.html index 59c0ec3a..2d1f7229 100644 --- a/html/024jump.cc.html +++ b/html/024jump.cc.html @@ -78,11 +78,11 @@ if ('onhashchange' in window) { 16 :(before "End Primitive Recipe Checks") 17 case JUMP: { 18 if (SIZE(inst.ingredients) != 1) { - 19 raise << maybe(get(Recipe, r).name) << "'jump' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 19 raise << maybe(get(Recipe, r).name) << "'jump' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 20 break; 21 } 22 if (!is_literal(inst.ingredients.at(0))) { - 23 raise << maybe(get(Recipe, r).name) << "first ingredient of 'jump' should be a label or offset, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + 23 raise << maybe(get(Recipe, r).name) << "first ingredient of 'jump' should be a label or offset, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 24 break; 25 } 26 break; @@ -91,7 +91,7 @@ if ('onhashchange' in window) { 29 case JUMP: { 30 assert(current_instruction().ingredients.at(0).initialized); 31 current_step_index() += ingredients.at(0).at(0)+1; - 32 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); + 32 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); 33 continue; // skip rest of this instruction 34 } 35 @@ -117,15 +117,15 @@ if ('onhashchange' in window) { 55 :(before "End Primitive Recipe Checks") 56 case JUMP_IF: { 57 if (SIZE(inst.ingredients) != 2) { - 58 raise << maybe(get(Recipe, r).name) << "'jump-if' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); + 58 raise << maybe(get(Recipe, r).name) << "'jump-if' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 59 break; 60 } 61 if (!is_mu_scalar(inst.ingredients.at(0))) { - 62 raise << maybe(get(Recipe, r).name) << "'jump-if' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + 62 raise << maybe(get(Recipe, r).name) << "'jump-if' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 63 break; 64 } 65 if (!is_literal(inst.ingredients.at(1))) { - 66 raise << maybe(get(Recipe, r).name) << "'jump-if' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + 66 raise << maybe(get(Recipe, r).name) << "'jump-if' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 67 break; 68 } 69 // End JUMP_IF Checks @@ -135,11 +135,11 @@ if ('onhashchange' in window) { 73 case JUMP_IF: { 74 assert(current_instruction().ingredients.at(1).initialized); 75 if (!ingredients.at(0).at(0)) { - 76 trace(9998, "run") << "jump-if fell through" << end(); + 76 trace(9998, "run") << "jump-if fell through" << end(); 77 break; 78 } 79 current_step_index() += ingredients.at(1).at(0)+1; - 80 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); + 80 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); 81 continue; // skip rest of this instruction 82 } 83 @@ -170,15 +170,15 @@ if ('onhashchange' in window) { 108 :(before "End Primitive Recipe Checks") 109 case JUMP_UNLESS: { 110 if (SIZE(inst.ingredients) != 2) { -111 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +111 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 112 break; 113 } 114 if (!is_mu_scalar(inst.ingredients.at(0))) { -115 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +115 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 116 break; 117 } 118 if (!is_literal(inst.ingredients.at(1))) { -119 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +119 raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 120 break; 121 } 122 // End JUMP_UNLESS Checks @@ -188,11 +188,11 @@ if ('onhashchange' in window) { 126 case JUMP_UNLESS: { 127 assert(current_instruction().ingredients.at(1).initialized); 128 if (ingredients.at(0).at(0)) { -129 trace(9998, "run") << "jump-unless fell through" << end(); +129 trace(9998, "run") << "jump-unless fell through" << end(); 130 break; 131 } 132 current_step_index() += ingredients.at(1).at(0)+1; -133 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); +133 trace(9998, "run") << "jumping to instruction " << current_step_index() << end(); 134 continue; // skip rest of this instruction 135 } 136 diff --git a/html/025compare.cc.html b/html/025compare.cc.html index 1605a091..b142cc30 100644 --- a/html/025compare.cc.html +++ b/html/025compare.cc.html @@ -68,22 +68,22 @@ if ('onhashchange' in window) { 7 :(before "End Primitive Recipe Checks") 8 case EQUAL: { 9 if (SIZE(inst.ingredients) <= 1) { - 10 raise << maybe(get(Recipe, r).name) << "'equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); + 10 raise << maybe(get(Recipe, r).name) << "'equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 11 break; 12 } 13 const reagent& exemplar = inst.ingredients.at(0); 14 for (int i = /*skip exemplar*/1; i < SIZE(inst.ingredients); ++i) { 15 if (!types_match(inst.ingredients.at(i), exemplar) && !types_match(exemplar, inst.ingredients.at(i))) { - 16 raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << inst.original_string << "'\n" << end(); + 16 raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << inst.original_string << "'\n" << end(); 17 goto finish_checking_instruction; 18 } 19 } 20 if (SIZE(inst.products) > 1) { - 21 raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 21 raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); 22 break; 23 } 24 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { - 25 raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 25 raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 26 break; 27 } 28 break; @@ -93,7 +93,7 @@ if ('onhashchange' in window) { 32 vector<double>& exemplar = ingredients.at(0); 33 bool result = true; 34 for (int i = /*skip exemplar*/1; i < SIZE(ingredients); ++i) { - 35 if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) { + 35 if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) { 36 result = false; 37 break; 38 } @@ -142,20 +142,20 @@ if ('onhashchange' in window) { 81 :(before "End Primitive Recipe Checks") 82 case NOT_EQUAL: { 83 if (SIZE(inst.ingredients) != 2) { - 84 raise << maybe(get(Recipe, r).name) << "'equal' needs two ingredients to compare in '" << inst.original_string << "'\n" << end(); + 84 raise << maybe(get(Recipe, r).name) << "'equal' needs two ingredients to compare in '" << inst.original_string << "'\n" << end(); 85 break; 86 } 87 const reagent& exemplar = inst.ingredients.at(0); 88 if (!types_match(inst.ingredients.at(1), exemplar) && !types_match(exemplar, inst.ingredients.at(1))) { - 89 raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << inst.original_string << "'\n" << end(); + 89 raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << inst.original_string << "'\n" << end(); 90 goto finish_checking_instruction; 91 } 92 if (SIZE(inst.products) > 1) { - 93 raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); + 93 raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); 94 break; 95 } 96 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { - 97 raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); + 97 raise << maybe(get(Recipe, r).name) << "'equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 98 break; 99 } 100 break; @@ -164,7 +164,7 @@ if ('onhashchange' in window) { 103 case NOT_EQUAL: { 104 vector<double>& exemplar = ingredients.at(0); 105 products.resize(1); -106 bool equal_ingredients = equal(ingredients.at(1).begin(), ingredients.at(1).end(), exemplar.begin()); +106 bool equal_ingredients = equal(ingredients.at(1).begin(), ingredients.at(1).end(), exemplar.begin()); 107 products.at(0).push_back(!equal_ingredients); 108 break; 109 } @@ -196,21 +196,21 @@ if ('onhashchange' in window) { 135 :(before "End Primitive Recipe Checks") 136 case GREATER_THAN: { 137 if (SIZE(inst.ingredients) <= 1) { -138 raise << maybe(get(Recipe, r).name) << "'greater-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +138 raise << maybe(get(Recipe, r).name) << "'greater-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 139 break; 140 } 141 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 142 if (!is_mu_number(inst.ingredients.at(i))) { -143 raise << maybe(get(Recipe, r).name) << "'greater-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +143 raise << maybe(get(Recipe, r).name) << "'greater-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 144 goto finish_checking_instruction; 145 } 146 } 147 if (SIZE(inst.products) > 1) { -148 raise << maybe(get(Recipe, r).name) << "'greater-than' yields exactly one product in '" << inst.original_string << "'\n" << end(); +148 raise << maybe(get(Recipe, r).name) << "'greater-than' yields exactly one product in '" << inst.original_string << "'\n" << end(); 149 break; 150 } 151 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { -152 raise << maybe(get(Recipe, r).name) << "'greater-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); +152 raise << maybe(get(Recipe, r).name) << "'greater-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 153 break; 154 } 155 break; @@ -263,21 +263,21 @@ if ('onhashchange' in window) { 202 :(before "End Primitive Recipe Checks") 203 case LESSER_THAN: { 204 if (SIZE(inst.ingredients) <= 1) { -205 raise << maybe(get(Recipe, r).name) << "'lesser-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +205 raise << maybe(get(Recipe, r).name) << "'lesser-than' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 206 break; 207 } 208 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 209 if (!is_mu_number(inst.ingredients.at(i))) { -210 raise << maybe(get(Recipe, r).name) << "'lesser-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +210 raise << maybe(get(Recipe, r).name) << "'lesser-than' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 211 goto finish_checking_instruction; 212 } 213 } 214 if (SIZE(inst.products) > 1) { -215 raise << maybe(get(Recipe, r).name) << "'lesser-than' yields exactly one product in '" << inst.original_string << "'\n" << end(); +215 raise << maybe(get(Recipe, r).name) << "'lesser-than' yields exactly one product in '" << inst.original_string << "'\n" << end(); 216 break; 217 } 218 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { -219 raise << maybe(get(Recipe, r).name) << "'lesser-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); +219 raise << maybe(get(Recipe, r).name) << "'lesser-than' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 220 break; 221 } 222 break; @@ -330,21 +330,21 @@ if ('onhashchange' in window) { 269 :(before "End Primitive Recipe Checks") 270 case GREATER_OR_EQUAL: { 271 if (SIZE(inst.ingredients) <= 1) { -272 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +272 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 273 break; 274 } 275 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 276 if (!is_mu_number(inst.ingredients.at(i))) { -277 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +277 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 278 goto finish_checking_instruction; 279 } 280 } 281 if (SIZE(inst.products) > 1) { -282 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); +282 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); 283 break; 284 } 285 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { -286 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); +286 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 287 break; 288 } 289 break; @@ -405,21 +405,21 @@ if ('onhashchange' in window) { 344 :(before "End Primitive Recipe Checks") 345 case LESSER_OR_EQUAL: { 346 if (SIZE(inst.ingredients) <= 1) { -347 raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +347 raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 348 break; 349 } 350 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 351 if (!is_mu_number(inst.ingredients.at(i))) { -352 raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +352 raise << maybe(get(Recipe, r).name) << "'lesser-or-equal' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 353 goto finish_checking_instruction; 354 } 355 } 356 if (SIZE(inst.products) > 1) { -357 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); +357 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' yields exactly one product in '" << inst.original_string << "'\n" << end(); 358 break; 359 } 360 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { -361 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); +361 raise << maybe(get(Recipe, r).name) << "'greater-or-equal' should yield a boolean, but got '" << inst.products.at(0).original_string << "'\n" << end(); 362 break; 363 } 364 break; @@ -480,21 +480,21 @@ if ('onhashchange' in window) { 419 :(before "End Primitive Recipe Checks") 420 case MAX: { 421 if (SIZE(inst.ingredients) <= 1) { -422 raise << maybe(get(Recipe, r).name) << "'max' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +422 raise << maybe(get(Recipe, r).name) << "'max' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 423 break; 424 } 425 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 426 if (!is_mu_number(inst.ingredients.at(i))) { -427 raise << maybe(get(Recipe, r).name) << "'max' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +427 raise << maybe(get(Recipe, r).name) << "'max' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 428 goto finish_checking_instruction; 429 } 430 } 431 if (SIZE(inst.products) > 1) { -432 raise << maybe(get(Recipe, r).name) << "'max' yields exactly one product in '" << inst.original_string << "'\n" << end(); +432 raise << maybe(get(Recipe, r).name) << "'max' yields exactly one product in '" << inst.original_string << "'\n" << end(); 433 break; 434 } 435 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -436 raise << maybe(get(Recipe, r).name) << "'max' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +436 raise << maybe(get(Recipe, r).name) << "'max' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 437 break; 438 } 439 break; @@ -519,21 +519,21 @@ if ('onhashchange' in window) { 458 :(before "End Primitive Recipe Checks") 459 case MIN: { 460 if (SIZE(inst.ingredients) <= 1) { -461 raise << maybe(get(Recipe, r).name) << "'min' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); +461 raise << maybe(get(Recipe, r).name) << "'min' needs at least two ingredients to compare in '" << inst.original_string << "'\n" << end(); 462 break; 463 } 464 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 465 if (!is_mu_number(inst.ingredients.at(i))) { -466 raise << maybe(get(Recipe, r).name) << "'min' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); +466 raise << maybe(get(Recipe, r).name) << "'min' can only compare numbers; got '" << inst.ingredients.at(i).original_string << "'\n" << end(); 467 goto finish_checking_instruction; 468 } 469 } 470 if (SIZE(inst.products) > 1) { -471 raise << maybe(get(Recipe, r).name) << "'min' yields exactly one product in '" << inst.original_string << "'\n" << end(); +471 raise << maybe(get(Recipe, r).name) << "'min' yields exactly one product in '" << inst.original_string << "'\n" << end(); 472 break; 473 } 474 if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_number(inst.products.at(0))) { -475 raise << maybe(get(Recipe, r).name) << "'min' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); +475 raise << maybe(get(Recipe, r).name) << "'min' should yield a number, but got '" << inst.products.at(0).original_string << "'\n" << end(); 476 break; 477 } 478 break; diff --git a/html/026call.cc.html b/html/026call.cc.html index aeaefb47..b07855e3 100644 --- a/html/026call.cc.html +++ b/html/026call.cc.html @@ -122,7 +122,7 @@ if ('onhashchange' in window) { 60 routine::routine(recipe_ordinal r) { 61 if (Trace_stream) { 62 ++Trace_stream->callstack_depth; - 63 trace(9999, "trace") << "new routine; incrementing callstack depth to " << Trace_stream->callstack_depth << end(); + 63 trace(9999, "trace") << "new routine; incrementing callstack depth to " << Trace_stream->callstack_depth << end(); 64 assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion 65 } 66 calls.push_front(call(r)); @@ -164,13 +164,13 @@ if ('onhashchange' in window) { 102 :(after "Defined Recipe Checks") 103 // not a primitive; check that it's present in the book of recipes 104 if (!contains_key(Recipe, inst.operation)) { -105 raise << maybe(get(Recipe, r).name) << "undefined operation in '" << inst.original_string << "'\n" << end(); +105 raise << maybe(get(Recipe, r).name) << "undefined operation in '" << inst.original_string << "'\n" << end(); 106 break; 107 } 108 :(replace{} "default:" following "End Primitive Recipe Implementations") 109 default: { 110 const instruction& call_instruction = current_instruction(); -111 if (Recipe.find(current_instruction().operation) == Recipe.end()) { // duplicate from Checks +111 if (Recipe.find(current_instruction().operation) == Recipe.end()) { // duplicate from Checks 112 // stop running this instruction immediately 113 ++current_step_index(); 114 continue; @@ -178,7 +178,7 @@ if ('onhashchange' in window) { 116 // not a primitive; look up the book of recipes 117 if (Trace_stream) { 118 ++Trace_stream->callstack_depth; -119 trace(9999, "trace") << "incrementing callstack depth to " << Trace_stream->callstack_depth << end(); +119 trace(9999, "trace") << "incrementing callstack depth to " << Trace_stream->callstack_depth << end(); 120 assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion 121 } 122 Current_routine->calls.push_front(call(current_instruction().operation)); @@ -223,7 +223,7 @@ if ('onhashchange' in window) { 161 while (current_step_index() >= SIZE(Current_routine->steps())) { 162 // Falling Through End Of Recipe 163 if (Trace_stream) { -164 trace(9999, "trace") << "fall-through: exiting " << current_recipe_name() << "; decrementing callstack depth from " << Trace_stream->callstack_depth << end(); +164 trace(9999, "trace") << "fall-through: exiting " << current_recipe_name() << "; decrementing callstack depth from " << Trace_stream->callstack_depth << end(); 165 --Trace_stream->callstack_depth; 166 assert(Trace_stream->callstack_depth >= 0); 167 } diff --git a/html/027call_ingredient.cc.html b/html/027call_ingredient.cc.html index 996f6efb..f6580ffa 100644 --- a/html/027call_ingredient.cc.html +++ b/html/027call_ingredient.cc.html @@ -104,7 +104,7 @@ if ('onhashchange' in window) { 43 :(before "End Primitive Recipe Checks") 44 case NEXT_INGREDIENT: { 45 if (!inst.ingredients.empty()) { - 46 raise << maybe(get(Recipe, r).name) << "'next-ingredient' didn't expect any ingredients in '" << inst.original_string << "'\n" << end(); + 46 raise << maybe(get(Recipe, r).name) << "'next-ingredient' didn't expect any ingredients in '" << inst.original_string << "'\n" << end(); 47 break; 48 } 49 break; @@ -119,11 +119,11 @@ if ('onhashchange' in window) { 58 // no ingredient types since the call might be implicit; assume ingredients are always strings 59 // todo: how to test this? 60 if (!is_mu_text(product)) - 61 raise << "main: wrong type for ingredient '" << product.original_string << "'\n" << end(); + 61 raise << "main: wrong type for ingredient '" << product.original_string << "'\n" << end(); 62 } 63 else if (!types_coercible(product, 64 current_call().ingredients.at(current_call().next_ingredient_to_process))) { - 65 raise << maybe(current_recipe_name()) << "wrong type for ingredient '" << product.original_string << "'\n" << end(); + 65 raise << maybe(current_recipe_name()) << "wrong type for ingredient '" << product.original_string << "'\n" << end(); 66 // End next-ingredient Type Mismatch Error 67 } 68 products.push_back( @@ -134,7 +134,7 @@ if ('onhashchange' in window) { 73 } 74 else { 75 if (SIZE(current_instruction().products) < 2) - 76 raise << maybe(current_recipe_name()) << "no ingredient to save in '" << current_instruction().products.at(0).original_string << "'\n" << end(); + 76 raise << maybe(current_recipe_name()) << "no ingredient to save in '" << current_instruction().products.at(0).original_string << "'\n" << end(); 77 if (current_instruction().products.empty()) break; 78 products.resize(2); 79 // pad the first product with sufficient zeros to match its type @@ -201,11 +201,11 @@ if ('onhashchange' in window) { 140 :(before "End Primitive Recipe Checks") 141 case INGREDIENT: { 142 if (SIZE(inst.ingredients) != 1) { -143 raise << maybe(get(Recipe, r).name) << "'ingredient' expects exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +143 raise << maybe(get(Recipe, r).name) << "'ingredient' expects exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 144 break; 145 } 146 if (!is_literal(inst.ingredients.at(0)) && !is_mu_number(inst.ingredients.at(0))) { -147 raise << maybe(get(Recipe, r).name) << "'ingredient' expects a literal ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +147 raise << maybe(get(Recipe, r).name) << "'ingredient' expects a literal ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 148 break; 149 } 150 break; diff --git a/html/028call_return.cc.html b/html/028call_return.cc.html index 01e609cc..f092b76d 100644 --- a/html/028call_return.cc.html +++ b/html/028call_return.cc.html @@ -98,7 +98,7 @@ if ('onhashchange' in window) { 37 case RETURN: { 38 // Starting Reply 39 if (Trace_stream) { - 40 trace(9999, "trace") << current_instruction().name << ": decrementing callstack depth from " << Trace_stream->callstack_depth << end(); + 40 trace(9999, "trace") << current_instruction().name << ": decrementing callstack depth from " << Trace_stream->callstack_depth << end(); 41 --Trace_stream->callstack_depth; 42 if (Trace_stream->callstack_depth < 0) { 43 Current_routine->calls.clear(); @@ -109,9 +109,9 @@ if ('onhashchange' in window) { 48 // just in case 'main' returns a value, drop it for now 49 if (Current_routine->calls.empty()) goto stop_running_current_routine; 50 for (int i = 0; i < SIZE(ingredients); ++i) - 51 trace(9998, "run") << "result " << i << " is " << to_string(ingredients.at(i)) << end(); + 51 trace(9998, "run") << "result " << i << " is " << to_string(ingredients.at(i)) << end(); 52 // make return products available to caller - 53 copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); + 53 copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); 54 // End Reply 55 break; // continue to process rest of *caller* instruction 56 } @@ -123,7 +123,7 @@ if ('onhashchange' in window) { 62 :(code) 63 void check_types_of_return_instructions(const recipe_ordinal r) { 64 const recipe& caller = get(Recipe, r); - 65 trace(9991, "transform") << "--- check types of return instructions in recipe " << caller.name << end(); + 65 trace(9991, "transform") << "--- check types of return instructions in recipe " << caller.name << end(); 66 for (int i = 0; i < SIZE(caller.steps); ++i) { 67 const instruction& caller_instruction = caller.steps.at(i); 68 if (caller_instruction.is_label) continue; @@ -135,7 +135,7 @@ if ('onhashchange' in window) { 74 if (return_inst.operation != RETURN) continue; 75 // check types with the caller 76 if (SIZE(caller_instruction.products) > SIZE(return_inst.ingredients)) { - 77 raise << maybe(caller.name) << "too few values returned from " << callee.name << '\n' << end(); + 77 raise << maybe(caller.name) << "too few values returned from " << callee.name << '\n' << end(); 78 break; 79 } 80 for (int i = 0; i < SIZE(caller_instruction.products); ++i) { @@ -143,8 +143,8 @@ if ('onhashchange' in window) { 82 reagent/*copy*/ rhs = caller_instruction.products.at(i); 83 // End Check RETURN Copy(lhs, rhs) 84 if (!types_coercible(rhs, lhs)) { - 85 raise << maybe(callee.name) << return_inst.name << " ingredient '" << lhs.original_string << "' can't be saved in '" << rhs.original_string << "'\n" << end(); - 86 raise << " ['" << to_string(lhs.type) << "' vs '" << to_string(rhs.type) << "']\n" << end(); + 85 raise << maybe(callee.name) << return_inst.name << " ingredient '" << lhs.original_string << "' can't be saved in '" << rhs.original_string << "'\n" << end(); + 86 raise << " ['" << to_string(lhs.type) << "' vs '" << to_string(rhs.type) << "']\n" << end(); 87 goto finish_return_check; 88 } 89 } @@ -154,16 +154,16 @@ if ('onhashchange' in window) { 93 if (has_property(return_inst.ingredients.at(i), "same-as-ingredient")) { 94 string_tree* tmp = property(return_inst.ingredients.at(i), "same-as-ingredient"); 95 if (!tmp || !tmp->atom) { - 96 raise << maybe(caller.name) << "'same-as-ingredient' metadata should take exactly one value in '" << to_original_string(return_inst) << "'\n" << end(); + 96 raise << maybe(caller.name) << "'same-as-ingredient' metadata should take exactly one value in '" << to_original_string(return_inst) << "'\n" << end(); 97 goto finish_return_check; 98 } 99 int ingredient_index = to_integer(tmp->value); 100 if (ingredient_index >= SIZE(caller_instruction.ingredients)) { -101 raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(caller_instruction) << "'\n" << end(); +101 raise << maybe(caller.name) << "too few ingredients in '" << to_original_string(caller_instruction) << "'\n" << end(); 102 goto finish_return_check; 103 } 104 if (!is_dummy(caller_instruction.products.at(i)) && !is_literal(caller_instruction.ingredients.at(ingredient_index)) && caller_instruction.products.at(i).name != caller_instruction.ingredients.at(ingredient_index).name) { -105 raise << maybe(caller.name) << "'" << to_original_string(caller_instruction) << "' should write to '" << caller_instruction.ingredients.at(ingredient_index).original_string << "' rather than '" << caller_instruction.products.at(i).original_string << "'\n" << end(); +105 raise << maybe(caller.name) << "'" << to_original_string(caller_instruction) << "' should write to '" << caller_instruction.ingredients.at(ingredient_index).original_string << "' rather than '" << caller_instruction.products.at(i).original_string << "'\n" << end(); 106 } 107 } 108 } diff --git a/html/029tools.cc.html b/html/029tools.cc.html index 11cbd8ce..0d7f7cf1 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -65,9 +65,9 @@ if ('onhashchange' in window) { 2 3 :(scenario trace) 4 def main [ - 5 trace 1, [foo], [this is a trace in Mu] + 5 trace 1, [foo], [this is a trace in Mu] 6 ] - 7 +foo: this is a trace in Mu + 7 +foo: this is a trace in Mu 8 9 :(before "End Primitive Recipe Declarations") 10 TRACE, @@ -76,15 +76,15 @@ if ('onhashchange' in window) { 13 :(before "End Primitive Recipe Checks") 14 case TRACE: { 15 if (SIZE(inst.ingredients) < 3) { - 16 raise << maybe(get(Recipe, r).name) << "'trace' takes three or more ingredients rather than '" << inst.original_string << "'\n" << end(); + 16 raise << maybe(get(Recipe, r).name) << "'trace' takes three or more ingredients rather than '" << inst.original_string << "'\n" << end(); 17 break; 18 } 19 if (!is_mu_number(inst.ingredients.at(0))) { - 20 raise << maybe(get(Recipe, r).name) << "first ingredient of 'trace' should be a number (depth), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + 20 raise << maybe(get(Recipe, r).name) << "first ingredient of 'trace' should be a number (depth), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 21 break; 22 } 23 if (!is_literal_text(inst.ingredients.at(1))) { - 24 raise << maybe(get(Recipe, r).name) << "second ingredient of 'trace' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); + 24 raise << maybe(get(Recipe, r).name) << "second ingredient of 'trace' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 25 break; 26 } 27 break; @@ -98,7 +98,7 @@ if ('onhashchange' in window) { 35 if (i > 2) out << ' '; 36 out << inspect(current_instruction().ingredients.at(i), ingredients.at(i)); 37 } - 38 trace(depth, label) << out.str() << end(); + 38 trace(depth, label) << out.str() << end(); 39 break; 40 } 41 @@ -119,7 +119,7 @@ if ('onhashchange' in window) { 56 if (i) out << ' '; 57 out << inspect(current_instruction().ingredients.at(i), ingredients.at(i)); 58 } - 59 trace(2, "app") << out.str() << end(); + 59 trace(2, "app") << out.str() << end(); 60 break; 61 } 62 @@ -210,10 +210,10 @@ if ('onhashchange' in window) { 147 :(before "End Primitive Recipe Implementations") 148 case _DUMP_TRACE: { 149 if (ingredients.empty()) { -150 DUMP(""); +150 DUMP(""); 151 } 152 else { -153 DUMP(current_instruction().ingredients.at(0).name); +153 DUMP(current_instruction().ingredients.at(0).name); 154 } 155 break; 156 } @@ -244,7 +244,7 @@ if ('onhashchange' in window) { 181 case _SAVE_TRACE: { 182 if (Save_trace) { 183 ofstream fout("last_trace"); -184 fout << Trace_stream->readable_contents(""); +184 fout << Trace_stream->readable_contents(""); 185 fout.close(); 186 } 187 break; @@ -264,7 +264,7 @@ if ('onhashchange' in window) { 201 case _PRINT: { 202 for (int i = 0; i < SIZE(ingredients); ++i) { 203 if (is_literal(current_instruction().ingredients.at(i))) { -204 trace(9998, "run") << "$print: " << current_instruction().ingredients.at(i).name << end(); +204 trace(9998, "run") << "$print: " << current_instruction().ingredients.at(i).name << end(); 205 if (!has_property(current_instruction().ingredients.at(i), "newline")) { 206 cout << current_instruction().ingredients.at(i).name; 207 } @@ -277,7 +277,7 @@ if ('onhashchange' in window) { 214 // End $print Special-cases 215 else { 216 for (int j = 0; j < SIZE(ingredients.at(i)); ++j) { -217 trace(9998, "run") << "$print: " << ingredients.at(i).at(j) << end(); +217 trace(9998, "run") << "$print: " << ingredients.at(i).at(j) << end(); 218 if (j > 0) cout << " "; 219 cout << no_scientific(ingredients.at(i).at(j)); 220 } @@ -308,11 +308,11 @@ if ('onhashchange' in window) { 245 :(before "End Primitive Recipe Checks") 246 case _SYSTEM: { 247 if (SIZE(inst.ingredients) != 1) { -248 raise << maybe(get(Recipe, r).name) << "'$system' requires exactly one ingredient, but got '" << to_string(inst) << "'\n" << end(); +248 raise << maybe(get(Recipe, r).name) << "'$system' requires exactly one ingredient, but got '" << to_string(inst) << "'\n" << end(); 249 break; 250 } 251 if (!is_literal_text(inst.ingredients.at(0))) { -252 raise << maybe(get(Recipe, r).name) << "ingredient to '$system' must be a literal text, but got '" << to_string(inst) << "'\n" << end(); +252 raise << maybe(get(Recipe, r).name) << "ingredient to '$system' must be a literal text, but got '" << to_string(inst) << "'\n" << end(); 253 } 254 break; 255 } diff --git a/html/030container.cc.html b/html/030container.cc.html index b343aa85..d3196b37 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -216,14 +216,14 @@ if ('onhashchange' in window) { 151 const type_tree* base_type = type; 152 // Update base_type in size_of(type) 153 if (!contains_key(Type, base_type->value)) { -154 raise << "no such type " << base_type->value << '\n' << end(); +154 raise << "no such type " << base_type->value << '\n' << end(); 155 return 0; 156 } 157 type_info t = get(Type, base_type->value); 158 if (t.kind == CONTAINER) { 159 // Compute size_of Container 160 if (!contains_key(Container_metadata, type)) { -161 raise << "unknown size for container type '" << to_string(type) << "'\n" << end(); +161 raise << "unknown size for container type '" << to_string(type) << "'\n" << end(); 162 //? DUMP(""); 163 return 0; 164 } @@ -238,10 +238,10 @@ if ('onhashchange' in window) { 173 :(code) 174 void compute_container_sizes(const recipe_ordinal r) { 175 recipe& caller = get(Recipe, r); -176 trace(9992, "transform") << "--- compute container sizes for " << caller.name << end(); +176 trace(9992, "transform") << "--- compute container sizes for " << caller.name << end(); 177 for (int i = 0; i < SIZE(caller.steps); ++i) { 178 instruction& inst = caller.steps.at(i); -179 trace(9993, "transform") << "- compute container sizes for " << to_string(inst) << end(); +179 trace(9993, "transform") << "- compute container sizes for " << to_string(inst) << end(); 180 for (int i = 0; i < SIZE(inst.ingredients); ++i) 181 compute_container_sizes(inst.ingredients.at(i), " in '"+to_original_string(inst)+"'"); 182 for (int i = 0; i < SIZE(inst.products); ++i) @@ -262,13 +262,13 @@ if ('onhashchange' in window) { 197 198 void compute_container_sizes(const type_tree* type, set<type_tree>& pending_metadata, const string& location_for_error_messages) { 199 if (!type) return; -200 trace(9993, "transform") << "compute container sizes for " << to_string(type) << end(); +200 trace(9993, "transform") << "compute container sizes for " << to_string(type) << end(); 201 if (contains_key(Container_metadata, type)) return; 202 if (contains_key(pending_metadata, *type)) return; 203 pending_metadata.insert(*type); 204 if (!type->atom) { 205 if (!type->left->atom) { -206 raise << "invalid type " << to_string(type) << location_for_error_messages << '\n' << end(); +206 raise << "invalid type " << to_string(type) << location_for_error_messages << '\n' << end(); 207 return; 208 } 209 if (type->left->name == "address") @@ -314,7 +314,7 @@ if ('onhashchange' in window) { 249 return all.at(i).second; 250 } 251 tb_shutdown(); -252 raise << "unknown size for type '" << to_string(key) << "'\n" << end(); +252 raise << "unknown size for type '" << to_string(key) << "'\n" << end(); 253 assert(false); 254 } 255 @@ -426,24 +426,24 @@ if ('onhashchange' in window) { 361 :(before "End Primitive Recipe Checks") 362 case GET: { 363 if (SIZE(inst.ingredients) != 2) { -364 raise << maybe(get(Recipe, r).name) << "'get' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +364 raise << maybe(get(Recipe, r).name) << "'get' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 365 break; 366 } 367 reagent/*copy*/ base = inst.ingredients.at(0); // new copy for every invocation 368 // Update GET base in Check 369 if (!base.type) { -370 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +370 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 371 break; 372 } 373 const type_tree* base_type = base.type; 374 // Update GET base_type in Check 375 if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != CONTAINER) { -376 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +376 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 377 break; 378 } 379 const reagent& offset = inst.ingredients.at(1); 380 if (!is_literal(offset) || !is_mu_scalar(offset)) { -381 raise << maybe(get(Recipe, r).name) << "second ingredient of 'get' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +381 raise << maybe(get(Recipe, r).name) << "second ingredient of 'get' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 382 break; 383 } 384 int offset_value = 0; @@ -452,7 +452,7 @@ if ('onhashchange' in window) { 387 } 388 // End update GET offset_value in Check 389 if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { -390 raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); +390 raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); 391 break; 392 } 393 if (inst.products.empty()) break; @@ -461,7 +461,7 @@ if ('onhashchange' in window) { 396 //: use base.type rather than base_type because later layers will introduce compound types 397 const reagent/*copy*/ element = element_type(base.type, offset_value); 398 if (!types_coercible(product, element)) { -399 raise << maybe(get(Recipe, r).name) << "'get " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << product.name << "' has type " << names_to_string_without_quotes(product.type) << '\n' << end(); +399 raise << maybe(get(Recipe, r).name) << "'get " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << product.name << "' has type " << names_to_string_without_quotes(product.type) << '\n' << end(); 400 break; 401 } 402 break; @@ -472,7 +472,7 @@ if ('onhashchange' in window) { 407 // Update GET base in Run 408 int base_address = base.value; 409 if (base_address == 0) { -410 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +410 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 411 break; 412 } 413 const type_tree* base_type = base.type; @@ -481,11 +481,11 @@ if ('onhashchange' in window) { 416 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above 417 assert(base.metadata.size); 418 int src = base_address + base.metadata.offset.at(offset); -419 trace(9998, "run") << "address to copy is " << src << end(); +419 trace(9998, "run") << "address to copy is " << src << end(); 420 //: use base.type rather than base_type because later layers will introduce compound types 421 reagent/*copy*/ element = element_type(base.type, offset); 422 element.set_value(src); -423 trace(9998, "run") << "its type is " << names_to_string(element.type) << end(); +423 trace(9998, "run") << "its type is " << names_to_string(element.type) << end(); 424 // Read element 425 products.push_back(read_memory(element)); 426 break; @@ -574,25 +574,25 @@ if ('onhashchange' in window) { 509 :(before "End Primitive Recipe Checks") 510 case PUT: { 511 if (SIZE(inst.ingredients) != 3) { -512 raise << maybe(get(Recipe, r).name) << "'put' expects exactly 3 ingredients in '" << inst.original_string << "'\n" << end(); +512 raise << maybe(get(Recipe, r).name) << "'put' expects exactly 3 ingredients in '" << inst.original_string << "'\n" << end(); 513 break; 514 } 515 reagent/*copy*/ base = inst.ingredients.at(0); 516 // Update PUT base in Check 517 if (!base.type) { -518 raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +518 raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 519 break; 520 } 521 const type_tree* base_type = base.type; 522 // Update PUT base_type in Check 523 if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != CONTAINER) { -524 raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +524 raise << maybe(get(Recipe, r).name) << "first ingredient of 'put' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 525 break; 526 } 527 reagent/*copy*/ offset = inst.ingredients.at(1); 528 // Update PUT offset in Check 529 if (!is_literal(offset) || !is_mu_scalar(offset)) { -530 raise << maybe(get(Recipe, r).name) << "second ingredient of 'put' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +530 raise << maybe(get(Recipe, r).name) << "second ingredient of 'put' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 531 break; 532 } 533 int offset_value = 0; @@ -600,7 +600,7 @@ if ('onhashchange' in window) { 535 if (is_integer(offset.name)) { 536 offset_value = to_integer(offset.name); 537 if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { -538 raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); +538 raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); 539 break; 540 } 541 } @@ -611,12 +611,12 @@ if ('onhashchange' in window) { 546 //: use base.type rather than base_type because later layers will introduce compound types 547 const reagent& element = element_type(base.type, offset_value); 548 if (!types_coercible(element, value)) { -549 raise << maybe(get(Recipe, r).name) << "'put " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); +549 raise << maybe(get(Recipe, r).name) << "'put " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); 550 break; 551 } 552 if (inst.products.empty()) break; // no more checks necessary 553 if (inst.products.at(0).name != inst.ingredients.at(0).name) { -554 raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +554 raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 555 break; 556 } 557 // End PUT Product Checks @@ -628,7 +628,7 @@ if ('onhashchange' in window) { 563 // Update PUT base in Run 564 int base_address = base.value; 565 if (base_address == 0) { -566 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +566 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 567 break; 568 } 569 const type_tree* base_type = base.type; @@ -636,12 +636,12 @@ if ('onhashchange' in window) { 571 int offset = ingredients.at(1).at(0); 572 if (offset < 0 || offset >= SIZE(get(Type, base_type->value).elements)) break; // copied from Check above 573 int address = base_address + base.metadata.offset.at(offset); -574 trace(9998, "run") << "address to copy to is " << address << end(); +574 trace(9998, "run") << "address to copy to is " << address << end(); 575 // optimization: directly write the element rather than updating 'product' 576 // and writing the entire container 577 // Write Memory in PUT in Run 578 for (int i = 0; i < SIZE(ingredients.at(2)); ++i) { -579 trace(9999, "mem") << "storing " << no_scientific(ingredients.at(2).at(i)) << " in location " << address+i << end(); +579 trace(9999, "mem") << "storing " << no_scientific(ingredients.at(2).at(i)) << " in location " << address+i << end(); 580 put(Memory, address+i, ingredients.at(2).at(i)); 581 } 582 goto finish_instruction; @@ -728,16 +728,16 @@ if ('onhashchange' in window) { 663 string name = next_word(in); 664 if (name.empty()) { 665 assert(!has_data(in)); -666 raise << "incomplete container definition at end of file (0)\n" << end(); +666 raise << "incomplete container definition at end of file (0)\n" << end(); 667 return; 668 } 669 // End container Name Refinements -670 trace(9991, "parse") << "--- defining " << command << ' ' << name << end(); +670 trace(9991, "parse") << "--- defining " << command << ' ' << name << end(); 671 if (!contains_key(Type_ordinal, name) 672 || get(Type_ordinal, name) == 0) { 673 put(Type_ordinal, name, Next_type_ordinal++); 674 } -675 trace(9999, "parse") << "type number: " << get(Type_ordinal, name) << end(); +675 trace(9999, "parse") << "type number: " << get(Type_ordinal, name) << end(); 676 skip_bracket(in, "'"+command+"' must begin with '['"); 677 type_info& info = get_or_insert(Type, get(Type_ordinal, name)); 678 if (info.Num_calls_to_transform_all_at_first_definition == -1) { @@ -746,7 +746,7 @@ if ('onhashchange' in window) { 681 } 682 else if (info.Num_calls_to_transform_all_at_first_definition != Num_calls_to_transform_all) { 683 // extension after transform_all -684 raise << "there was a call to transform_all() between the definition of container '" << name << "' and a subsequent extension. This is not supported, since any recipes that used '" << name << "' values have already been transformed and \"frozen\".\n" << end(); +684 raise << "there was a call to transform_all() between the definition of container '" << name << "' and a subsequent extension. This is not supported, since any recipes that used '" << name << "' values have already been transformed and \"frozen\".\n" << end(); 685 return; 686 } 687 info.name = name; @@ -756,12 +756,12 @@ if ('onhashchange' in window) { 691 string element = next_word(in); 692 if (element.empty()) { 693 assert(!has_data(in)); -694 raise << "incomplete container definition at end of file (1)\n" << end(); +694 raise << "incomplete container definition at end of file (1)\n" << end(); 695 return; 696 } 697 if (element == "]") break; 698 if (in.peek() != '\n') { -699 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(); +699 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(); 700 // skip rest of container declaration 701 while (has_data(in)) { 702 skip_whitespace_and_comments(in); @@ -772,7 +772,7 @@ if ('onhashchange' in window) { 707 info.elements.push_back(reagent(element)); 708 expand_type_abbreviations(info.elements.back().type); // todo: use abbreviation before declaration 709 replace_unknown_types_with_unique_ordinals(info.elements.back().type, info); -710 trace(9993, "parse") << " element: " << to_string(info.elements.back()) << end(); +710 trace(9993, "parse") << " element: " << to_string(info.elements.back()) << end(); 711 // End Load Container Element Definition 712 } 713 } @@ -798,7 +798,7 @@ if ('onhashchange' in window) { 733 void skip_bracket(istream& in, string message) { 734 skip_whitespace_and_comments(in); 735 if (in.get() != '[') -736 raise << message << '\n' << end(); +736 raise << message << '\n' << end(); 737 } 738 739 :(scenario multi_word_line_in_container_declaration) @@ -827,7 +827,7 @@ if ('onhashchange' in window) { 762 // extremely inefficient; we process all types over and over again, once for every single recipe 763 // but it doesn't seem to cause any noticeable slowdown 764 void expand_type_abbreviations_in_containers(unused const recipe_ordinal r) { -765 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { +765 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { 766 for (int i = 0; i < SIZE(p->second.elements); ++i) 767 expand_type_abbreviations(p->second.elements.at(i).type); 768 } @@ -848,12 +848,12 @@ if ('onhashchange' in window) { 783 "]\n"); 784 // try to extend the container after transform 785 transform_all(); -786 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); +786 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); 787 Hide_errors = true; 788 run("container foo [\n" 789 " b:num\n" 790 "]\n"); -791 CHECK_TRACE_CONTAINS_ERRORS(); +791 CHECK_TRACE_CONTAINS_ERRORS(); 792 } 793 794 //:: Allow container definitions anywhere in the codebase, but complain if you @@ -882,7 +882,7 @@ if ('onhashchange' in window) { 817 :(code) 818 void check_or_set_invalid_types(const recipe_ordinal r) { 819 recipe& caller = get(Recipe, r); -820 trace(9991, "transform") << "--- check for invalid types in recipe " << caller.name << end(); +820 trace(9991, "transform") << "--- check for invalid types in recipe " << caller.name << end(); 821 for (int index = 0; index < SIZE(caller.steps); ++index) { 822 instruction& inst = caller.steps.at(index); 823 for (int i = 0; i < SIZE(inst.ingredients); ++i) @@ -912,7 +912,7 @@ if ('onhashchange' in window) { 847 if (contains_key(Type_ordinal, type->name)) 848 type->value = get(Type_ordinal, type->name); 849 else -850 raise << location_for_error_messages << "unknown type " << type->name << " in " << name_for_error_messages << '\n' << end(); +850 raise << location_for_error_messages << "unknown type " << type->name << " in " << name_for_error_messages << '\n' << end(); 851 } 852 } 853 @@ -945,7 +945,7 @@ if ('onhashchange' in window) { 880 881 :(code) 882 void check_container_field_types() { -883 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { +883 for (map<type_ordinal, type_info>::iterator p = Type.begin(); p != Type.end(); ++p) { 884 const type_info& info = p->second; 885 // Check Container Field Types(info) 886 for (int i = 0; i < SIZE(info.elements); ++i) @@ -962,7 +962,7 @@ if ('onhashchange' in window) { 897 } 898 if (type->value != 0) { // value 0 = compound types (layer parse_tree) or type ingredients (layer shape_shifting_container) 899 if (!contains_key(Type, type->value)) -900 raise << location_for_error_messages << "unknown type in " << name_for_error_messages << '\n' << end(); +900 raise << location_for_error_messages << "unknown type in " << name_for_error_messages << '\n' << end(); 901 } 902 } diff --git a/html/031merge.cc.html b/html/031merge.cc.html index bc0c1166..9fe3e71b 100644 --- a/html/031merge.cc.html +++ b/html/031merge.cc.html @@ -177,12 +177,12 @@ if ('onhashchange' in window) { 114 :(code) 115 void check_merge_calls(const recipe_ordinal r) { 116 const recipe& caller = get(Recipe, r); -117 trace(9991, "transform") << "--- type-check merge instructions in recipe " << caller.name << end(); +117 trace(9991, "transform") << "--- type-check merge instructions in recipe " << caller.name << end(); 118 for (int i = 0; i < SIZE(caller.steps); ++i) { 119 const instruction& inst = caller.steps.at(i); 120 if (inst.name != "merge") continue; 121 if (SIZE(inst.products) != 1) { -122 raise << maybe(caller.name) << "'merge' should yield a single product in '" << inst.original_string << "'\n" << end(); +122 raise << maybe(caller.name) << "'merge' should yield a single product in '" << inst.original_string << "'\n" << end(); 123 continue; 124 } 125 reagent/*copy*/ product = inst.products.at(0); @@ -190,12 +190,12 @@ if ('onhashchange' in window) { 127 const type_tree* product_base_type = product.type->atom ? product.type : product.type->left; 128 assert(product_base_type->atom); 129 if (product_base_type->value == 0 || !contains_key(Type, product_base_type->value)) { -130 raise << maybe(caller.name) << "'merge' should yield a container in '" << inst.original_string << "'\n" << end(); +130 raise << maybe(caller.name) << "'merge' should yield a container in '" << inst.original_string << "'\n" << end(); 131 continue; 132 } 133 const type_info& info = get(Type, product_base_type->value); 134 if (info.kind != CONTAINER && info.kind != EXCLUSIVE_CONTAINER) { -135 raise << maybe(caller.name) << "'merge' should yield a container in '" << inst.original_string << "'\n" << end(); +135 raise << maybe(caller.name) << "'merge' should yield a container in '" << inst.original_string << "'\n" << end(); 136 continue; 137 } 138 check_merge_call(inst.ingredients, product, caller, inst); @@ -208,9 +208,9 @@ if ('onhashchange' in window) { 145 state.data.push(merge_check_point(product, 0)); 146 while (true) { 147 assert(!state.data.empty()); -148 trace(9999, "transform") << ingredient_index << " vs " << SIZE(ingredients) << end(); +148 trace(9999, "transform") << ingredient_index << " vs " << SIZE(ingredients) << end(); 149 if (ingredient_index >= SIZE(ingredients)) { -150 raise << maybe(caller.name) << "too few ingredients in '" << inst.original_string << "'\n" << end(); +150 raise << maybe(caller.name) << "too few ingredients in '" << inst.original_string << "'\n" << end(); 151 return; 152 } 153 reagent& container = state.data.top().container; @@ -224,7 +224,7 @@ if ('onhashchange' in window) { 161 if (state.data.top().container_element_index == 0 && types_coercible(container, inst.ingredients.at(ingredient_index))) 162 return; 163 const reagent& expected_ingredient = element_type(container.type, state.data.top().container_element_index); -164 trace(9999, "transform") << "checking container " << to_string(container) << " || " << to_string(expected_ingredient) << " vs ingredient " << ingredient_index << end(); +164 trace(9999, "transform") << "checking container " << to_string(container) << " || " << to_string(expected_ingredient) << " vs ingredient " << ingredient_index << end(); 165 // if the current element is the ingredient we expect, move on to the next element/ingredient 166 if (types_coercible(expected_ingredient, ingredients.at(ingredient_index))) { 167 ++ingredient_index; @@ -233,7 +233,7 @@ if ('onhashchange' in window) { 170 state.data.pop(); 171 if (state.data.empty()) { 172 if (ingredient_index < SIZE(ingredients)) -173 raise << maybe(caller.name) << "too many ingredients in '" << inst.original_string << "'\n" << end(); +173 raise << maybe(caller.name) << "too many ingredients in '" << inst.original_string << "'\n" << end(); 174 return; 175 } 176 ++state.data.top().container_element_index; @@ -249,9 +249,9 @@ if ('onhashchange' in window) { 186 // End check_merge_call Special-cases 187 default: { 188 if (!types_coercible(container, ingredients.at(ingredient_index))) { -189 raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << inst.original_string << "'\n" << end(); -190 raise << " (expected '" << debug_string(container) << "')\n" << end(); -191 raise << " (got '" << debug_string(ingredients.at(ingredient_index)) << "')\n" << end(); +189 raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << inst.original_string << "'\n" << end(); +190 raise << " (expected '" << debug_string(container) << "')\n" << end(); +191 raise << " (got '" << debug_string(ingredients.at(ingredient_index)) << "')\n" << end(); 192 return; 193 } 194 ++ingredient_index; @@ -260,7 +260,7 @@ if ('onhashchange' in window) { 197 state.data.pop(); 198 if (state.data.empty()) { 199 if (ingredient_index < SIZE(ingredients)) -200 raise << maybe(caller.name) << "too many ingredients in '" << inst.original_string << "'\n" << end(); +200 raise << maybe(caller.name) << "too many ingredients in '" << inst.original_string << "'\n" << end(); 201 return; 202 } 203 ++state.data.top().container_element_index; diff --git a/html/032array.cc.html b/html/032array.cc.html index 44270c72..71876de7 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -83,29 +83,29 @@ if ('onhashchange' in window) { 20 :(before "End Primitive Recipe Checks") 21 case CREATE_ARRAY: { 22 if (inst.products.empty()) { - 23 raise << maybe(get(Recipe, r).name) << "'create-array' needs one product and no ingredients but got '" << inst.original_string << '\n' << end(); + 23 raise << maybe(get(Recipe, r).name) << "'create-array' needs one product and no ingredients but got '" << inst.original_string << '\n' << end(); 24 break; 25 } 26 reagent/*copy*/ product = inst.products.at(0); 27 // Update CREATE_ARRAY product in Check 28 if (!is_mu_array(product)) { - 29 raise << maybe(get(Recipe, r).name) << "'create-array' cannot create non-array '" << product.original_string << "'\n" << end(); + 29 raise << maybe(get(Recipe, r).name) << "'create-array' cannot create non-array '" << product.original_string << "'\n" << end(); 30 break; 31 } 32 if (!product.type->right) { - 33 raise << maybe(get(Recipe, r).name) << "create array of what? '" << inst.original_string << "'\n" << end(); + 33 raise << maybe(get(Recipe, r).name) << "create array of what? '" << inst.original_string << "'\n" << end(); 34 break; 35 } 36 // 'create-array' will need to check properties rather than types 37 type_tree* array_length_from_type = product.type->right->right; 38 if (!array_length_from_type) { - 39 raise << maybe(get(Recipe, r).name) << "create array of what size? '" << inst.original_string << "'\n" << end(); + 39 raise << maybe(get(Recipe, r).name) << "create array of what size? '" << inst.original_string << "'\n" << end(); 40 break; 41 } 42 if (!product.type->right->right->atom) 43 array_length_from_type = array_length_from_type->left; 44 if (!is_integer(array_length_from_type->name)) { - 45 raise << maybe(get(Recipe, r).name) << "'create-array' product should specify size of array after its element type, but got '" << product.type->right->right->name << "'\n" << end(); + 45 raise << maybe(get(Recipe, r).name) << "'create-array' product should specify size of array after its element type, but got '" << product.type->right->right->name << "'\n" << end(); 46 break; 47 } 48 break; @@ -120,10 +120,10 @@ if ('onhashchange' in window) { 57 array_length_from_type = array_length_from_type->left; 58 int array_length = to_integer(array_length_from_type->name); 59 // initialize array length, so that size_of will work - 60 trace(9999, "mem") << "storing " << array_length << " in location " << base_address << end(); + 60 trace(9999, "mem") << "storing " << array_length << " in location " << base_address << end(); 61 put(Memory, base_address, array_length); // in array elements 62 int size = size_of(product); // in locations - 63 trace(9998, "run") << "creating array of size " << size << end(); + 63 trace(9998, "run") << "creating array of size " << size << end(); 64 // initialize array 65 for (int i = 1; i <= size_of(product); ++i) { 66 put(Memory, base_address+i, 0); @@ -168,7 +168,7 @@ if ('onhashchange' in window) { 105 :(before "End size_of(reagent r) Special-cases") 106 if (!r.type->atom && r.type->left->atom && r.type->left->value == get(Type_ordinal, "array")) { 107 if (!r.type->right) { -108 raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end(); +108 raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end(); 109 return 1; 110 } 111 return /*space for length*/1 + array_length(r)*size_of(array_element(r.type)); @@ -218,16 +218,16 @@ if ('onhashchange' in window) { 155 { 156 const type_tree* type = info.elements.back().type; 157 if (type && type->atom && type->name == "array") { -158 raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end(); +158 raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end(); 159 continue; 160 } 161 if (type && !type->atom && type->left->atom && type->left->name == "array") { 162 if (!type->right) { -163 raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end(); +163 raise << "container '" << name << "' doesn't specify type of array elements for '" << info.elements.back().name << "'\n" << end(); 164 continue; 165 } 166 if (!type->right->right || !is_integer(type->right->right->left->name)) { // array has no length -167 raise << "container '" << name << "' cannot determine size of element '" << info.elements.back().name << "'\n" << end(); +167 raise << "container '" << name << "' cannot determine size of element '" << info.elements.back().name << "'\n" << end(); 168 continue; 169 } 170 } @@ -372,19 +372,19 @@ if ('onhashchange' in window) { 309 :(before "End Primitive Recipe Checks") 310 case INDEX: { 311 if (SIZE(inst.ingredients) != 2) { -312 raise << maybe(get(Recipe, r).name) << "'index' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +312 raise << maybe(get(Recipe, r).name) << "'index' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 313 break; 314 } 315 reagent/*copy*/ base = inst.ingredients.at(0); 316 // Update INDEX base in Check 317 if (!is_mu_array(base)) { -318 raise << maybe(get(Recipe, r).name) << "'index' on a non-array '" << base.original_string << "'\n" << end(); +318 raise << maybe(get(Recipe, r).name) << "'index' on a non-array '" << base.original_string << "'\n" << end(); 319 break; 320 } 321 reagent/*copy*/ index = inst.ingredients.at(1); 322 // Update INDEX index in Check 323 if (!is_mu_number(index)) { -324 raise << maybe(get(Recipe, r).name) << "second ingredient of 'index' should be a number, but got '" << index.original_string << "'\n" << end(); +324 raise << maybe(get(Recipe, r).name) << "second ingredient of 'index' should be a number, but got '" << index.original_string << "'\n" << end(); 325 break; 326 } 327 if (inst.products.empty()) break; @@ -393,7 +393,7 @@ if ('onhashchange' in window) { 330 reagent/*local*/ element; 331 element.type = copy_array_element(base.type); 332 if (!types_coercible(product, element)) { -333 raise << maybe(get(Recipe, r).name) << "'index' on '" << base.original_string << "' can't be saved in '" << product.original_string << "'; type should be '" << names_to_string_without_quotes(element.type) << "'\n" << end(); +333 raise << maybe(get(Recipe, r).name) << "'index' on '" << base.original_string << "' can't be saved in '" << product.original_string << "'; type should be '" << names_to_string_without_quotes(element.type) << "'\n" << end(); 334 break; 335 } 336 break; @@ -403,23 +403,23 @@ if ('onhashchange' in window) { 340 reagent/*copy*/ base = current_instruction().ingredients.at(0); 341 // Update INDEX base in Run 342 int base_address = base.value; -343 trace(9998, "run") << "base address is " << base_address << end(); +343 trace(9998, "run") << "base address is " << base_address << end(); 344 if (base_address == 0) { -345 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +345 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 346 break; 347 } 348 reagent/*copy*/ index = current_instruction().ingredients.at(1); 349 // Update INDEX index in Run 350 vector<double> index_val(read_memory(index)); 351 if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) { -352 raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); +352 raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); 353 break; 354 } 355 reagent/*local*/ element; 356 element.type = copy_array_element(base.type); 357 element.set_value(base_address + /*skip length*/1 + index_val.at(0)*size_of(element.type)); -358 trace(9998, "run") << "address to copy is " << element.value << end(); -359 trace(9998, "run") << "its type is " << to_string(element.type) << end(); +358 trace(9998, "run") << "address to copy is " << element.value << end(); +359 trace(9998, "run") << "its type is " << to_string(element.type) << end(); 360 // Read element 361 products.push_back(read_memory(element)); 362 break; @@ -558,19 +558,19 @@ if ('onhashchange' in window) { 495 :(before "End Primitive Recipe Checks") 496 case PUT_INDEX: { 497 if (SIZE(inst.ingredients) != 3) { -498 raise << maybe(get(Recipe, r).name) << "'put-index' expects exactly 3 ingredients in '" << inst.original_string << "'\n" << end(); +498 raise << maybe(get(Recipe, r).name) << "'put-index' expects exactly 3 ingredients in '" << inst.original_string << "'\n" << end(); 499 break; 500 } 501 reagent/*copy*/ base = inst.ingredients.at(0); 502 // Update PUT_INDEX base in Check 503 if (!is_mu_array(base)) { -504 raise << maybe(get(Recipe, r).name) << "'put-index' on a non-array '" << base.original_string << "'\n" << end(); +504 raise << maybe(get(Recipe, r).name) << "'put-index' on a non-array '" << base.original_string << "'\n" << end(); 505 break; 506 } 507 reagent/*copy*/ index = inst.ingredients.at(1); 508 // Update PUT_INDEX index in Check 509 if (!is_mu_number(index)) { -510 raise << maybe(get(Recipe, r).name) << "second ingredient of 'put-index' should have type 'number', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +510 raise << maybe(get(Recipe, r).name) << "second ingredient of 'put-index' should have type 'number', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 511 break; 512 } 513 reagent/*copy*/ value = inst.ingredients.at(2); @@ -578,12 +578,12 @@ if ('onhashchange' in window) { 515 reagent/*local*/ element; 516 element.type = copy_array_element(base.type); 517 if (!types_coercible(element, value)) { -518 raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); +518 raise << maybe(get(Recipe, r).name) << "'put-index " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should store " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); 519 break; 520 } 521 if (inst.products.empty()) break; // no more checks necessary 522 if (inst.products.at(0).name != inst.ingredients.at(0).name) { -523 raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +523 raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 524 break; 525 } 526 // End PUT_INDEX Product Checks @@ -595,24 +595,24 @@ if ('onhashchange' in window) { 532 // Update PUT_INDEX base in Run 533 int base_address = base.value; 534 if (base_address == 0) { -535 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +535 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 536 break; 537 } 538 reagent/*copy*/ index = current_instruction().ingredients.at(1); 539 // Update PUT_INDEX index in Run 540 vector<double> index_val(read_memory(index)); 541 if (index_val.at(0) < 0 || index_val.at(0) >= get_or_insert(Memory, base_address)) { -542 raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); +542 raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << " in '" << to_original_string(current_instruction()) << "'\n" << end(); 543 break; 544 } 545 int address = base_address + /*skip length*/1 + index_val.at(0)*size_of(array_element(base.type)); -546 trace(9998, "run") << "address to copy to is " << address << end(); +546 trace(9998, "run") << "address to copy to is " << address << end(); 547 // optimization: directly write the element rather than updating 'product' 548 // and writing the entire array 549 vector<double> value = read_memory(current_instruction().ingredients.at(2)); 550 // Write Memory in PUT_INDEX in Run 551 for (int i = 0; i < SIZE(value); ++i) { -552 trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end(); +552 trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end(); 553 put(Memory, address+i, value.at(i)); 554 } 555 goto finish_instruction; @@ -677,13 +677,13 @@ if ('onhashchange' in window) { 614 :(before "End Primitive Recipe Checks") 615 case LENGTH: { 616 if (SIZE(inst.ingredients) != 1) { -617 raise << maybe(get(Recipe, r).name) << "'length' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +617 raise << maybe(get(Recipe, r).name) << "'length' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 618 break; 619 } 620 reagent/*copy*/ array = inst.ingredients.at(0); 621 // Update LENGTH array in Check 622 if (!is_mu_array(array)) { -623 raise << "tried to calculate length of non-array '" << array.original_string << "'\n" << end(); +623 raise << "tried to calculate length of non-array '" << array.original_string << "'\n" << end(); 624 break; 625 } 626 break; @@ -693,7 +693,7 @@ if ('onhashchange' in window) { 630 reagent/*copy*/ array = current_instruction().ingredients.at(0); 631 // Update LENGTH array in Run 632 if (array.value == 0) { -633 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +633 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 634 break; 635 } 636 products.resize(1); diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index 5677b5b7..424b892a 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -163,28 +163,28 @@ if ('onhashchange' in window) { 100 case MAYBE_CONVERT: { 101 const recipe& caller = get(Recipe, r); 102 if (SIZE(inst.ingredients) != 2) { -103 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +103 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 104 break; 105 } 106 reagent/*copy*/ base = inst.ingredients.at(0); 107 // Update MAYBE_CONVERT base in Check 108 if (!base.type) { -109 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); +109 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); 110 break; 111 } 112 const type_tree* base_type = base.type; 113 // Update MAYBE_CONVERT base_type in Check 114 if (!base_type->atom || base_type->value == 0 || !contains_key(Type, base_type->value) || get(Type, base_type->value).kind != EXCLUSIVE_CONTAINER) { -115 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); +115 raise << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got '" << base.original_string << "'\n" << end(); 116 break; 117 } 118 if (!is_literal(inst.ingredients.at(1))) { -119 raise << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +119 raise << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 120 break; 121 } 122 if (inst.products.empty()) break; 123 if (SIZE(inst.products) != 2) { -124 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 products in '" << inst.original_string << "'\n" << end(); +124 raise << maybe(caller.name) << "'maybe-convert' expects exactly 2 products in '" << inst.original_string << "'\n" << end(); 125 break; 126 } 127 reagent/*copy*/ product = inst.products.at(0); @@ -192,18 +192,18 @@ if ('onhashchange' in window) { 129 reagent& offset = inst.ingredients.at(1); 130 populate_value(offset); 131 if (offset.value >= SIZE(get(Type, base_type->value).elements)) { -132 raise << maybe(caller.name) << "invalid tag " << offset.value << " in '" << inst.original_string << '\n' << end(); +132 raise << maybe(caller.name) << "invalid tag " << offset.value << " in '" << inst.original_string << '\n' << end(); 133 break; 134 } 135 const reagent& variant = variant_type(base, offset.value); 136 if (!types_coercible(product, variant)) { -137 raise << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but '" << product.name << "' has type " << to_string(product.type) << '\n' << end(); +137 raise << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << to_string(variant.type) << " but '" << product.name << "' has type " << to_string(product.type) << '\n' << end(); 138 break; 139 } 140 reagent/*copy*/ status = inst.products.at(1); 141 // Update MAYBE_CONVERT status in Check 142 if (!is_mu_boolean(status)) { -143 raise << maybe(get(Recipe, r).name) << "second product yielded by 'maybe-convert' should be a boolean, but tried to write to '" << inst.products.at(1).original_string << "'\n" << end(); +143 raise << maybe(get(Recipe, r).name) << "second product yielded by 'maybe-convert' should be a boolean, but tried to write to '" << inst.products.at(1).original_string << "'\n" << end(); 144 break; 145 } 146 break; @@ -214,7 +214,7 @@ if ('onhashchange' in window) { 151 // Update MAYBE_CONVERT base in Run 152 int base_address = base.value; 153 if (base_address == 0) { -154 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +154 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 155 break; 156 } 157 int tag = current_instruction().ingredients.at(1).value; @@ -225,19 +225,19 @@ if ('onhashchange' in window) { 162 // optimization: directly write results to only update first product when necessary 163 if (tag == static_cast<int>(get_or_insert(Memory, base_address))) { 164 const reagent& variant = variant_type(base, tag); -165 trace(9999, "mem") << "storing 1 in location " << status.value << end(); +165 trace(9999, "mem") << "storing 1 in location " << status.value << end(); 166 put(Memory, status.value, 1); 167 if (!is_dummy(product)) { 168 // Write Memory in Successful MAYBE_CONVERT in Run 169 for (int i = 0; i < size_of(variant); ++i) { 170 double val = get_or_insert(Memory, base_address+/*skip tag*/1+i); -171 trace(9999, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end(); +171 trace(9999, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end(); 172 put(Memory, product.value+i, val); 173 } 174 } 175 } 176 else { -177 trace(9999, "mem") << "storing 0 in location " << status.value << end(); +177 trace(9999, "mem") << "storing 0 in location " << status.value << end(); 178 put(Memory, status.value, 0); 179 } 180 goto finish_instruction; @@ -380,22 +380,22 @@ if ('onhashchange' in window) { 317 :(before "End check_merge_call Special-cases") 318 case EXCLUSIVE_CONTAINER: { 319 assert(state.data.top().container_element_index == 0); -320 trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end(); +320 trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end(); 321 // easy case: exact match 322 if (types_strictly_match(container, inst.ingredients.at(ingredient_index))) 323 return; 324 if (!is_literal(ingredients.at(ingredient_index))) { -325 raise << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); +325 raise << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); 326 return; 327 } 328 reagent/*copy*/ ingredient = ingredients.at(ingredient_index); // unnecessary copy just to keep this function from modifying caller 329 populate_value(ingredient); 330 if (ingredient.value >= SIZE(container_info.elements)) { -331 raise << maybe(caller.name) << "invalid tag at " << ingredient_index << " for '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); +331 raise << maybe(caller.name) << "invalid tag at " << ingredient_index << " for '" << container_info.name << "' in '" << inst.original_string << "'\n" << end(); 332 return; 333 } 334 const reagent& variant = variant_type(container, ingredient.value); -335 trace(9999, "transform") << "tag: " << ingredient.value << end(); +335 trace(9999, "transform") << "tag: " << ingredient.value << end(); 336 // replace union with its variant 337 state.data.pop(); 338 state.data.push(merge_check_point(variant, 0)); diff --git a/html/034address.cc.html b/html/034address.cc.html index c487ff0a..0b70cbc9 100644 --- a/html/034address.cc.html +++ b/html/034address.cc.html @@ -225,25 +225,25 @@ if ('onhashchange' in window) { 163 case NEW: { 164 const recipe& caller = get(Recipe, r); 165 if (inst.ingredients.empty() || SIZE(inst.ingredients) > 2) { -166 raise << maybe(caller.name) << "'new' requires one or two ingredients, but got '" << inst.original_string << "'\n" << end(); +166 raise << maybe(caller.name) << "'new' requires one or two ingredients, but got '" << inst.original_string << "'\n" << end(); 167 break; 168 } 169 // End NEW Check Special-cases 170 const reagent& type = inst.ingredients.at(0); 171 if (!is_mu_type_literal(type)) { -172 raise << maybe(caller.name) << "first ingredient of 'new' should be a type, but got '" << type.original_string << "'\n" << end(); +172 raise << maybe(caller.name) << "first ingredient of 'new' should be a type, but got '" << type.original_string << "'\n" << end(); 173 break; 174 } 175 if (SIZE(inst.ingredients) > 1 && !is_mu_number(inst.ingredients.at(1))) { -176 raise << maybe(caller.name) << "second ingredient of 'new' should be a number (array length), but got '" << type.original_string << "'\n" << end(); +176 raise << maybe(caller.name) << "second ingredient of 'new' should be a number (array length), but got '" << type.original_string << "'\n" << end(); 177 break; 178 } 179 if (inst.products.empty()) { -180 raise << maybe(caller.name) << "result of 'new' should never be ignored\n" << end(); +180 raise << maybe(caller.name) << "result of 'new' should never be ignored\n" << end(); 181 break; 182 } 183 if (!product_of_new_is_valid(inst)) { -184 raise << maybe(caller.name) << "product of 'new' has incorrect type: '" << inst.original_string << "'\n" << end(); +184 raise << maybe(caller.name) << "product of 'new' has incorrect type: '" << inst.original_string << "'\n" << end(); 185 break; 186 } 187 break; @@ -269,7 +269,7 @@ if ('onhashchange' in window) { 207 void drop_from_type(reagent& r, string expected_type) { 208 assert(!r.type->atom); 209 if (r.type->left->name != expected_type) { -210 raise << "can't drop2 " << expected_type << " from '" << to_string(r) << "'\n" << end(); +210 raise << "can't drop2 " << expected_type << " from '" << to_string(r) << "'\n" << end(); 211 return; 212 } 213 // r.type = r.type->right @@ -320,12 +320,12 @@ if ('onhashchange' in window) { 258 //: instructions left after the transforms have run. 259 :(before "End Primitive Recipe Checks") 260 case ALLOCATE: { -261 raise << "never call 'allocate' directly'; always use 'new'\n" << end(); +261 raise << "never call 'allocate' directly'; always use 'new'\n" << end(); 262 break; 263 } 264 :(before "End Primitive Recipe Implementations") 265 case NEW: { -266 raise << "no implementation for 'new'; why wasn't it translated to 'allocate'? Please save a copy of your program and send it to Kartik.\n" << end(); +266 raise << "no implementation for 'new'; why wasn't it translated to 'allocate'? Please save a copy of your program and send it to Kartik.\n" << end(); 267 break; 268 } 269 @@ -334,7 +334,7 @@ if ('onhashchange' in window) { 272 273 :(code) 274 void transform_new_to_allocate(const recipe_ordinal r) { -275 trace(9991, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end(); +275 trace(9991, "transform") << "--- convert 'new' to 'allocate' for recipe " << get(Recipe, r).name << end(); 276 for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { 277 instruction& inst = get(Recipe, r).steps.at(i); 278 // Convert 'new' To 'allocate' @@ -342,7 +342,7 @@ if ('onhashchange' in window) { 280 inst.operation = ALLOCATE; 281 type_tree* type = new_type_tree(inst.ingredients.at(0).name); 282 inst.ingredients.at(0).set_value(size_of(type)); -283 trace(9992, "new") << "size of '" << inst.ingredients.at(0).name << "' is " << inst.ingredients.at(0).value << end(); +283 trace(9992, "new") << "size of '" << inst.ingredients.at(0).name << "' is " << inst.ingredients.at(0).value << end(); 284 delete type; 285 } 286 } @@ -363,7 +363,7 @@ if ('onhashchange' in window) { 301 alloc = Memory_allocated_until; 302 Memory_allocated_until += Initial_memory_per_routine; 303 alloc_max = Memory_allocated_until; -304 trace(9999, "new") << "routine allocated memory from " << alloc << " to " << alloc_max << end(); +304 trace(9999, "new") << "routine allocated memory from " << alloc << " to " << alloc_max << end(); 305 306 :(before "End Primitive Recipe Declarations") 307 ALLOCATE, @@ -375,13 +375,13 @@ if ('onhashchange' in window) { 313 int size = ingredients.at(0).at(0); 314 if (SIZE(ingredients) > 1) { 315 // array allocation -316 trace(9999, "mem") << "array length is " << ingredients.at(1).at(0) << end(); +316 trace(9999, "mem") << "array length is " << ingredients.at(1).at(0) << end(); 317 size = /*space for length*/1 + size*ingredients.at(1).at(0); 318 } 319 int result = allocate(size); 320 if (SIZE(current_instruction().ingredients) > 1) { 321 // initialize array length -322 trace(9999, "mem") << "storing " << ingredients.at(1).at(0) << " in location " << result+/*skip refcount*/1 << end(); +322 trace(9999, "mem") << "storing " << ingredients.at(1).at(0) << " in location " << result+/*skip refcount*/1 << end(); 323 put(Memory, result+/*skip refcount*/1, ingredients.at(1).at(0)); 324 } 325 products.resize(1); @@ -392,7 +392,7 @@ if ('onhashchange' in window) { 330 int allocate(int size) { 331 // include space for refcount 332 ++size; -333 trace(9999, "mem") << "allocating size " << size << end(); +333 trace(9999, "mem") << "allocating size " << size << end(); 334 //? Total_alloc += size; 335 //? ++Num_alloc; 336 // Allocate Special-cases @@ -400,10 +400,10 @@ if ('onhashchange' in window) { 338 // really crappy at the moment 339 ensure_space(size); 340 const int result = Current_routine->alloc; -341 trace(9999, "mem") << "new alloc: " << result << end(); +341 trace(9999, "mem") << "new alloc: " << result << end(); 342 // initialize allocated space 343 for (int address = result; address < result+size; ++address) { -344 trace(9999, "mem") << "storing 0 in location " << address << end(); +344 trace(9999, "mem") << "storing 0 in location " << address << end(); 345 put(Memory, address, 0); 346 } 347 Current_routine->alloc += size; @@ -437,7 +437,7 @@ if ('onhashchange' in window) { 375 Current_routine->alloc = Memory_allocated_until; 376 Memory_allocated_until += Initial_memory_per_routine; 377 Current_routine->alloc_max = Memory_allocated_until; -378 trace(9999, "new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max << end(); +378 trace(9999, "new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max << end(); 379 } 380 } 381 diff --git a/html/035lookup.cc.html b/html/035lookup.cc.html index 98f16f77..42ea2b90 100644 --- a/html/035lookup.cc.html +++ b/html/035lookup.cc.html @@ -149,12 +149,12 @@ if ('onhashchange' in window) { 86 87 void lookup_memory(reagent& x) { 88 if (!x.type || x.type->atom || x.type->left->value != get(Type_ordinal, "address")) { - 89 raise << maybe(current_recipe_name()) << "tried to /lookup '" << x.original_string << "' but it isn't an address\n" << end(); + 89 raise << maybe(current_recipe_name()) << "tried to /lookup '" << x.original_string << "' but it isn't an address\n" << end(); 90 return; 91 } 92 // compute value 93 if (x.value == 0) { - 94 raise << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end(); + 94 raise << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end(); 95 return; 96 } 97 lookup_memory_core(x, /*check_for_null*/true); @@ -162,18 +162,18 @@ if ('onhashchange' in window) { 99 100 void lookup_memory_core(reagent& x, bool check_for_null) { 101 if (x.value == 0) return; -102 trace(9999, "mem") << "location " << x.value << " is " << no_scientific(get_or_insert(Memory, x.value)) << end(); +102 trace(9999, "mem") << "location " << x.value << " is " << no_scientific(get_or_insert(Memory, x.value)) << end(); 103 x.set_value(get_or_insert(Memory, x.value)); 104 drop_from_type(x, "address"); 105 if (x.value) { -106 trace(9999, "mem") << "skipping refcount at " << x.value << end(); +106 trace(9999, "mem") << "skipping refcount at " << x.value << end(); 107 x.set_value(x.value+1); // skip refcount 108 } 109 else if (check_for_null) { 110 if (Current_routine) -111 raise << "tried to /lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +111 raise << "tried to /lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 112 else -113 raise << "tried to /lookup 0\n" << end(); +113 raise << "tried to /lookup 0\n" << end(); 114 } 115 drop_one_lookup(x); 116 } @@ -183,7 +183,7 @@ if ('onhashchange' in window) { 120 x.set_value(34); // unsafe 121 put(Memory, 34, 1000); 122 lookup_memory(x); -123 CHECK_TRACE_CONTENTS("mem: skipping refcount at 1000"); +123 CHECK_TRACE_CONTENTS("mem: skipping refcount at 1000"); 124 CHECK_EQ(x.value, 1001); 125 } 126 @@ -193,7 +193,7 @@ if ('onhashchange' in window) { 130 x.set_value(34); // unsafe 131 put(Memory, 34, 0); 132 lookup_memory(x); -133 CHECK_TRACE_DOESNT_CONTAIN("mem: skipping refcount at 0"); +133 CHECK_TRACE_DOESNT_CONTAIN("mem: skipping refcount at 0"); 134 CHECK_EQ(x.value, 0); 135 } 136 @@ -237,7 +237,7 @@ if ('onhashchange' in window) { 174 bool canonize_type(reagent& r) { 175 while (has_property(r, "lookup")) { 176 if (!r.type || r.type->atom || !r.type->left || !r.type->left->atom || r.type->left->value != get(Type_ordinal, "address")) { -177 raise << "can't lookup non-address: '" << to_string(r) << "': '" << to_string(r.type) << "'\n" << end(); +177 raise << "can't lookup non-address: '" << to_string(r) << "': '" << to_string(r.type) << "'\n" << end(); 178 return false; 179 } 180 drop_from_type(r, "address"); @@ -247,7 +247,7 @@ if ('onhashchange' in window) { 184 } 185 186 void drop_one_lookup(reagent& r) { -187 for (vector<pair<string, string_tree*> >::iterator p = r.properties.begin(); p != r.properties.end(); ++p) { +187 for (vector<pair<string, string_tree*> >::iterator p = r.properties.begin(); p != r.properties.end(); ++p) { 188 if (p->first == "lookup") { 189 r.properties.erase(p); 190 return; @@ -332,7 +332,7 @@ if ('onhashchange' in window) { 269 reagent/*copy*/ i = inst.ingredients.at(0); 270 if (!canonize_type(i)) break; // error raised elsewhere 271 if (!types_strictly_match(p, i)) { -272 raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +272 raise << maybe(get(Recipe, r).name) << "product of 'put' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 273 break; 274 } 275 @@ -442,7 +442,7 @@ if ('onhashchange' in window) { 379 reagent/*copy*/ i = inst.ingredients.at(0); 380 if (!canonize_type(i)) break; // error raised elsewhere 381 if (!types_strictly_match(p, i)) { -382 raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +382 raise << maybe(get(Recipe, r).name) << "product of 'put-index' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 383 break; 384 } 385 @@ -563,7 +563,7 @@ if ('onhashchange' in window) { 500 properties.push_back(pair<string, string_tree*>("lookup", NULL)); 501 } 502 if (name.empty()) -503 raise << "illegal name '" << original_string << "'\n" << end(); +503 raise << "illegal name '" << original_string << "'\n" << end(); 504 } 505 506 //:: helpers for debugging diff --git a/html/036refcount.cc.html b/html/036refcount.cc.html index 1f3b3fc7..41c7a557 100644 --- a/html/036refcount.cc.html +++ b/html/036refcount.cc.html @@ -107,7 +107,7 @@ if ('onhashchange' in window) { 44 assert(new_address >= 0); 45 if (new_address == 0) return; 46 int new_refcount = get_or_insert(Memory, new_address); - 47 trace(9999, "mem") << "incrementing refcount of " << new_address << ": " << new_refcount << " -> " << new_refcount+1 << end(); + 47 trace(9999, "mem") << "incrementing refcount of " << new_address << ": " << new_refcount << " -> " << new_refcount+1 << end(); 48 put(Memory, new_address, new_refcount+1); 49 } 50 @@ -124,16 +124,16 @@ if ('onhashchange' in window) { 61 assert(old_address >= 0); 62 if (old_address) { 63 int old_refcount = get_or_insert(Memory, old_address); - 64 trace(9999, "mem") << "decrementing refcount of " << old_address << ": " << old_refcount << " -> " << old_refcount-1 << end(); + 64 trace(9999, "mem") << "decrementing refcount of " << old_address << ": " << old_refcount << " -> " << old_refcount-1 << end(); 65 --old_refcount; 66 put(Memory, old_address, old_refcount); 67 if (old_refcount < 0) { 68 tb_shutdown(); 69 cerr << "Negative refcount!!! " << old_address << ' ' << old_refcount << '\n'; 70 if (Trace_stream) { - 71 cerr << "Saving trace to last_trace.\n"; + 71 cerr << "Saving trace to last_trace.\n"; 72 ofstream fout("last_trace"); - 73 fout << Trace_stream->readable_contents(""); + 73 fout << Trace_stream->readable_contents(""); 74 fout.close(); 75 } 76 exit(0); @@ -325,7 +325,7 @@ if ('onhashchange' in window) { 262 :(code) 263 bool operator<(const set<tag_condition_info>& a, const set<tag_condition_info>& b) { 264 if (a.size() != b.size()) return a.size() < b.size(); - 265 for (set<tag_condition_info>::const_iterator pa = a.begin(), pb = b.begin(); pa != a.end(); ++pa, ++pb) { + 265 for (set<tag_condition_info>::const_iterator pa = a.begin(), pb = b.begin(); pa != a.end(); ++pa, ++pb) { 266 if (pa->offset != pb->offset) return pa->offset < pb->offset; 267 if (pa->tag != pb->tag) return pa->tag < pb->tag; 268 } @@ -338,7 +338,7 @@ if ('onhashchange' in window) { 275 } 276 bool operator<(const set<address_element_info>& a, const set<address_element_info>& b) { 277 if (a.size() != b.size()) return a.size() < b.size(); - 278 for (set<address_element_info>::const_iterator pa = a.begin(), pb = b.begin(); pa != a.end(); ++pa, ++pb) { + 278 for (set<address_element_info>::const_iterator pa = a.begin(), pb = b.begin(); pa != a.end(); ++pa, ++pb) { 279 if (pa->offset != pb->offset) return pa->offset < pb->offset; 280 } 281 return false; // equal @@ -356,10 +356,10 @@ if ('onhashchange' in window) { 293 :(code) 294 void compute_container_address_offsets(const recipe_ordinal r) { 295 recipe& caller = get(Recipe, r); - 296 trace(9992, "transform") << "--- compute address offsets for " << caller.name << end(); + 296 trace(9992, "transform") << "--- compute address offsets for " << caller.name << end(); 297 for (int i = 0; i < SIZE(caller.steps); ++i) { 298 instruction& inst = caller.steps.at(i); - 299 trace(9993, "transform") << "- compute address offsets for " << to_string(inst) << end(); + 299 trace(9993, "transform") << "- compute address offsets for " << to_string(inst) << end(); 300 for (int i = 0; i < SIZE(inst.ingredients); ++i) 301 compute_container_address_offsets(inst.ingredients.at(i), " in '"+to_original_string(inst)+"'"); 302 for (int i = 0; i < SIZE(inst.products); ++i) @@ -380,7 +380,7 @@ if ('onhashchange' in window) { 317 if (!type) return; 318 if (!type->atom) { 319 if (!type->left->atom) { - 320 raise << "invalid type " << to_string(type) << location_for_error_messages << '\n' << end(); + 320 raise << "invalid type " << to_string(type) << location_for_error_messages << '\n' << end(); 321 return; 322 } 323 if (type->left->name == "address") @@ -404,13 +404,13 @@ if ('onhashchange' in window) { 341 void compute_container_address_offsets(const type_info& container_info, const type_tree* full_type, const string& location_for_error_messages) { 342 container_metadata& metadata = get(Container_metadata, full_type); 343 if (!metadata.address.empty()) return; - 344 trace(9994, "transform") << "compute address offsets for container " << container_info.name << end(); + 344 trace(9994, "transform") << "compute address offsets for container " << container_info.name << end(); 345 append_addresses(0, full_type, metadata.address, set<tag_condition_info>(), location_for_error_messages); 346 } 347 348 void compute_exclusive_container_address_offsets(const type_info& exclusive_container_info, const type_tree* full_type, const string& location_for_error_messages) { 349 container_metadata& metadata = get(Container_metadata, full_type); - 350 trace(9994, "transform") << "compute address offsets for exclusive container " << exclusive_container_info.name << end(); + 350 trace(9994, "transform") << "compute address offsets for exclusive container " << exclusive_container_info.name << end(); 351 for (int tag = 0; tag < SIZE(exclusive_container_info.elements); ++tag) { 352 set<tag_condition_info> key; 353 key.insert(tag_condition_info(/*tag is at offset*/0, tag)); @@ -428,11 +428,11 @@ if ('onhashchange' in window) { 365 const type_info& info = get(Type, base_type->value); 366 if (info.kind == CONTAINER) { 367 for (int curr_index = 0, curr_offset = base_offset; curr_index < SIZE(info.elements); ++curr_index) { - 368 trace(9993, "transform") << "checking container " << base_type->name << ", element " << curr_index << end(); + 368 trace(9993, "transform") << "checking container " << base_type->name << ", element " << curr_index << end(); 369 reagent/*copy*/ element = element_type(type, curr_index); // not base_type 370 // Compute Container Address Offset(element) 371 if (is_mu_address(element)) { - 372 trace(9993, "transform") << "address at offset " << curr_offset << end(); + 372 trace(9993, "transform") << "address at offset " << curr_offset << end(); 373 get_or_insert(out, key).insert(address_element_info(curr_offset, new type_tree(*payload_type(element.type)))); 374 ++curr_offset; 375 } @@ -757,26 +757,26 @@ if ('onhashchange' in window) { 694 :(before "End Increment Refcounts(canonized_x)") 695 if (is_mu_container(canonized_x) || is_mu_exclusive_container(canonized_x)) { 696 const container_metadata& metadata = get(Container_metadata, canonized_x.type); - 697 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { + 697 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { 698 if (!all_match(data, p->first)) continue; - 699 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) + 699 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) 700 increment_refcount(data.at(info->offset)); 701 } 702 } 703 704 :(before "End Decrement Refcounts(canonized_x)") 705 if (is_mu_container(canonized_x) || is_mu_exclusive_container(canonized_x)) { - 706 trace(9999, "mem") << "need to read old value of '" << to_string(canonized_x) << "' to figure out what refcounts to decrement" << end(); + 706 trace(9999, "mem") << "need to read old value of '" << to_string(canonized_x) << "' to figure out what refcounts to decrement" << end(); 707 // read from canonized_x but without canonizing again 708 // todo: inline without running canonize all over again 709 reagent/*copy*/ tmp = canonized_x; 710 tmp.properties.push_back(pair<string, string_tree*>("raw", NULL)); 711 vector<double> data = read_memory(tmp); - 712 trace(9999, "mem") << "done reading old value of '" << to_string(canonized_x) << "'" << end(); + 712 trace(9999, "mem") << "done reading old value of '" << to_string(canonized_x) << "'" << end(); 713 const container_metadata& metadata = get(Container_metadata, canonized_x.type); - 714 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { + 714 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { 715 if (!all_match(data, p->first)) continue; - 716 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { + 716 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { 717 int element_address = get_or_insert(Memory, canonized_x.value + info->offset); 718 reagent/*local*/ element; 719 element.set_value(element_address+/*skip refcount*/1); @@ -788,7 +788,7 @@ if ('onhashchange' in window) { 725 726 :(code) 727 bool all_match(const vector<double>& data, const set<tag_condition_info>& conditions) { - 728 for (set<tag_condition_info>::const_iterator p = conditions.begin(); p != conditions.end(); ++p) { + 728 for (set<tag_condition_info>::const_iterator p = conditions.begin(); p != conditions.end(); ++p) { 729 if (data.at(p->offset) != p->tag) 730 return false; 731 } diff --git a/html/037abandon.cc.html b/html/037abandon.cc.html index 93cd0015..c686c4cc 100644 --- a/html/037abandon.cc.html +++ b/html/037abandon.cc.html @@ -78,7 +78,7 @@ if ('onhashchange' in window) { 15 16 :(before "End Decrement Refcount(old_address, payload_type, payload_size)") 17 if (old_refcount == 0) { - 18 trace(9999, "mem") << "automatically abandoning " << old_address << end(); + 18 trace(9999, "mem") << "automatically abandoning " << old_address << end(); 19 abandon(old_address, payload_type, payload_size); 20 } 21 @@ -89,7 +89,7 @@ if ('onhashchange' in window) { 26 27 :(code) 28 void abandon(int address, const type_tree* payload_type, int payload_size) { - 29 trace(9999, "abandon") << "updating refcounts inside " << address << ": " << to_string(payload_type) << end(); + 29 trace(9999, "abandon") << "updating refcounts inside " << address << ": " << to_string(payload_type) << end(); 30 //? Total_free += size; 31 //? ++Num_free; 32 //? cerr << "abandon: " << size << '\n'; @@ -115,21 +115,21 @@ if ('onhashchange' in window) { 52 for (int curr = address; curr < address+payload_size; ++curr) 53 put(Memory, curr, 0); 54 // append existing free list to address - 55 trace(9999, "abandon") << "saving " << address << " in free-list of size " << payload_size << end(); + 55 trace(9999, "abandon") << "saving " << address << " in free-list of size " << payload_size << end(); 56 put(Memory, address, get_or_insert(Current_routine->free_list, payload_size)); 57 put(Current_routine->free_list, payload_size, address); 58 } 59 60 :(after "Allocate Special-cases") 61 if (get_or_insert(Current_routine->free_list, size)) { - 62 trace(9999, "abandon") << "picking up space from free-list of size " << size << end(); + 62 trace(9999, "abandon") << "picking up space from free-list of size " << size << end(); 63 int result = get_or_insert(Current_routine->free_list, size); - 64 trace(9999, "mem") << "new alloc from free list: " << result << end(); + 64 trace(9999, "mem") << "new alloc from free list: " << result << end(); 65 put(Current_routine->free_list, size, get_or_insert(Memory, result)); 66 put(Memory, result, 0); 67 for (int curr = result; curr < result+size; ++curr) { 68 if (get_or_insert(Memory, curr) != 0) { - 69 raise << maybe(current_recipe_name()) << "memory in free list was not zeroed out: " << curr << '/' << result << "; somebody wrote to us after free!!!\n" << end(); + 69 raise << maybe(current_recipe_name()) << "memory in free list was not zeroed out: " << curr << '/' << result << "; somebody wrote to us after free!!!\n" << end(); 70 break; // always fatal 71 } 72 } diff --git a/html/038new_text.cc.html b/html/038new_text.cc.html index 6c16b620..53a0e19c 100644 --- a/html/038new_text.cc.html +++ b/html/038new_text.cc.html @@ -93,7 +93,7 @@ if ('onhashchange' in window) { 30 if (is_literal_text(current_instruction().ingredients.at(0))) { 31 products.resize(1); 32 products.at(0).push_back(new_mu_text(current_instruction().ingredients.at(0).name)); - 33 trace(9999, "mem") << "new string alloc: " << products.at(0).at(0) << end(); + 33 trace(9999, "mem") << "new string alloc: " << products.at(0).at(0) << end(); 34 break; 35 } 36 @@ -104,10 +104,10 @@ if ('onhashchange' in window) { 41 //? Total_alloc += string_length+1; 42 //? ++Num_alloc; 43 int result = allocate(string_length+/*array length*/1); - 44 trace(9999, "mem") << "storing string refcount 0 in location " << result << end(); + 44 trace(9999, "mem") << "storing string refcount 0 in location " << result << end(); 45 put(Memory, result, 0); 46 int curr_address = result+/*skip refcount*/1; - 47 trace(9999, "mem") << "storing string length " << string_length << " in location " << curr_address << end(); + 47 trace(9999, "mem") << "storing string length " << string_length << " in location " << curr_address << end(); 48 put(Memory, curr_address, string_length); 49 ++curr_address; // skip length 50 int curr = 0; @@ -116,7 +116,7 @@ if ('onhashchange' in window) { 53 uint32_t curr_character; 54 assert(curr < SIZE(contents)); 55 tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]); - 56 trace(9999, "mem") << "storing string character " << curr_character << " in location " << curr_address << end(); + 56 trace(9999, "mem") << "storing string character " << curr_character << " in location " << curr_address << end(); 57 put(Memory, curr_address, curr_character); 58 curr += tb_utf8_char_length(raw_contents[curr]); 59 ++curr_address; @@ -233,15 +233,15 @@ if ('onhashchange' in window) { 170 :(before "End Primitive Recipe Checks") 171 case ASSERT: { 172 if (SIZE(inst.ingredients) != 2) { -173 raise << maybe(get(Recipe, r).name) << "'assert' takes exactly two ingredients rather than '" << inst.original_string << "'\n" << end(); +173 raise << maybe(get(Recipe, r).name) << "'assert' takes exactly two ingredients rather than '" << inst.original_string << "'\n" << end(); 174 break; 175 } 176 if (!is_mu_scalar(inst.ingredients.at(0))) { -177 raise << maybe(get(Recipe, r).name) << "'assert' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +177 raise << maybe(get(Recipe, r).name) << "'assert' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 178 break; 179 } 180 if (!is_literal_text(inst.ingredients.at(1)) && !is_mu_text(inst.ingredients.at(1))) { -181 raise << maybe(get(Recipe, r).name) << "'assert' requires a text as its second ingredient, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +181 raise << maybe(get(Recipe, r).name) << "'assert' requires a text as its second ingredient, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 182 break; 183 } 184 break; @@ -250,9 +250,9 @@ if ('onhashchange' in window) { 187 case ASSERT: { 188 if (!ingredients.at(0).at(0)) { 189 if (is_literal_text(current_instruction().ingredients.at(1))) -190 raise << current_instruction().ingredients.at(1).name << '\n' << end(); +190 raise << current_instruction().ingredients.at(1).name << '\n' << end(); 191 else -192 raise << read_mu_text(ingredients.at(1).at(0)) << '\n' << end(); +192 raise << read_mu_text(ingredients.at(1).at(0)) << '\n' << end(); 193 } 194 break; 195 } diff --git a/html/039location_array.cc.html b/html/039location_array.cc.html index 3f019c07..eb39d030 100644 --- a/html/039location_array.cc.html +++ b/html/039location_array.cc.html @@ -64,7 +64,7 @@ if ('onhashchange' in window) { 6 case TO_LOCATION_ARRAY: { 7 const recipe& caller = get(Recipe, r); 8 if (!is_address_of_array_of_numbers(inst.products.at(0))) { - 9 raise << maybe(caller.name) << "product of 'to-location-array' has incorrect type: '" << inst.original_string << "'\n" << end(); + 9 raise << maybe(caller.name) << "product of 'to-location-array' has incorrect type: '" << inst.original_string << "'\n" << end(); 10 break; 11 } 12 break; diff --git a/html/040brace.cc.html b/html/040brace.cc.html index 1964ef2e..2a1e286a 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -100,15 +100,15 @@ if ('onhashchange' in window) { 39 const int OPEN = 0, CLOSE = 1; 40 // use signed integer for step index because we'll be doing arithmetic on it 41 list<pair<int/*OPEN/CLOSE*/, /*step*/int> > braces; - 42 trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end(); + 42 trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end(); 43 for (int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { 44 const instruction& inst = get(Recipe, r).steps.at(index); 45 if (inst.label == "{") { - 46 trace(9993, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end(); + 46 trace(9993, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end(); 47 braces.push_back(pair<int,int>(OPEN, index)); 48 } 49 if (inst.label == "}") { - 50 trace(9993, "transform") << "push (close, " << index << ")" << end(); + 50 trace(9993, "transform") << "push (close, " << index << ")" << end(); 51 braces.push_back(pair<int,int>(CLOSE, index)); 52 } 53 } @@ -121,7 +121,7 @@ if ('onhashchange' in window) { 60 } 61 if (inst.label == "}") { 62 if (open_braces.empty()) { - 63 raise << "missing '{' in '" << get(Recipe, r).name << "'\n" << end(); + 63 raise << "missing '{' in '" << get(Recipe, r).name << "'\n" << end(); 64 return; 65 } 66 open_braces.pop(); @@ -134,13 +134,13 @@ if ('onhashchange' in window) { 73 && inst.name != "break" 74 && inst.name != "break-if" 75 && inst.name != "break-unless") { - 76 trace(9992, "transform") << inst.name << " ..." << end(); + 76 trace(9992, "transform") << inst.name << " ..." << end(); 77 continue; 78 } 79 // check for errors 80 if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { 81 if (inst.ingredients.empty()) { - 82 raise << "'" << inst.name << "' expects 1 or 2 ingredients, but got none\n" << end(); + 82 raise << "'" << inst.name << "' expects 1 or 2 ingredients, but got none\n" << end(); 83 continue; 84 } 85 } @@ -162,14 +162,14 @@ if ('onhashchange' in window) { 101 if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { 102 // conditional branches check arg 1 103 if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { -104 trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(1).name << ":offset" << end(); +104 trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(1).name << ":offset" << end(); 105 continue; 106 } 107 } 108 else { 109 // unconditional branches check arg 0 110 if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) { -111 trace(9992, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end(); +111 trace(9992, "transform") << "jump " << inst.ingredients.at(0).name << ":offset" << end(); 112 continue; 113 } 114 } @@ -178,7 +178,7 @@ if ('onhashchange' in window) { 117 target.type = new type_tree("offset"); 118 target.set_value(0); 119 if (open_braces.empty()) -120 raise << "'" << old_name << "' needs a '{' before\n" << end(); +120 raise << "'" << old_name << "' needs a '{' before\n" << end(); 121 else if (old_name.find("loop") != string::npos) 122 target.set_value(open_braces.top()-index); 123 else // break instruction @@ -186,9 +186,9 @@ if ('onhashchange' in window) { 125 inst.ingredients.push_back(target); 126 // log computed target 127 if (inst.name == "jump") -128 trace(9992, "transform") << "jump " << no_scientific(target.value) << ":offset" << end(); +128 trace(9992, "transform") << "jump " << no_scientific(target.value) << ":offset" << end(); 129 else -130 trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); +130 trace(9992, "transform") << inst.name << ' ' << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); 131 } 132 } 133 @@ -196,12 +196,12 @@ if ('onhashchange' in window) { 135 // enable future signed arithmetic 136 int matching_brace(int index, const list<pair<int, int> >& braces, recipe_ordinal r) { 137 int stacksize = 0; -138 for (list<pair<int, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { +138 for (list<pair<int, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { 139 if (p->second < index) continue; 140 stacksize += (p->first ? 1 : -1); 141 if (stacksize == 0) return p->second; 142 } -143 raise << maybe(get(Recipe, r).name) << "unbalanced '{'\n" << end(); +143 raise << maybe(get(Recipe, r).name) << "unbalanced '{'\n" << end(); 144 return SIZE(get(Recipe, r).steps); // exit current routine 145 } 146 @@ -458,7 +458,7 @@ if ('onhashchange' in window) { 397 curr.clear(); 398 } 399 else { -400 raise << "'" << curr.name << "' never yields any products\n" << end(); +400 raise << "'" << curr.name << "' never yields any products\n" << end(); 401 } 402 } 403 // rewrite `return-unless a, b, c, ...` to @@ -474,7 +474,7 @@ if ('onhashchange' in window) { 413 curr.clear(); 414 } 415 else { -416 raise << "'" << curr.name << "' never yields any products\n" << end(); +416 raise << "'" << curr.name << "' never yields any products\n" << end(); 417 } 418 } 419 @@ -483,7 +483,7 @@ if ('onhashchange' in window) { 422 const vector<reagent>& ingredients = inst.ingredients; 423 reagent/*copy*/ condition = ingredients.at(0); 424 vector<reagent> return_ingredients; -425 copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end())); +425 copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end())); 426 427 // { 428 instruction open_label; open_label.is_label=true; open_label.label = "{"; diff --git a/html/041jump_target.cc.html b/html/041jump_target.cc.html index 3194ffd4..12da93a5 100644 --- a/html/041jump_target.cc.html +++ b/html/041jump_target.cc.html @@ -101,7 +101,7 @@ if ('onhashchange' in window) { 39 put(offset, inst.label, i); 40 } 41 else { - 42 raise << maybe(get(Recipe, r).name) << "duplicate label '" << inst.label << "'" << end(); + 42 raise << maybe(get(Recipe, r).name) << "duplicate label '" << inst.label << "'" << end(); 43 // have all jumps skip some random but noticeable and deterministic amount of code 44 put(offset, inst.label, 9999); 45 } @@ -111,14 +111,14 @@ if ('onhashchange' in window) { 49 instruction& inst = get(Recipe, r).steps.at(i); 50 if (inst.name == "jump") { 51 if (inst.ingredients.empty()) { - 52 raise << maybe(get(Recipe, r).name) << "'jump' expects an ingredient but got none\n" << end(); + 52 raise << maybe(get(Recipe, r).name) << "'jump' expects an ingredient but got none\n" << end(); 53 return; 54 } 55 replace_offset(inst.ingredients.at(0), offset, i, r); 56 } 57 if (inst.name == "jump-if" || inst.name == "jump-unless") { 58 if (SIZE(inst.ingredients) < 2) { - 59 raise << maybe(get(Recipe, r).name) << "'" << inst.name << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end(); + 59 raise << maybe(get(Recipe, r).name) << "'" << inst.name << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end(); 60 return; 61 } 62 replace_offset(inst.ingredients.at(1), offset, i, r); @@ -137,19 +137,19 @@ if ('onhashchange' in window) { 75 76 void replace_offset(reagent& x, /*const*/ map<string, int>& offset, const int current_offset, const recipe_ordinal r) { 77 if (!is_literal(x)) { - 78 raise << maybe(get(Recipe, r).name) << "jump target must be offset or label but is '" << x.original_string << "'\n" << end(); + 78 raise << maybe(get(Recipe, r).name) << "jump target must be offset or label but is '" << x.original_string << "'\n" << end(); 79 x.set_value(0); // no jump by default 80 return; 81 } 82 if (x.initialized) return; 83 if (is_integer(x.name)) return; // non-labels will be handled like other number operands 84 if (!is_jump_target(x.name)) { - 85 raise << maybe(get(Recipe, r).name) << "can't jump to label '" << x.name << "'\n" << end(); + 85 raise << maybe(get(Recipe, r).name) << "can't jump to label '" << x.name << "'\n" << end(); 86 x.set_value(0); // no jump by default 87 return; 88 } 89 if (!contains_key(offset, x.name)) { - 90 raise << maybe(get(Recipe, r).name) << "can't find label '" << x.name << "'\n" << end(); + 90 raise << maybe(get(Recipe, r).name) << "can't find label '" << x.name << "'\n" << end(); 91 x.set_value(0); // no jump by default 92 return; 93 } diff --git a/html/042name.cc.html b/html/042name.cc.html index f5e7e4b9..9082f8a8 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -99,7 +99,7 @@ if ('onhashchange' in window) { 36 :(code) 37 void transform_names(const recipe_ordinal r) { 38 recipe& caller = get(Recipe, r); - 39 trace(9991, "transform") << "--- transform names for recipe " << caller.name << end(); + 39 trace(9991, "transform") << "--- transform names for recipe " << caller.name << end(); 40 bool names_used = false; 41 bool numeric_locations_used = false; 42 map<string, int>& names = Name[r]; @@ -118,7 +118,7 @@ if ('onhashchange' in window) { 55 if (is_named_location(ingredient)) names_used = true; 56 if (is_integer(ingredient.name)) continue; 57 if (!already_transformed(ingredient, names)) { - 58 raise << maybe(caller.name) << "tried to read ingredient '" << ingredient.name << "' in '" << to_original_string(inst) << "' but it hasn't been written to yet\n" << end(); + 58 raise << maybe(caller.name) << "tried to read ingredient '" << ingredient.name << "' in '" << to_original_string(inst) << "' but it hasn't been written to yet\n" << end(); 59 // use-before-set Error 60 return; 61 } @@ -128,7 +128,7 @@ if ('onhashchange' in window) { 65 // Done Placing Ingredient(ingredient, inst, caller) 66 } 67 else { - 68 raise << maybe(caller.name) << "can't find a place to store '" << ingredient.name << "'\n" << end(); + 68 raise << maybe(caller.name) << "can't find a place to store '" << ingredient.name << "'\n" << end(); 69 return; 70 } 71 } @@ -139,8 +139,8 @@ if ('onhashchange' in window) { 76 if (is_numeric_location(product)) numeric_locations_used = true; 77 if (is_named_location(product)) names_used = true; 78 if (is_integer(product.name)) continue; - 79 if (names.find(product.name) == names.end()) { - 80 trace(9993, "name") << "assign " << product.name << " " << curr_idx << end(); + 79 if (names.find(product.name) == names.end()) { + 80 trace(9993, "name") << "assign " << product.name << " " << curr_idx << end(); 81 names[product.name] = curr_idx; 82 curr_idx += size_of(product); 83 } @@ -150,18 +150,18 @@ if ('onhashchange' in window) { 87 // Done Placing Product(product, inst, caller) 88 } 89 else { - 90 raise << maybe(caller.name) << "can't find a place to store '" << product.name << "'\n" << end(); + 90 raise << maybe(caller.name) << "can't find a place to store '" << product.name << "'\n" << end(); 91 return; 92 } 93 } 94 } 95 if (names_used && numeric_locations_used) - 96 raise << maybe(caller.name) << "mixing variable names and numeric addresses\n" << end(); + 96 raise << maybe(caller.name) << "mixing variable names and numeric addresses\n" << end(); 97 } 98 99 bool is_disqualified(/*mutable*/ reagent& x, const instruction& inst, const string& recipe_name) { 100 if (!x.type) { -101 raise << maybe(recipe_name) << "missing type for '" << x.original_string << "' in '" << inst.original_string << "'\n" << end(); +101 raise << maybe(recipe_name) << "missing type for '" << x.original_string << "' in '" << inst.original_string << "'\n" << end(); 102 // missing-type Error 1 103 return true; 104 } @@ -197,7 +197,7 @@ if ('onhashchange' in window) { 134 const type_info& container = get(Type, t); 135 for (int i = 0; i < SIZE(container.elements); ++i) 136 if (container.elements.at(i).name == name) return i; -137 raise << maybe(recipe_name) << "unknown element '" << name << "' in container '" << get(Type, t).name << "'\n" << end(); +137 raise << maybe(recipe_name) << "unknown element '" << name << "' in container '" << get(Type, t).name << "'\n" << end(); 138 return -1; 139 } 140 @@ -295,7 +295,7 @@ if ('onhashchange' in window) { 232 :(before "End update GET offset_value in Check") 233 else { 234 if (!offset.initialized) { -235 raise << maybe(get(Recipe, r).name) << "uninitialized offset '" << offset.name << "' in '" << to_original_string(inst) << "'\n" << end(); +235 raise << maybe(get(Recipe, r).name) << "uninitialized offset '" << offset.name << "' in '" << to_original_string(inst) << "'\n" << end(); 236 break; 237 } 238 offset_value = offset.value; @@ -325,7 +325,7 @@ if ('onhashchange' in window) { 262 type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); 263 if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere 264 inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); -265 trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); +265 trace(9993, "name") << "element " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " is at offset " << no_scientific(inst.ingredients.at(1).value) << end(); 266 } 267 } 268 } @@ -366,7 +366,7 @@ if ('onhashchange' in window) { 303 // convert variant names of exclusive containers 304 if (inst.name == "maybe-convert") { 305 if (SIZE(inst.ingredients) != 2) { -306 raise << maybe(get(Recipe, r).name) << "exactly 2 ingredients expected in '" << inst.original_string << "'\n" << end(); +306 raise << maybe(get(Recipe, r).name) << "exactly 2 ingredients expected in '" << inst.original_string << "'\n" << end(); 307 break; 308 } 309 assert(is_literal(inst.ingredients.at(1))); @@ -375,7 +375,7 @@ if ('onhashchange' in window) { 312 type_ordinal base_type = skip_addresses(inst.ingredients.at(0).type); 313 if (contains_key(Type, base_type)) { // otherwise we'll raise an error elsewhere 314 inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name, get(Recipe, r).name)); -315 trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); +315 trace(9993, "name") << "variant " << inst.ingredients.at(1).name << " of type " << get(Type, base_type).name << " has tag " << no_scientific(inst.ingredients.at(1).value) << end(); 316 } 317 } 318 } diff --git a/html/043space.cc.html b/html/043space.cc.html index 657bfe46..a73959b0 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -126,7 +126,7 @@ if ('onhashchange' in window) { 62 if (is_raw(x) || is_dummy(x)) return; 63 if (x.name == "default-space") return; 64 if (!x.initialized) - 65 raise << to_original_string(current_instruction()) << ": reagent not initialized: '" << x.original_string << "'\n" << end(); + 65 raise << to_original_string(current_instruction()) << ": reagent not initialized: '" << x.original_string << "'\n" << end(); 66 x.set_value(address(x.value, space_base(x))); 67 x.properties.push_back(pair<string, string_tree*>("raw", NULL)); 68 assert(is_raw(x)); @@ -143,7 +143,7 @@ if ('onhashchange' in window) { 79 int size = get_or_insert(Memory, base); 80 if (offset >= size) { 81 // todo: test - 82 raise << "location " << offset << " is out of bounds " << size << " at " << base << '\n' << end(); + 82 raise << "location " << offset << " is out of bounds " << size << " at " << base << '\n' << end(); 83 return 0; 84 } 85 return base + /*skip length*/1 + offset; @@ -154,7 +154,7 @@ if ('onhashchange' in window) { 90 :(after "Begin Preprocess write_memory(x, data)") 91 if (x.name == "default-space") { 92 if (!scalar(data) || !is_space(x)) - 93 raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but is " << to_string(x.type) << '\n' << end(); + 93 raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but is " << to_string(x.type) << '\n' << end(); 94 current_call().default_space = data.at(0); 95 return; 96 } @@ -248,12 +248,12 @@ if ('onhashchange' in window) { 184 vector<double> result; 185 result.push_back(Name[get(Recipe_ordinal, current_recipe_name())][""]); 186 if (result.back() == 0) -187 raise << "no space allocated for default-space in recipe " << current_recipe_name() << "; are you using names?\n" << end(); +187 raise << "no space allocated for default-space in recipe " << current_recipe_name() << "; are you using names?\n" << end(); 188 return result; 189 } 190 :(after "Begin Preprocess write_memory(x, data)") 191 if (x.name == "number-of-locals") { -192 raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end(); +192 raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end(); 193 return; 194 } 195 @@ -311,12 +311,12 @@ if ('onhashchange' in window) { 247 if (has_property(product, "raw")) continue; // tests often want to check such locations after they run 248 if (escaping(product)) continue; 249 // End Checks For Reclaiming Locals -250 trace(9999, "mem") << "clearing " << product.original_string << end(); +250 trace(9999, "mem") << "clearing " << product.original_string << end(); 251 zeros.resize(size_of(product)); 252 write_memory(product, zeros); 253 } 254 } -255 trace(9999, "mem") << "automatically abandoning " << current_call().default_space << end(); +255 trace(9999, "mem") << "automatically abandoning " << current_call().default_space << end(); 256 abandon(current_call().default_space, 257 inst.products.at(0).type->right, 258 /*refcount*/1 + /*array length*/1 + /*number-of-locals*/Name[r][""]); @@ -377,12 +377,12 @@ if ('onhashchange' in window) { 313 314 void rewrite_default_space_instruction(instruction& curr) { 315 if (!curr.ingredients.empty()) -316 raise << to_original_string(curr) << " can't take any ingredients\n" << end(); +316 raise << to_original_string(curr) << " can't take any ingredients\n" << end(); 317 curr.name = "new"; 318 curr.ingredients.push_back(reagent("location:type")); 319 curr.ingredients.push_back(reagent("number-of-locals:literal")); 320 if (!curr.products.empty()) -321 raise << "new-default-space can't take any results\n" << end(); +321 raise << "new-default-space can't take any results\n" << end(); 322 curr.products.push_back(reagent("default-space:space")); 323 } 324 @@ -466,11 +466,11 @@ if ('onhashchange' in window) { 402 // End check_default_space Special-cases 403 // assume recipes with only numeric addresses know what they're doing (usually tests) 404 if (!contains_non_special_name(r)) return; -405 trace(9991, "transform") << "--- check that recipe " << caller.name << " sets default-space" << end(); +405 trace(9991, "transform") << "--- check that recipe " << caller.name << " sets default-space" << end(); 406 if (caller.steps.empty()) return; 407 if (caller.steps.at(0).products.empty() 408 || caller.steps.at(0).products.at(0).name != "default-space") { -409 raise << caller.name << " does not seem to start with default-space or local-scope\n" << end(); +409 raise << caller.name << " does not seem to start with default-space or local-scope\n" << end(); 410 } 411 } 412 :(after "Load Mu Prelude") @@ -482,7 +482,7 @@ if ('onhashchange' in window) { 418 419 :(code) 420 bool contains_non_special_name(const recipe_ordinal r) { -421 for (map<string, int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { +421 for (map<string, int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) { 422 if (p->first.empty()) continue; 423 if (p->first.find("stash_") == 0) continue; // generated by rewrite_stashes_to_text (cross-layer) 424 if (!is_special_name(p->first)) diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index 4b8b8d0a..1d951dce 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -114,7 +114,7 @@ if ('onhashchange' in window) { 53 for (int i = 0; i < SIZE(x.properties); ++i) { 54 if (x.properties.at(i).first == "space") { 55 if (!x.properties.at(i).second || x.properties.at(i).second->right) -56 raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in '" << x.original_string << "'\n" << end(); +56 raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in '" << x.original_string << "'\n" << end(); 57 return to_integer(x.properties.at(i).second->value); 58 } 59 } diff --git a/html/045closure_name.cc.html b/html/045closure_name.cc.html index 1e73dd3d..b54d3153 100644 --- a/html/045closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -98,7 +98,7 @@ if ('onhashchange' in window) { 37 38 :(code) 39 void collect_surrounding_spaces(const recipe_ordinal r) { - 40 trace(9991, "transform") << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << end(); + 40 trace(9991, "transform") << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << end(); 41 for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { 42 const instruction& inst = get(Recipe, r).steps.at(i); 43 if (inst.is_label) continue; @@ -106,28 +106,28 @@ if ('onhashchange' in window) { 45 if (is_literal(inst.products.at(j))) continue; 46 if (inst.products.at(j).name != "0") continue; 47 if (!is_space(inst.products.at(j))) { - 48 raise << "slot 0 should always have type address:array:location, but is '" << to_string(inst.products.at(j)) << "'\n" << end(); + 48 raise << "slot 0 should always have type address:array:location, but is '" << to_string(inst.products.at(j)) << "'\n" << end(); 49 continue; 50 } 51 string_tree* s = property(inst.products.at(j), "names"); 52 if (!s) { - 53 raise << "slot 0 requires a /names property in recipe '" << get(Recipe, r).name << "'\n" << end(); + 53 raise << "slot 0 requires a /names property in recipe '" << get(Recipe, r).name << "'\n" << end(); 54 continue; 55 } - 56 if (!s->atom) raise << "slot 0 should have a single value in /names, but got '" << to_string(inst.products.at(j)) << "'\n" << end(); + 56 if (!s->atom) raise << "slot 0 should have a single value in /names, but got '" << to_string(inst.products.at(j)) << "'\n" << end(); 57 const string& surrounding_recipe_name = s->value; 58 if (surrounding_recipe_name.empty()) { - 59 raise << "slot 0 doesn't initialize its /names property in recipe '" << get(Recipe, r).name << "'\n" << end(); + 59 raise << "slot 0 doesn't initialize its /names property in recipe '" << get(Recipe, r).name << "'\n" << end(); 60 continue; 61 } 62 if (contains_key(Surrounding_space, r) 63 && get(Surrounding_space, r) != get(Recipe_ordinal, surrounding_recipe_name)) { - 64 raise << "recipe '" << get(Recipe, r).name << "' can have only one 'surrounding' recipe but has '" << get(Recipe, get(Surrounding_space, r)).name << "' and '" << surrounding_recipe_name << "'\n" << end(); + 64 raise << "recipe '" << get(Recipe, r).name << "' can have only one 'surrounding' recipe but has '" << get(Recipe, get(Surrounding_space, r)).name << "' and '" << surrounding_recipe_name << "'\n" << end(); 65 continue; 66 } - 67 trace(9993, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end(); + 67 trace(9993, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end(); 68 if (!contains_key(Recipe_ordinal, surrounding_recipe_name)) { - 69 raise << "can't find recipe providing surrounding space for '" << get(Recipe, r).name << "'; looking for '" << surrounding_recipe_name << "'\n" << end(); + 69 raise << "can't find recipe providing surrounding space for '" << get(Recipe, r).name << "'; looking for '" << surrounding_recipe_name << "'\n" << end(); 70 continue; 71 } 72 put(Surrounding_space, r, get(Recipe_ordinal, surrounding_recipe_name)); @@ -141,11 +141,11 @@ if ('onhashchange' in window) { 80 :(replace{} "int lookup_name(const reagent& r, const recipe_ordinal default_recipe)") 81 int lookup_name(const reagent& x, const recipe_ordinal default_recipe) { 82 if (!has_property(x, "space")) { - 83 if (Name[default_recipe].empty()) raise << "name not found: " << x.name << '\n' << end(); + 83 if (Name[default_recipe].empty()) raise << "name not found: " << x.name << '\n' << end(); 84 return Name[default_recipe][x.name]; 85 } 86 string_tree* p = property(x, "space"); - 87 if (!p || !p->atom) raise << "/space property should have exactly one (non-negative integer) value\n" << end(); + 87 if (!p || !p->atom) raise << "/space property should have exactly one (non-negative integer) value\n" << end(); 88 int n = to_integer(p->value); 89 assert(n >= 0); 90 recipe_ordinal surrounding_recipe = lookup_surrounding_recipe(default_recipe, n); @@ -160,11 +160,11 @@ if ('onhashchange' in window) { 99 int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) { 100 if (!Name[r].empty()) return Name[r][x.name]; 101 if (contains_key(done, r)) { -102 raise << "can't compute address of '" << to_string(x) << "' because\n" << end(); +102 raise << "can't compute address of '" << to_string(x) << "' because\n" << end(); 103 for (int i = 1; i < SIZE(path); ++i) { -104 raise << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end(); +104 raise << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end(); 105 } -106 raise << path.at(SIZE(path)-1) << " requires computing names of " << r << "..ad infinitum\n" << end(); +106 raise << path.at(SIZE(path)-1) << " requires computing names of " << r << "..ad infinitum\n" << end(); 107 return -1; 108 } 109 done.insert(r); @@ -177,7 +177,7 @@ if ('onhashchange' in window) { 116 recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, int n) { 117 if (n == 0) return r; 118 if (!contains_key(Surrounding_space, r)) { -119 raise << "don't know surrounding recipe of '" << get(Recipe, r).name << "'\n" << end(); +119 raise << "don't know surrounding recipe of '" << get(Recipe, r).name << "'\n" << end(); 120 return -1; 121 } 122 assert(contains_key(Surrounding_space, r)); @@ -190,7 +190,7 @@ if ('onhashchange' in window) { 129 if (has_property(r, "space")) { 130 string_tree* p = property(r, "space"); 131 if (!p || !p->atom) { -132 raise << "/space property should have exactly one (non-negative integer) value in '" << r.original_string << "'\n" << end(); +132 raise << "/space property should have exactly one (non-negative integer) value in '" << r.original_string << "'\n" << end(); 133 return false; 134 } 135 if (p->value != "0") return true; diff --git a/html/046global.cc.html b/html/046global.cc.html index 5ca78f18..2c71bbfb 100644 --- a/html/046global.cc.html +++ b/html/046global.cc.html @@ -104,9 +104,9 @@ if ('onhashchange' in window) { 43 :(after "Begin Preprocess write_memory(x, data)") 44 if (x.name == "global-space") { 45 if (!scalar(data) || !is_space(x)) -46 raise << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write '" << to_string(x.type) << "'\n" << end(); +46 raise << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write '" << to_string(x.type) << "'\n" << end(); 47 if (Current_routine->global_space) -48 raise << "routine already has a global-space; you can't over-write your globals" << end(); +48 raise << "routine already has a global-space; you can't over-write your globals" << end(); 49 Current_routine->global_space = data.at(0); 50 return; 51 } @@ -115,7 +115,7 @@ if ('onhashchange' in window) { 54 :(after "int space_base(const reagent& x)") 55 if (is_global(x)) { 56 if (!Current_routine->global_space) -57 raise << "routine has no global space\n" << end(); +57 raise << "routine has no global space\n" << end(); 58 return Current_routine->global_space + /*skip refcount*/1; 59 } 60 diff --git a/html/047check_type_by_name.cc.html b/html/047check_type_by_name.cc.html index f5f58f32..c5c1f057 100644 --- a/html/047check_type_by_name.cc.html +++ b/html/047check_type_by_name.cc.html @@ -81,7 +81,7 @@ if ('onhashchange' in window) { 19 20 :(code) 21 void check_or_set_types_by_name(const recipe_ordinal r) { - 22 trace(9991, "transform") << "--- deduce types for recipe " << get(Recipe, r).name << end(); + 22 trace(9991, "transform") << "--- deduce types for recipe " << get(Recipe, r).name << end(); 23 recipe& caller = get(Recipe, r); 24 set<reagent> known; 25 for (int i = 0; i < SIZE(caller.steps); ++i) { @@ -103,9 +103,9 @@ if ('onhashchange' in window) { 41 x.type = new type_tree("label"); 42 return; 43 } - 44 if (known.find(x) == known.end()) return; + 44 if (known.find(x) == known.end()) return; 45 x.type = new type_tree(*known.find(x)->type); - 46 trace(9992, "transform") << x.name << " <= " << names_to_string(x.type) << end(); + 46 trace(9992, "transform") << x.name << " <= " << names_to_string(x.type) << end(); 47 } 48 49 void check_type(set<reagent>& known, const reagent& x, const recipe& caller) { @@ -114,24 +114,24 @@ if ('onhashchange' in window) { 52 if (!x.type) return; // might get filled in by other logic later 53 if (is_jump_target(x.name)) { 54 if (!x.type->atom || x.type->name != "label") - 55 raise << maybe(caller.name) << "non-label '" << x.name << "' must begin with a letter\n" << end(); + 55 raise << maybe(caller.name) << "non-label '" << x.name << "' must begin with a letter\n" << end(); 56 return; 57 } - 58 if (known.find(x) == known.end()) { - 59 trace(9992, "transform") << x.name << " => " << names_to_string(x.type) << end(); + 58 if (known.find(x) == known.end()) { + 59 trace(9992, "transform") << x.name << " => " << names_to_string(x.type) << end(); 60 known.insert(x); 61 } 62 if (!types_strictly_match(known.find(x)->type, x.type)) { - 63 raise << maybe(caller.name) << "'" << x.name << "' used with multiple types\n" << end(); + 63 raise << maybe(caller.name) << "'" << x.name << "' used with multiple types\n" << end(); 64 return; 65 } 66 if (is_mu_array(x)) { 67 if (!x.type->right) { - 68 raise << maybe(caller.name) << "'" << x.name << ": can't be just an array. What is it an array of?\n" << end(); + 68 raise << maybe(caller.name) << "'" << x.name << ": can't be just an array. What is it an array of?\n" << end(); 69 return; 70 } 71 if (!x.type->right->right) { - 72 raise << caller.name << " can't determine the size of array variable '" << x.name << "'. Either allocate it separately and make the type of '" << x.name << "' an address, or specify the length of the array in the type of '" << x.name << "'.\n" << end(); + 72 raise << caller.name << " can't determine the size of array variable '" << x.name << "'. Either allocate it separately and make the type of '" << x.name << "' an address, or specify the length of the array in the type of '" << x.name << "'.\n" << end(); 73 return; 74 } 75 } diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 43a9bd49..ac47b8a0 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -102,7 +102,7 @@ if ('onhashchange' in window) { 37 scenario foo [ 38 run [ 39 1:num <- copy 13 - 40 trace 1, [a], [a b c] + 40 trace 1, [a], [a b c] 41 ] 42 memory-should-contain [ 43 1 <- 13 @@ -157,16 +157,16 @@ if ('onhashchange' in window) { 92 scenario result; 93 result.name = next_word(in); 94 if (contains_key(Scenario_names, result.name)) - 95 raise << "duplicate scenario name: '" << result.name << "'\n" << end(); + 95 raise << "duplicate scenario name: '" << result.name << "'\n" << end(); 96 Scenario_names.insert(result.name); 97 if (result.name.empty()) { 98 assert(!has_data(in)); - 99 raise << "incomplete scenario at end of file\n" << end(); + 99 raise << "incomplete scenario at end of file\n" << end(); 100 return result; 101 } 102 skip_whitespace_and_comments(in); 103 if (in.peek() != '[') { -104 raise << "Expected '[' after scenario '" << result.name << "'\n" << end(); +104 raise << "Expected '[' after scenario '" << result.name << "'\n" << end(); 105 exit(0); 106 } 107 // scenarios are take special 'code' strings so we need to ignore brackets @@ -174,13 +174,13 @@ if ('onhashchange' in window) { 109 result.to_run = slurp_quoted(in); 110 // delete [] delimiters 111 if (!starts_with(result.to_run, "[")) { -112 raise << "scenario " << result.name << " should start with '['\n" << end(); +112 raise << "scenario " << result.name << " should start with '['\n" << end(); 113 result.clear(); 114 return result; 115 } 116 result.to_run.erase(0, 1); 117 if (result.to_run.at(SIZE(result.to_run)-1) != ']') { -118 raise << "scenario " << result.name << " has an unbalanced '['\n" << end(); +118 raise << "scenario " << result.name << " has an unbalanced '['\n" << end(); 119 result.clear(); 120 return result; 121 } @@ -291,13 +291,13 @@ if ('onhashchange' in window) { 226 if (!trace_contains_errors()) 227 run(tmp.front()); 228 // End Mu Test Teardown -229 if (!Hide_errors && trace_contains_errors() && !Scenario_testing_scenario) +229 if (!Hide_errors && trace_contains_errors() && !Scenario_testing_scenario) 230 Passed = false; 231 if (not_already_inside_test && Trace_stream) { 232 teardown(); 233 if (Save_trace) { 234 ofstream fout("last_trace"); -235 fout << Trace_stream->readable_contents(""); +235 fout << Trace_stream->readable_contents(""); 236 fout.close(); 237 } 238 delete Trace_stream; @@ -350,7 +350,7 @@ if ('onhashchange' in window) { 285 bind_special_scenario_names(tmp.at(0)); 286 transform_all(); 287 run(tmp.at(0)); -288 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); +288 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); 289 } 290 291 //: Watch out for redefinitions of scenario routines. We should never ever be @@ -467,7 +467,7 @@ if ('onhashchange' in window) { 402 string lhs = next_word(in); 403 if (lhs.empty()) { 404 assert(!has_data(in)); -405 raise << "incomplete 'memory-should-contain' block at end of file (0)\n" << end(); +405 raise << "incomplete 'memory-should-contain' block at end of file (0)\n" << end(); 406 return; 407 } 408 if (!is_integer(lhs)) { @@ -481,31 +481,31 @@ if ('onhashchange' in window) { 416 string rhs = next_word(in); 417 if (rhs.empty()) { 418 assert(!has_data(in)); -419 raise << "incomplete 'memory-should-contain' block at end of file (1)\n" << end(); +419 raise << "incomplete 'memory-should-contain' block at end of file (1)\n" << end(); 420 return; 421 } 422 if (!is_integer(rhs) && !is_noninteger(rhs)) { 423 if (Current_scenario && !Scenario_testing_scenario) 424 // genuine test in a .mu file -425 raise << "\nF - " << Current_scenario->name << ": location '" << address << "' can't contain non-number " << rhs << "\n" << end(); +425 raise << "\nF - " << Current_scenario->name << ": location '" << address << "' can't contain non-number " << rhs << "\n" << end(); 426 else 427 // just testing scenario support -428 raise << "location '" << address << "' can't contain non-number " << rhs << '\n' << end(); +428 raise << "location '" << address << "' can't contain non-number " << rhs << '\n' << end(); 429 if (!Scenario_testing_scenario) Passed = false; 430 return; 431 } 432 double value = to_double(rhs); 433 if (contains_key(locations_checked, address)) -434 raise << "duplicate expectation for location '" << address << "'\n" << end(); -435 trace(9999, "run") << "checking location " << address << end(); +434 raise << "duplicate expectation for location '" << address << "'\n" << end(); +435 trace(9999, "run") << "checking location " << address << end(); 436 if (get_or_insert(Memory, address) != value) { 437 if (Current_scenario && !Scenario_testing_scenario) { 438 // genuine test in a .mu file -439 raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); +439 raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); 440 } 441 else { 442 // just testing scenario support -443 raise << "expected location '" << address << "' to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); +443 raise << "expected location '" << address << "' to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); 444 } 445 if (!Scenario_testing_scenario) Passed = false; 446 return; @@ -522,7 +522,7 @@ if ('onhashchange' in window) { 457 string _assign = next_word(in); 458 if (_assign.empty()) { 459 assert(!has_data(in)); -460 raise << "incomplete 'memory-should-contain' block at end of file (2)\n" << end(); +460 raise << "incomplete 'memory-should-contain' block at end of file (2)\n" << end(); 461 return; 462 } 463 assert(_assign == "<-"); @@ -530,41 +530,41 @@ if ('onhashchange' in window) { 465 string literal = next_word(in); 466 if (literal.empty()) { 467 assert(!has_data(in)); -468 raise << "incomplete 'memory-should-contain' block at end of file (3)\n" << end(); +468 raise << "incomplete 'memory-should-contain' block at end of file (3)\n" << end(); 469 return; 470 } 471 int address = x.value; 472 // exclude quoting brackets 473 assert(*literal.begin() == '['); literal.erase(literal.begin()); -474 assert(*--literal.end() == ']'); literal.erase(--literal.end()); +474 assert(*--literal.end() == ']'); literal.erase(--literal.end()); 475 check_string(address, literal); 476 return; 477 } 478 // End Scenario Type Special-cases -479 raise << "don't know how to check memory for '" << lhs << "'\n" << end(); +479 raise << "don't know how to check memory for '" << lhs << "'\n" << end(); 480 } 481 482 void check_string(int address, const string& literal) { -483 trace(9999, "run") << "checking string length at " << address << end(); +483 trace(9999, "run") << "checking string length at " << address << end(); 484 if (get_or_insert(Memory, address) != SIZE(literal)) { 485 if (Current_scenario && !Scenario_testing_scenario) -486 raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << " (" << read_mu_text(address-/*fake refcount*/1) << ")\n" << end(); +486 raise << "\nF - " << Current_scenario->name << ": expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << " (" << read_mu_text(address-/*fake refcount*/1) << ")\n" << end(); 487 else -488 raise << "expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); +488 raise << "expected location '" << address << "' to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end(); 489 if (!Scenario_testing_scenario) Passed = false; 490 return; 491 } 492 ++address; // now skip length 493 for (int i = 0; i < SIZE(literal); ++i) { -494 trace(9999, "run") << "checking location " << address+i << end(); +494 trace(9999, "run") << "checking location " << address+i << end(); 495 if (get_or_insert(Memory, address+i) != literal.at(i)) { 496 if (Current_scenario && !Scenario_testing_scenario) { 497 // genuine test in a .mu file -498 raise << "\nF - " << Current_scenario->name << ": expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << " ('" << static_cast<char>(get_or_insert(Memory, address+i)) << "')\n" << end(); +498 raise << "\nF - " << Current_scenario->name << ": expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << " ('" << static_cast<char>(get_or_insert(Memory, address+i)) << "')\n" << end(); 499 } 500 else { 501 // just testing scenario support -502 raise << "expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << '\n' << end(); +502 raise << "expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << '\n' << end(); 503 } 504 if (!Scenario_testing_scenario) Passed = false; 505 return; @@ -647,7 +647,7 @@ if ('onhashchange' in window) { 582 a: d 583 ] 584 ] -585 +error: missing [b] in trace with label 'a' +585 +error: missing [b] in trace with label 'a' 586 587 :(before "End Primitive Recipe Declarations") 588 TRACE_SHOULD_CONTAIN, @@ -668,41 +668,41 @@ if ('onhashchange' in window) { 603 // simplified version of check_trace_contents() that emits errors rather 604 // than just printing to stderr 605 void check_trace(const string& expected) { -606 Trace_stream->newline(); +606 Trace_stream->newline(); 607 vector<trace_line> expected_lines = parse_trace(expected); 608 if (expected_lines.empty()) return; 609 int curr_expected_line = 0; -610 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +610 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 611 if (expected_lines.at(curr_expected_line).label != p->label) continue; -612 if (expected_lines.at(curr_expected_line).contents != trim(p->contents)) continue; +612 if (expected_lines.at(curr_expected_line).contents != trim(p->contents)) continue; 613 // match 614 ++curr_expected_line; 615 if (curr_expected_line == SIZE(expected_lines)) return; 616 } 617 if (Current_scenario && !Scenario_testing_scenario) -618 raise << "\nF - " << Current_scenario->name << ": missing [" << expected_lines.at(curr_expected_line).contents << "] " -619 << "in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end(); +618 raise << "\nF - " << Current_scenario->name << ": missing [" << expected_lines.at(curr_expected_line).contents << "] " +619 << "in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end(); 620 else -621 raise << "missing [" << expected_lines.at(curr_expected_line).contents << "] " -622 << "in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end(); +621 raise << "missing [" << expected_lines.at(curr_expected_line).contents << "] " +622 << "in trace with label '" << expected_lines.at(curr_expected_line).label << "'\n" << end(); 623 if (!Hide_errors) -624 DUMP(expected_lines.at(curr_expected_line).label); +624 DUMP(expected_lines.at(curr_expected_line).label); 625 if (!Scenario_testing_scenario) Passed = false; 626 } 627 628 vector<trace_line> parse_trace(const string& expected) { -629 vector<string> buf = split(expected, "\n"); +629 vector<string> buf = split(expected, "\n"); 630 vector<trace_line> result; 631 for (int i = 0; i < SIZE(buf); ++i) { -632 buf.at(i) = trim(buf.at(i)); +632 buf.at(i) = trim(buf.at(i)); 633 if (buf.at(i).empty()) continue; 634 int delim = buf.at(i).find(": "); 635 if (delim == -1) { -636 raise << Current_scenario->name << ": lines in 'trace-should-contain' should be of the form <label>: <contents>. Both parts are required.\n" << end(); +636 raise << Current_scenario->name << ": lines in 'trace-should-contain' should be of the form <label>: <contents>. Both parts are required.\n" << end(); 637 result.clear(); 638 return result; 639 } -640 result.push_back(trace_line(trim(buf.at(i).substr(0, delim)), trim(buf.at(i).substr(delim+2)))); +640 result.push_back(trace_line(trim(buf.at(i).substr(0, delim)), trim(buf.at(i).substr(delim+2)))); 641 } 642 return result; 643 } @@ -712,26 +712,26 @@ if ('onhashchange' in window) { 647 % Hide_errors = true; 648 def main [ 649 run [ -650 trace 1, [a], [b] +650 trace 1, [a], [b] 651 ] 652 trace-should-contain [ 653 a: b 654 a: d 655 ] 656 ] -657 +error: missing [d] in trace with label 'a' +657 +error: missing [d] in trace with label 'a' 658 659 :(scenario trace_check_passes_silently) 660 % Scenario_testing_scenario = true; 661 def main [ 662 run [ -663 trace 1, [a], [b] +663 trace 1, [a], [b] 664 ] 665 trace-should-contain [ 666 a: b 667 ] 668 ] -669 -error: missing [b] in trace with label 'a' +669 -error: missing [b] in trace with label 'a' 670 $error: 0 671 672 //: 'trace-should-not-contain' is like the '-' lines in our scenarios so far @@ -743,13 +743,13 @@ if ('onhashchange' in window) { 678 % Hide_errors = true; 679 def main [ 680 run [ -681 trace 1, [a], [b] +681 trace 1, [a], [b] 682 ] 683 trace-should-not-contain [ 684 a: b 685 ] 686 ] -687 +error: unexpected [b] in trace with label 'a' +687 +error: unexpected [b] in trace with label 'a' 688 689 :(before "End Primitive Recipe Declarations") 690 TRACE_SHOULD_NOT_CONTAIN, @@ -770,11 +770,11 @@ if ('onhashchange' in window) { 705 // simplified version of check_trace_contents() that emits errors rather 706 // than just printing to stderr 707 bool check_trace_missing(const string& in) { -708 Trace_stream->newline(); +708 Trace_stream->newline(); 709 vector<trace_line> lines = parse_trace(in); 710 for (int i = 0; i < SIZE(lines); ++i) { 711 if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) { -712 raise << "unexpected [" << lines.at(i).contents << "] in trace with label '" << lines.at(i).label << "'\n" << end(); +712 raise << "unexpected [" << lines.at(i).contents << "] in trace with label '" << lines.at(i).label << "'\n" << end(); 713 if (!Scenario_testing_scenario) Passed = false; 714 return false; 715 } @@ -789,7 +789,7 @@ if ('onhashchange' in window) { 724 a: b 725 ] 726 ] -727 -error: unexpected [b] in trace with label 'a' +727 -error: unexpected [b] in trace with label 'a' 728 $error: 0 729 730 :(scenario trace_negative_check_fails_on_any_unexpected_line) @@ -797,19 +797,19 @@ if ('onhashchange' in window) { 732 % Hide_errors = true; 733 def main [ 734 run [ -735 trace 1, [a], [d] +735 trace 1, [a], [d] 736 ] 737 trace-should-not-contain [ 738 a: b 739 a: d 740 ] 741 ] -742 +error: unexpected [d] in trace with label 'a' +742 +error: unexpected [d] in trace with label 'a' 743 744 :(scenario trace_count_check) 745 def main [ 746 run [ -747 trace 1, [a], [foo] +747 trace 1, [a], [foo] 748 ] 749 check-trace-count-for-label 1, [a] 750 ] @@ -822,15 +822,15 @@ if ('onhashchange' in window) { 757 :(before "End Primitive Recipe Checks") 758 case CHECK_TRACE_COUNT_FOR_LABEL: { 759 if (SIZE(inst.ingredients) != 2) { -760 raise << maybe(get(Recipe, r).name) << "'check-trace-count-for-label' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +760 raise << maybe(get(Recipe, r).name) << "'check-trace-count-for-label' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 761 break; 762 } 763 if (!is_mu_number(inst.ingredients.at(0))) { -764 raise << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-count-for-label' should be a number (count), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +764 raise << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-count-for-label' should be a number (count), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 765 break; 766 } 767 if (!is_literal_text(inst.ingredients.at(1))) { -768 raise << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-count-for-label' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +768 raise << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-count-for-label' should be a literal string (label), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 769 break; 770 } 771 break; @@ -844,12 +844,12 @@ if ('onhashchange' in window) { 779 if (count != expected_count) { 780 if (Current_scenario && !Scenario_testing_scenario) { 781 // genuine test in a .mu file -782 raise << "\nF - " << Current_scenario->name << ": " << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label '" << label << "' in trace: " << end(); -783 DUMP(label); +782 raise << "\nF - " << Current_scenario->name << ": " << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label '" << label << "' in trace: " << end(); +783 DUMP(label); 784 } 785 else { 786 // just testing scenario support -787 raise << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label '" << label << "' in trace\n" << end(); +787 raise << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label '" << label << "' in trace\n" << end(); 788 } 789 if (!Scenario_testing_scenario) Passed = false; 790 } @@ -861,11 +861,11 @@ if ('onhashchange' in window) { 796 % Hide_errors = true; 797 def main [ 798 run [ -799 trace 1, [a], [foo] +799 trace 1, [a], [foo] 800 ] 801 check-trace-count-for-label 2, [a] 802 ] -803 +error: main: expected 2 lines in trace with label 'a' in trace +803 +error: main: expected 2 lines in trace with label 'a' in trace 804 805 //: Minor detail: ignore 'system' calls in scenarios, since anything we do 806 //: with them is by definition impossible to test through Mu. @@ -890,11 +890,11 @@ if ('onhashchange' in window) { 825 } 826 827 :(after "void transform_all()") -828 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { +828 for (map<recipe_ordinal, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) { 829 const recipe& r = p->second; 830 if (r.name.find('_') == string::npos) continue; 831 if (r.is_autogenerated) continue; // created by previous call to transform_all() -832 raise << r.name << ": don't create recipes with '_' in the name\n" << end(); +832 raise << r.name << ": don't create recipes with '_' in the name\n" << end(); 833 } 834 835 //:: Helpers @@ -909,7 +909,7 @@ if ('onhashchange' in window) { 844 string _scenario = next_word(in); 845 if (_scenario.empty()) { 846 assert(!has_data(in)); -847 raise << "no scenario in string passed into run_mu_scenario()\n" << end(); +847 raise << "no scenario in string passed into run_mu_scenario()\n" << end(); 848 return; 849 } 850 assert(_scenario == "scenario"); diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html index 32289deb..2f67ef45 100644 --- a/html/052tangle.cc.html +++ b/html/052tangle.cc.html @@ -106,30 +106,30 @@ if ('onhashchange' in window) { 44 string label = next_word(in); 45 if (label.empty()) { 46 assert(!has_data(in)); - 47 raise << "incomplete 'before' block at end of file\n" << end(); + 47 raise << "incomplete 'before' block at end of file\n" << end(); 48 return result; 49 } 50 recipe tmp; 51 slurp_body(in, tmp); 52 if (is_waypoint(label)) - 53 Before_fragments[label].steps.insert(Before_fragments[label].steps.end(), tmp.steps.begin(), tmp.steps.end()); + 53 Before_fragments[label].steps.insert(Before_fragments[label].steps.end(), tmp.steps.begin(), tmp.steps.end()); 54 else - 55 raise << "can't tangle before non-waypoint " << label << '\n' << end(); + 55 raise << "can't tangle before non-waypoint " << label << '\n' << end(); 56 // End before Command Handler 57 } 58 else if (command == "after") { 59 string label = next_word(in); 60 if (label.empty()) { 61 assert(!has_data(in)); - 62 raise << "incomplete 'after' block at end of file\n" << end(); + 62 raise << "incomplete 'after' block at end of file\n" << end(); 63 return result; 64 } 65 recipe tmp; 66 slurp_body(in, tmp); 67 if (is_waypoint(label)) - 68 After_fragments[label].steps.insert(After_fragments[label].steps.begin(), tmp.steps.begin(), tmp.steps.end()); + 68 After_fragments[label].steps.insert(After_fragments[label].steps.begin(), tmp.steps.begin(), tmp.steps.end()); 69 else - 70 raise << "can't tangle after non-waypoint " << label << '\n' << end(); + 70 raise << "can't tangle after non-waypoint " << label << '\n' << end(); 71 // End after Command Handler 72 } 73 @@ -152,7 +152,7 @@ if ('onhashchange' in window) { 90 } 91 92 void insert_fragments(recipe& r) { - 93 trace(9991, "transform") << "--- insert fragments into recipe " << r.name << end(); + 93 trace(9991, "transform") << "--- insert fragments into recipe " << r.name << end(); 94 bool made_progress = true; 95 int pass = 0; 96 while (made_progress) { @@ -173,12 +173,12 @@ if ('onhashchange' in window) { 111 // ok to use contains_key even though Before_fragments uses [], 112 // because appending an empty recipe is a noop 113 if (contains_key(Before_fragments, inst.label)) { -114 trace(9992, "transform") << "insert fragments before label " << inst.label << end(); +114 trace(9992, "transform") << "insert fragments before label " << inst.label << end(); 115 append_fragment(result, Before_fragments[inst.label].steps, prefix.str()); 116 } 117 result.push_back(inst); 118 if (contains_key(After_fragments, inst.label)) { -119 trace(9992, "transform") << "insert fragments after label " << inst.label << end(); +119 trace(9992, "transform") << "insert fragments after label " << inst.label << end(); 120 append_fragment(result, After_fragments[inst.label].steps, prefix.str()); 121 } 122 } @@ -227,13 +227,13 @@ if ('onhashchange' in window) { 165 check_insert_fragments(); 166 :(code) 167 void check_insert_fragments() { -168 for (map<string, recipe>::iterator p = Before_fragments.begin(); p != Before_fragments.end(); ++p) { +168 for (map<string, recipe>::iterator p = Before_fragments.begin(); p != Before_fragments.end(); ++p) { 169 if (!contains_key(Fragments_used, p->first)) -170 raise << "could not locate insert before label " << p->first << '\n' << end(); +170 raise << "could not locate insert before label " << p->first << '\n' << end(); 171 } -172 for (map<string, recipe>::iterator p = After_fragments.begin(); p != After_fragments.end(); ++p) { +172 for (map<string, recipe>::iterator p = After_fragments.begin(); p != After_fragments.end(); ++p) { 173 if (!contains_key(Fragments_used, p->first)) -174 raise << "could not locate insert after label " << p->first << '\n' << end(); +174 raise << "could not locate insert after label " << p->first << '\n' << end(); 175 } 176 } 177 @@ -514,21 +514,21 @@ if ('onhashchange' in window) { 452 " 1:num/raw <- copy 34\n" 453 "]\n"); 454 transform_all(); -455 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); +455 CHECK_TRACE_DOESNT_CONTAIN_ERRORS(); 456 Hide_errors = true; 457 // try to tangle into recipe foo after transform 458 load("before <label> [\n" 459 " 2:num/raw <- copy 35\n" 460 "]\n"); -461 CHECK_TRACE_CONTAINS_ERRORS(); +461 CHECK_TRACE_CONTAINS_ERRORS(); 462 } 463 464 :(before "End before Command Handler") 465 if (contains_key(Fragments_used, label)) -466 raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end(); +466 raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end(); 467 :(before "End after Command Handler") 468 if (contains_key(Fragments_used, label)) -469 raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end(); +469 raise << "we've already tangled some code at label " << label << " in a previous call to transform_all(). Those locations won't be updated.\n" << end(); diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index 713dc04e..ad21220a 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -88,7 +88,7 @@ if ('onhashchange' in window) { 24 25 :(before "End Recipe Refinements") 26 if (in.peek() != '[') { - 27 trace(9999, "parse") << "recipe has a header; parsing" << end(); + 27 trace(9999, "parse") << "recipe has a header; parsing" << end(); 28 load_recipe_header(in, result); 29 } 30 @@ -99,25 +99,25 @@ if ('onhashchange' in window) { 35 string s = next_word(in); 36 if (s.empty()) { 37 assert(!has_data(in)); - 38 raise << "incomplete recipe header at end of file (0)\n" << end(); + 38 raise << "incomplete recipe header at end of file (0)\n" << end(); 39 return; 40 } 41 if (s == "<-") - 42 raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end(); + 42 raise << "recipe " << result.name << " should say '->' and not '<-'\n" << end(); 43 if (s == "->") break; 44 result.ingredients.push_back(reagent(s)); - 45 trace(9999, "parse") << "header ingredient: " << result.ingredients.back().original_string << end(); + 45 trace(9999, "parse") << "header ingredient: " << result.ingredients.back().original_string << end(); 46 skip_whitespace_but_not_newline(in); 47 } 48 while (has_data(in) && in.peek() != '[' && in.peek() != '\n') { 49 string s = next_word(in); 50 if (s.empty()) { 51 assert(!has_data(in)); - 52 raise << "incomplete recipe header at end of file (1)\n" << end(); + 52 raise << "incomplete recipe header at end of file (1)\n" << end(); 53 return; 54 } 55 result.products.push_back(reagent(s)); - 56 trace(9999, "parse") << "header product: " << result.products.back().original_string << end(); + 56 trace(9999, "parse") << "header product: " << result.products.back().original_string << end(); 57 skip_whitespace_but_not_newline(in); 58 } 59 // End Load Recipe Header(result) @@ -213,7 +213,7 @@ if ('onhashchange' in window) { 149 } 150 } 151 if (result.has_header) { -152 trace(9999, "parse") << "recipe " << result.name << " has a header" << end(); +152 trace(9999, "parse") << "recipe " << result.name << " has a header" << end(); 153 } 154 155 //: Support type abbreviations in headers. @@ -252,7 +252,7 @@ if ('onhashchange' in window) { 188 } 189 } 190 if (curr.name == "next-ingredient-without-typechecking") { -191 raise << maybe(result.name) << "never call 'next-ingredient-without-typechecking' directly\n" << end(); +191 raise << maybe(result.name) << "never call 'next-ingredient-without-typechecking' directly\n" << end(); 192 curr.clear(); 193 } 194 @@ -297,7 +297,7 @@ if ('onhashchange' in window) { 233 234 :(after "use-before-set Error") 235 if (is_present_in_ingredients(caller, ingredient.name)) -236 raise << " did you forget 'load-ingredients'?\n" << end(); +236 raise << " did you forget 'load-ingredients'?\n" << end(); 237 238 :(scenario load_ingredients_missing_error_2) 239 % Hide_errors = true; @@ -310,7 +310,7 @@ if ('onhashchange' in window) { 246 247 :(after "missing-type Error 1") 248 if (is_present_in_ingredients(get(Recipe, get(Recipe_ordinal, recipe_name)), x.name)) -249 raise << " did you forget 'load-ingredients'?\n" << end(); +249 raise << " did you forget 'load-ingredients'?\n" << end(); 250 251 :(code) 252 bool is_present_in_ingredients(const recipe& callee, const string& ingredient_name) { @@ -352,7 +352,7 @@ if ('onhashchange' in window) { 288 :(code) 289 void check_calls_against_header(const recipe_ordinal r) { 290 const recipe& caller = get(Recipe, r); -291 trace(9991, "transform") << "--- type-check calls inside recipe " << caller.name << end(); +291 trace(9991, "transform") << "--- type-check calls inside recipe " << caller.name << end(); 292 for (int i = 0; i < SIZE(caller.steps); ++i) { 293 const instruction& inst = caller.steps.at(i); 294 if (inst.operation < MAX_PRIMITIVE_RECIPES) continue; @@ -361,13 +361,13 @@ if ('onhashchange' in window) { 297 for (long int i = 0; i < min(SIZE(inst.ingredients), SIZE(callee.ingredients)); ++i) { 298 // ingredients coerced from call to callee 299 if (!types_coercible(callee.ingredients.at(i), inst.ingredients.at(i))) -300 raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); +300 raise << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); 301 } 302 for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee.products)); ++i) { 303 if (is_dummy(inst.products.at(i))) continue; 304 // products coerced from callee to call 305 if (!types_coercible(inst.products.at(i), callee.products.at(i))) -306 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); +306 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); 307 } 308 } 309 } @@ -392,17 +392,17 @@ if ('onhashchange' in window) { 328 void check_return_instructions_against_header(const recipe_ordinal r) { 329 const recipe& caller_recipe = get(Recipe, r); 330 if (!caller_recipe.has_header) return; -331 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); +331 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); 332 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 333 const instruction& inst = caller_recipe.steps.at(i); 334 if (inst.name != "reply" && inst.name != "return") continue; 335 if (SIZE(caller_recipe.products) != SIZE(inst.ingredients)) { -336 raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << inst.original_string << "'\n" << end(); +336 raise << maybe(caller_recipe.name) << "replied with the wrong number of products at '" << inst.original_string << "'\n" << end(); 337 continue; 338 } 339 for (int i = 0; i < SIZE(caller_recipe.products); ++i) { 340 if (!types_match(caller_recipe.products.at(i), inst.ingredients.at(i))) -341 raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << inst.original_string << "'\n" << end(); +341 raise << maybe(caller_recipe.name) << "replied with the wrong type at '" << inst.original_string << "'\n" << end(); 342 } 343 } 344 } @@ -447,10 +447,10 @@ if ('onhashchange' in window) { 383 recipe& caller_recipe = get(Recipe, r); 384 if (caller_recipe.products.empty()) return; 385 caller_recipe.ingredient_index.clear(); -386 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); +386 trace(9991, "transform") << "--- checking return instructions against header for " << caller_recipe.name << end(); 387 for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { 388 if (contains_key(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name)) -389 raise << maybe(caller_recipe.name) << "'" << caller_recipe.ingredients.at(i).name << "' can't repeat in the ingredients\n" << end(); +389 raise << maybe(caller_recipe.name) << "'" << caller_recipe.ingredients.at(i).name << "' can't repeat in the ingredients\n" << end(); 390 put(caller_recipe.ingredient_index, caller_recipe.ingredients.at(i).name, i); 391 } 392 } @@ -477,37 +477,37 @@ if ('onhashchange' in window) { 413 void deduce_types_from_header(const recipe_ordinal r) { 414 recipe& caller_recipe = get(Recipe, r); 415 if (caller_recipe.products.empty()) return; -416 trace(9991, "transform") << "--- deduce types from header for " << caller_recipe.name << end(); +416 trace(9991, "transform") << "--- deduce types from header for " << caller_recipe.name << end(); 417 map<string, const type_tree*> header_type; 418 for (int i = 0; i < SIZE(caller_recipe.ingredients); ++i) { 419 if (!caller_recipe.ingredients.at(i).type) continue; // error handled elsewhere 420 put(header_type, caller_recipe.ingredients.at(i).name, caller_recipe.ingredients.at(i).type); -421 trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end(); +421 trace(9993, "transform") << "type of " << caller_recipe.ingredients.at(i).name << " is " << names_to_string(caller_recipe.ingredients.at(i).type) << end(); 422 } 423 for (int i = 0; i < SIZE(caller_recipe.products); ++i) { 424 if (!caller_recipe.products.at(i).type) continue; // error handled elsewhere 425 put(header_type, caller_recipe.products.at(i).name, caller_recipe.products.at(i).type); -426 trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end(); +426 trace(9993, "transform") << "type of " << caller_recipe.products.at(i).name << " is " << names_to_string(caller_recipe.products.at(i).type) << end(); 427 } 428 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 429 instruction& inst = caller_recipe.steps.at(i); -430 trace(9992, "transform") << "instruction: " << to_string(inst) << end(); +430 trace(9992, "transform") << "instruction: " << to_string(inst) << end(); 431 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 432 if (inst.ingredients.at(i).type) continue; -433 if (header_type.find(inst.ingredients.at(i).name) == header_type.end()) +433 if (header_type.find(inst.ingredients.at(i).name) == header_type.end()) 434 continue; 435 if (!contains_key(header_type, inst.ingredients.at(i).name)) continue; // error handled elsewhere 436 inst.ingredients.at(i).type = new type_tree(*get(header_type, inst.ingredients.at(i).name)); -437 trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end(); +437 trace(9993, "transform") << "type of " << inst.ingredients.at(i).name << " is " << names_to_string(inst.ingredients.at(i).type) << end(); 438 } 439 for (int i = 0; i < SIZE(inst.products); ++i) { -440 trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); +440 trace(9993, "transform") << " product: " << to_string(inst.products.at(i)) << end(); 441 if (inst.products.at(i).type) continue; -442 if (header_type.find(inst.products.at(i).name) == header_type.end()) +442 if (header_type.find(inst.products.at(i).name) == header_type.end()) 443 continue; 444 if (!contains_key(header_type, inst.products.at(i).name)) continue; // error handled elsewhere 445 inst.products.at(i).type = new type_tree(*get(header_type, inst.products.at(i).name)); -446 trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << names_to_string(inst.products.at(i).type) << end(); +446 trace(9993, "transform") << "type of " << inst.products.at(i).name << " is " << names_to_string(inst.products.at(i).type) << end(); 447 } 448 } 449 } @@ -534,7 +534,7 @@ if ('onhashchange' in window) { 470 void fill_in_return_ingredients(const recipe_ordinal r) { 471 recipe& caller_recipe = get(Recipe, r); 472 if (!caller_recipe.has_header) return; -473 trace(9991, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe.name << end(); +473 trace(9991, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe.name << end(); 474 for (int i = 0; i < SIZE(caller_recipe.steps); ++i) { 475 instruction& inst = caller_recipe.steps.at(i); 476 if (inst.name == "reply" || inst.name == "return") @@ -663,7 +663,7 @@ if ('onhashchange' in window) { 599 reagent/*local*/ expected_ingredient("x:address:array:character"); 600 for (int i = 0; i < SIZE(caller.ingredients); ++i) { 601 if (!types_strictly_match(expected_ingredient, caller.ingredients.at(i))) { -602 raise << "ingredients of recipe 'main' must all be text (address:array:character)\n" << end(); +602 raise << "ingredients of recipe 'main' must all be text (address:array:character)\n" << end(); 603 break; 604 } 605 } @@ -671,7 +671,7 @@ if ('onhashchange' in window) { 607 reagent/*local*/ expected_product("x:number"); 608 if (nprod > 1 609 || (nprod == 1 && !types_strictly_match(expected_product, caller.products.at(0)))) { -610 raise << "recipe 'main' must return at most a single product, a number\n" << end(); +610 raise << "recipe 'main' must return at most a single product, a number\n" << end(); 611 } 612 } 613 diff --git a/html/054static_dispatch.cc.html b/html/054static_dispatch.cc.html index d4a018c6..8803f098 100644 --- a/html/054static_dispatch.cc.html +++ b/html/054static_dispatch.cc.html @@ -104,7 +104,7 @@ if ('onhashchange' in window) { 41 put(Recipe_ordinal, new_name, Next_recipe_ordinal++); 42 get_or_insert(Recipe_variants, result.name).push_back(get(Recipe_ordinal, new_name)); 43 } - 44 trace(9999, "load") << "switching " << result.name << " to " << new_name << end(); + 44 trace(9999, "load") << "switching " << result.name << " to " << new_name << end(); 45 result.name = new_name; 46 result.is_autogenerated = true; 47 } @@ -162,9 +162,9 @@ if ('onhashchange' in window) { 99 if (a->name == "literal" && b->name == "literal") 100 return true; 101 if (a->name == "literal") -102 return Literal_type_names.find(b->name) != Literal_type_names.end(); +102 return Literal_type_names.find(b->name) != Literal_type_names.end(); 103 if (b->name == "literal") -104 return Literal_type_names.find(a->name) != Literal_type_names.end(); +104 return Literal_type_names.find(a->name) != Literal_type_names.end(); 105 return a->name == b->name; 106 } 107 return deeply_equal_type_names(a->left, b->left) @@ -218,12 +218,12 @@ if ('onhashchange' in window) { 155 :(code) 156 void resolve_ambiguous_calls(const recipe_ordinal r) { 157 recipe& caller_recipe = get(Recipe, r); -158 trace(9991, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end(); +158 trace(9991, "transform") << "--- resolve ambiguous calls for recipe " << caller_recipe.name << end(); 159 for (int index = 0; index < SIZE(caller_recipe.steps); ++index) { 160 instruction& inst = caller_recipe.steps.at(index); 161 if (inst.is_label) continue; 162 if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) continue; -163 trace(9992, "transform") << "instruction " << inst.original_string << end(); +163 trace(9992, "transform") << "instruction " << inst.original_string << end(); 164 Resolve_stack.push_front(call(r)); 165 Resolve_stack.front().running_step_index = index; 166 string new_name = best_variant(inst, caller_recipe); @@ -261,22 +261,22 @@ if ('onhashchange' in window) { 198 199 // error messages 200 if (get(Recipe_ordinal, inst.name) >= MAX_PRIMITIVE_RECIPES) { // we currently don't check types for primitive variants -201 raise << maybe(caller_recipe.name) << "failed to find a matching call for '" << inst.original_string << "'\n" << end(); -202 for (list<call>::iterator p = /*skip*/++Resolve_stack.begin(); p != Resolve_stack.end(); ++p) { +201 raise << maybe(caller_recipe.name) << "failed to find a matching call for '" << inst.original_string << "'\n" << end(); +202 for (list<call>::iterator p = /*skip*/++Resolve_stack.begin(); p != Resolve_stack.end(); ++p) { 203 const recipe& specializer_recipe = get(Recipe, p->running_recipe); 204 const instruction& specializer_inst = specializer_recipe.steps.at(p->running_step_index); 205 if (specializer_recipe.name != "interactive") -206 raise << " (from '" << to_original_string(specializer_inst) << "' in " << specializer_recipe.name << ")\n" << end(); +206 raise << " (from '" << to_original_string(specializer_inst) << "' in " << specializer_recipe.name << ")\n" << end(); 207 else -208 raise << " (from '" << to_original_string(specializer_inst) << "')\n" << end(); +208 raise << " (from '" << to_original_string(specializer_inst) << "')\n" << end(); 209 // One special-case to help with the rewrite_stash transform. (cross-layer) 210 if (specializer_inst.products.at(0).name.find("stash_") == 0) { 211 instruction stash_inst; 212 if (next_stash(*p, &stash_inst)) { 213 if (specializer_recipe.name != "interactive") -214 raise << " (part of '" << stash_inst.original_string << "' in " << specializer_recipe.name << ")\n" << end(); +214 raise << " (part of '" << stash_inst.original_string << "' in " << specializer_recipe.name << ")\n" << end(); 215 else -216 raise << " (part of '" << stash_inst.original_string << "')\n" << end(); +216 raise << " (part of '" << stash_inst.original_string << "')\n" << end(); 217 } 218 } 219 } @@ -289,7 +289,7 @@ if ('onhashchange' in window) { 226 vector<recipe_ordinal> result; 227 for (int i = 0; i < SIZE(variants); ++i) { 228 if (variants.at(i) == -1) continue; -229 trace(9992, "transform") << "checking variant (strict) " << i << ": " << header_label(variants.at(i)) << end(); +229 trace(9992, "transform") << "checking variant (strict) " << i << ": " << header_label(variants.at(i)) << end(); 230 if (all_header_reagents_strictly_match(inst, get(Recipe, variants.at(i)))) 231 result.push_back(variants.at(i)); 232 } @@ -299,14 +299,14 @@ if ('onhashchange' in window) { 236 bool all_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { 237 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 238 if (!types_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) { -239 trace(9993, "transform") << "strict match failed: ingredient " << i << end(); +239 trace(9993, "transform") << "strict match failed: ingredient " << i << end(); 240 return false; 241 } 242 } 243 for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { 244 if (is_dummy(inst.products.at(i))) continue; 245 if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) { -246 trace(9993, "transform") << "strict match failed: product " << i << end(); +246 trace(9993, "transform") << "strict match failed: product " << i << end(); 247 return false; 248 } 249 } @@ -318,7 +318,7 @@ if ('onhashchange' in window) { 255 vector<recipe_ordinal> result; 256 for (int i = 0; i < SIZE(variants); ++i) { 257 if (variants.at(i) == -1) continue; -258 trace(9992, "transform") << "checking variant (strict except literal-zero-against-address) " << i << ": " << header_label(variants.at(i)) << end(); +258 trace(9992, "transform") << "checking variant (strict except literal-zero-against-address) " << i << ": " << header_label(variants.at(i)) << end(); 259 if (all_header_reagents_strictly_match_except_literal_zero_against_address(inst, get(Recipe, variants.at(i)))) 260 result.push_back(variants.at(i)); 261 } @@ -328,14 +328,14 @@ if ('onhashchange' in window) { 265 bool all_header_reagents_strictly_match_except_literal_zero_against_address(const instruction& inst, const recipe& variant) { 266 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 267 if (!types_strictly_match_except_literal_zero_against_address(variant.ingredients.at(i), inst.ingredients.at(i))) { -268 trace(9993, "transform") << "match failed: ingredient " << i << end(); +268 trace(9993, "transform") << "match failed: ingredient " << i << end(); 269 return false; 270 } 271 } 272 for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.products)); ++i) { 273 if (is_dummy(inst.products.at(i))) continue; 274 if (!types_strictly_match(variant.products.at(i), inst.products.at(i))) { -275 trace(9993, "transform") << "match failed: product " << i << end(); +275 trace(9993, "transform") << "match failed: product " << i << end(); 276 return false; 277 } 278 } @@ -353,7 +353,7 @@ if ('onhashchange' in window) { 290 vector<recipe_ordinal> result; 291 for (int i = 0; i < SIZE(variants); ++i) { 292 if (variants.at(i) == -1) continue; -293 trace(9992, "transform") << "checking variant (strict except literal-against-boolean) " << i << ": " << header_label(variants.at(i)) << end(); +293 trace(9992, "transform") << "checking variant (strict except literal-against-boolean) " << i << ": " << header_label(variants.at(i)) << end(); 294 if (all_header_reagents_strictly_match_except_literal_against_address_or_boolean(inst, get(Recipe, variants.at(i)))) 295 result.push_back(variants.at(i)); 296 } @@ -363,14 +363,14 @@ if ('onhashchange' in window) { 300 bool all_header_reagents_strictly_match_except_literal_against_address_or_boolean(const instruction& inst, const recipe& variant) { 301 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 302 if (!types_strictly_match_except_literal_against_address_or_boolean(variant.ingredients.at(i), inst.ingredients.at(i))) { -303 trace(9993, "transform") << "match failed: ingredient " << i << end(); +303 trace(9993, "transform") << "match failed: ingredient " << i << end(); 304 return false; 305 } 306 } 307 for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) { 308 if (is_dummy(inst.products.at(i))) continue; 309 if (!types_strictly_match_except_literal_against_address_or_boolean(variant.products.at(i), inst.products.at(i))) { -310 trace(9993, "transform") << "match failed: product " << i << end(); +310 trace(9993, "transform") << "match failed: product " << i << end(); 311 return false; 312 } 313 } @@ -388,7 +388,7 @@ if ('onhashchange' in window) { 325 vector<recipe_ordinal> result; 326 for (int i = 0; i < SIZE(variants); ++i) { 327 if (variants.at(i) == -1) continue; -328 trace(9992, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end(); +328 trace(9992, "transform") << "checking variant " << i << ": " << header_label(variants.at(i)) << end(); 329 if (all_header_reagents_match(inst, get(Recipe, variants.at(i)))) 330 result.push_back(variants.at(i)); 331 } @@ -398,14 +398,14 @@ if ('onhashchange' in window) { 335 bool all_header_reagents_match(const instruction& inst, const recipe& variant) { 336 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 337 if (!types_match(variant.ingredients.at(i), inst.ingredients.at(i))) { -338 trace(9993, "transform") << "match failed: ingredient " << i << end(); +338 trace(9993, "transform") << "match failed: ingredient " << i << end(); 339 return false; 340 } 341 } 342 for (int i = 0; i < min(SIZE(variant.products), SIZE(inst.products)); ++i) { 343 if (is_dummy(inst.products.at(i))) continue; 344 if (!types_match(variant.products.at(i), inst.products.at(i))) { -345 trace(9993, "transform") << "match failed: product " << i << end(); +345 trace(9993, "transform") << "match failed: product " << i << end(); 346 return false; 347 } 348 } diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index 3bad5f3a..3206cb55 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -98,7 +98,7 @@ if ('onhashchange' in window) { 34 const type_tree* get_base_type(const type_tree* t) { 35 const type_tree* result = t->atom ? t : t->left; 36 if (!result->atom) - 37 raise << "invalid type " << to_string(t) << '\n' << end(); + 37 raise << "invalid type " << to_string(t) << '\n' << end(); 38 return result; 39 } 40 @@ -208,7 +208,7 @@ if ('onhashchange' in window) { 144 145 :(before "End container Name Refinements") 146 if (name.find(':') != string::npos) { -147 trace(9999, "parse") << "container has type ingredients; parsing" << end(); +147 trace(9999, "parse") << "container has type ingredients; parsing" << end(); 148 if (!read_type_ingredients(name, command)) { 149 // error; skip rest of the container definition and continue 150 slurp_balanced_bracket(in); @@ -230,7 +230,7 @@ if ('onhashchange' in window) { 166 const type_info& previous_info = get(Type, get(Type_ordinal, name)); 167 // we've already seen this container; make sure type ingredients match 168 if (!type_ingredients_match(type_ingredient_names, previous_info.type_ingredient_names)) { -169 raise << "headers of " << command << " '" << name << "' must use identical type ingredients\n" << end(); +169 raise << "headers of " << command << " '" << name << "' must use identical type ingredients\n" << end(); 170 return false; 171 } 172 return true; @@ -248,15 +248,15 @@ if ('onhashchange' in window) { 184 while (has_data(in)) { 185 string curr = slurp_until(in, ':'); 186 if (curr.empty()) { -187 raise << container_name << ": empty type ingredients not permitted\n" << end(); +187 raise << container_name << ": empty type ingredients not permitted\n" << end(); 188 return false; 189 } 190 if (!starts_with(curr, "_")) { -191 raise << container_name << ": type ingredient '" << curr << "' must begin with an underscore\n" << end(); +191 raise << container_name << ": type ingredient '" << curr << "' must begin with an underscore\n" << end(); 192 return false; 193 } -194 if (out.find(curr) != out.end()) { -195 raise << container_name << ": can't repeat type ingredient name'" << curr << "' in a single container definition\n" << end(); +194 if (out.find(curr) != out.end()) { +195 raise << container_name << ": can't repeat type ingredient name'" << curr << "' in a single container definition\n" << end(); 196 return false; 197 } 198 put(out, curr, next_type_ordinal++); @@ -266,7 +266,7 @@ if ('onhashchange' in window) { 202 203 bool type_ingredients_match(const map<string, type_ordinal>& a, const map<string, type_ordinal>& b) { 204 if (SIZE(a) != SIZE(b)) return false; -205 for (map<string, type_ordinal>::const_iterator p = a.begin(); p != a.end(); ++p) { +205 for (map<string, type_ordinal>::const_iterator p = a.begin(); p != a.end(); ++p) { 206 if (!contains_key(b, p->first)) return false; 207 if (p->second != get(b, p->first)) return false; 208 } @@ -407,7 +407,7 @@ if ('onhashchange' in window) { 343 void replace_type_ingredients(reagent& element, const type_tree* caller_type, const type_info& info, const string& location_for_error_messages) { 344 if (contains_type_ingredient(element)) { 345 if (!caller_type->right) -346 raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end(); +346 raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end(); 347 replace_type_ingredients(element.type, caller_type->right, info, location_for_error_messages); 348 } 349 } @@ -435,11 +435,11 @@ if ('onhashchange' in window) { 371 372 const type_tree* corresponding(const type_tree* type, int index, bool final) { 373 for (const type_tree* curr = type; curr; curr = curr->right, --index) { -374 assert_for_now(!curr->atom); +374 assert_for_now(!curr->atom); 375 if (index == 0) 376 return final ? curr : curr->left; 377 } -378 assert_for_now(false); +378 assert_for_now(false); 379 } 380 381 bool is_type_ingredient(const type_tree* type) { @@ -453,7 +453,7 @@ if ('onhashchange' in window) { 389 390 void replace_type_ingredient_at(const int type_ingredient_index, type_tree* element_type, const type_tree* callsite_type, const type_info& container_info, const string& location_for_error_messages) { 391 if (!has_nth_type(callsite_type, type_ingredient_index)) { -392 raise << "illegal type " << names_to_string(callsite_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end(); +392 raise << "illegal type " << names_to_string(callsite_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end(); 393 return; 394 } 395 *element_type = *nth_type_ingredient(callsite_type, type_ingredient_index, container_info); @@ -477,7 +477,7 @@ if ('onhashchange' in window) { 413 414 bool is_final_type_ingredient(int type_ingredient_index, const type_info& container_info) { 415 for (map<string, type_ordinal>::const_iterator p = container_info.type_ingredient_names.begin(); -416 p != container_info.type_ingredient_names.end(); +416 p != container_info.type_ingredient_names.end(); 417 ++p) { 418 if (p->second > START_TYPE_INGREDIENTS+type_ingredient_index) return false; 419 } @@ -717,7 +717,7 @@ if ('onhashchange' in window) { 653 " y:foo:_t\n" 654 "]\n"); 655 reagent r("x:bar:&:num"); -656 CLEAR_TRACE; +656 CLEAR_TRACE; 657 compute_container_sizes(r, ""); 658 compute_container_address_offsets(r, ""); 659 CHECK_EQ(SIZE(r.metadata.address), 1); diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index a2519c1b..fb3bb405 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -102,7 +102,7 @@ if ('onhashchange' in window) { 37 if (Current_routine->calls.front().running_step_index == 0 38 && any_type_ingredient_in_header(Current_routine->calls.front().running_recipe)) { 39 //? DUMP(""); - 40 raise << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end(); + 40 raise << "ran into unspecialized shape-shifting recipe " << current_recipe_name() << '\n' << end(); 41 //? exit(0); 42 } 43 @@ -122,14 +122,14 @@ if ('onhashchange' in window) { 57 candidates = strictly_matching_shape_shifting_variants(inst, variants); 58 if (!candidates.empty()) { 59 recipe_ordinal exemplar = best_shape_shifting_variant(inst, candidates); - 60 trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end(); + 60 trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end(); 61 recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe); 62 if (new_recipe_ordinal == 0) goto skip_shape_shifting_variants; 63 variants.push_back(new_recipe_ordinal); // side-effect 64 recipe& variant = get(Recipe, new_recipe_ordinal); 65 // perform all transforms on the new specialization 66 if (!variant.steps.empty()) { - 67 trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); + 67 trace(9992, "transform") << "transforming new specialization: " << variant.name << end(); 68 for (int t = 0; t < SIZE(Transform); ++t) { 69 // one exception: skip tangle, which would have already occurred inside new_variant above 70 if (Transform.at(t) == /*disambiguate overloading*/static_cast<transform_fn>(insert_fragments)) @@ -138,7 +138,7 @@ if ('onhashchange' in window) { 73 } 74 } 75 variant.transformed_until = SIZE(Transform)-1; - 76 trace(9992, "transform") << "new specialization: " << variant.name << end(); + 76 trace(9992, "transform") << "new specialization: " << variant.name << end(); 77 return variant.name; 78 } 79 skip_shape_shifting_variants:; @@ -149,7 +149,7 @@ if ('onhashchange' in window) { 84 :(before "End Instruction Operation Checks") 85 if (contains_key(Recipe, inst.operation) && inst.operation >= MAX_PRIMITIVE_RECIPES 86 && any_type_ingredient_in_header(inst.operation)) { - 87 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no valid specialization\n" << end(); + 87 raise << maybe(caller.name) << "instruction '" << inst.name << "' has no valid specialization\n" << end(); 88 return; 89 } 90 @@ -176,14 +176,14 @@ if ('onhashchange' in window) { 111 bool all_concrete_header_reagents_strictly_match(const instruction& inst, const recipe& variant) { 112 for (int i = 0; i < min(SIZE(inst.ingredients), SIZE(variant.ingredients)); ++i) { 113 if (!concrete_type_names_strictly_match(variant.ingredients.at(i), inst.ingredients.at(i))) { - 114 trace(9993, "transform") << "concrete-type match failed: ingredient " << i << end(); + 114 trace(9993, "transform") << "concrete-type match failed: ingredient " << i << end(); 115 return false; 116 } 117 } 118 for (int i = 0; i < min(SIZE(inst.products), SIZE(variant.ingredients)); ++i) { 119 if (is_dummy(inst.products.at(i))) continue; 120 if (!concrete_type_names_strictly_match(variant.products.at(i), inst.products.at(i))) { - 121 trace(9993, "transform") << "concrete-type match failed: product " << i << end(); + 121 trace(9993, "transform") << "concrete-type match failed: product " << i << end(); 122 return false; 123 } 124 } @@ -251,9 +251,9 @@ if ('onhashchange' in window) { 186 if (from->atom != to->atom) return false; 187 // both from and to are atoms 188 if (from->name == "literal") - 189 return Literal_type_names.find(to->name) != Literal_type_names.end(); + 189 return Literal_type_names.find(to->name) != Literal_type_names.end(); 190 if (to->name == "literal") - 191 return Literal_type_names.find(from->name) != Literal_type_names.end(); + 191 return Literal_type_names.find(from->name) != Literal_type_names.end(); 192 return to->name == from->name; 193 } 194 @@ -299,7 +299,7 @@ if ('onhashchange' in window) { 234 recipe new_recipe = get(Recipe, exemplar); 235 new_recipe.name = new_name; 236 new_recipe.is_autogenerated = true; - 237 trace(9993, "transform") << "switching " << inst.name << " to specialized " << header_label(new_recipe) << end(); + 237 trace(9993, "transform") << "switching " << inst.name << " to specialized " << header_label(new_recipe) << end(); 238 239 // Replace type ingredients with concrete types in new_recipe. 240 // @@ -318,7 +318,7 @@ if ('onhashchange' in window) { 253 compute_type_ingredient_mappings(get(Recipe, exemplar), inst, mappings, caller_recipe, &error); 254 if (!error) error = (SIZE(mappings) != type_ingredient_count_in_header(exemplar)); 255 if (!error) replace_type_ingredients(new_recipe, mappings); - 256 for (map<string, const type_tree*>::iterator p = mappings.begin(); p != mappings.end(); ++p) + 256 for (map<string, const type_tree*>::iterator p = mappings.begin(); p != mappings.end(); ++p) 257 delete p->second; 258 if (error) return 0; 259 } @@ -328,7 +328,7 @@ if ('onhashchange' in window) { 263 } 264 265 void compute_type_names(recipe& variant) { - 266 trace(9993, "transform") << "-- compute type names: " << variant.name << end(); + 266 trace(9993, "transform") << "-- compute type names: " << variant.name << end(); 267 map<string, type_tree*> type_names; 268 for (int i = 0; i < SIZE(variant.ingredients); ++i) 269 save_or_deduce_type_name(variant.ingredients.at(i), type_names, variant, ""); @@ -336,7 +336,7 @@ if ('onhashchange' in window) { 271 save_or_deduce_type_name(variant.products.at(i), type_names, variant, ""); 272 for (int i = 0; i < SIZE(variant.steps); ++i) { 273 instruction& inst = variant.steps.at(i); - 274 trace(9993, "transform") << " instruction: " << to_string(inst) << end(); + 274 trace(9993, "transform") << " instruction: " << to_string(inst) << end(); 275 for (int in = 0; in < SIZE(inst.ingredients); ++in) 276 save_or_deduce_type_name(inst.ingredients.at(in), type_names, variant, " in '" + inst.original_string + "'"); 277 for (int out = 0; out < SIZE(inst.products); ++out) @@ -345,20 +345,20 @@ if ('onhashchange' in window) { 280 } 281 282 void save_or_deduce_type_name(reagent& x, map<string, type_tree*>& type, const recipe& variant, const string& context) { - 283 trace(9994, "transform") << " checking " << to_string(x) << ": " << names_to_string(x.type) << end(); + 283 trace(9994, "transform") << " checking " << to_string(x) << ": " << names_to_string(x.type) << end(); 284 if (!x.type && contains_key(type, x.name)) { 285 x.type = new type_tree(*get(type, x.name)); - 286 trace(9994, "transform") << " deducing type to " << names_to_string(x.type) << end(); + 286 trace(9994, "transform") << " deducing type to " << names_to_string(x.type) << end(); 287 return; 288 } 289 if (!x.type) { - 290 raise << maybe(variant.original_name) << "unknown type for '" << x.original_string << "'" << context << " (check the name for typos)\n" << end(); + 290 raise << maybe(variant.original_name) << "unknown type for '" << x.original_string << "'" << context << " (check the name for typos)\n" << end(); 291 return; 292 } 293 if (contains_key(type, x.name)) return; 294 if (x.type->name == "offset" || x.type->name == "variant") return; // special-case for container-access instructions 295 put(type, x.name, x.type); - 296 trace(9993, "transform") << "type of '" << x.name << "' is " << names_to_string(x.type) << end(); + 296 trace(9993, "transform") << "type of '" << x.name << "' is " << names_to_string(x.type) << end(); 297 } 298 299 void compute_type_ingredient_mappings(const recipe& exemplar, const instruction& inst, map<string, const type_tree*>& mappings, const recipe& caller_recipe, bool* error) { @@ -390,13 +390,13 @@ if ('onhashchange' in window) { 325 if (!refinement_type) { 326 // probably a bug in mu 327 // todo: make this smarter; only flag an error if exemplar_type contains some *new* type ingredient - 328 raise << maybe(exemplar.name) << "missing type ingredient for " << exemplar_reagent.original_string << '\n' << end(); - 329 raise << " (called from '" << to_original_string(call_instruction) << "')\n" << end(); + 328 raise << maybe(exemplar.name) << "missing type ingredient for " << exemplar_reagent.original_string << '\n' << end(); + 329 raise << " (called from '" << to_original_string(call_instruction) << "')\n" << end(); 330 return; 331 } 332 if (!exemplar_type->atom && exemplar_type->right == NULL && !refinement_type->atom && refinement_type->right != NULL) { 333 exemplar_type = exemplar_type->left; - 334 assert_for_now(exemplar_type->atom); + 334 assert_for_now(exemplar_type->atom); 335 } 336 if (exemplar_type->atom) { 337 if (is_type_ingredient_name(exemplar_type->name)) { @@ -408,12 +408,12 @@ if ('onhashchange' in window) { 343 curr_refinement_type = new type_tree(*refinement_type->left); 344 } 345 if (!contains_key(mappings, exemplar_type->name)) { - 346 trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end(); + 346 trace(9993, "transform") << "adding mapping from " << exemplar_type->name << " to " << to_string(curr_refinement_type) << end(); 347 put(mappings, exemplar_type->name, new type_tree(*curr_refinement_type)); 348 } 349 else { 350 if (!deeply_equal_type_names(get(mappings, exemplar_type->name), curr_refinement_type)) { - 351 raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end(); + 351 raise << maybe(caller_recipe.name) << "no call found for '" << to_original_string(call_instruction) << "'\n" << end(); 352 *error = true; 353 delete curr_refinement_type; 354 return; @@ -435,16 +435,16 @@ if ('onhashchange' in window) { 370 void replace_type_ingredients(recipe& new_recipe, const map<string, const type_tree*>& mappings) { 371 // update its header 372 if (mappings.empty()) return; - 373 trace(9993, "transform") << "replacing in recipe header ingredients" << end(); + 373 trace(9993, "transform") << "replacing in recipe header ingredients" << end(); 374 for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) 375 replace_type_ingredients(new_recipe.ingredients.at(i), mappings, new_recipe); - 376 trace(9993, "transform") << "replacing in recipe header products" << end(); + 376 trace(9993, "transform") << "replacing in recipe header products" << end(); 377 for (int i = 0; i < SIZE(new_recipe.products); ++i) 378 replace_type_ingredients(new_recipe.products.at(i), mappings, new_recipe); 379 // update its body 380 for (int i = 0; i < SIZE(new_recipe.steps); ++i) { 381 instruction& inst = new_recipe.steps.at(i); - 382 trace(9993, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end(); + 382 trace(9993, "transform") << "replacing in instruction '" << to_string(inst) << "'" << end(); 383 for (int j = 0; j < SIZE(inst.ingredients); ++j) 384 replace_type_ingredients(inst.ingredients.at(j), mappings, new_recipe); 385 for (int j = 0; j < SIZE(inst.products); ++j) @@ -461,9 +461,9 @@ if ('onhashchange' in window) { 396 397 void replace_type_ingredients(reagent& x, const map<string, const type_tree*>& mappings, const recipe& caller) { 398 string before = to_string(x); - 399 trace(9993, "transform") << "replacing in ingredient " << x.original_string << end(); + 399 trace(9993, "transform") << "replacing in ingredient " << x.original_string << end(); 400 if (!x.type) { - 401 raise << "specializing " << caller.original_name << ": missing type for '" << x.original_string << "'\n" << end(); + 401 raise << "specializing " << caller.original_name << ": missing type for '" << x.original_string << "'\n" << end(); 402 return; 403 } 404 replace_type_ingredients(x.type, mappings); @@ -485,7 +485,7 @@ if ('onhashchange' in window) { 420 if (!contains_key(mappings, type->name)) 421 return; 422 const type_tree* replacement = get(mappings, type->name); - 423 trace(9993, "transform") << type->name << " => " << names_to_string(replacement) << end(); + 423 trace(9993, "transform") << type->name << " => " << names_to_string(replacement) << end(); 424 if (replacement->atom) { 425 if (!contains_key(Type_ordinal, replacement->name)) { 426 // error in program; should be reported elsewhere @@ -546,7 +546,7 @@ if ('onhashchange' in window) { 481 } 482 483 void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) { - 484 trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end(); + 484 trace(9993, "transform") << "-- ensure all concrete types in recipe " << new_recipe.name << end(); 485 for (int i = 0; i < SIZE(new_recipe.ingredients); ++i) 486 ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar); 487 for (int i = 0; i < SIZE(new_recipe.products); ++i) @@ -562,12 +562,12 @@ if ('onhashchange' in window) { 497 498 void ensure_all_concrete_types(/*const*/ reagent& x, const recipe& exemplar) { 499 if (!x.type || contains_type_ingredient_name(x.type)) { - 500 raise << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end(); + 500 raise << maybe(exemplar.name) << "failed to map a type to " << x.original_string << '\n' << end(); 501 if (!x.type) x.type = new type_tree("", 0); // just to prevent crashes later 502 return; 503 } 504 if (x.type->value == -1) { - 505 raise << maybe(exemplar.name) << "failed to map a type to the unknown " << x.original_string << '\n' << end(); + 505 raise << maybe(exemplar.name) << "failed to map a type to the unknown " << x.original_string << '\n' << end(); 506 return; 507 } 508 } diff --git a/html/057immutable.cc.html b/html/057immutable.cc.html index 8157d755..99147f16 100644 --- a/html/057immutable.cc.html +++ b/html/057immutable.cc.html @@ -406,7 +406,7 @@ if ('onhashchange' in window) { 344 // b) we never call 'put' or 'put-index' on it, and 345 // c) any non-primitive recipe calls in the body aren't returning it as a product 346 const recipe& caller = get(Recipe, r); -347 trace(9991, "transform") << "--- check mutability of ingredients in recipe " << caller.name << end(); +347 trace(9991, "transform") << "--- check mutability of ingredients in recipe " << caller.name << end(); 348 if (!caller.has_header) return; // skip check for old-style recipes calling next-ingredient directly 349 for (int i = 0; i < SIZE(caller.ingredients); ++i) { 350 const reagent& current_ingredient = caller.ingredients.at(i); @@ -429,7 +429,7 @@ if ('onhashchange' in window) { 367 // primitive recipe 368 switch (inst.operation) { 369 case COPY: -370 for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) +370 for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) 371 current_ingredient_and_aliases.insert(inst.products.at(*p).name); 372 break; 373 case GET: @@ -447,7 +447,7 @@ if ('onhashchange' in window) { 385 else { 386 // defined recipe 387 set<int> contained_in_product_indices = scan_contained_in_product_indices(inst, current_ingredient_indices); -388 for (set<int>::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { +388 for (set<int>::iterator p = contained_in_product_indices.begin(); p != contained_in_product_indices.end(); ++p) { 389 if (*p < SIZE(inst.products)) 390 current_ingredient_and_aliases.insert(inst.products.at(*p)); 391 } @@ -457,7 +457,7 @@ if ('onhashchange' in window) { 395 set<int> scan_contained_in_product_indices(const instruction& inst, set<int>& ingredient_indices) { 396 set<reagent> selected_ingredients; 397 const recipe& callee = get(Recipe, inst.operation); -398 for (set<int>::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { +398 for (set<int>::iterator p = ingredient_indices.begin(); p != ingredient_indices.end(); ++p) { 399 if (*p >= SIZE(callee.ingredients)) continue; // optional immutable ingredient 400 selected_ingredients.insert(callee.ingredients.at(*p)); 401 } @@ -465,7 +465,7 @@ if ('onhashchange' in window) { 403 for (int i = 0; i < SIZE(callee.products); ++i) { 404 const reagent& current_product = callee.products.at(i); 405 const string_tree* contained_in_name = property(current_product, "contained-in"); -406 if (contained_in_name && selected_ingredients.find(contained_in_name->value) != selected_ingredients.end()) +406 if (contained_in_name && selected_ingredients.find(contained_in_name->value) != selected_ingredients.end()) 407 result.insert(i); 408 } 409 return result; @@ -501,19 +501,19 @@ if ('onhashchange' in window) { 439 // first check if the instruction is directly modifying something it shouldn't 440 for (int i = 0; i < SIZE(inst.products); ++i) { 441 if (has_property(inst.products.at(i), "lookup") -442 && current_ingredient_and_aliases.find(inst.products.at(i)) != current_ingredient_and_aliases.end()) { +442 && current_ingredient_and_aliases.find(inst.products.at(i)) != current_ingredient_and_aliases.end()) { 443 string current_product_name = inst.products.at(i).name; 444 if (current_product_name == original_ingredient_name) -445 raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +445 raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 446 else -447 raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << inst.original_string << "' because that would modify " << original_ingredient_name << " which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +447 raise << maybe(caller.name) << "cannot modify '" << current_product_name << "' in instruction '" << inst.original_string << "' because that would modify " << original_ingredient_name << " which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 448 return; 449 } 450 } 451 // check if there's any indirect modification going on 452 set<int> current_ingredient_indices = ingredient_indices(inst, current_ingredient_and_aliases); 453 if (current_ingredient_indices.empty()) return; // ingredient not found in call -454 for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) { +454 for (set<int>::iterator p = current_ingredient_indices.begin(); p != current_ingredient_indices.end(); ++p) { 455 const int current_ingredient_index = *p; 456 reagent current_ingredient = inst.ingredients.at(current_ingredient_index); 457 canonize_type(current_ingredient); @@ -527,9 +527,9 @@ if ('onhashchange' in window) { 465 if (inst.operation == PUT || inst.operation == PUT_INDEX) { 466 if (current_ingredient_index == 0) { 467 if (current_ingredient_name == original_ingredient_name) -468 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +468 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 469 else -470 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +470 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 471 } 472 } 473 } @@ -537,9 +537,9 @@ if ('onhashchange' in window) { 475 // defined recipe 476 if (is_modified_in_recipe(inst.operation, current_ingredient_index, caller)) { 477 if (current_ingredient_name == original_ingredient_name) -478 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +478 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because it's an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 479 else -480 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); +480 raise << maybe(caller.name) << "cannot modify '" << current_ingredient_name << "' in instruction '" << inst.original_string << "' because that would modify '" << original_ingredient_name << "' which is an ingredient of recipe " << caller.name << " but not also a product\n" << end(); 481 } 482 } 483 } @@ -548,7 +548,7 @@ if ('onhashchange' in window) { 486 bool is_modified_in_recipe(const recipe_ordinal r, const int ingredient_index, const recipe& caller) { 487 const recipe& callee = get(Recipe, r); 488 if (!callee.has_header) { -489 raise << maybe(caller.name) << "can't check mutability of ingredients in recipe " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end(); +489 raise << maybe(caller.name) << "can't check mutability of ingredients in recipe " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end(); 490 return true; 491 } 492 if (ingredient_index >= SIZE(callee.ingredients)) return false; // optional immutable ingredient @@ -567,7 +567,7 @@ if ('onhashchange' in window) { 505 set<int> result; 506 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 507 if (is_literal(inst.ingredients.at(i))) continue; -508 if (ingredient_names.find(inst.ingredients.at(i)) != ingredient_names.end()) +508 if (ingredient_names.find(inst.ingredients.at(i)) != ingredient_names.end()) 509 result.insert(i); 510 } 511 return result; @@ -619,7 +619,7 @@ if ('onhashchange' in window) { 557 if (!tmp->atom 558 || (!is_present_in_ingredients(caller, tmp->value) 559 && !is_present_in_products(caller, tmp->value))) { -560 raise << maybe(caller.name) << "/contained-in can only point to another ingredient or product, but got '" << to_string(property(current_ingredient, "contained-in")) << "'\n" << end(); +560 raise << maybe(caller.name) << "/contained-in can only point to another ingredient or product, but got '" << to_string(property(current_ingredient, "contained-in")) << "'\n" << end(); 561 } 562 continue; 563 } diff --git a/html/058to_text.cc.html b/html/058to_text.cc.html index 81b9bcd9..d3b8b2cb 100644 --- a/html/058to_text.cc.html +++ b/html/058to_text.cc.html @@ -67,7 +67,7 @@ if ('onhashchange' in window) { 9 :(before "End Primitive Recipe Checks") 10 case TO_TEXT: { 11 if (SIZE(inst.ingredients) != 1) { -12 raise << maybe(get(Recipe, r).name) << "'to-text' requires a single ingredient, but got '" << inst.original_string << "'\n" << end(); +12 raise << maybe(get(Recipe, r).name) << "'to-text' requires a single ingredient, but got '" << inst.original_string << "'\n" << end(); 13 break; 14 } 15 // can handle any type diff --git a/html/060rewrite_literal_string.cc.html b/html/060rewrite_literal_string.cc.html index b36c07e2..bccfbd07 100644 --- a/html/060rewrite_literal_string.cc.html +++ b/html/060rewrite_literal_string.cc.html @@ -95,12 +95,12 @@ if ('onhashchange' in window) { 35 36 void rewrite_literal_string_to_text(const recipe_ordinal r) { 37 recipe& caller = get(Recipe, r); -38 trace(9991, "transform") << "--- rewrite literal strings in recipe " << caller.name << end(); +38 trace(9991, "transform") << "--- rewrite literal strings in recipe " << caller.name << end(); 39 if (contains_numeric_locations(caller)) return; 40 vector<instruction> new_instructions; 41 for (int i = 0; i < SIZE(caller.steps); ++i) { 42 instruction& inst = caller.steps.at(i); -43 if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) { +43 if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) { 44 for (int j = 0; j < SIZE(inst.ingredients); ++j) { 45 if (!is_literal_text(inst.ingredients.at(j))) continue; 46 instruction def; diff --git a/html/062convert_ingredients_to_text.cc.html b/html/062convert_ingredients_to_text.cc.html index 963c3fe3..09b0cd2c 100644 --- a/html/062convert_ingredients_to_text.cc.html +++ b/html/062convert_ingredients_to_text.cc.html @@ -75,10 +75,10 @@ if ('onhashchange' in window) { 14 def main [ 15 local-scope 16 n:num <- copy 34 - 17 trace 2, [app], n + 17 trace 2, [app], n 18 ] 19 +transform: {trace_2_2: ("address" "array" "character")} <- to-text-line {n: "number"} - 20 +transform: trace {2: "literal"}, {"app": "literal-string"}, {trace_2_2: ("address" "array" "character")} + 20 +transform: trace {2: "literal"}, {"app": "literal-string"}, {trace_2_2: ("address" "array" "character")} 21 22 //: special case: rewrite attempts to stash contents of most arrays to avoid 23 //: passing addresses around @@ -120,7 +120,7 @@ if ('onhashchange' in window) { 59 :(code) 60 void convert_ingredients_to_text(const recipe_ordinal r) { 61 recipe& caller = get(Recipe, r); - 62 trace(9991, "transform") << "--- convert some ingredients to text in recipe " << caller.name << end(); + 62 trace(9991, "transform") << "--- convert some ingredients to text in recipe " << caller.name << end(); 63 // in recipes without named locations, 'stash' is still not extensible 64 if (contains_numeric_locations(caller)) return; 65 convert_ingredients_to_text(caller); @@ -161,7 +161,7 @@ if ('onhashchange' in window) { 100 } 101 } 102 } -103 trace(9993, "transform") << to_string(inst) << end(); +103 trace(9993, "transform") << to_string(inst) << end(); 104 new_instructions.push_back(inst); 105 } 106 caller.steps.swap(new_instructions); @@ -186,7 +186,7 @@ if ('onhashchange' in window) { 125 def.ingredients.push_back(r); 126 } 127 def.products.push_back(reagent(tmp_var)); -128 trace(9993, "transform") << to_string(def) << end(); +128 trace(9993, "transform") << to_string(def) << end(); 129 out.push_back(def); 130 r.clear(); // reclaim old memory 131 r = reagent(tmp_var); diff --git a/html/069hash.cc.html b/html/069hash.cc.html index 8e6e1f54..1c454bb6 100644 --- a/html/069hash.cc.html +++ b/html/069hash.cc.html @@ -78,7 +78,7 @@ if ('onhashchange' in window) { 15 :(before "End Primitive Recipe Checks") 16 case HASH: { 17 if (SIZE(inst.ingredients) != 1) { - 18 raise << maybe(get(Recipe, r).name) << "'hash' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); + 18 raise << maybe(get(Recipe, r).name) << "'hash' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); 19 break; 20 } 21 break; @@ -118,10 +118,10 @@ if ('onhashchange' in window) { 55 56 size_t hash_mu_address(size_t h, reagent& r) { 57 if (r.value == 0) return 0; - 58 trace(9999, "mem") << "location " << r.value << " is " << no_scientific(get_or_insert(Memory, r.value)) << end(); + 58 trace(9999, "mem") << "location " << r.value << " is " << no_scientific(get_or_insert(Memory, r.value)) << end(); 59 r.set_value(get_or_insert(Memory, r.value)); 60 if (r.value != 0) { - 61 trace(9999, "mem") << "skipping refcount at " << r.value << end(); + 61 trace(9999, "mem") << "skipping refcount at " << r.value << end(); 62 r.set_value(r.value+1); // skip refcount 63 } 64 drop_from_type(r, "address"); @@ -173,7 +173,7 @@ if ('onhashchange' in window) { 110 reagent/*copy*/ variant = variant_type(r, tag); 111 // todo: move this error to container definition time 112 if (has_property(variant, "ignore-for-hash")) -113 raise << get(Type, type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end(); +113 raise << get(Type, type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end(); 114 variant.set_value(r.value + /*skip tag*/1); 115 h = hash(h, variant); 116 return h; @@ -414,11 +414,11 @@ if ('onhashchange' in window) { 351 :(before "End Primitive Recipe Checks") 352 case HASH_OLD: { 353 if (SIZE(inst.ingredients) != 1) { -354 raise << maybe(get(Recipe, r).name) << "'hash_old' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); +354 raise << maybe(get(Recipe, r).name) << "'hash_old' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); 355 break; 356 } 357 if (!is_mu_text(inst.ingredients.at(0))) { -358 raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports texts (address array character), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +358 raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports texts (address array character), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 359 break; 360 } 361 break; diff --git a/html/071recipe.cc.html b/html/071recipe.cc.html index 53e3f088..93055af1 100644 --- a/html/071recipe.cc.html +++ b/html/071recipe.cc.html @@ -110,7 +110,7 @@ if ('onhashchange' in window) { 48 if (x.type) return false; 49 if (!contains_key(Recipe_ordinal, x.name)) return false; 50 if (contains_reagent_with_type(caller, x.name)) { - 51 raise << maybe(caller.name) << "you can't use '" << x.name << "' as a recipe literal when it's also a variable\n" << end(); + 51 raise << maybe(caller.name) << "you can't use '" << x.name << "' as a recipe literal when it's also a variable\n" << end(); 52 return false; 53 } 54 return true; @@ -155,11 +155,11 @@ if ('onhashchange' in window) { 93 :(before "End Primitive Recipe Checks") 94 case CALL: { 95 if (inst.ingredients.empty()) { - 96 raise << maybe(get(Recipe, r).name) << "'call' requires at least one ingredient (the recipe to call)\n" << end(); + 96 raise << maybe(get(Recipe, r).name) << "'call' requires at least one ingredient (the recipe to call)\n" << end(); 97 break; 98 } 99 if (!is_mu_recipe(inst.ingredients.at(0))) { -100 raise << maybe(get(Recipe, r).name) << "first ingredient of 'call' should be a recipe, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +100 raise << maybe(get(Recipe, r).name) << "first ingredient of 'call' should be a recipe, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 101 break; 102 } 103 break; @@ -169,11 +169,11 @@ if ('onhashchange' in window) { 107 // Begin Call 108 if (Trace_stream) { 109 ++Trace_stream->callstack_depth; -110 trace("trace") << "indirect 'call': incrementing callstack depth to " << Trace_stream->callstack_depth << end(); +110 trace("trace") << "indirect 'call': incrementing callstack depth to " << Trace_stream->callstack_depth << end(); 111 assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion 112 } 113 if (!ingredients.at(0).at(0)) { -114 raise << maybe(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end(); +114 raise << maybe(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end(); 115 break; 116 } 117 instruction/*copy*/ call_instruction = current_instruction(); @@ -218,7 +218,7 @@ if ('onhashchange' in window) { 156 Transform.push_back(check_indirect_calls_against_header); // idempotent 157 :(code) 158 void check_indirect_calls_against_header(const recipe_ordinal r) { -159 trace(9991, "transform") << "--- type-check 'call' instructions inside recipe " << get(Recipe, r).name << end(); +159 trace(9991, "transform") << "--- type-check 'call' instructions inside recipe " << get(Recipe, r).name << end(); 160 const recipe& caller = get(Recipe, r); 161 for (int i = 0; i < SIZE(caller.steps); ++i) { 162 const instruction& inst = caller.steps.at(i); @@ -231,14 +231,14 @@ if ('onhashchange' in window) { 169 if (is_indirect_call_with_ingredients(inst.operation)) { 170 for (long int i = /*skip callee*/1; i < min(SIZE(inst.ingredients), SIZE(callee_header.ingredients)+/*skip callee*/1); ++i) { 171 if (!types_coercible(callee_header.ingredients.at(i-/*skip callee*/1), inst.ingredients.at(i))) -172 raise << maybe(caller.name) << "ingredient " << i-/*skip callee*/1 << " has the wrong type at '" << inst.original_string << "'\n" << end(); +172 raise << maybe(caller.name) << "ingredient " << i-/*skip callee*/1 << " has the wrong type at '" << inst.original_string << "'\n" << end(); 173 } 174 } 175 if (is_indirect_call_with_products(inst.operation)) { 176 for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee_header.products)); ++i) { 177 if (is_dummy(inst.products.at(i))) continue; 178 if (!types_coercible(callee_header.products.at(i), inst.products.at(i))) -179 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); +179 raise << maybe(caller.name) << "product " << i << " has the wrong type at '" << inst.original_string << "'\n" << end(); 180 } 181 } 182 } @@ -366,7 +366,7 @@ if ('onhashchange' in window) { 304 :(before "End Matching Types For Literal(to)") 305 if (is_mu_recipe(to)) { 306 if (!contains_key(Recipe, from.value)) { -307 raise << "trying to store recipe " << from.name << " into " << to_string(to) << " but there's no such recipe\n" << end(); +307 raise << "trying to store recipe " << from.name << " into " << to_string(to) << " but there's no such recipe\n" << end(); 308 return false; 309 } 310 const recipe& rrhs = get(Recipe, from.value); @@ -418,9 +418,9 @@ if ('onhashchange' in window) { 356 void check_for_recipe_literals(const instruction& inst, const recipe& caller) { 357 for (int i = 0; i < SIZE(inst.ingredients); ++i) { 358 if (is_mu_recipe(inst.ingredients.at(i))) { -359 raise << maybe(caller.name) << "missing type for '" << inst.ingredients.at(i).original_string << "' in '" << inst.original_string << "'\n" << end(); +359 raise << maybe(caller.name) << "missing type for '" << inst.ingredients.at(i).original_string << "' in '" << inst.original_string << "'\n" << end(); 360 if (is_present_in_ingredients(caller, inst.ingredients.at(i).name)) -361 raise << " did you forget 'load-ingredients'?\n" << end(); +361 raise << " did you forget 'load-ingredients'?\n" << end(); 362 } 363 } 364 } diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 0e035242..37bc5fc4 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -129,7 +129,7 @@ if ('onhashchange' in window) { 66 skip_to_next_routine(); 67 assert(Current_routine); 68 assert(Current_routine->state == RUNNING); - 69 trace(9990, "schedule") << current_routine_label() << end(); + 69 trace(9990, "schedule") << current_routine_label() << end(); 70 run_current_routine(); 71 // Scheduler State Transitions 72 if (Current_routine->completed()) @@ -170,7 +170,7 @@ if ('onhashchange' in window) { 107 string routine_label(routine* r) { 108 ostringstream result; 109 const call_stack& calls = r->calls; -110 for (call_stack::const_iterator p = calls.begin(); p != calls.end(); ++p) { +110 for (call_stack::const_iterator p = calls.begin(); p != calls.end(); ++p) { 111 if (p != calls.begin()) result << '/'; 112 result << get(Recipe, p->running_recipe).name; 113 } @@ -230,11 +230,11 @@ if ('onhashchange' in window) { 167 :(before "End Primitive Recipe Checks") 168 case START_RUNNING: { 169 if (inst.ingredients.empty()) { -170 raise << maybe(get(Recipe, r).name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end(); +170 raise << maybe(get(Recipe, r).name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end(); 171 break; 172 } 173 if (!is_mu_recipe(inst.ingredients.at(0))) { -174 raise << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +174 raise << maybe(get(Recipe, r).name) << "first ingredient of 'start-running' should be a recipe, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 175 break; 176 } 177 break; @@ -521,11 +521,11 @@ if ('onhashchange' in window) { 458 :(before "End Primitive Recipe Checks") 459 case ROUTINE_STATE: { 460 if (SIZE(inst.ingredients) != 1) { -461 raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +461 raise << maybe(get(Recipe, r).name) << "'routine-state' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 462 break; 463 } 464 if (!is_mu_number(inst.ingredients.at(0))) { -465 raise << maybe(get(Recipe, r).name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +465 raise << maybe(get(Recipe, r).name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 466 break; 467 } 468 break; @@ -554,11 +554,11 @@ if ('onhashchange' in window) { 491 :(before "End Primitive Recipe Checks") 492 case STOP: { 493 if (SIZE(inst.ingredients) != 1) { -494 raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +494 raise << maybe(get(Recipe, r).name) << "'stop' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 495 break; 496 } 497 if (!is_mu_number(inst.ingredients.at(0))) { -498 raise << maybe(get(Recipe, r).name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +498 raise << maybe(get(Recipe, r).name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 499 break; 500 } 501 break; @@ -615,7 +615,7 @@ if ('onhashchange' in window) { 552 :(before "End Scheduler State Transitions") 553 if (Current_routine->limit >= 0) { 554 if (Current_routine->limit <= Scheduling_interval) { -555 trace(9999, "schedule") << "discontinuing routine " << Current_routine->id << end(); +555 trace(9999, "schedule") << "discontinuing routine " << Current_routine->id << end(); 556 Current_routine->state = DISCONTINUED; 557 Current_routine->limit = 0; 558 } @@ -626,10 +626,10 @@ if ('onhashchange' in window) { 563 564 :(before "End Test Teardown") 565 if (Passed && any_routines_with_error()) -566 raise << "some routines died with errors\n" << end(); +566 raise << "some routines died with errors\n" << end(); 567 :(before "End Mu Test Teardown") 568 if (Passed && any_routines_with_error()) -569 raise << Current_scenario->name << ": some routines died with errors\n" << end(); +569 raise << Current_scenario->name << ": some routines died with errors\n" << end(); 570 571 :(code) 572 bool any_routines_with_error() { @@ -652,15 +652,15 @@ if ('onhashchange' in window) { 589 :(before "End Primitive Recipe Checks") 590 case LIMIT_TIME: { 591 if (SIZE(inst.ingredients) != 2) { -592 raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); +592 raise << maybe(get(Recipe, r).name) << "'limit-time' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); 593 break; 594 } 595 if (!is_mu_number(inst.ingredients.at(0))) { -596 raise << maybe(get(Recipe, r).name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +596 raise << maybe(get(Recipe, r).name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 597 break; 598 } 599 if (!is_mu_number(inst.ingredients.at(1))) { -600 raise << maybe(get(Recipe, r).name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +600 raise << maybe(get(Recipe, r).name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 601 break; 602 } 603 break; @@ -690,11 +690,11 @@ if ('onhashchange' in window) { 627 :(before "End Primitive Recipe Checks") 628 case NUMBER_OF_INSTRUCTIONS: { 629 if (SIZE(inst.ingredients) != 1) { -630 raise << maybe(get(Recipe, r).name) << "'number-of-instructions' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +630 raise << maybe(get(Recipe, r).name) << "'number-of-instructions' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 631 break; 632 } 633 if (!is_mu_number(inst.ingredients.at(0))) { -634 raise << maybe(get(Recipe, r).name) << "first ingredient of 'number-of-instructions' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +634 raise << maybe(get(Recipe, r).name) << "first ingredient of 'number-of-instructions' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 635 break; 636 } 637 break; diff --git a/html/073wait.cc.html b/html/073wait.cc.html index 914b47b8..c2569b5a 100644 --- a/html/073wait.cc.html +++ b/html/073wait.cc.html @@ -97,15 +97,15 @@ if ('onhashchange' in window) { 34 35 :(before "End Mu Test Teardown") 36 if (Passed && any_routines_waiting()) - 37 raise << Current_scenario->name << ": deadlock!\n" << end(); + 37 raise << Current_scenario->name << ": deadlock!\n" << end(); 38 :(before "End Run Routine") 39 if (any_routines_waiting()) { - 40 raise << "deadlock!\n" << end(); + 40 raise << "deadlock!\n" << end(); 41 dump_waiting_routines(); 42 } 43 :(before "End Test Teardown") 44 if (Passed && any_routines_with_error()) - 45 raise << "some routines died with errors\n" << end(); + 45 raise << "some routines died with errors\n" << end(); 46 :(code) 47 bool any_routines_waiting() { 48 for (int i = 0; i < SIZE(Routines); ++i) { @@ -141,24 +141,24 @@ if ('onhashchange' in window) { 78 :(before "End Primitive Recipe Checks") 79 case WAIT_FOR_RESET_THEN_SET: { 80 if (SIZE(inst.ingredients) != 1) { - 81 raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 81 raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 82 break; 83 } 84 if (!is_mu_location(inst.ingredients.at(0))) { - 85 raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + 85 raise << maybe(get(Recipe, r).name) << "'wait-for-reset-then-set' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 86 } 87 break; 88 } 89 :(before "End Primitive Recipe Implementations") 90 case WAIT_FOR_RESET_THEN_SET: { 91 int loc = static_cast<int>(ingredients.at(0).at(0)); - 92 trace(9998, "run") << "wait: *" << loc << " = " << get_or_insert(Memory, loc) << end(); + 92 trace(9998, "run") << "wait: *" << loc << " = " << get_or_insert(Memory, loc) << end(); 93 if (get_or_insert(Memory, loc) == 0) { - 94 trace(9998, "run") << "location " << loc << " is already 0; setting" << end(); + 94 trace(9998, "run") << "location " << loc << " is already 0; setting" << end(); 95 put(Memory, loc, 1); 96 break; 97 } - 98 trace(9998, "run") << "waiting for location " << loc << " to reset" << end(); + 98 trace(9998, "run") << "waiting for location " << loc << " to reset" << end(); 99 Current_routine->state = WAITING; 100 Current_routine->waiting_on_location = loc; 101 break; @@ -172,11 +172,11 @@ if ('onhashchange' in window) { 109 :(before "End Primitive Recipe Checks") 110 case RESET: { 111 if (SIZE(inst.ingredients) != 1) { -112 raise << maybe(get(Recipe, r).name) << "'reset' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +112 raise << maybe(get(Recipe, r).name) << "'reset' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 113 break; 114 } 115 if (!is_mu_location(inst.ingredients.at(0))) { -116 raise << maybe(get(Recipe, r).name) << "'reset' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +116 raise << maybe(get(Recipe, r).name) << "'reset' requires a location ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 117 } 118 break; 119 } @@ -184,7 +184,7 @@ if ('onhashchange' in window) { 121 case RESET: { 122 int loc = static_cast<int>(ingredients.at(0).at(0)); 123 put(Memory, loc, 0); -124 trace(9998, "run") << "reset: *" << loc << " = " << get_or_insert(Memory, loc) << end(); +124 trace(9998, "run") << "reset: *" << loc << " = " << get_or_insert(Memory, loc) << end(); 125 break; 126 } 127 @@ -195,7 +195,7 @@ if ('onhashchange' in window) { 132 if (Routines.at(i)->state != WAITING) continue; 133 int loc = Routines.at(i)->waiting_on_location; 134 if (loc && get_or_insert(Memory, loc) == 0) { -135 trace(9999, "schedule") << "waking up routine " << Routines.at(i)->id << end(); +135 trace(9999, "schedule") << "waking up routine " << Routines.at(i)->id << end(); 136 put(Memory, loc, 1); 137 Routines.at(i)->state = RUNNING; 138 Routines.at(i)->waiting_on_location = 0; @@ -221,24 +221,24 @@ if ('onhashchange' in window) { 158 :(before "End Primitive Recipe Checks") 159 case GET_LOCATION: { 160 if (SIZE(inst.ingredients) != 2) { -161 raise << maybe(get(Recipe, r).name) << "'get-location' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); +161 raise << maybe(get(Recipe, r).name) << "'get-location' expects exactly 2 ingredients in '" << inst.original_string << "'\n" << end(); 162 break; 163 } 164 reagent/*copy*/ base = inst.ingredients.at(0); 165 if (!canonize_type(base)) break; 166 if (!base.type) { -167 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +167 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 168 break; 169 } 170 const type_tree* base_root_type = base.type->atom ? base.type : base.type->left; 171 if (!base_root_type->atom || base_root_type->value == 0 || !contains_key(Type, base_root_type->value) || get(Type, base_root_type->value).kind != CONTAINER) { -172 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +172 raise << maybe(get(Recipe, r).name) << "first ingredient of 'get-location' should be a container, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 173 break; 174 } 175 type_ordinal base_type = base.type->value; 176 const reagent& offset = inst.ingredients.at(1); 177 if (!is_literal(offset) || !is_mu_scalar(offset)) { -178 raise << maybe(get(Recipe, r).name) << "second ingredient of 'get-location' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +178 raise << maybe(get(Recipe, r).name) << "second ingredient of 'get-location' should have type 'offset', but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 179 break; 180 } 181 int offset_value = 0; @@ -246,7 +246,7 @@ if ('onhashchange' in window) { 183 if (is_integer(offset.name)) { 184 offset_value = to_integer(offset.name); 185 if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type).elements)) { -186 raise << maybe(get(Recipe, r).name) << "invalid offset " << offset_value << " for '" << get(Type, base_type).name << "'\n" << end(); +186 raise << maybe(get(Recipe, r).name) << "invalid offset " << offset_value << " for '" << get(Type, base_type).name << "'\n" << end(); 187 break; 188 } 189 } @@ -255,7 +255,7 @@ if ('onhashchange' in window) { 192 } 193 if (inst.products.empty()) break; 194 if (!is_mu_location(inst.products.at(0))) { -195 raise << maybe(get(Recipe, r).name) << "'get-location " << base.original_string << ", " << offset.original_string << "' should write to type location but '" << inst.products.at(0).name << "' has type '" << names_to_string_without_quotes(inst.products.at(0).type) << "'\n" << end(); +195 raise << maybe(get(Recipe, r).name) << "'get-location " << base.original_string << ", " << offset.original_string << "' should write to type location but '" << inst.products.at(0).name << "' has type '" << names_to_string_without_quotes(inst.products.at(0).type) << "'\n" << end(); 196 break; 197 } 198 break; @@ -266,7 +266,7 @@ if ('onhashchange' in window) { 203 canonize(base); 204 int base_address = base.value; 205 if (base_address == 0) { -206 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); +206 raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); 207 break; 208 } 209 const type_tree* base_type = get_base_type(base.type); @@ -275,7 +275,7 @@ if ('onhashchange' in window) { 212 int result = base_address; 213 for (int i = 0; i < offset; ++i) 214 result += size_of(element_type(base.type, i)); -215 trace(9998, "run") << "address to copy is " << result << end(); +215 trace(9998, "run") << "address to copy is " << result << end(); 216 products.resize(1); 217 products.at(0).push_back(result); 218 break; @@ -388,11 +388,11 @@ if ('onhashchange' in window) { 325 :(before "End Primitive Recipe Checks") 326 case WAIT_FOR_ROUTINE: { 327 if (SIZE(inst.ingredients) != 1) { -328 raise << maybe(get(Recipe, r).name) << "'wait-for-routine' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +328 raise << maybe(get(Recipe, r).name) << "'wait-for-routine' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 329 break; 330 } 331 if (!is_mu_number(inst.ingredients.at(0))) { -332 raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +332 raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 333 break; 334 } 335 break; @@ -400,12 +400,12 @@ if ('onhashchange' in window) { 337 :(before "End Primitive Recipe Implementations") 338 case WAIT_FOR_ROUTINE: { 339 if (ingredients.at(0).at(0) == Current_routine->id) { -340 raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end(); +340 raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end(); 341 break; 342 } 343 Current_routine->state = WAITING; 344 Current_routine->waiting_on_routine = ingredients.at(0).at(0); -345 trace(9998, "run") << "waiting for routine " << ingredients.at(0).at(0) << end(); +345 trace(9998, "run") << "waiting for routine " << ingredients.at(0).at(0) << end(); 346 break; 347 } 348 @@ -423,7 +423,7 @@ if ('onhashchange' in window) { 360 const routine* waitee = Routines.at(j); 361 if (waitee->id == id && waitee->state != RUNNING && waitee->state != WAITING) { 362 // routine is COMPLETED or DISCONTINUED -363 trace(9999, "schedule") << "waking up routine " << waiter->id << end(); +363 trace(9999, "schedule") << "waking up routine " << waiter->id << end(); 364 waiter->state = RUNNING; 365 waiter->waiting_on_routine = 0; 366 } @@ -487,7 +487,7 @@ if ('onhashchange' in window) { 424 :(before "End Primitive Recipe Checks") 425 case CURRENT_ROUTINE_IS_BLOCKED: { 426 if (!inst.ingredients.empty()) { -427 raise << maybe(get(Recipe, r).name) << "'current-routine-is-blocked' should have no ingredients, but got '" << inst.original_string << "'\n" << end(); +427 raise << maybe(get(Recipe, r).name) << "'current-routine-is-blocked' should have no ingredients, but got '" << inst.original_string << "'\n" << end(); 428 break; 429 } 430 break; @@ -505,7 +505,7 @@ if ('onhashchange' in window) { 442 :(before "End Primitive Recipe Checks") 443 case CURRENT_ROUTINE_IS_UNBLOCKED: { 444 if (!inst.ingredients.empty()) { -445 raise << maybe(get(Recipe, r).name) << "'current-routine-is-unblocked' should have no ingredients, but got '" << inst.original_string << "'\n" << end(); +445 raise << maybe(get(Recipe, r).name) << "'current-routine-is-unblocked' should have no ingredients, but got '" << inst.original_string << "'\n" << end(); 446 break; 447 } 448 break; @@ -550,11 +550,11 @@ if ('onhashchange' in window) { 487 :(before "End Primitive Recipe Checks") 488 case WAIT_FOR_ROUTINE_TO_BLOCK: { 489 if (SIZE(inst.ingredients) != 1) { -490 raise << maybe(get(Recipe, r).name) << "'wait-for-routine-to-block' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +490 raise << maybe(get(Recipe, r).name) << "'wait-for-routine-to-block' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 491 break; 492 } 493 if (!is_mu_number(inst.ingredients.at(0))) { -494 raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine-to-block' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +494 raise << maybe(get(Recipe, r).name) << "first ingredient of 'wait-for-routine-to-block' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 495 break; 496 } 497 break; @@ -562,12 +562,12 @@ if ('onhashchange' in window) { 499 :(before "End Primitive Recipe Implementations") 500 case WAIT_FOR_ROUTINE_TO_BLOCK: { 501 if (ingredients.at(0).at(0) == Current_routine->id) { -502 raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end(); +502 raise << maybe(current_recipe_name()) << "routine can't wait for itself! '" << to_original_string(current_instruction()) << "'\n" << end(); 503 break; 504 } 505 Current_routine->state = WAITING; 506 Current_routine->waiting_on_routine_to_block = ingredients.at(0).at(0); -507 trace(9998, "run") << "waiting for routine " << ingredients.at(0).at(0) << " to block" << end(); +507 trace(9998, "run") << "waiting for routine " << ingredients.at(0).at(0) << " to block" << end(); 508 break; 509 } 510 @@ -583,7 +583,7 @@ if ('onhashchange' in window) { 520 const routine* waitee = Routines.at(j); 521 if (waitee->id != id) continue; 522 if (waitee->state != RUNNING || waitee->blocked) { -523 trace(9999, "schedule") << "waking up routine " << waiter->id << " because routine " << waitee->id << " is blocked" << end(); +523 trace(9999, "schedule") << "waking up routine " << waiter->id << " because routine " << waitee->id << " is blocked" << end(); 524 waiter->state = RUNNING; 525 waiter->waiting_on_routine_to_block = 0; 526 } @@ -599,11 +599,11 @@ if ('onhashchange' in window) { 536 :(before "End Primitive Recipe Checks") 537 case RESTART: { 538 if (SIZE(inst.ingredients) != 1) { -539 raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +539 raise << maybe(get(Recipe, r).name) << "'restart' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 540 break; 541 } 542 if (!is_mu_number(inst.ingredients.at(0))) { -543 raise << maybe(get(Recipe, r).name) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +543 raise << maybe(get(Recipe, r).name) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 544 break; 545 } 546 break; diff --git a/html/074deep_copy.cc.html b/html/074deep_copy.cc.html index 6ce251c7..a095aac9 100644 --- a/html/074deep_copy.cc.html +++ b/html/074deep_copy.cc.html @@ -257,15 +257,15 @@ if ('onhashchange' in window) { 195 :(before "End Primitive Recipe Checks") 196 case DEEP_COPY: { 197 if (SIZE(inst.ingredients) != 1) { -198 raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); +198 raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); 199 break; 200 } 201 if (SIZE(inst.products) != 1) { -202 raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); +202 raise << maybe(get(Recipe, r).name) << "'deep-copy' takes exactly one ingredient rather than '" << inst.original_string << "'\n" << end(); 203 break; 204 } 205 if (!types_strictly_match(inst.ingredients.at(0), inst.products.at(0))) { -206 raise << maybe(get(Recipe, r).name) << "'deep-copy' requires its ingredient and product to be the same type, but got '" << inst.original_string << "'\n" << end(); +206 raise << maybe(get(Recipe, r).name) << "'deep-copy' requires its ingredient and product to be the same type, but got '" << inst.original_string << "'\n" << end(); 207 break; 208 } 209 break; @@ -274,12 +274,12 @@ if ('onhashchange' in window) { 212 case DEEP_COPY: { 213 const reagent& input = current_instruction().ingredients.at(0); 214 // allocate a tiny bit of temporary space for deep_copy() -215 trace(9991, "run") << "deep-copy: allocating space for temporary" << end(); +215 trace(9991, "run") << "deep-copy: allocating space for temporary" << end(); 216 reagent tmp("tmp:address:number"); 217 tmp.set_value(allocate(1)); 218 products.push_back(deep_copy(input, tmp)); 219 // reclaim Mu memory allocated for tmp -220 trace(9991, "run") << "deep-copy: reclaiming temporary" << end(); +220 trace(9991, "run") << "deep-copy: reclaiming temporary" << end(); 221 abandon(tmp.value, payload_type(tmp.type), payload_size(tmp)); 222 // reclaim host memory allocated for tmp.type when tmp goes out of scope 223 break; @@ -305,29 +305,29 @@ if ('onhashchange' in window) { 243 int deep_copy_address(const reagent& canonized_in, map<int, int>& addresses_copied, const reagent& tmp) { 244 if (canonized_in.value == 0) return 0; 245 int in_address = payload_address(canonized_in); -246 trace(9991, "run") << "deep-copy: copying address " << in_address << end(); +246 trace(9991, "run") << "deep-copy: copying address " << in_address << end(); 247 if (contains_key(addresses_copied, in_address)) { 248 int out = get(addresses_copied, in_address); -249 trace(9991, "run") << "deep-copy: copy already exists: " << out << end(); +249 trace(9991, "run") << "deep-copy: copy already exists: " << out << end(); 250 return out; 251 } 252 int out = allocate(payload_size(canonized_in)); -253 trace(9991, "run") << "deep-copy: new address is " << out << end(); +253 trace(9991, "run") << "deep-copy: new address is " << out << end(); 254 put(addresses_copied, in_address, out); 255 reagent/*copy*/ payload = canonized_in; 256 payload.properties.push_back(pair<string, string_tree*>("lookup", NULL)); -257 trace(9991, "run") << "recursing on payload " << payload.value << ' ' << to_string(payload) << end(); +257 trace(9991, "run") << "recursing on payload " << payload.value << ' ' << to_string(payload) << end(); 258 vector<double> data = deep_copy(payload, addresses_copied, tmp); -259 trace(9991, "run") << "deep-copy: writing result " << out << ": " << to_string(data) << end(); +259 trace(9991, "run") << "deep-copy: writing result " << out << ": " << to_string(data) << end(); 260 // HACK: write_memory interface isn't ideal for this situation; we need 261 // a temporary location to help copy the payload. -262 trace(9991, "run") << "deep-copy: writing temporary " << tmp.value << ": " << out << end(); +262 trace(9991, "run") << "deep-copy: writing temporary " << tmp.value << ": " << out << end(); 263 put(Memory, tmp.value, out); 264 payload.set_value(tmp.value); // now modified for output 265 vector<double> old_data = read_memory(payload); -266 trace(9991, "run") << "deep-copy: really writing to " << payload.value << ' ' << to_string(payload) << " (old value " << to_string(old_data) << " new value " << to_string(data) << ")" << end(); +266 trace(9991, "run") << "deep-copy: really writing to " << payload.value << ' ' << to_string(payload) << " (old value " << to_string(old_data) << " new value " << to_string(data) << ")" << end(); 267 write_memory(payload, data); -268 trace(9991, "run") << "deep-copy: output is " << to_string(data) << end(); +268 trace(9991, "run") << "deep-copy: output is " << to_string(data) << end(); 269 return out; 270 } 271 @@ -335,13 +335,13 @@ if ('onhashchange' in window) { 273 void deep_copy(const reagent& canonized_in, map<int, int>& addresses_copied, const reagent& tmp, vector<double>& out) { 274 assert(!is_mu_address(canonized_in)); 275 vector<double> data = read_memory(canonized_in); -276 out.insert(out.end(), data.begin(), data.end()); +276 out.insert(out.end(), data.begin(), data.end()); 277 if (!contains_key(Container_metadata, canonized_in.type)) return; -278 trace(9991, "run") << "deep-copy: scanning for addresses in " << to_string(data) << end(); +278 trace(9991, "run") << "deep-copy: scanning for addresses in " << to_string(data) << end(); 279 const container_metadata& metadata = get(Container_metadata, canonized_in.type); -280 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { +280 for (map<set<tag_condition_info>, set<address_element_info> >::const_iterator p = metadata.address.begin(); p != metadata.address.end(); ++p) { 281 if (!all_match(data, p->first)) continue; -282 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { +282 for (set<address_element_info>::const_iterator info = p->second.begin(); info != p->second.end(); ++info) { 283 // construct a fake reagent that reads directly from the appropriate 284 // field of the container 285 reagent curr; @@ -351,7 +351,7 @@ if ('onhashchange' in window) { 289 curr.type = new type_tree(new type_tree("address"), new type_tree(*info->payload_type)); 290 curr.set_value(canonized_in.value + info->offset); 291 curr.properties.push_back(pair<string, string_tree*>("raw", NULL)); -292 trace(9991, "run") << "deep-copy: copying address " << curr.value << end(); +292 trace(9991, "run") << "deep-copy: copying address " << curr.value << end(); 293 out.at(info->offset) = deep_copy_address(curr, addresses_copied, tmp); 294 } 295 } diff --git a/html/080display.cc.html b/html/080display.cc.html index a9d13779..38129417 100644 --- a/html/080display.cc.html +++ b/html/080display.cc.html @@ -73,17 +73,17 @@ if ('onhashchange' in window) { 13 #define CHECK_SCREEN \ 14 if (!tb_is_active()) { \ 15 if (Run_tests) \ - 16 raise << maybe(current_recipe_name()) << "tried to print to real screen in a test!\n" << end(); \ + 16 raise << maybe(current_recipe_name()) << "tried to print to real screen in a test!\n" << end(); \ 17 else \ - 18 raise << maybe(current_recipe_name()) << "tried to print to real screen before 'open-console' or after 'close-console'\n" << end(); \ + 18 raise << maybe(current_recipe_name()) << "tried to print to real screen before 'open-console' or after 'close-console'\n" << end(); \ 19 break; \ 20 } 21 #define CHECK_CONSOLE \ 22 if (!tb_is_active()) { \ 23 if (Run_tests) \ - 24 raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse in a test!\n" << end(); \ + 24 raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse in a test!\n" << end(); \ 25 else \ - 26 raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse before 'open-console' or after 'close-console'\n" << end(); \ + 26 raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse before 'open-console' or after 'close-console'\n" << end(); \ 27 break; \ 28 } 29 @@ -103,9 +103,9 @@ if ('onhashchange' in window) { 43 int height = tb_height(); 44 if (width > 222 || height > 222) tb_shutdown(); 45 if (width > 222) - 46 raise << "sorry, Mu doesn't support windows wider than 222 characters in console mode. Please resize your window.\n" << end(); + 46 raise << "sorry, Mu doesn't support windows wider than 222 characters in console mode. Please resize your window.\n" << end(); 47 if (height > 222) - 48 raise << "sorry, Mu doesn't support windows taller than 222 characters in console mode. Please resize your window.\n" << end(); + 48 raise << "sorry, Mu doesn't support windows taller than 222 characters in console mode. Please resize your window.\n" << end(); 49 break; 50 } 51 @@ -184,22 +184,22 @@ if ('onhashchange' in window) { 124 :(before "End Primitive Recipe Checks") 125 case PRINT_CHARACTER_TO_DISPLAY: { 126 if (inst.ingredients.empty()) { -127 raise << maybe(get(Recipe, r).name) << "'print-character-to-display' requires at least one ingredient, but got '" << inst.original_string << "'\n" << end(); +127 raise << maybe(get(Recipe, r).name) << "'print-character-to-display' requires at least one ingredient, but got '" << inst.original_string << "'\n" << end(); 128 break; 129 } 130 if (!is_mu_number(inst.ingredients.at(0))) { -131 raise << maybe(get(Recipe, r).name) << "first ingredient of 'print-character-to-display' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +131 raise << maybe(get(Recipe, r).name) << "first ingredient of 'print-character-to-display' should be a character, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 132 break; 133 } 134 if (SIZE(inst.ingredients) > 1) { 135 if (!is_mu_number(inst.ingredients.at(1))) { -136 raise << maybe(get(Recipe, r).name) << "second ingredient of 'print-character-to-display' should be a foreground color number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +136 raise << maybe(get(Recipe, r).name) << "second ingredient of 'print-character-to-display' should be a foreground color number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 137 break; 138 } 139 } 140 if (SIZE(inst.ingredients) > 2) { 141 if (!is_mu_number(inst.ingredients.at(2))) { -142 raise << maybe(get(Recipe, r).name) << "third ingredient of 'print-character-to-display' should be a background color number, but got '" << inst.ingredients.at(2).original_string << "'\n" << end(); +142 raise << maybe(get(Recipe, r).name) << "third ingredient of 'print-character-to-display' should be a background color number, but got '" << inst.ingredients.at(2).original_string << "'\n" << end(); 143 break; 144 } 145 } @@ -272,15 +272,15 @@ if ('onhashchange' in window) { 212 :(before "End Primitive Recipe Checks") 213 case MOVE_CURSOR_ON_DISPLAY: { 214 if (SIZE(inst.ingredients) != 2) { -215 raise << maybe(get(Recipe, r).name) << "'move-cursor-on-display' requires two ingredients, but got '" << inst.original_string << "'\n" << end(); +215 raise << maybe(get(Recipe, r).name) << "'move-cursor-on-display' requires two ingredients, but got '" << inst.original_string << "'\n" << end(); 216 break; 217 } 218 if (!is_mu_number(inst.ingredients.at(0))) { -219 raise << maybe(get(Recipe, r).name) << "first ingredient of 'move-cursor-on-display' should be a row number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +219 raise << maybe(get(Recipe, r).name) << "first ingredient of 'move-cursor-on-display' should be a row number, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 220 break; 221 } 222 if (!is_mu_number(inst.ingredients.at(1))) { -223 raise << maybe(get(Recipe, r).name) << "second ingredient of 'move-cursor-on-display' should be a column number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +223 raise << maybe(get(Recipe, r).name) << "second ingredient of 'move-cursor-on-display' should be a column number, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 224 break; 225 } 226 break; diff --git a/html/082scenario_screen.cc.html b/html/082scenario_screen.cc.html index a4fb9b03..45f55deb 100644 --- a/html/082scenario_screen.cc.html +++ b/html/082scenario_screen.cc.html @@ -224,10 +224,10 @@ if ('onhashchange' in window) { 161 if (curr.name == "assume-screen") { 162 curr.name = "new-fake-screen"; 163 if (!curr.products.empty()) { -164 raise << result.name << ": 'assume-screen' has no products\n" << end(); +164 raise << result.name << ": 'assume-screen' has no products\n" << end(); 165 } 166 else if (!starts_with(result.name, "scenario_")) { -167 raise << result.name << ": 'assume-screen' can't be called here, only in scenarios\n" << end(); +167 raise << result.name << ": 'assume-screen' can't be called here, only in scenarios\n" << end(); 168 } 169 else { 170 assert(curr.products.empty()); @@ -251,11 +251,11 @@ if ('onhashchange' in window) { 188 :(before "End Primitive Recipe Checks") 189 case SCREEN_SHOULD_CONTAIN: { 190 if (SIZE(inst.ingredients) != 1) { -191 raise << maybe(get(Recipe, r).name) << "'screen-should-contain' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +191 raise << maybe(get(Recipe, r).name) << "'screen-should-contain' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 192 break; 193 } 194 if (!is_literal_text(inst.ingredients.at(0))) { -195 raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain' should be a literal string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +195 raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain' should be a literal string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 196 break; 197 } 198 break; @@ -275,15 +275,15 @@ if ('onhashchange' in window) { 212 :(before "End Primitive Recipe Checks") 213 case SCREEN_SHOULD_CONTAIN_IN_COLOR: { 214 if (SIZE(inst.ingredients) != 2) { -215 raise << maybe(get(Recipe, r).name) << "'screen-should-contain-in-color' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +215 raise << maybe(get(Recipe, r).name) << "'screen-should-contain-in-color' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 216 break; 217 } 218 if (!is_mu_number(inst.ingredients.at(0))) { -219 raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain-in-color' should be a number (color code), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +219 raise << maybe(get(Recipe, r).name) << "first ingredient of 'screen-should-contain-in-color' should be a number (color code), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 220 break; 221 } 222 if (!is_literal_text(inst.ingredients.at(1))) { -223 raise << maybe(get(Recipe, r).name) << "second ingredient of 'screen-should-contain-in-color' should be a literal string, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); +223 raise << maybe(get(Recipe, r).name) << "second ingredient of 'screen-should-contain-in-color' should be a literal string, but got '" << inst.ingredients.at(1).original_string << "'\n" << end(); 224 break; 225 } 226 break; @@ -329,7 +329,7 @@ if ('onhashchange' in window) { 266 cursor.skip_whitespace_and_comments(); 267 if (cursor.at_end()) break; 268 if (cursor.get() != '.') { -269 raise << Current_scenario->name << ": each row of the expected screen should start with a '.'\n" << end(); +269 raise << Current_scenario->name << ": each row of the expected screen should start with a '.'\n" << end(); 270 if (!Scenario_testing_scenario) Passed = false; 271 return; 272 } @@ -346,12 +346,12 @@ if ('onhashchange' in window) { 283 // contents match but color is off 284 if (Current_scenario && !Scenario_testing_scenario) { 285 // genuine test in a .mu file -286 raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ", address " << addr << ", value " << no_scientific(get_or_insert(Memory, addr)) << ") to be in color " << color << " instead of " << no_scientific(get_or_insert(Memory, addr+cell_color_offset)) << "\n" << end(); +286 raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ", address " << addr << ", value " << no_scientific(get_or_insert(Memory, addr)) << ") to be in color " << color << " instead of " << no_scientific(get_or_insert(Memory, addr+cell_color_offset)) << "\n" << end(); 287 dump_screen(); 288 } 289 else { 290 // just testing check_screen -291 raise << "expected screen location (" << row << ", " << column << ") to be in color " << color << " instead of " << no_scientific(get_or_insert(Memory, addr+cell_color_offset)) << '\n' << end(); +291 raise << "expected screen location (" << row << ", " << column << ") to be in color " << color << " instead of " << no_scientific(get_or_insert(Memory, addr+cell_color_offset)) << '\n' << end(); 292 } 293 if (!Scenario_testing_scenario) Passed = false; 294 return; @@ -374,25 +374,25 @@ if ('onhashchange' in window) { 311 if (color != -1) color_phrase << " in color " << color; 312 if (Current_scenario && !Scenario_testing_scenario) { 313 // genuine test in a .mu file -314 raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << color_phrase.str() << " instead of " << no_scientific(get_or_insert(Memory, addr)) << actual_pretty << '\n' << end(); +314 raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << color_phrase.str() << " instead of " << no_scientific(get_or_insert(Memory, addr)) << actual_pretty << '\n' << end(); 315 dump_screen(); 316 } 317 else { 318 // just testing check_screen -319 raise << "expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << color_phrase.str() << " instead of " << no_scientific(get_or_insert(Memory, addr)) << actual_pretty << '\n' << end(); +319 raise << "expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << color_phrase.str() << " instead of " << no_scientific(get_or_insert(Memory, addr)) << actual_pretty << '\n' << end(); 320 } 321 if (!Scenario_testing_scenario) Passed = false; 322 return; 323 } 324 if (cursor.get() != '.') { -325 raise << Current_scenario->name << ": row " << row << " of the expected screen is too long\n" << end(); +325 raise << Current_scenario->name << ": row " << row << " of the expected screen is too long\n" << end(); 326 if (!Scenario_testing_scenario) Passed = false; 327 return; 328 } 329 } 330 cursor.skip_whitespace_and_comments(); 331 if (!cursor.at_end()) { -332 raise << Current_scenario->name << ": expected screen has too many rows\n" << end(); +332 raise << Current_scenario->name << ": expected screen has too many rows\n" << end(); 333 Passed = false; 334 } 335 } @@ -402,7 +402,7 @@ if ('onhashchange' in window) { 339 bool raw_string_stream::at_end() const { 340 if (index >= max) return true; 341 if (tb_utf8_char_length(buf[index]) > max-index) { -342 raise << "unicode string seems corrupted at index "<< index << " character " << static_cast<int>(buf[index]) << '\n' << end(); +342 raise << "unicode string seems corrupted at index "<< index << " character " << static_cast<int>(buf[index]) << '\n' << end(); 343 return true; 344 } 345 return false; diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html index 951253a5..869ec321 100644 --- a/html/085scenario_console.cc.html +++ b/html/085scenario_console.cc.html @@ -126,7 +126,7 @@ if ('onhashchange' in window) { 66 for (int i = 0; i < SIZE(r.steps); ++i) { 67 const instruction& inst = r.steps.at(i); 68 if (inst.name == "left-click") { - 69 trace(9999, "mem") << "storing 'left-click' event starting at " << Current_routine->alloc << end(); + 69 trace(9999, "mem") << "storing 'left-click' event starting at " << Current_routine->alloc << end(); 70 put(Memory, curr_address, /*tag for 'touch-event' variant of 'event' exclusive-container*/2); 71 put(Memory, curr_address+/*skip tag*/1+/*offset of 'type' in 'mouse-event'*/0, TB_KEY_MOUSE_LEFT); 72 put(Memory, curr_address+/*skip tag*/1+/*offset of 'row' in 'mouse-event'*/1, to_integer(inst.ingredients.at(0).name)); @@ -134,14 +134,14 @@ if ('onhashchange' in window) { 74 curr_address += size_of_event(); 75 } 76 else if (inst.name == "press") { - 77 trace(9999, "mem") << "storing 'press' event starting at " << curr_address << end(); + 77 trace(9999, "mem") << "storing 'press' event starting at " << curr_address << end(); 78 string key = inst.ingredients.at(0).name; 79 if (is_integer(key)) 80 put(Memory, curr_address+1, to_integer(key)); 81 else if (contains_key(Key, key)) 82 put(Memory, curr_address+1, Key[key]); 83 else - 84 raise << "assume-console: can't press '" << key << "'\n" << end(); + 84 raise << "assume-console: can't press '" << key << "'\n" << end(); 85 if (get_or_insert(Memory, curr_address+1) < 256) 86 // these keys are in ascii 87 put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0); @@ -155,18 +155,18 @@ if ('onhashchange' in window) { 95 else { 96 // keyboard input 97 assert(inst.name == "type"); - 98 trace(9999, "mem") << "storing 'type' event starting at " << curr_address << end(); + 98 trace(9999, "mem") << "storing 'type' event starting at " << curr_address << end(); 99 const string& contents = inst.ingredients.at(0).name; 100 const char* raw_contents = contents.c_str(); 101 int num_keyboard_events = unicode_length(contents); 102 int curr = 0; 103 for (int i = 0; i < num_keyboard_events; ++i) { -104 trace(9999, "mem") << "storing 'text' tag at " << curr_address << end(); +104 trace(9999, "mem") << "storing 'text' tag at " << curr_address << end(); 105 put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0); 106 uint32_t curr_character; 107 assert(curr < SIZE(contents)); 108 tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]); -109 trace(9999, "mem") << "storing character " << curr_character << " at " << curr_address+/*skip exclusive container tag*/1 << end(); +109 trace(9999, "mem") << "storing character " << curr_character << " at " << curr_address+/*skip exclusive container tag*/1 << end(); 110 put(Memory, curr_address+/*skip exclusive container tag*/1, curr_character); 111 curr += tb_utf8_char_length(raw_contents[curr]); 112 curr_address += size_of_event(); @@ -176,9 +176,9 @@ if ('onhashchange' in window) { 116 assert(curr_address == event_data_address+size); 117 // wrap the array of events in a console object 118 int console_address = allocate(size_of_console()); -119 trace(9999, "mem") << "storing console in " << console_address << end(); +119 trace(9999, "mem") << "storing console in " << console_address << end(); 120 put(Memory, CONSOLE, console_address); -121 trace(9999, "mem") << "storing console data in " << console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1 << end(); +121 trace(9999, "mem") << "storing console data in " << console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1 << end(); 122 put(Memory, console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1, event_data_address); 123 // increment refcount for event data 124 put(Memory, event_data_address, 1); @@ -324,7 +324,7 @@ if ('onhashchange' in window) { 264 case REPLACE_IN_CONSOLE: { 265 assert(scalar(ingredients.at(0))); 266 if (!get_or_insert(Memory, CONSOLE)) { -267 raise << "console not initialized\n" << end(); +267 raise << "console not initialized\n" << end(); 268 break; 269 } 270 int console_address = get_or_insert(Memory, CONSOLE); diff --git a/html/087file.cc.html b/html/087file.cc.html index 50bf1f18..4fd646d2 100644 --- a/html/087file.cc.html +++ b/html/087file.cc.html @@ -75,19 +75,19 @@ if ('onhashchange' in window) { 16 :(before "End Primitive Recipe Checks") 17 case _OPEN_FILE_FOR_READING: { 18 if (SIZE(inst.ingredients) != 1) { - 19 raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 19 raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 20 break; 21 } 22 if (!is_mu_text(inst.ingredients.at(0))) { - 23 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-reading' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 23 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-reading' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 24 break; 25 } 26 if (SIZE(inst.products) != 1) { - 27 raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); + 27 raise << maybe(get(Recipe, r).name) << "'$open-file-for-reading' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 28 break; 29 } 30 if (!is_mu_number(inst.products.at(0))) { - 31 raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-reading' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); + 31 raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-reading' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 32 break; 33 } 34 break; @@ -110,19 +110,19 @@ if ('onhashchange' in window) { 51 :(before "End Primitive Recipe Checks") 52 case _OPEN_FILE_FOR_WRITING: { 53 if (SIZE(inst.ingredients) != 1) { - 54 raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 54 raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 55 break; 56 } 57 if (!is_mu_text(inst.ingredients.at(0))) { - 58 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-writing' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 58 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-file-for-writing' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 59 break; 60 } 61 if (SIZE(inst.products) != 1) { - 62 raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); + 62 raise << maybe(get(Recipe, r).name) << "'$open-file-for-writing' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 63 break; 64 } 65 if (!is_mu_number(inst.products.at(0))) { - 66 raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-writing' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); + 66 raise << maybe(get(Recipe, r).name) << "first product of '$open-file-for-writing' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 67 break; 68 } 69 break; @@ -144,23 +144,23 @@ if ('onhashchange' in window) { 85 :(before "End Primitive Recipe Checks") 86 case _READ_FROM_FILE: { 87 if (SIZE(inst.ingredients) != 1) { - 88 raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 88 raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 89 break; 90 } 91 if (!is_mu_number(inst.ingredients.at(0))) { - 92 raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 92 raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 93 break; 94 } 95 if (SIZE(inst.products) != 2) { - 96 raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly two products, but got '" << inst.original_string << "'\n" << end(); + 96 raise << maybe(get(Recipe, r).name) << "'$read-from-file' requires exactly two products, but got '" << inst.original_string << "'\n" << end(); 97 break; 98 } 99 if (!is_mu_character(inst.products.at(0))) { -100 raise << maybe(get(Recipe, r).name) << "first product of '$read-from-file' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end(); +100 raise << maybe(get(Recipe, r).name) << "first product of '$read-from-file' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 101 break; 102 } 103 if (!is_mu_boolean(inst.products.at(1))) { -104 raise << maybe(get(Recipe, r).name) << "second product of '$read-from-file' should be a boolean, but got '" << to_string(inst.products.at(1)) << "'\n" << end(); +104 raise << maybe(get(Recipe, r).name) << "second product of '$read-from-file' should be a boolean, but got '" << to_string(inst.products.at(1)) << "'\n" << end(); 105 break; 106 } 107 break; @@ -170,7 +170,7 @@ if ('onhashchange' in window) { 111 long long int x = static_cast<long long int>(ingredients.at(0).at(0)); 112 FILE* f = reinterpret_cast<FILE*>(x); 113 if (f == NULL) { -114 raise << maybe(current_recipe_name()) << "can't read from null file in '" << to_string(current_instruction()) << "'\n" << end(); +114 raise << maybe(current_recipe_name()) << "can't read from null file in '" << to_string(current_instruction()) << "'\n" << end(); 115 break; 116 } 117 products.resize(2); @@ -180,7 +180,7 @@ if ('onhashchange' in window) { 121 break; 122 } 123 if (ferror(f)) { -124 raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end(); +124 raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end(); 125 break; 126 } 127 char c = getc(f); // todo: unicode @@ -190,8 +190,8 @@ if ('onhashchange' in window) { 131 break; 132 } 133 if (ferror(f)) { -134 raise << maybe(current_recipe_name()) << "couldn't read from file in '" << to_string(current_instruction()) << "'\n" << end(); -135 raise << " errno: " << errno << '\n' << end(); +134 raise << maybe(current_recipe_name()) << "couldn't read from file in '" << to_string(current_instruction()) << "'\n" << end(); +135 raise << " errno: " << errno << '\n' << end(); 136 break; 137 } 138 products.at(0).push_back(c); @@ -208,19 +208,19 @@ if ('onhashchange' in window) { 149 :(before "End Primitive Recipe Checks") 150 case _WRITE_TO_FILE: { 151 if (SIZE(inst.ingredients) != 2) { -152 raise << maybe(get(Recipe, r).name) << "'$write-to-file' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); +152 raise << maybe(get(Recipe, r).name) << "'$write-to-file' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 153 break; 154 } 155 if (!is_mu_number(inst.ingredients.at(0))) { -156 raise << maybe(get(Recipe, r).name) << "first ingredient of '$write-to-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +156 raise << maybe(get(Recipe, r).name) << "first ingredient of '$write-to-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 157 break; 158 } 159 if (!is_mu_character(inst.ingredients.at(1))) { -160 raise << maybe(get(Recipe, r).name) << "second ingredient of '$write-to-file' should be a character, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +160 raise << maybe(get(Recipe, r).name) << "second ingredient of '$write-to-file' should be a character, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 161 break; 162 } 163 if (!inst.products.empty()) { -164 raise << maybe(get(Recipe, r).name) << "'$write-to-file' writes to no products, but got '" << inst.original_string << "'\n" << end(); +164 raise << maybe(get(Recipe, r).name) << "'$write-to-file' writes to no products, but got '" << inst.original_string << "'\n" << end(); 165 break; 166 } 167 break; @@ -230,20 +230,20 @@ if ('onhashchange' in window) { 171 long long int x = static_cast<long long int>(ingredients.at(0).at(0)); 172 FILE* f = reinterpret_cast<FILE*>(x); 173 if (f == NULL) { -174 raise << maybe(current_recipe_name()) << "can't write to null file in '" << to_string(current_instruction()) << "'\n" << end(); +174 raise << maybe(current_recipe_name()) << "can't write to null file in '" << to_string(current_instruction()) << "'\n" << end(); 175 break; 176 } 177 if (feof(f)) break; 178 if (ferror(f)) { -179 raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end(); +179 raise << maybe(current_recipe_name()) << "file in invalid state in '" << to_string(current_instruction()) << "'\n" << end(); 180 break; 181 } 182 long long int y = static_cast<long long int>(ingredients.at(1).at(0)); 183 char c = static_cast<char>(y); 184 putc(c, f); // todo: unicode 185 if (ferror(f)) { -186 raise << maybe(current_recipe_name()) << "couldn't write to file in '" << to_string(current_instruction()) << "'\n" << end(); -187 raise << " errno: " << errno << '\n' << end(); +186 raise << maybe(current_recipe_name()) << "couldn't write to file in '" << to_string(current_instruction()) << "'\n" << end(); +187 raise << " errno: " << errno << '\n' << end(); 188 break; 189 } 190 break; @@ -256,19 +256,19 @@ if ('onhashchange' in window) { 197 :(before "End Primitive Recipe Checks") 198 case _CLOSE_FILE: { 199 if (SIZE(inst.ingredients) != 1) { -200 raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +200 raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 201 break; 202 } 203 if (!is_mu_number(inst.ingredients.at(0))) { -204 raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +204 raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-file' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 205 break; 206 } 207 if (SIZE(inst.products) != 1) { -208 raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); +208 raise << maybe(get(Recipe, r).name) << "'$close-file' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 209 break; 210 } 211 if (inst.products.at(0).name != inst.ingredients.at(0).name) { -212 raise << maybe(get(Recipe, r).name) << "'$close-file' requires its product to be the same as its ingredient, but got '" << inst.original_string << "'\n" << end(); +212 raise << maybe(get(Recipe, r).name) << "'$close-file' requires its product to be the same as its ingredient, but got '" << inst.original_string << "'\n" << end(); 213 break; 214 } 215 break; diff --git a/html/089scenario_filesystem.cc.html b/html/089scenario_filesystem.cc.html index 4d503671..e4128820 100644 --- a/html/089scenario_filesystem.cc.html +++ b/html/089scenario_filesystem.cc.html @@ -177,49 +177,49 @@ if ('onhashchange' in window) { 117 string filename = next_word(in); 118 if (filename.empty()) { 119 assert(!has_data(in)); -120 raise << "incomplete 'resources' block at end of file (0)\n" << end(); +120 raise << "incomplete 'resources' block at end of file (0)\n" << end(); 121 return; 122 } 123 if (*filename.begin() != '[') { -124 raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end(); +124 raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end(); 125 break; 126 } 127 if (*filename.rbegin() != ']') { -128 raise << caller << ": assume-resources: filename '" << filename << "' must end with a ']'\n" << end(); +128 raise << caller << ": assume-resources: filename '" << filename << "' must end with a ']'\n" << end(); 129 break; 130 } 131 filename.erase(0, 1); 132 filename.erase(SIZE(filename)-1); 133 if (!has_data(in)) { -134 raise << caller << ": assume-resources: no data for filename '" << filename << "'\n" << end(); +134 raise << caller << ": assume-resources: no data for filename '" << filename << "'\n" << end(); 135 break; 136 } 137 string arrow = next_word(in); 138 if (arrow.empty()) { 139 assert(!has_data(in)); -140 raise << "incomplete 'resources' block at end of file (1)\n" << end(); +140 raise << "incomplete 'resources' block at end of file (1)\n" << end(); 141 return; 142 } 143 if (arrow != "<-") { -144 raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end(); +144 raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end(); 145 break; 146 } 147 if (!has_data(in)) { -148 raise << caller << ": assume-resources: no data for filename '" << filename << "' after '<-'\n" << end(); +148 raise << caller << ": assume-resources: no data for filename '" << filename << "' after '<-'\n" << end(); 149 break; 150 } 151 string contents = next_word(in); 152 if (contents.empty()) { 153 assert(!has_data(in)); -154 raise << "incomplete 'resources' block at end of file (2)\n" << end(); +154 raise << "incomplete 'resources' block at end of file (2)\n" << end(); 155 return; 156 } 157 if (*contents.begin() != '[') { -158 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end(); +158 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end(); 159 break; 160 } 161 if (*contents.rbegin() != ']') { -162 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must end with a ']'\n" << end(); +162 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must end with a ']'\n" << end(); 163 break; 164 } 165 contents.erase(0, 1); @@ -239,7 +239,7 @@ if ('onhashchange' in window) { 179 skip_whitespace(in); 180 if (!has_data(in)) break; 181 if (in.peek() != '|') { -182 raise << caller << ": assume-resources: file contents for filename '" << filename << "' must be delimited in '|'s\n" << end(); +182 raise << caller << ": assume-resources: file contents for filename '" << filename << "' must be delimited in '|'s\n" << end(); 183 break; 184 } 185 in.get(); // skip leading '|' @@ -250,7 +250,7 @@ if ('onhashchange' in window) { 190 if (line.at(i) == '\\') { 191 ++i; // skip 192 if (i == SIZE(line)) { -193 raise << caller << ": assume-resources: file contents can't end a line with '\\'\n" << end(); +193 raise << caller << ": assume-resources: file contents can't end a line with '\\'\n" << end(); 194 break; 195 } 196 } @@ -265,33 +265,33 @@ if ('onhashchange' in window) { 205 void construct_resources_object(const map<string, string>& contents) { 206 int resources_data_address = allocate(SIZE(contents)*2 + /*array length*/1); 207 int curr = resources_data_address + /*skip refcount and length*/2; -208 for (map<string, string>::const_iterator p = contents.begin(); p != contents.end(); ++p) { +208 for (map<string, string>::const_iterator p = contents.begin(); p != contents.end(); ++p) { 209 put(Memory, curr, new_mu_text(p->first)); -210 trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); +210 trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); 211 put(Memory, get(Memory, curr), 1); -212 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); +212 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); 213 ++curr; 214 put(Memory, curr, new_mu_text(p->second)); -215 trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end(); +215 trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end(); 216 put(Memory, get(Memory, curr), 1); -217 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); +217 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); 218 ++curr; 219 } 220 curr = resources_data_address+/*skip refcount*/1; 221 put(Memory, curr, SIZE(contents)); // size of array -222 trace(9999, "mem") << "storing resources size " << get(Memory, curr) << " in location " << curr << end(); +222 trace(9999, "mem") << "storing resources size " << get(Memory, curr) << " in location " << curr << end(); 223 put(Memory, resources_data_address, 1); // initialize refcount -224 trace(9999, "mem") << "storing refcount 1 in location " << resources_data_address << end(); +224 trace(9999, "mem") << "storing refcount 1 in location " << resources_data_address << end(); 225 // wrap the resources data in a 'resources' object 226 int resources_address = allocate(size_of_resources()); 227 curr = resources_address+/*skip refcount*/1+/*offset of 'data' element*/1; 228 put(Memory, curr, resources_data_address); -229 trace(9999, "mem") << "storing resources data address " << resources_data_address << " in location " << curr << end(); +229 trace(9999, "mem") << "storing resources data address " << resources_data_address << " in location " << curr << end(); 230 put(Memory, resources_address, 1); // initialize refcount -231 trace(9999, "mem") << "storing refcount 1 in location " << resources_address << end(); +231 trace(9999, "mem") << "storing refcount 1 in location " << resources_address << end(); 232 // save in product 233 put(Memory, RESOURCES, resources_address); -234 trace(9999, "mem") << "storing resources address " << resources_address << " in location " << RESOURCES << end(); +234 trace(9999, "mem") << "storing resources address " << resources_address << " in location " << RESOURCES << end(); 235 } 236 237 int size_of_resources() { diff --git a/html/091socket.cc.html b/html/091socket.cc.html index 555af1c4..f503d40c 100644 --- a/html/091socket.cc.html +++ b/html/091socket.cc.html @@ -77,23 +77,23 @@ if ('onhashchange' in window) { 17 :(before "End Primitive Recipe Checks") 18 case _OPEN_CLIENT_SOCKET: { 19 if (SIZE(inst.ingredients) != 2) { - 20 raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); + 20 raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); 21 break; 22 } 23 if (!is_mu_text(inst.ingredients.at(0))) { - 24 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-client-socket' should be text (the hostname), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 24 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-client-socket' should be text (the hostname), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 25 break; 26 } 27 if (!is_mu_number(inst.ingredients.at(1))) { - 28 raise << maybe(get(Recipe, r).name) << "second ingredient of '$open-client-socket' should be a number (the port of the hostname to connect to), but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end(); + 28 raise << maybe(get(Recipe, r).name) << "second ingredient of '$open-client-socket' should be a number (the port of the hostname to connect to), but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end(); 29 break; 30 } 31 if (SIZE(inst.products) != 1) { - 32 raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); + 32 raise << maybe(get(Recipe, r).name) << "'$open-client-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 33 break; 34 } 35 if (!is_mu_number(inst.products.at(0))) { - 36 raise << maybe(get(Recipe, r).name) << "first product of '$open-client-socket' should be a number (socket handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); + 36 raise << maybe(get(Recipe, r).name) << "first product of '$open-client-socket' should be a number (socket handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 37 break; 38 } 39 break; @@ -118,7 +118,7 @@ if ('onhashchange' in window) { 58 socket_t* result = new socket_t; 59 result->fd = socket(AF_INET, SOCK_STREAM, 0); 60 if (result->fd < 0) { - 61 raise << "Failed to create socket.\n" << end(); + 61 raise << "Failed to create socket.\n" << end(); 62 return result; 63 } 64 result->addr.sin_family = AF_INET; @@ -128,7 +128,7 @@ if ('onhashchange' in window) { 68 if (connect(result->fd, reinterpret_cast<sockaddr*>(&result->addr), sizeof(result->addr)) < 0) { 69 close(result->fd); 70 result->fd = -1; - 71 raise << "Failed to connect to " << host << ':' << port << '\n' << end(); + 71 raise << "Failed to connect to " << host << ':' << port << '\n' << end(); 72 } 73 return result; 74 } @@ -140,19 +140,19 @@ if ('onhashchange' in window) { 80 :(before "End Primitive Recipe Checks") 81 case _OPEN_SERVER_SOCKET: { 82 if (SIZE(inst.ingredients) != 1) { - 83 raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one ingredient (the port to listen for requests on), but got '" << inst.original_string << "'\n" << end(); + 83 raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one ingredient (the port to listen for requests on), but got '" << inst.original_string << "'\n" << end(); 84 break; 85 } 86 if (!is_mu_number(inst.ingredients.at(0))) { - 87 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-server-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 87 raise << maybe(get(Recipe, r).name) << "first ingredient of '$open-server-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 88 break; 89 } 90 if (SIZE(inst.products) != 1) { - 91 raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); + 91 raise << maybe(get(Recipe, r).name) << "'$open-server-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 92 break; 93 } 94 if (!is_mu_number(inst.products.at(0))) { - 95 raise << maybe(get(Recipe, r).name) << "first product of '$open-server-socket' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); + 95 raise << maybe(get(Recipe, r).name) << "first product of '$open-server-socket' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 96 break; 97 } 98 break; @@ -176,7 +176,7 @@ if ('onhashchange' in window) { 116 socket_t* result = new socket_t; 117 result->fd = socket(AF_INET, SOCK_STREAM, 0); 118 if (result->fd < 0) { -119 raise << "Failed to create server socket.\n" << end(); +119 raise << "Failed to create server socket.\n" << end(); 120 return result; 121 } 122 int dummy = 0; @@ -190,7 +190,7 @@ if ('onhashchange' in window) { 130 else { 131 close(result->fd); 132 result->fd = -1; -133 raise << "Failed to bind result socket to port " << port << ". Something's already using that port.\n" << end(); +133 raise << "Failed to bind result socket to port " << port << ". Something's already using that port.\n" << end(); 134 } 135 return result; 136 } @@ -202,19 +202,19 @@ if ('onhashchange' in window) { 142 :(before "End Primitive Recipe Checks") 143 case _ACCEPT: { 144 if (SIZE(inst.ingredients) != 1) { -145 raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +145 raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 146 break; 147 } 148 if (!is_mu_number(inst.ingredients.at(0))) { -149 raise << maybe(get(Recipe, r).name) << "first ingredient of '$accept' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +149 raise << maybe(get(Recipe, r).name) << "first ingredient of '$accept' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 150 break; 151 } 152 if (SIZE(inst.products) != 1) { -153 raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); +153 raise << maybe(get(Recipe, r).name) << "'$accept' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 154 break; 155 } 156 if (!is_mu_number(inst.products.at(0))) { -157 raise << maybe(get(Recipe, r).name) << "first product of '$accept' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); +157 raise << maybe(get(Recipe, r).name) << "first product of '$accept' should be a number (file handle), but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 158 break; 159 } 160 break; @@ -251,32 +251,32 @@ if ('onhashchange' in window) { 191 :(before "End Primitive Recipe Checks") 192 case _READ_FROM_SOCKET: { 193 if (SIZE(inst.ingredients) != 1) { -194 raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +194 raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 195 break; 196 } 197 if (!is_mu_number(inst.ingredients.at(0))) { -198 raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-socket' should be a number (socket), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +198 raise << maybe(get(Recipe, r).name) << "first ingredient of '$read-from-socket' should be a number (socket), but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 199 break; 200 } 201 int nprod = SIZE(inst.products); 202 if (nprod == 0 || nprod > 4) { -203 raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires 1-4 products, but got '" << inst.original_string << "'\n" << end(); +203 raise << maybe(get(Recipe, r).name) << "'$read-from-socket' requires 1-4 products, but got '" << inst.original_string << "'\n" << end(); 204 break; 205 } 206 if (!is_mu_character(inst.products.at(0))) { -207 raise << maybe(get(Recipe, r).name) << "first product of '$read-from-socket' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end(); +207 raise << maybe(get(Recipe, r).name) << "first product of '$read-from-socket' should be a character, but got '" << to_string(inst.products.at(0)) << "'\n" << end(); 208 break; 209 } 210 if (nprod > 1 && !is_mu_boolean(inst.products.at(1))) { -211 raise << maybe(get(Recipe, r).name) << "second product of '$read-from-socket' should be a boolean (data received?), but got '" << to_string(inst.products.at(1)) << "'\n" << end(); +211 raise << maybe(get(Recipe, r).name) << "second product of '$read-from-socket' should be a boolean (data received?), but got '" << to_string(inst.products.at(1)) << "'\n" << end(); 212 break; 213 } 214 if (nprod > 2 && !is_mu_boolean(inst.products.at(2))) { -215 raise << maybe(get(Recipe, r).name) << "third product of '$read-from-socket' should be a boolean (eof?), but got '" << to_string(inst.products.at(2)) << "'\n" << end(); +215 raise << maybe(get(Recipe, r).name) << "third product of '$read-from-socket' should be a boolean (eof?), but got '" << to_string(inst.products.at(2)) << "'\n" << end(); 216 break; 217 } 218 if (nprod > 3 && !is_mu_number(inst.products.at(3))) { -219 raise << maybe(get(Recipe, r).name) << "fourth product of '$read-from-socket' should be a number (error code), but got '" << to_string(inst.products.at(3)) << "'\n" << end(); +219 raise << maybe(get(Recipe, r).name) << "fourth product of '$read-from-socket' should be a number (error code), but got '" << to_string(inst.products.at(3)) << "'\n" << end(); 220 break; 221 } 222 break; @@ -312,7 +312,7 @@ if ('onhashchange' in window) { 252 } 253 else if (poll_result < 0) { 254 int error_code = errno; -255 raise << maybe(current_recipe_name()) << "error in $read-from-socket\n" << end(); +255 raise << maybe(current_recipe_name()) << "error in $read-from-socket\n" << end(); 256 products.at(0).push_back(/*no data*/0); 257 products.at(1).push_back(/*found*/false); 258 products.at(2).push_back(/*eof*/false); @@ -344,7 +344,7 @@ if ('onhashchange' in window) { 284 :(before "End Primitive Recipe Checks") 285 case _WRITE_TO_SOCKET: { 286 if (SIZE(inst.ingredients) != 2) { -287 raise << maybe(get(Recipe, r).name) << "'$write-to-socket' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); +287 raise << maybe(get(Recipe, r).name) << "'$write-to-socket' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); 288 break; 289 } 290 break; @@ -357,7 +357,7 @@ if ('onhashchange' in window) { 297 long long int y = static_cast<long long int>(ingredients.at(1).at(0)); 298 char c = static_cast<char>(y); 299 if (write(socket->fd, &c, 1) != 1) { -300 raise << maybe(current_recipe_name()) << "failed to write to socket\n" << end(); +300 raise << maybe(current_recipe_name()) << "failed to write to socket\n" << end(); 301 exit(0); 302 } 303 products.resize(1); @@ -372,19 +372,19 @@ if ('onhashchange' in window) { 312 :(before "End Primitive Recipe Checks") 313 case _CLOSE_SOCKET: { 314 if (SIZE(inst.ingredients) != 1) { -315 raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); +315 raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly two ingredient, but got '" << inst.original_string << "'\n" << end(); 316 break; 317 } 318 if (!is_mu_number(inst.ingredients.at(0))) { -319 raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); +319 raise << maybe(get(Recipe, r).name) << "first ingredient of '$close-socket' should be a number, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 320 break; 321 } 322 if (SIZE(inst.products) != 1) { -323 raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); +323 raise << maybe(get(Recipe, r).name) << "'$close-socket' requires exactly one product, but got '" << inst.original_string << "'\n" << end(); 324 break; 325 } 326 if (inst.products.at(0).name != inst.ingredients.at(0).name) { -327 raise << maybe(get(Recipe, r).name) << "product of '$close-socket' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); +327 raise << maybe(get(Recipe, r).name) << "product of '$close-socket' must be first ingredient '" << inst.ingredients.at(0).original_string << "', but got '" << inst.products.at(0).original_string << "'\n" << end(); 328 break; 329 } 330 break; diff --git a/html/100trace_browser.cc.html b/html/100trace_browser.cc.html index bb486439..611fcb2b 100644 --- a/html/100trace_browser.cc.html +++ b/html/100trace_browser.cc.html @@ -136,7 +136,7 @@ if ('onhashchange' in window) { 78 } 79 if (key == 'J' || key == TB_KEY_PGDN) { 80 // page-down - 81 if (Trace_index.find(tb_height()-1) != Trace_index.end()) { + 81 if (Trace_index.find(tb_height()-1) != Trace_index.end()) { 82 Top_of_screen = get(Trace_index, tb_height()-1) + 1; 83 refresh_screen_rows(); 84 } @@ -298,7 +298,7 @@ if ('onhashchange' in window) { 240 tin >> depth; 241 string label; 242 tin >> label; -243 if (*--label.end() == ':') label.erase(--label.end()); +243 if (*--label.end() == ':') label.erase(--label.end()); 244 string line; 245 getline(tin, line); 246 Trace_stream->past_lines.push_back(trace_line(depth, label, line)); diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index 3c4abbf9..9b3b875b 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -103,11 +103,11 @@ if ('onhashchange' in window) { 41 :(before "End Primitive Recipe Checks") 42 case RUN_SANDBOXED: { 43 if (SIZE(inst.ingredients) != 1) { - 44 raise << maybe(get(Recipe, r).name) << "'run-sandboxed' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + 44 raise << maybe(get(Recipe, r).name) << "'run-sandboxed' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 45 break; 46 } 47 if (!is_mu_text(inst.ingredients.at(0))) { - 48 raise << maybe(get(Recipe, r).name) << "first ingredient of 'run-sandboxed' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); + 48 raise << maybe(get(Recipe, r).name) << "first ingredient of 'run-sandboxed' should be a string, but got '" << to_string(inst.ingredients.at(0)) << "'\n" << end(); 49 break; 50 } 51 break; @@ -157,7 +157,7 @@ if ('onhashchange' in window) { 95 for (int i = 1; i < Reserved_for_tests; ++i) 96 Memory.erase(i); 97 } - 98 string command = trim(strip_comments(read_mu_text(address))); + 98 string command = trim(strip_comments(read_mu_text(address))); 99 Name[get(Recipe_ordinal, "interactive")].clear(); 100 run_code_begin(/*should_stash_snapshots*/true); 101 if (command.empty()) return false; @@ -180,7 +180,7 @@ if ('onhashchange' in window) { 118 // and wait for it 119 if (Save_trace_stream) { 120 ++Save_trace_stream->callstack_depth; -121 trace(9999, "trace") << "run-sandboxed: incrementing callstack depth to " << Save_trace_stream->callstack_depth << end(); +121 trace(9999, "trace") << "run-sandboxed: incrementing callstack depth to " << Save_trace_stream->callstack_depth << end(); 122 assert(Save_trace_stream->callstack_depth < 9000); // 9998-101 plus cushion 123 } 124 Current_routine->calls.push_front(call(get(Recipe_ordinal, "sandbox"))); @@ -491,10 +491,10 @@ if ('onhashchange' in window) { 429 int trace_error_contents() { 430 if (!Trace_stream) return 0; 431 ostringstream out; -432 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +432 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 433 if (p->label != "error") continue; 434 out << p->contents; -435 if (*--p->contents.end() != '\n') out << '\n'; +435 if (*--p->contents.end() != '\n') out << '\n'; 436 } 437 string result = out.str(); 438 truncate(result); @@ -505,10 +505,10 @@ if ('onhashchange' in window) { 443 int trace_app_contents() { 444 if (!Trace_stream) return 0; 445 ostringstream out; -446 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +446 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { 447 if (p->depth != App_depth) continue; 448 out << p->contents; -449 if (*--p->contents.end() != '\n') out << '\n'; +449 if (*--p->contents.end() != '\n') out << '\n'; 450 } 451 string result = out.str(); 452 if (result.empty()) return 0; @@ -535,11 +535,11 @@ if ('onhashchange' in window) { 473 :(before "End Primitive Recipe Checks") 474 case RELOAD: { 475 if (SIZE(inst.ingredients) != 1) { -476 raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +476 raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); 477 break; 478 } 479 if (!is_mu_text(inst.ingredients.at(0))) { -480 raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +480 raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); 481 break; 482 } 483 break; @@ -554,7 +554,7 @@ if ('onhashchange' in window) { 492 Sandbox_mode = true; 493 vector<recipe_ordinal> recipes_reloaded = load(code); 494 transform_all(); -495 Trace_stream->newline(); // flush trace +495 Trace_stream->newline(); // flush trace 496 Sandbox_mode = false; 497 Current_routine = save_current_routine; 498 products.resize(1); -- cgit 1.4.1-2-gfad0