diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-26 23:59:59 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-27 17:43:41 -0700 |
commit | a654e4ecace2d506d1b10f1dde2c287ebe84ef37 (patch) | |
tree | 1e34a3ad99a56e32bdf9ee03ecfe7d339e7942ae /html | |
parent | 859f35fbe2f6a78157b875e12eb7dc8cd95c1152 (diff) | |
download | mu-a654e4ecace2d506d1b10f1dde2c287ebe84ef37.tar.gz |
2812
Diffstat (limited to 'html')
98 files changed, 3970 insertions, 2838 deletions
diff --git a/html/000organization.cc.html b/html/000organization.cc.html index 118a1eeb..817b74d5 100644 --- a/html/000organization.cc.html +++ b/html/000organization.cc.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 000organization.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } .Delimiter { color: #800080; } -.Normal { color: #eeeeee; background-color: #080808; } +.Comment { color: #9090ff; } .Constant { color: #00a0a0; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .PreProc { color: #800080; } -.Comment { color: #9090ff; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: You guessed right: the '000' prefix means you should start reading here.</span> <span class="Comment">//:</span> <span class="Comment">//: This project is setup to load all files with a numeric prefix. Just create</span> @@ -152,3 +160,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/001help.cc.html b/html/001help.cc.html index c3456ec6..0783ad54 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 001help.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.PreProc { color: #800080; } -.SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Everything this project/binary supports.</span> <span class="Comment">//: This should give you a sense for what to look forward to in later layers.</span> @@ -111,8 +119,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment">//: unsigned and that'll cause warnings about mixing signed and unsigned,</span> <span class="Comment">//: yadda-yadda. Instead use this macro below to perform an unsafe cast to</span> <span class="Comment">//: signed. We'll just give up immediately if a container's ever too large.</span> +<span class="Comment">//:</span> +<span class="Comment">//: Addendum to corollary: We're going to uniformly avoid long long int</span> +<span class="Comment">//: everywhere, since Clang on 32-bit platforms doesn't yet support</span> +<span class="Comment">//: multiplication over 64-bit integers, and since that seems like a more</span> +<span class="Comment">//: common situation to end up in than integer overflow.</span> <span class="Delimiter">:(before "End Includes")</span> -<span class="PreProc">#define SIZE(X) (assert((X)</span><span class="Delimiter">.</span><span class="PreProc">size() < (</span><span class="Constant">1LL</span><span class="PreProc"><<(</span><span class="Normal">sizeof</span><span class="PreProc">(</span><span class="Normal">long</span><span class="PreProc"> </span><span class="Normal">long</span><span class="PreProc"> </span><span class="Normal">int</span><span class="PreProc">)*</span><span class="Constant">8</span><span class="PreProc">-</span><span class="Constant">2</span><span class="PreProc">)))</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">static_cast</span><span class="PreProc"><</span><span class="Normal">long</span><span class="PreProc"> </span><span class="Normal">long</span><span class="PreProc"> </span><span class="Normal">int</span><span class="PreProc">>((X)</span><span class="Delimiter">.</span><span class="PreProc">size()))</span> +<span class="PreProc">#define SIZE(X) (assert((X)</span><span class="Delimiter">.</span><span class="PreProc">size() < (</span><span class="Constant">1LL</span><span class="PreProc"><<(</span><span class="Normal">sizeof</span><span class="PreProc">(</span><span class="Normal">int</span><span class="PreProc">)*</span><span class="Constant">8</span><span class="PreProc">-</span><span class="Constant">2</span><span class="PreProc">)))</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">static_cast</span><span class="PreProc"><</span><span class="Normal">int</span><span class="PreProc">>((X)</span><span class="Delimiter">.</span><span class="PreProc">size()))</span> <span class="Comment">//:</span> <span class="Comment">//: 5. Integer overflow is still impossible to guard against. Maybe after</span> <span class="Comment">//: reading <a href="http://www.cs.utah.edu/~regehr/papers/overflow12.pdf">http://www.cs.utah.edu/~regehr/papers/overflow12.pdf</a></span> @@ -168,3 +181,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/002test.cc.html b/html/002test.cc.html index 6799ec20..6774e3ca 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 002test.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.CommentedCode { color: #6c6c6c; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.PreProc { color: #800080; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: A simple test harness. To create new tests define functions starting with</span> <span class="Comment">//: 'test_'. To run all tests so defined, run:</span> <span class="Comment">//: $ wart test</span> @@ -114,10 +122,10 @@ Passed = <span class="Constant">true</span><span class="Delimiter">;</span> && s<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'-'</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">)</span> == string::npos<span class="Delimiter">;</span> <span class="Comment">// '-' only at first position</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> to_integer<span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> to_integer<span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">char</span>* end = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Comment">// safe because string.c_str() is guaranteed to be null-terminated</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = strtoll<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">any base</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> result = strtoll<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">any base</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*end != <span class="cSpecial">'\0'</span><span class="Delimiter">)</span> cerr << <span class="Constant">"tried to convert "</span> << n << <span class="Constant">" to number</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>*end == <span class="cSpecial">'\0'</span><span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> @@ -138,3 +146,4 @@ Passed = <span class="Constant">true</span><span class="Delimiter">;</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 2a666948..a478ef5c 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -3,26 +3,34 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 003trace.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.PreProc { color: #800080; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: The goal of this skeleton is to make programs more easy to understand and</span> <span class="Comment">//: more malleable, easy to rewrite in radical ways without accidentally</span> <span class="Comment">//: breaking some corner case. Tests further both goals. They help</span> @@ -182,7 +190,7 @@ trace_stream* Trace_stream = <span class="Constant">NULL</span><span class="Deli <span class="PreProc">#define trace(</span><span class="Delimiter">...</span><span class="PreProc">) !Trace_stream ? cerr </span><span class="Comment">/*</span><span class="Comment">print nothing</span><span class="Comment">*/</span><span class="PreProc"> : Trace_stream</span><span class="Delimiter">-></span><span class="PreProc">stream(__VA_ARGS__)</span> <span class="Comment">// Errors are a special layer.</span> -<span class="PreProc">#define raise (!Trace_stream ? </span><span class="Delimiter">(</span><span class="PreProc">tb_shutdown</span><span class="Delimiter">(),</span><span class="PreProc">cerr</span><span class="Delimiter">)</span><span class="PreProc"> </span><span class="Comment">/*</span><span class="Comment">do print</span><span class="Comment">*/</span><span class="PreProc"> : Trace_stream</span><span class="Delimiter">-></span><span class="PreProc">stream(Error_depth</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Constant">"error"</span><span class="PreProc">))</span> +<span class="PreProc">#define raise (!Trace_stream ? (tb_shutdown()</span><span class="Delimiter">,</span><span class="PreProc">cerr) </span><span class="Comment">/*</span><span class="Comment">do print</span><span class="Comment">*/</span><span class="PreProc"> : Trace_stream</span><span class="Delimiter">-></span><span class="PreProc">stream(Error_depth</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Constant">"error"</span><span class="PreProc">))</span> <span class="Comment">// Inside tests, fail any tests that displayed (unexpected) errors.</span> <span class="Comment">// Expected errors in tests should always be hidden and silently checked for.</span> <span class="Delimiter">:(before "End Test Teardown")</span> @@ -233,7 +241,7 @@ START_TRACING_UNTIL_END_OF_SCOPE <span class="Normal">bool</span> check_trace_contents<span class="Delimiter">(</span>string FUNCTION<span class="Delimiter">,</span> string <span class="Normal">FILE</span><span class="Delimiter">,</span> <span class="Normal">int</span> LINE<span class="Delimiter">,</span> string expected<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> vector<string> expected_lines = split<span class="Delimiter">(</span>expected<span class="Delimiter">,</span> <span class="Constant">"^D"</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr_expected_line = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> curr_expected_line = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr_expected_line < SIZE<span class="Delimiter">(</span>expected_lines<span class="Delimiter">)</span> && expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> ++curr_expected_line<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == SIZE<span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> @@ -399,3 +407,4 @@ string trim<span class="Delimiter">(</span><span class="Normal">const</span> str </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/003trace.test.cc.html b/html/003trace.test.cc.html index 110a548c..439e8613 100644 --- a/html/003trace.test.cc.html +++ b/html/003trace.test.cc.html @@ -3,24 +3,32 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 003trace.test.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Comment { color: #9090ff; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } +.Comment { color: #9090ff; } .Delimiter { color: #800080; } -.Normal { color: #eeeeee; background-color: #080808; } +.cSpecial { color: #008000; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Normal">void</span> test_trace_check_compares<span class="Delimiter">()</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">"test layer"</span><span class="Delimiter">)</span> << <span class="Constant">"foo"</span> << end<span class="Delimiter">();</span> CHECK_TRACE_CONTENTS<span class="Delimiter">(</span><span class="Constant">"test layer: foo"</span><span class="Delimiter">);</span> @@ -151,3 +159,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 6814a1be..5cf2cb71 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 010vm.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.PreProc { color: #800080; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.SalientComment { color: #00ffff; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.cSpecial { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: A program is a book of 'recipes' (functions)</span> <span class="Delimiter">:(before "End Globals")</span> <span class="Comment">//: Each recipe is stored at a specific page number, or ordinal.</span> @@ -37,7 +45,7 @@ recipe_ordinal Next_recipe_ordinal = <span class="Constant">1</span><span class= <span class="Comment">//: adding two phone numbers is meaningless. Here each recipe does something</span> <span class="Comment">//: incommensurable with any other recipe.</span> <span class="Delimiter">:(after "Types")</span> -<span class="Normal">typedef</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> recipe_ordinal<span class="Delimiter">;</span> +<span class="Normal">typedef</span> <span class="Normal">int</span> recipe_ordinal<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Types")</span> <span class="Comment">// Recipes are lists of instructions. To perform or 'run' a recipe, the</span> @@ -60,7 +68,7 @@ recipe_ordinal Next_recipe_ordinal = <span class="Constant">1</span><span class= string label<span class="Delimiter">;</span> <span class="Comment">// only if is_label</span> string name<span class="Delimiter">;</span> <span class="Comment">// only if !is_label</span> string old_name<span class="Delimiter">;</span> <span class="Comment">// before our automatic rewrite rules</span> - string original_string<span class="Delimiter">;</span> + string original_string<span class="Delimiter">;</span> <span class="Comment">// for error messages</span> recipe_ordinal operation<span class="Delimiter">;</span> <span class="Comment">// get(Recipe_ordinal, name)</span> vector<reagent> ingredients<span class="Delimiter">;</span> <span class="Comment">// only if !is_label</span> vector<reagent> products<span class="Delimiter">;</span> <span class="Comment">// only if !is_label</span> @@ -125,7 +133,7 @@ recipe_ordinal Next_recipe_ordinal = <span class="Constant">1</span><span class= <span class="Delimiter">:(before "End Globals")</span> <span class="Comment">// Locations refer to a common 'memory'. Each location can store a number.</span> -map<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">double</span>> Memory<span class="Delimiter">;</span> +map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">double</span>> Memory<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Memory<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> @@ -138,7 +146,7 @@ Memory<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Comment">// Unlike most computers today, mu stores types in a single big table, shared</span> <span class="Comment">// by all the mu programs on the computer. This is useful in providing a</span> <span class="Comment">// seamless experience to help understand arbitrary mu programs.</span> -<span class="Normal">typedef</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> type_ordinal<span class="Delimiter">;</span> +<span class="Normal">typedef</span> <span class="Normal">int</span> type_ordinal<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Globals")</span> map<string<span class="Delimiter">,</span> type_ordinal> Type_ordinal<span class="Delimiter">;</span> map<type_ordinal<span class="Delimiter">,</span> type_info> Type<span class="Delimiter">;</span> @@ -166,7 +174,7 @@ type_ordinal Next_type_ordinal = <span class="Constant">1</span><span class="Del <span class="Delimiter">}</span> <span class="Normal">void</span> teardown_types<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<type_ordinal<span class="Delimiter">,</span> type_info>::iterator p = Type<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> p<span class="Delimiter">-></span>second<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> Type_ordinal<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> @@ -195,7 +203,7 @@ atexit<span class="Delimiter">(</span>teardown_types<span class="Delimiter">);</ <span class="Normal">struct</span> type_info <span class="Delimiter">{</span> string name<span class="Delimiter">;</span> kind_of_type kind<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size<span class="Delimiter">;</span> <span class="Comment">// only if type is not primitive; primitives and addresses have size 1 (except arrays are dynamic)</span> + <span class="Normal">int</span> size<span class="Delimiter">;</span> <span class="Comment">// only if type is not primitive; primitives and addresses have size 1 (except arrays are dynamic)</span> vector<reagent> elements<span class="Delimiter">;</span> <span class="Comment">// End type_info Fields</span> type_info<span class="Delimiter">()</span> :kind<span class="Delimiter">(</span>PRIMITIVE<span class="Delimiter">),</span> size<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{}</span> @@ -234,6 +242,36 @@ assert<span class="Delimiter">(</span>Next_recipe_ordinal < <span class="Cons <span class="Delimiter">:(before "End Setup")</span> Next_recipe_ordinal = <span class="Constant">1000</span><span class="Delimiter">;</span> <span class="Comment">// consistent new numbers for each test</span> +<span class="Comment">//: One final detail: tests can modify our global tables of recipes and types,</span> +<span class="Comment">//: so we need some way to clean up after each test is done so it doesn't</span> +<span class="Comment">//: influence later ones.</span> +<span class="Delimiter">:(before "End Globals")</span> +map<string<span class="Delimiter">,</span> recipe_ordinal> Recipe_ordinal_snapshot<span class="Delimiter">;</span> +map<recipe_ordinal<span class="Delimiter">,</span> recipe> Recipe_snapshot<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> type_ordinal> Type_ordinal_snapshot<span class="Delimiter">;</span> +map<type_ordinal<span class="Delimiter">,</span> type_info> Type_snapshot<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End One-time Setup")</span> +save_snapshots<span class="Delimiter">();</span> +<span class="Delimiter">:(before "End Setup")</span> +restore_snapshots<span class="Delimiter">();</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> save_snapshots<span class="Delimiter">()</span> <span class="Delimiter">{</span> + Recipe_ordinal_snapshot = Recipe_ordinal<span class="Delimiter">;</span> + Recipe_snapshot = Recipe<span class="Delimiter">;</span> + Type_ordinal_snapshot = Type_ordinal<span class="Delimiter">;</span> + Type_snapshot = Type<span class="Delimiter">;</span> + <span class="Comment">// End save_snapshots</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> restore_snapshots<span class="Delimiter">()</span> <span class="Delimiter">{</span> + Recipe = Recipe_snapshot<span class="Delimiter">;</span> + Recipe_ordinal = Recipe_ordinal_snapshot<span class="Delimiter">;</span> + Type_ordinal = Type_ordinal_snapshot<span class="Delimiter">;</span> + Type = Type_snapshot<span class="Delimiter">;</span> + <span class="Comment">// End restore_snapshots</span> +<span class="Delimiter">}</span> + ^L <span class="SalientComment">//:: Helpers</span> @@ -309,7 +347,7 @@ reagent::reagent<span class="Delimiter">(</span><span class="Normal">const</span name = old<span class="Delimiter">.</span>name<span class="Delimiter">;</span> value = old<span class="Delimiter">.</span>value<span class="Delimiter">;</span> initialized = old<span class="Delimiter">.</span>initialized<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first<span class="Delimiter">,</span> old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second ? <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>*old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">)</span> : <span class="Constant">NULL</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -331,10 +369,10 @@ string_tree::string_tree<span class="Delimiter">(</span><span class="Normal">con reagent& reagent::<span class="Normal">operator</span>=<span class="Delimiter">(</span><span class="Normal">const</span> reagent& old<span class="Delimiter">)</span> <span class="Delimiter">{</span> original_string = old<span class="Delimiter">.</span>original_string<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">)</span> <span class="Normal">delete</span> properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">;</span> properties<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first<span class="Delimiter">,</span> old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second ? <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>*old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">)</span> : <span class="Constant">NULL</span><span class="Delimiter">));</span> name = old<span class="Delimiter">.</span>name<span class="Delimiter">;</span> value = old<span class="Delimiter">.</span>value<span class="Delimiter">;</span> @@ -349,7 +387,7 @@ reagent::~reagent<span class="Delimiter">()</span> <span class="Delimiter">{</sp <span class="Delimiter">}</span> <span class="Normal">void</span> reagent::clear<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">delete</span> properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">;</span> properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second = <span class="Constant">NULL</span><span class="Delimiter">;</span> @@ -381,14 +419,14 @@ string slurp_until<span class="Delimiter">(</span>istream& in<span class="De <span class="Delimiter">}</span> <span class="Normal">bool</span> has_property<span class="Delimiter">(</span>reagent x<span class="Delimiter">,</span> string name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first == name<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> string_tree* property<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> string& name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> p = <span class="Constant">0</span><span class="Delimiter">;</span> p != SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> p = <span class="Constant">0</span><span class="Delimiter">;</span> p != SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>p<span class="Delimiter">).</span>first == name<span class="Delimiter">)</span> <span class="Identifier">return</span> r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>p<span class="Delimiter">).</span>second<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -409,7 +447,7 @@ string_tree* property<span class="Delimiter">(</span><span class="Normal">const< <span class="Delimiter">}</span> <span class="Normal">void</span> dump_memory<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">double</span>>::iterator p = Memory<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Memory<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">double</span>>::iterator p = Memory<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Memory<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> cout << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << no_scientific<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -424,7 +462,7 @@ string_tree* property<span class="Delimiter">(</span><span class="Normal">const< string to_string<span class="Delimiter">(</span><span class="Normal">const</span> recipe& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> out << <span class="Constant">"recipe "</span> << r<span class="Delimiter">.</span>name << <span class="Constant">" [</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">" "</span> << to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> out << <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> @@ -434,49 +472,69 @@ string debug_string<span class="Delimiter">(</span><span class="Normal">const</s ostringstream out<span class="Delimiter">;</span> out << <span class="Constant">"- recipe "</span> << x<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Comment">// Begin debug_string(recipe x)</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = x<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> out << <span class="Constant">"inst: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> out << <span class="Constant">" ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">" "</span> << debug_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> out << <span class="Constant">" products</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">" "</span> << debug_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> -string to_string<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> +string to_original_string<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> out << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> out << inst<span class="Delimiter">.</span>name << <span class="Constant">' '</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> out << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> +string to_string<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span> + ostringstream out<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> + out << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + <span class="Delimiter">}</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> + out << inst<span class="Delimiter">.</span>name << <span class="Constant">' '</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> + out << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + string to_string<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">"_"</span><span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> + out << <span class="Constant">"{"</span><span class="Delimiter">;</span> out << r<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << names_to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - out << <span class="Constant">", {"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> - out << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">"</span> << r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span> << to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">);</span> - <span class="Delimiter">}</span> - out << <span class="Constant">"}"</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + out << <span class="Constant">", </span><span class="cSpecial">\"</span><span class="Constant">"</span> << r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span> << to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">);</span> <span class="Delimiter">}</span> + out << <span class="Constant">"}"</span><span class="Delimiter">;</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> +<span class="Comment">// special name for ignoring some products</span> +<span class="Normal">inline</span> <span class="Normal">bool</span> is_dummy<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Identifier">return</span> x<span class="Delimiter">.</span>name == <span class="Constant">"_"</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + string debug_string<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> out << x<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << x<span class="Delimiter">.</span>value << <span class="Constant">' '</span> << to_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" -- "</span> << to_string<span class="Delimiter">(</span>x<span class="Delimiter">);</span> @@ -612,7 +670,7 @@ ostream& <span class="Normal">operator</span><<<span class="Delimiter" string trim_floating_point<span class="Delimiter">(</span><span class="Normal">const</span> string& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> len = SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + <span class="Normal">int</span> len = SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Normal">while</span> <span class="Delimiter">(</span>len > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>len-<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="Constant">'0'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> --len<span class="Delimiter">;</span> @@ -643,3 +701,4 @@ string trim_floating_point<span class="Delimiter">(</span><span class="Normal">c </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/011load.cc.html b/html/011load.cc.html index 6a28f8b5..bd2620ad 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 011load.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Phase 1 of running mu code: load it from a textual representation.</span> <span class="Delimiter">:(scenarios load)</span> <span class="Comment">// use 'load' instead of 'run' in all scenarios in this layer</span> @@ -33,8 +41,8 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(code)</span> vector<recipe_ordinal> load<span class="Delimiter">(</span>string form<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -67,7 +75,7 @@ vector<recipe_ordinal> load<span class="Delimiter">(</span>istream& in <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> slurp_recipe<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> slurp_recipe<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe result<span class="Delimiter">;</span> result<span class="Delimiter">.</span>name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Comment">// End Load Recipe Name</span> @@ -87,8 +95,6 @@ vector<recipe_ordinal> load<span class="Delimiter">(</span>istream& in slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">,</span> result<span class="Delimiter">);</span> <span class="Comment">// End Recipe Body(result)</span> put<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">),</span> result<span class="Delimiter">);</span> - <span class="Comment">// track added recipes because we may need to undo them in tests; see below</span> - Recently_added_recipes<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">));</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -255,24 +261,6 @@ Disable_redefine_checks = <span class="Constant">false</span><span class="Delimi exit<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Comment">//: Have tests clean up any recipes they added.</span> -<span class="Delimiter">:(before "End Globals")</span> -vector<recipe_ordinal> Recently_added_recipes<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Reserved_for_tests = <span class="Constant">1000</span><span class="Delimiter">;</span> -<span class="Delimiter">:(before "End Setup")</span> -clear_recently_added_recipes<span class="Delimiter">();</span> -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> clear_recently_added_recipes<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> >= Reserved_for_tests <span class="Comment">// don't renumber existing recipes, like 'interactive'</span> - && contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Comment">// in case previous test had duplicate definitions</span> - Recipe_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> - Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Delimiter">}</span> - <span class="Comment">// Clear Other State For Recently_added_recipes</span> - Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -<span class="Delimiter">}</span> - <span class="Delimiter">:(scenario parse_comment_outside_recipe)</span> <span class="Comment"># this comment will be dropped by the tangler, so we need a dummy recipe to stop that</span> def f1 [ @@ -282,8 +270,8 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(scenario parse_comment_amongst_instruction)</span> def main [ @@ -291,8 +279,8 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(scenario parse_comment_amongst_instruction_2)</span> def main [ @@ -301,8 +289,8 @@ def main [ <span class="Comment"># comment</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(scenario parse_comment_amongst_instruction_3)</span> def main [ @@ -311,19 +299,19 @@ def main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 2: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {2: "number"}</span> <span class="Delimiter">:(scenario parse_comment_after_instruction)</span> def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Comment"># comment</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(scenario parse_label)</span> def main [ @@ -342,43 +330,43 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>/foo:bar:baz ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal", {"foo": ("bar" "baz")}</span> -<span class="traceContains">+parse: product: 1: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal", "foo": ("bar" "baz")}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> <span class="Delimiter">:(scenario parse_multiple_products)</span> def main [ <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: product: 1: "number"</span> -<span class="traceContains">+parse: product: 2: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> +<span class="traceContains">+parse: product: {2: "number"}</span> <span class="Delimiter">:(scenario parse_multiple_ingredients)</span> def main [ <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">4</span>:number ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: ingredient: 4: "number"</span> -<span class="traceContains">+parse: product: 1: "number"</span> -<span class="traceContains">+parse: product: 2: "number"</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: ingredient: {4: "number"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> +<span class="traceContains">+parse: product: {2: "number"}</span> <span class="Delimiter">:(scenario parse_multiple_types)</span> def main [ <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">2</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">4</span>:number ] <span class="traceContains">+parse: instruction: copy</span> -<span class="traceContains">+parse: ingredient: 23: "literal"</span> -<span class="traceContains">+parse: ingredient: 4: "number"</span> -<span class="traceContains">+parse: product: 1: "number"</span> -<span class="traceContains">+parse: product: 2: ("address" "number")</span> +<span class="traceContains">+parse: ingredient: {23: "literal"}</span> +<span class="traceContains">+parse: ingredient: {4: "number"}</span> +<span class="traceContains">+parse: product: {1: "number"}</span> +<span class="traceContains">+parse: product: {2: ("address" "number")}</span> <span class="Delimiter">:(scenario parse_properties)</span> def main [ <span class="Constant">1</span>:address:number/lookup<span class="Special"> <- </span>copy <span class="Constant">23</span> ] -<span class="traceContains">+parse: product: 1: ("address" "number"), {"lookup": ()}</span> +<span class="traceContains">+parse: product: {1: ("address" "number"), "lookup": ()}</span> <span class="Comment">//: this test we can't represent with a scenario</span> <span class="Delimiter">:(code)</span> @@ -413,3 +401,4 @@ $error: <span class="Constant">0</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/012transform.cc.html b/html/012transform.cc.html index 052df113..7d46535e 100644 --- a/html/012transform.cc.html +++ b/html/012transform.cc.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 012transform.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } -.CommentedCode { color: #6c6c6c; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.CommentedCode { color: #6c6c6c; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Identifier { color: #fcb165; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Phase 2: Filter loaded recipes through an extensible list of 'transforms'.</span> <span class="Comment">//:</span> <span class="Comment">//: The hope is that this framework of transform tools will provide a</span> @@ -38,7 +46,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment">//: relative to those in previous layers to find a better arrangement.</span> <span class="Delimiter">:(before "End recipe Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> transformed_until<span class="Delimiter">;</span> +<span class="Normal">int</span> transformed_until<span class="Delimiter">;</span> <span class="Delimiter">:(before "End recipe Constructor")</span> transformed_until = -<span class="Constant">1</span><span class="Delimiter">;</span> @@ -63,7 +71,8 @@ vector<transform_fn> Transform<span class="Delimiter">;</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> transform_all<span class="Delimiter">()</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"=== transform_all()"</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << "=== transform_all\n";</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << "transform " << t << '\n';</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<recipe_ordinal<span class="Delimiter">,</span> recipe>::iterator p = Recipe<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe& r = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> @@ -81,16 +90,15 @@ vector<transform_fn> Transform<span class="Delimiter">;</span> <span class="Normal">void</span> parse_int_reagents<span class="Delimiter">()</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- parsing any uninitialized reagents as integers"</span> << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << "--- parsing any uninitialized reagents as integers" << '\n';</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<recipe_ordinal<span class="Delimiter">,</span> recipe>::iterator p = Recipe<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe& r = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> populate_value<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> populate_value<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -112,3 +120,4 @@ vector<transform_fn> Transform<span class="Delimiter">;</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/013update_operation.cc.html b/html/013update_operation.cc.html index 3dc72146..26654755 100644 --- a/html/013update_operation.cc.html +++ b/html/013update_operation.cc.html @@ -3,26 +3,34 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 013update_operation.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.CommentedCode { color: #6c6c6c; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.CommentedCode { color: #6c6c6c; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Identifier { color: #fcb165; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Once all code is loaded, save operation ids of instructions and check that</span> <span class="Comment">//: nothing's undefined.</span> @@ -34,7 +42,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- compute instruction operations for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="CommentedCode">//? cerr << "--- compute instruction operations for recipe " << caller.name << '\n';</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -53,3 +61,4 @@ string maybe<span class="Delimiter">(</span>string s<span class="Delimiter">)</s </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 1a98bd39..6aa34381 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -3,28 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 014literal_string.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> -<span class="Comment">//: For convenience, some instructions will take literal arrays of characters (strings).</span> +<pre id='vimCodeElement'> +<span class="Comment">//: For convenience, some instructions will take literal arrays of characters</span> +<span class="Comment">//: (text or strings).</span> <span class="Comment">//:</span> <span class="Comment">//: Instead of quotes, we'll use [] to delimit strings. That'll reduce the</span> <span class="Comment">//: need for escaping since we can support nested brackets. And we can also</span> @@ -36,13 +45,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color def main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc def] <span class="Comment"># copy can't really take a string</span> ] -<span class="traceContains">+parse: ingredient: "abc def": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"abc def": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_with_colons)</span> def main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc:def/ghi] ] -<span class="traceContains">+parse: ingredient: "abc:def/ghi": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"abc:def/ghi": "literal-string"}</span> <span class="Delimiter">:(before "End Mu Types Initialization")</span> put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"literal-string"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> @@ -156,7 +165,7 @@ string emit_literal_string<span class="Delimiter">(</span>string name<span class <span class="Normal">size_t</span> pos = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>pos != string::npos<span class="Delimiter">)</span> pos = replace<span class="Delimiter">(</span>name<span class="Delimiter">,</span> <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">,</span> <span class="Constant">"</span><span class="cSpecial">\\</span><span class="Constant">n"</span><span class="Delimiter">,</span> pos<span class="Delimiter">);</span> - <span class="Identifier">return</span> <span class="Constant">'"'</span>+name+<span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: </span><span class="cSpecial">\"</span><span class="Constant">literal-string</span><span class="cSpecial">\"</span><span class="Constant">"</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> <span class="Constant">"{</span><span class="cSpecial">\"</span><span class="Constant">"</span>+name+<span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: </span><span class="cSpecial">\"</span><span class="Constant">literal-string</span><span class="cSpecial">\"</span><span class="Constant">}"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">size_t</span> replace<span class="Delimiter">(</span>string& str<span class="Delimiter">,</span> <span class="Normal">const</span> string& from<span class="Delimiter">,</span> <span class="Normal">const</span> string& to<span class="Delimiter">,</span> <span class="Normal">size_t</span> n<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -174,20 +183,20 @@ string emit_literal_string<span class="Delimiter">(</span>string name<span class def main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc [def]] ] -<span class="traceContains">+parse: ingredient: "abc [def]": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"abc [def]": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_escaped)</span> def main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc \[def] ] -<span class="traceContains">+parse: ingredient: "abc [def": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"abc [def": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_escaped_comment_aware)</span> def main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [ abc \\\[def] ] -<span class="traceContains">+parse: ingredient: "\nabc \[def": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"\nabc \[def": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_and_comment)</span> def main [ @@ -196,15 +205,15 @@ def main [ <span class="traceContains">+parse: --- defining main</span> <span class="traceContains">+parse: instruction: copy</span> <span class="traceContains">+parse: number of ingredients: 1</span> -<span class="traceContains">+parse: ingredient: "abc": "literal-string"</span> -<span class="traceContains">+parse: product: 1: ("address" "array" "character")</span> +<span class="traceContains">+parse: ingredient: {"abc": "literal-string"}</span> +<span class="traceContains">+parse: product: {1: ("address" "array" "character")}</span> <span class="Delimiter">:(scenario string_literal_escapes_newlines_in_trace)</span> def main [ copy [abc def] ] -<span class="traceContains">+parse: ingredient: "abc\ndef": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"abc\ndef": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_can_skip_past_comments)</span> def main [ @@ -213,13 +222,14 @@ def main [ bar ] ] -<span class="traceContains">+parse: ingredient: "\n # ']' inside comment\n bar\n ": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"\n # ']' inside comment\n bar\n ": "literal-string"}</span> <span class="Delimiter">:(scenario string_literal_empty)</span> def main [ copy [] ] -<span class="traceContains">+parse: ingredient: "": "literal-string"</span> +<span class="traceContains">+parse: ingredient: {"": "literal-string"}</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/015literal_noninteger.cc.html b/html/015literal_noninteger.cc.html index 8f38cb27..c8fd93f3 100644 --- a/html/015literal_noninteger.cc.html +++ b/html/015literal_noninteger.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 015literal_noninteger.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Support literal non-integers.</span> <span class="Delimiter">:(scenarios load)</span> @@ -31,7 +39,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">3.14159</span> ] -<span class="traceContains">+parse: ingredient: 3.14159: "literal-fractional-number"</span> +<span class="traceContains">+parse: ingredient: {3.14159: "literal-fractional-number"}</span> <span class="Delimiter">:(after "Parsing reagent(string s)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -74,3 +82,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/020run.cc.html b/html/020run.cc.html index 6f24364a..a31b6dcd 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -3,31 +3,39 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 020run.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.PreProc { color: #800080; } -.CommentedCode { color: #6c6c6c; } -.SalientComment { color: #00ffff; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Phase 3: Start running a loaded and transformed recipe.</span> <span class="Comment">//:</span> <span class="Comment">//: So far we've seen recipes as lists of instructions, and instructions point</span> @@ -43,7 +51,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] -<span class="traceContains">+run: 1:number <- copy 23</span> +<span class="traceContains">+run: {1: "number"} <- copy {23: "literal"}</span> <span class="traceContains">+mem: storing 23 in location 1</span> <span class="Delimiter">:(scenario copy)</span> @@ -51,7 +59,7 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] -<span class="traceContains">+run: 2:number <- copy 1:number</span> +<span class="traceContains">+run: {2: "number"} <- copy {1: "number"}</span> <span class="traceContains">+mem: location 1 is 23</span> <span class="traceContains">+mem: storing 23 in location 2</span> @@ -67,16 +75,17 @@ def main [ <span class="Comment">//: Later layers will change this.</span> <span class="Normal">struct</span> routine <span class="Delimiter">{</span> recipe_ordinal running_recipe<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> running_step_index<span class="Delimiter">;</span> + <span class="Normal">int</span> running_step_index<span class="Delimiter">;</span> routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> :running_recipe<span class="Delimiter">(</span>r<span class="Delimiter">),</span> running_step_index<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{}</span> <span class="Normal">bool</span> completed<span class="Delimiter">()</span> <span class="Normal">const</span><span class="Delimiter">;</span> + <span class="Normal">const</span> vector<instruction>& steps<span class="Delimiter">()</span> <span class="Normal">const</span><span class="Delimiter">;</span> <span class="Delimiter">};</span> <span class="Delimiter">:(before "End Globals")</span> routine* Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> -map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Instructions_running<span class="Delimiter">;</span> -map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Locations_read<span class="Delimiter">;</span> -map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Locations_read_by_instruction<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> Instructions_running<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> Locations_read<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> Locations_read_by_instruction<span class="Delimiter">;</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> run<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -99,7 +108,7 @@ map<string<span class="Delimiter">,</span> <span class="Normal">long</span> < <span class="Comment">// read all ingredients from memory, each potentially spanning multiple locations</span> vector<vector<<span class="Normal">double</span>> > ingredients<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>should_copy_ingredients<span class="Delimiter">())</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>read_memory<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)));</span> <span class="Delimiter">}</span> <span class="Comment">// instructions below will write to 'products'</span> @@ -116,10 +125,10 @@ map<string<span class="Delimiter">,</span> <span class="Normal">long</span> < <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>products<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << SIZE<span class="Delimiter">(</span>products<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">)</span> << <span class="Constant">": failed to write to all products! "</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << SIZE<span class="Delimiter">(</span>products<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">)</span> << <span class="Constant">": failed to write to all products! "</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> write_memory<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -138,7 +147,7 @@ map<string<span class="Delimiter">,</span> <span class="Normal">long</span> < <span class="Comment">//: We'll need to override these later as we change the definition of routine.</span> <span class="Comment">//: Important that they return referrences into the routine.</span> -<span class="Normal">inline</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Normal">inline</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -154,6 +163,10 @@ map<string<span class="Delimiter">,</span> <span class="Normal">long</span> < <span class="Identifier">return</span> running_step_index >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Normal">inline</span> <span class="Normal">const</span> vector<instruction>& routine::steps<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> + <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + <span class="SalientComment">//:: Startup flow</span> <span class="Comment">//: Step 1: load all .mu files with numeric prefixes (in order)</span> @@ -161,14 +174,14 @@ map<string<span class="Delimiter">,</span> <span class="Normal">long</span> < <span class="Comment">// Load .mu Core</span> <span class="CommentedCode">//? Trace_file = "interactive";</span> <span class="CommentedCode">//? START_TRACING_UNTIL_END_OF_SCOPE;</span> -load_permanently<span class="Delimiter">(</span><span class="Constant">"core.mu"</span><span class="Delimiter">);</span> -transform_all<span class="Delimiter">();</span> +load_file_or_directory<span class="Delimiter">(</span><span class="Constant">"core.mu"</span><span class="Delimiter">);</span> <span class="CommentedCode">//? DUMP("");</span> <span class="CommentedCode">//? exit(0);</span> <span class="Comment">//: Step 2: load any .mu files provided at the commandline</span> <span class="Delimiter">:(before "End Commandline Parsing")</span> <span class="Comment">// Check For .mu Files</span> +<span class="CommentedCode">//? START_TRACING_UNTIL_END_OF_SCOPE</span> <span class="Normal">if</span> <span class="Delimiter">(</span>argc > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// skip argv[0]</span> argv++<span class="Delimiter">;</span> @@ -176,14 +189,15 @@ transform_all<span class="Delimiter">();</span> <span class="Comment">// ignore argv past '--'; that's commandline args for 'main'</span> <span class="Normal">while</span> <span class="Delimiter">(</span>argc > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>string<span class="Delimiter">(</span>*argv<span class="Delimiter">)</span> == <span class="Constant">"--"</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - load_permanently<span class="Delimiter">(</span>*argv<span class="Delimiter">);</span> + load_file_or_directory<span class="Delimiter">(</span>*argv<span class="Delimiter">);</span> argv++<span class="Delimiter">;</span> argc--<span class="Delimiter">;</span> <span class="Delimiter">}</span> - transform_all<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Run_tests<span class="Delimiter">)</span> Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> <span class="Comment">// End Loading .mu Files</span> <span class="Delimiter">}</span> +transform_all<span class="Delimiter">();</span> +save_snapshots<span class="Delimiter">();</span> <span class="Comment">//: Step 3: if we aren't running tests, locate a recipe called 'main' and</span> <span class="Comment">//: start running it.</span> @@ -206,15 +220,15 @@ transform_all<span class="Delimiter">();</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> dump_profile<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = Instructions_running<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Instructions_running<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = Instructions_running<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Instructions_running<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> cerr << <span class="Constant">"== locations read</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = Locations_read<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Locations_read<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = Locations_read<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Locations_read<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> cerr << <span class="Constant">"== locations read by instruction</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = Locations_read_by_instruction<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Locations_read_by_instruction<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = Locations_read_by_instruction<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Locations_read_by_instruction<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -233,9 +247,9 @@ transform_all<span class="Delimiter">();</span> atexit<span class="Delimiter">(</span>cleanup_main<span class="Delimiter">);</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> load_permanently<span class="Delimiter">(</span>string filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> load_file_or_directory<span class="Delimiter">(</span>string filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_directory<span class="Delimiter">(</span>filename<span class="Delimiter">))</span> <span class="Delimiter">{</span> - load_all_permanently<span class="Delimiter">(</span>filename<span class="Delimiter">);</span> + load_all<span class="Delimiter">(</span>filename<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ifstream fin<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> @@ -246,9 +260,6 @@ atexit<span class="Delimiter">(</span>cleanup_main<span class="Delimiter">);</sp trace<span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"=== "</span> << filename << end<span class="Delimiter">();</span> load<span class="Delimiter">(</span>fin<span class="Delimiter">);</span> fin<span class="Delimiter">.</span>close<span class="Delimiter">();</span> - <span class="Comment">// freeze everything so it doesn't get cleared by tests</span> - Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Comment">// End load_permanently.</span> <span class="Delimiter">}</span> <span class="Normal">bool</span> is_directory<span class="Delimiter">(</span>string path<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -257,13 +268,13 @@ atexit<span class="Delimiter">(</span>cleanup_main<span class="Delimiter">);</sp <span class="Identifier">return</span> info<span class="Delimiter">.</span>st_mode & S_IFDIR<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> load_all_permanently<span class="Delimiter">(</span>string dir<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> load_all<span class="Delimiter">(</span>string dir<span class="Delimiter">)</span> <span class="Delimiter">{</span> dirent** files<span class="Delimiter">;</span> <span class="Normal">int</span> num_files = scandir<span class="Delimiter">(</span>dir<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &files<span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">,</span> alphasort<span class="Delimiter">);</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num_files<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> string curr_file = files[i]<span class="Delimiter">-></span>d_name<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>isdigit<span class="Delimiter">(</span>curr_file<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> - load_permanently<span class="Delimiter">(</span>dir+<span class="Constant">'/'</span>+curr_file<span class="Delimiter">);</span> + load_file_or_directory<span class="Delimiter">(</span>dir+<span class="Constant">'/'</span>+curr_file<span class="Delimiter">);</span> free<span class="Delimiter">(</span>files[i]<span class="Delimiter">);</span> files[i] = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -282,44 +293,44 @@ vector<<span class="Normal">double</span>> read_memory<span class="Delimit result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value<span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>x<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < size<span class="Delimiter">;</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">double</span> val = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+offset<span class="Delimiter">);</span> - trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << base+offset << <span class="Constant">" is "</span> << no_scientific<span class="Delimiter">(</span>val<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + <span class="Comment">// End Preprocess read_memory(x)</span> + <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>x<span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < size<span class="Delimiter">;</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">double</span> val = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << x<span class="Delimiter">.</span>value+offset << <span class="Constant">" is "</span> << no_scientific<span class="Delimiter">(</span>val<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>val<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> write_memory<span class="Delimiter">(</span>reagent x<span class="Delimiter">,</span> vector<<span class="Normal">double</span>> data<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> write_memory<span class="Delimiter">(</span>reagent x<span class="Delimiter">,</span> <span class="Normal">const</span> vector<<span class="Normal">double</span>>& data<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << <span class="Constant">"can't write to "</span> << to_string<span class="Delimiter">(</span>x<span class="Delimiter">)</span> << <span class="Constant">"; no type</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Comment">// End Preprocess write_memory(x)</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>size_mismatch<span class="Delimiter">(</span>x<span class="Delimiter">,</span> data<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"size mismatch in storing to "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" ("</span> << size_of<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="Constant">") at '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"size mismatch in storing to "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" ("</span> << size_of<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="Constant">") at '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Comment">// End write_memory(reagent x, long long int base) Special-cases</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> - assert<span class="Delimiter">(</span>base+offset > <span class="Constant">0</span><span class="Delimiter">);</span> - trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << base+offset << end<span class="Delimiter">();</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+offset<span class="Delimiter">,</span> data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> + <span class="Comment">// End write_memory(reagent x) Special-cases</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value+offset > <span class="Constant">0</span><span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << x<span class="Delimiter">.</span>value+offset << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">,</span> data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size_of<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> size_of<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// End size_of(reagent) Cases</span> <span class="Identifier">return</span> size_of<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size_of<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> size_of<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// End size_of(type) Cases</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> @@ -332,10 +343,6 @@ vector<<span class="Normal">double</span>> read_memory<span class="Delimit <span class="Identifier">return</span> size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">inline</span> <span class="Normal">bool</span> is_dummy<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> x<span class="Delimiter">.</span>name == <span class="Constant">"_"</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> - <span class="Normal">inline</span> <span class="Normal">bool</span> is_literal<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == <span class="Constant">0</span><span class="Delimiter">)</span> @@ -343,7 +350,7 @@ vector<<span class="Normal">double</span>> read_memory<span class="Delimit <span class="Identifier">return</span> r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">inline</span> <span class="Normal">bool</span> scalar<span class="Delimiter">(</span><span class="Normal">const</span> vector<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">inline</span> <span class="Normal">bool</span> scalar<span class="Delimiter">(</span><span class="Normal">const</span> vector<<span class="Normal">int</span>>& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> SIZE<span class="Delimiter">(</span>x<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">inline</span> <span class="Normal">bool</span> scalar<span class="Delimiter">(</span><span class="Normal">const</span> vector<<span class="Normal">double</span>>& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -356,7 +363,12 @@ vector<<span class="Normal">double</span>> read_memory<span class="Delimit transform_all<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">)</span> > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - run<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>front<span class="Delimiter">());</span> + <span class="Comment">// if a test defines main, it probably wants to start there regardless of</span> + <span class="Comment">// definition order</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)))</span> + run<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> + <span class="Normal">else</span> + run<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>front<span class="Delimiter">());</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario run_label)</span> @@ -365,15 +377,15 @@ def main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] -<span class="traceContains">+run: 1:number <- copy 23</span> -<span class="traceContains">+run: 2:number <- copy 1:number</span> +<span class="traceContains">+run: {1: "number"} <- copy {23: "literal"}</span> +<span class="traceContains">+run: {2: "number"} <- copy {1: "number"}</span> <span class="traceAbsent">-run: +foo</span> <span class="Delimiter">:(scenario run_dummy)</span> def main [ _<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+run: _ <- copy 0</span> +<span class="traceContains">+run: _ <- copy {0: "literal"}</span> <span class="Delimiter">:(scenario write_to_0_disallowed)</span> <span class="Special">% Hide_errors = true;</span> @@ -411,3 +423,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/021check_instruction.cc.html b/html/021check_instruction.cc.html index f8e5aad6..580a32f6 100644 --- a/html/021check_instruction.cc.html +++ b/html/021check_instruction.cc.html @@ -3,28 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 021check_instruction.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .Special { color: #c00000; } +.traceContains { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #800080; } .cSpecial { color: #008000; } .Identifier { color: #fcb165; } -.CommentedCode { color: #6c6c6c; } -.Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } -.Comment { color: #9090ff; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Introduce a new transform to perform various checks in instructions before</span> <span class="Comment">//: we start running them. It'll be extensible, so that we can add checks for</span> <span class="Comment">//: new recipes as we extend 'run' to support them.</span> @@ -41,19 +48,18 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">:(code)</span> <span class="Normal">void</span> check_instruction<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- perform checks for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << "--- perform checks for recipe " << get(Recipe, r).name << '\n';</span> map<string<span class="Delimiter">,</span> vector<type_ordinal> > metadata<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">switch</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// Primitive Recipe Checks</span> <span class="Normal">case</span> COPY: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << <span class="Constant">"ingredients and products should match in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">"ingredients and products should match in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"can't copy "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="Constant">" to "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="Constant">"; types don't match</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> @@ -232,3 +238,4 @@ $error: <span class="Constant">0</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index 8c15c291..f90e0bc7 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 022arithmetic.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Special { color: #c00000; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.Special { color: #c00000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Arithmetic primitives</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -33,14 +41,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> ADD: <span class="Delimiter">{</span> <span class="Comment">// primary goal of these checks is to forbid address arithmetic</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'add' requires number ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'add' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'add' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -52,7 +60,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> ADD: <span class="Delimiter">{</span> <span class="Normal">double</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> result += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -104,7 +112,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'subtract' has no ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// permit address offset computations in tests</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'subtract' requires number ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -112,7 +120,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'subtract' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'subtract' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -124,7 +132,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> SUBTRACT: <span class="Delimiter">{</span> <span class="Normal">double</span> result = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result -= ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> @@ -161,14 +169,14 @@ MULTIPLY<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"multiply"</span><span class="Delimiter">,</span> MULTIPLY<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> MULTIPLY: <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'multiply' requires number ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'multiply' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'multiply' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -180,7 +188,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> MULTIPLY: <span class="Delimiter">{</span> <span class="Normal">double</span> result = <span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> result *= ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -218,14 +226,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide' has no ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide' requires number ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -237,7 +245,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> DIVIDE: <span class="Delimiter">{</span> <span class="Normal">double</span> result = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result /= ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> @@ -273,18 +281,18 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> DIVIDE_WITH_REMAINDER: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' yields two products in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' yields two products in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'divide-with-remainder' should yield a number, but got "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> @@ -295,17 +303,17 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> DIVIDE_WITH_REMAINDER: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>b == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"divide by zero in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"divide by zero in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> quotient = a / b<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> remainder = a % b<span class="Delimiter">;</span> + <span class="Normal">int</span> quotient = a / b<span class="Delimiter">;</span> + <span class="Normal">int</span> remainder = a % b<span class="Delimiter">;</span> <span class="Comment">// very large integers will lose precision</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>quotient<span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>remainder<span class="Delimiter">);</span> @@ -357,15 +365,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> SHIFT_LEFT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-left' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -377,11 +385,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> SHIFT_LEFT: <span class="Delimiter">{</span> <span class="Comment">// ingredients must be integers</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>b < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"second ingredient can't be negative in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"second ingredient can't be negative in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -428,15 +436,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> SHIFT_RIGHT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'shift-right' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -448,11 +456,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> SHIFT_RIGHT: <span class="Delimiter">{</span> <span class="Comment">// ingredients must be integers</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>b < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"second ingredient can't be negative in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"second ingredient can't be negative in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -499,15 +507,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> AND_BITS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and-bits' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -519,8 +527,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> AND_BITS: <span class="Delimiter">{</span> <span class="Comment">// ingredients must be integers</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>a&b<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -557,15 +565,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> OR_BITS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or-bits' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -577,8 +585,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> OR_BITS: <span class="Delimiter">{</span> <span class="Comment">// ingredients must be integers</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>a|b<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -609,15 +617,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> XOR_BITS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> || !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' requires number ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' requires number ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'xor-bits' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -629,8 +637,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> XOR_BITS: <span class="Delimiter">{</span> <span class="Comment">// ingredients must be integers</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>a^b<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -661,15 +669,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> FLIP_BITS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' requires exactly one ingredient, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' requires exactly one ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' requires a number ingredient, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' requires a number ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' yields one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'flip-bits' yields one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -681,7 +689,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> FLIP_BITS: <span class="Delimiter">{</span> <span class="Comment">// ingredient must be integer</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>~a<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -713,3 +721,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/023boolean.cc.html b/html/023boolean.cc.html index 1d9b4bdd..2f019f42 100644 --- a/html/023boolean.cc.html +++ b/html/023boolean.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 023boolean.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Special { color: #c00000; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.Special { color: #c00000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Boolean primitives</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -32,14 +40,14 @@ AND<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"and"</span><span class="Delimiter">,</span> AND<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> AND: <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and' requires boolean ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -51,7 +59,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> AND: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result = result && ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> @@ -90,14 +98,14 @@ OR<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"or"</span><span class="Delimiter">,</span> OR<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> OR: <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'and' requires boolean ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'or' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -109,7 +117,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> OR: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result = result || ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> @@ -149,16 +157,16 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> NOT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'not' cannot have fewer ingredients than products in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'not' cannot have fewer ingredients than products in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'not' requires boolean ingredients, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'not' should yield a boolean, but got "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -170,7 +178,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> NOT: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>!ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -193,3 +201,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/024jump.cc.html b/html/024jump.cc.html index 9ff53434..e6fb3aba 100644 --- a/html/024jump.cc.html +++ b/html/024jump.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 024jump.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } +.cSpecial { color: #008000; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Jump primitives</span> <span class="Delimiter">:(scenario jump_can_skip_instructions)</span> @@ -32,8 +40,8 @@ def main [ jump <span class="Constant">1</span>:offset <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] -<span class="traceContains">+run: jump 1:offset</span> -<span class="traceAbsent">-run: 1:number <- copy 1</span> +<span class="traceContains">+run: jump {1: "offset"}</span> +<span class="traceAbsent">-run: {1: "number"} <- copy {1: "literal"}</span> <span class="traceAbsent">-mem: storing 1 in location 1</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -43,7 +51,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> JUMP: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -71,9 +79,9 @@ def main [ <span class="Comment"># \/ /\ |</span> jump -<span class="Constant">2</span>:offset <span class="Comment"># 2 +-->+ |</span> ] <span class="Comment"># \/ 3</span> -<span class="traceContains">+run: jump 1:offset</span> -<span class="traceContains">+run: jump -2:offset</span> -<span class="traceContains">+run: jump 3:offset</span> +<span class="traceContains">+run: jump {1: "offset"}</span> +<span class="traceContains">+run: jump {-2: "offset"}</span> +<span class="traceContains">+run: jump {3: "offset"}</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> JUMP_IF<span class="Delimiter">,</span> @@ -82,7 +90,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-if' requires exactly two ingredients, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-if' requires exactly two ingredients, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -112,9 +120,9 @@ def main [ jump-<span class="Normal">if</span> <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Constant">123</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] -<span class="traceContains">+run: jump-if 999, 1:offset</span> +<span class="traceContains">+run: jump-if {999: "literal"}, {1: "offset"}</span> <span class="traceContains">+run: jumping to instruction 2</span> -<span class="traceAbsent">-run: 1:number <- copy 1</span> +<span class="traceAbsent">-run: {1: "number"} <- copy {1: "literal"}</span> <span class="traceAbsent">-mem: storing 1 in location 123</span> <span class="Delimiter">:(scenario jump_if_fallthrough)</span> @@ -122,9 +130,9 @@ def main [ jump-<span class="Normal">if</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Constant">123</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] -<span class="traceContains">+run: jump-if 0, 1:offset</span> +<span class="traceContains">+run: jump-if {0: "literal"}, {1: "offset"}</span> <span class="traceContains">+run: jump-if fell through</span> -<span class="traceContains">+run: 123:number <- copy 1</span> +<span class="traceContains">+run: {123: "number"} <- copy {1: "literal"}</span> <span class="traceContains">+mem: storing 1 in location 123</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -134,7 +142,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-unless' requires exactly two ingredients, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-unless' requires exactly two ingredients, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -164,9 +172,9 @@ def main [ jump-unless <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Constant">123</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] -<span class="traceContains">+run: jump-unless 0, 1:offset</span> +<span class="traceContains">+run: jump-unless {0: "literal"}, {1: "offset"}</span> <span class="traceContains">+run: jumping to instruction 2</span> -<span class="traceAbsent">-run: 123:number <- copy 1</span> +<span class="traceAbsent">-run: {123: "number"} <- copy {1: "literal"}</span> <span class="traceAbsent">-mem: storing 1 in location 123</span> <span class="Delimiter">:(scenario jump_unless_fallthrough)</span> @@ -174,10 +182,11 @@ def main [ jump-unless <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Constant">123</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] -<span class="traceContains">+run: jump-unless 999, 1:offset</span> +<span class="traceContains">+run: jump-unless {999: "literal"}, {1: "offset"}</span> <span class="traceContains">+run: jump-unless fell through</span> -<span class="traceContains">+run: 123:number <- copy 1</span> +<span class="traceContains">+run: {123: "number"} <- copy {1: "literal"}</span> <span class="traceContains">+mem: storing 1 in location 123</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/025compare.cc.html b/html/025compare.cc.html index 301da39d..2b06007e 100644 --- a/html/025compare.cc.html +++ b/html/025compare.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 025compare.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Special { color: #c00000; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.Special { color: #c00000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Comparison primitives</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -33,11 +41,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> EQUAL: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'equal' needs at least two ingredients to compare in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'equal' needs at least two ingredients to compare in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'equal' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'equal' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -50,7 +58,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> EQUAL: <span class="Delimiter">{</span> vector<<span class="Normal">double</span>>& exemplar = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!equal<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>begin<span class="Delimiter">(),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>end<span class="Delimiter">(),</span> exemplar<span class="Delimiter">.</span>begin<span class="Delimiter">()))</span> <span class="Delimiter">{</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -100,17 +108,17 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> GREATER_THAN: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-than' needs at least two ingredients to compare in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-than' needs at least two ingredients to compare in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-than' can only compare numbers; got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-than' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-than' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -122,7 +130,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> GREATER_THAN: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> <= ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -167,17 +175,17 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> LESSER_THAN: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-than' needs at least two ingredients to compare in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-than' needs at least two ingredients to compare in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-than' can only compare numbers; got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-than' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-than' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -189,7 +197,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> LESSER_THAN: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> >= ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -234,17 +242,17 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> GREATER_OR_EQUAL: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' needs at least two ingredients to compare in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' needs at least two ingredients to compare in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' can only compare numbers; got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -256,7 +264,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> GREATER_OR_EQUAL: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> < ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -309,17 +317,17 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> LESSER_OR_EQUAL: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-or-equal' needs at least two ingredients to compare in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-or-equal' needs at least two ingredients to compare in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'lesser-or-equal' can only compare numbers; got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_checking_instruction<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' yields exactly one product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'greater-or-equal' yields exactly one product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -331,7 +339,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> LESSER_OR_EQUAL: <span class="Delimiter">{</span> <span class="Normal">bool</span> result = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/**/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> > ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -379,3 +387,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/029tools.cc.html b/html/029tools.cc.html index 6e245746..fa165415 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 029tools.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.CommentedCode { color: #6c6c6c; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .Special { color: #c00000; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Allow mu programs to log facts just like we've been doing in C++ so far.</span> <span class="Delimiter">:(scenario trace)</span> @@ -41,7 +49,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> TRACE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> < <span class="Constant">3</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'trace' takes three or more ingredients rather than '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'trace' takes three or more ingredients rather than '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -56,10 +64,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> TRACE: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> depth = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> depth = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> string label = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span>depth<span class="Delimiter">,</span> label<span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> @@ -79,7 +87,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> STASH: <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"app"</span><span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> @@ -227,7 +235,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> ASSERT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'assert' takes exactly two ingredients rather than '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'assert' takes exactly two ingredients rather than '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -260,7 +268,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> _PRINT: <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"$print: "</span> << current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"newline"</span><span class="Delimiter">))</span> @@ -269,7 +277,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span cout << current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"$print: "</span> << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> cout << <span class="Constant">" "</span><span class="Delimiter">;</span> cout << no_scientific<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> @@ -347,7 +355,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> _LOG: <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> LOG << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> @@ -356,3 +364,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/030container.cc.html b/html/030container.cc.html index 5f494caa..1ab7d9ed 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 030container.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.PreProc { color: #800080; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Containers contain a fixed number of elements of different types.</span> <span class="Delimiter">:(before "End Mu Types Initialization")</span> @@ -122,8 +130,8 @@ def main [ type_info t = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>t<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// size of a container is the sum of the sizes of its elements</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>t<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>t<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// todo: strengthen assertion to disallow mutual type recursion</span> <span class="Normal">if</span> <span class="Delimiter">(</span>t<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">-></span>value == type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << <span class="Constant">"container "</span> << t<span class="Delimiter">.</span>name << <span class="Constant">" can't include itself as a member</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -161,7 +169,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> GET: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'get' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'get' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// new copy for every invocation</span> @@ -176,7 +184,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"second ingredient of 'get' should have type 'offset', but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Comment">// later layers permit non-integer offsets</span> offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">else</span> @@ -199,16 +207,16 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> GET: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// Update GET base in Run</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> type_ordinal base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> offset = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset < <span class="Constant">0</span> || offset >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// copied from Check above</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> src = base_address<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < offset<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> src = base_address<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < offset<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End GET field Cases</span> src += size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">(</span>base<span class="Delimiter">,</span> i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -221,7 +229,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">const</span> reagent element_type<span class="Delimiter">(</span><span class="Normal">const</span> reagent& canonized_base<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset_value<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">const</span> reagent element_type<span class="Delimiter">(</span><span class="Normal">const</span> reagent& canonized_base<span class="Delimiter">,</span> <span class="Normal">int</span> offset_value<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>offset_value >= <span class="Constant">0</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>!get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> @@ -298,7 +306,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> GET_ADDRESS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'get-address' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'get-address' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -313,7 +321,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"second ingredient of 'get' should have type 'offset', but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// later layers permit non-integer offsets</span> offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset_value < <span class="Constant">0</span> || offset_value >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -340,16 +348,16 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> GET_ADDRESS: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// Update GET_ADDRESS base in Run</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> type_ordinal base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> offset = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset < <span class="Constant">0</span> || offset >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// copied from Check above</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = base_address<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < offset<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = base_address<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < offset<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End GET_ADDRESS field Cases</span> result += size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">(</span>base<span class="Delimiter">,</span> i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -382,8 +390,8 @@ def main [ <span class="Delimiter">:(scenario get_address_product_type_mismatch)</span> <span class="Special">% Hide_errors = true;</span> container boolbool [ - x:boolean - y:boolean + <span class="Normal">x</span>:boolean + <span class="Normal">y</span>:boolean ] def main [ <span class="Constant">12</span>:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span> @@ -397,34 +405,34 @@ def main [ <span class="Delimiter">:(scenarios load)</span> <span class="Delimiter">:(scenario container)</span> container foo [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] <span class="traceContains">+parse: --- defining container foo</span> -<span class="traceContains">+parse: element: x: "number"</span> -<span class="traceContains">+parse: element: y: "number"</span> +<span class="traceContains">+parse: element: {x: "number"}</span> +<span class="traceContains">+parse: element: {y: "number"}</span> <span class="Delimiter">:(scenario container_use_before_definition)</span> container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] <span class="traceContains">+parse: --- defining container foo</span> <span class="traceContains">+parse: type number: 1000</span> -<span class="traceContains">+parse: element: x: "number"</span> +<span class="traceContains">+parse: element: {x: "number"}</span> <span class="Comment"># todo: brittle</span> <span class="Comment"># type bar is unknown at this point, but we assign it a number</span> -<span class="traceContains">+parse: element: y: "bar"</span> +<span class="traceContains">+parse: element: {y: "bar"}</span> <span class="Comment"># later type bar geon</span> <span class="traceContains">+parse: --- defining container bar</span> <span class="traceContains">+parse: type number: 1001</span> -<span class="traceContains">+parse: element: x: "number"</span> -<span class="traceContains">+parse: element: y: "number"</span> +<span class="traceContains">+parse: element: {x: "number"}</span> +<span class="traceContains">+parse: element: {y: "number"}</span> <span class="Delimiter">:(before "End Command Handlers")</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>command == <span class="Constant">"container"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -444,7 +452,6 @@ container bar [ trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"type number: "</span> << get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> skip_bracket<span class="Delimiter">(</span>in<span class="Delimiter">,</span> <span class="Constant">"'container' must begin with '['"</span><span class="Delimiter">);</span> type_info& info = get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">));</span> - Recently_added_types<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">));</span> info<span class="Delimiter">.</span>name = name<span class="Delimiter">;</span> info<span class="Delimiter">.</span>kind = kind<span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -487,11 +494,11 @@ container bar [ <span class="Delimiter">:(scenarios run)</span> <span class="Delimiter">:(scenario container_define_twice)</span> container foo [ - x:number + <span class="Normal">x</span>:number ] container foo [ - y:number + <span class="Normal">y</span>:number ] def main [ @@ -503,40 +510,12 @@ def main [ <span class="traceContains">+mem: storing 34 in location 3</span> <span class="traceContains">+mem: storing 35 in location 4</span> -<span class="Comment">//: ensure types created in one scenario don't leak outside it.</span> -<span class="Delimiter">:(before "End Globals")</span> -vector<type_ordinal> Recently_added_types<span class="Delimiter">;</span> -<span class="Delimiter">:(before "End load_permanently")</span> <span class="Comment">//: for non-tests</span> -Recently_added_types<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> +<span class="Comment">//: ensure scenarios are consistent by always starting them at the same type</span> +<span class="Comment">//: number.</span> <span class="Delimiter">:(before "End Setup")</span> <span class="Comment">//: for tests</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - Type_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> - <span class="Comment">// todo: why do I explicitly need to provide this?</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>Type<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>elements<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> - Type<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>clear<span class="Delimiter">();</span> - Type<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span class="Delimiter">}</span> -Recently_added_types<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -<span class="Comment">// delete recent type references</span> -<span class="Comment">// can't rely on Recently_added_types to cleanup Type_ordinal, because of deliberately misbehaving tests with references to undefined types</span> -map<string<span class="Delimiter">,</span> type_ordinal>::iterator p = Type_ordinal<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> -<span class="Normal">while</span><span class="Delimiter">(</span>p != Type_ordinal<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> - <span class="Comment">// save current item</span> - string name = p<span class="Delimiter">-></span>first<span class="Delimiter">;</span> - type_ordinal t = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> - <span class="Comment">// increment iterator</span> - ++p<span class="Delimiter">;</span> - <span class="Comment">// now delete current item if necessary</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>t >= <span class="Constant">1000</span><span class="Delimiter">)</span> Type_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>name<span class="Delimiter">);</span> -<span class="Delimiter">}</span> -<span class="Comment">//: lastly, ensure scenarios are consistent by always starting them at the</span> -<span class="Comment">//: same type number.</span> Next_type_ordinal = <span class="Constant">1000</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Test Run Initialization")</span> assert<span class="Delimiter">(</span>Next_type_ordinal < <span class="Constant">1000</span><span class="Delimiter">);</span> -<span class="Delimiter">:(before "End Setup")</span> -Next_type_ordinal = <span class="Constant">1000</span><span class="Delimiter">;</span> <span class="SalientComment">//:: Allow container definitions anywhere in the codebase, but complain if you</span> <span class="SalientComment">//:: can't find a definition at the end.</span> @@ -555,7 +534,7 @@ def main [ ] container bar [ - x:number + <span class="Normal">x</span>:number ] $error: <span class="Constant">0</span> @@ -568,12 +547,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_or_set_invalid_types<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check for invalid types in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - check_or_set_invalid_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"'"</span>+to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - check_or_set_invalid_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"'"</span>+to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + check_or_set_invalid_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"'"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + check_or_set_invalid_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"'"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// End check_or_set_invalid_types</span> <span class="Delimiter">}</span> @@ -596,20 +575,20 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">:(scenario container_unknown_field)</span> <span class="Special">% Hide_errors = true;</span> container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] <span class="traceContains">+error: foo: unknown type in y</span> <span class="Delimiter">:(scenario read_container_with_bracket_in_comment)</span> container foo [ - x:number + <span class="Normal">x</span>:number <span class="Comment"># ']' in comment</span> - y:number + <span class="Normal">y</span>:number ] <span class="traceContains">+parse: --- defining container foo</span> -<span class="traceContains">+parse: element: x: "number"</span> -<span class="traceContains">+parse: element: y: "number"</span> +<span class="traceContains">+parse: element: {x: "number"}</span> +<span class="traceContains">+parse: element: {y: "number"}</span> <span class="Delimiter">:(before "End Transform All")</span> check_container_field_types<span class="Delimiter">();</span> @@ -619,7 +598,7 @@ check_container_field_types<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<type_ordinal<span class="Delimiter">,</span> type_info>::iterator p = Type<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_info& info = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> <span class="Comment">// Check Container Field Types(info)</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> check_invalid_types<span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>info<span class="Delimiter">.</span>name<span class="Delimiter">),</span> info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -640,8 +619,8 @@ check_container_field_types<span class="Delimiter">();</span> <span class="Delimiter">:(scenario merge)</span> container foo [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ @@ -662,8 +641,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> MERGE: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -732,8 +711,8 @@ def main [ <span class="Delimiter">:(before "End Types")</span> <span class="Normal">struct</span> merge_check_point <span class="Delimiter">{</span> reagent container<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> container_element_index<span class="Delimiter">;</span> - merge_check_point<span class="Delimiter">(</span><span class="Normal">const</span> reagent& c<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i<span class="Delimiter">)</span> :container<span class="Delimiter">(</span>c<span class="Delimiter">),</span> container_element_index<span class="Delimiter">(</span>i<span class="Delimiter">)</span> <span class="Delimiter">{}</span> + <span class="Normal">int</span> container_element_index<span class="Delimiter">;</span> + merge_check_point<span class="Delimiter">(</span><span class="Normal">const</span> reagent& c<span class="Delimiter">,</span> <span class="Normal">int</span> i<span class="Delimiter">)</span> :container<span class="Delimiter">(</span>c<span class="Delimiter">),</span> container_element_index<span class="Delimiter">(</span>i<span class="Delimiter">)</span> <span class="Delimiter">{}</span> <span class="Delimiter">};</span> <span class="Normal">struct</span> merge_check_state <span class="Delimiter">{</span> @@ -746,23 +725,23 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_merge_calls<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check merge instructions in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name != <span class="Constant">"merge"</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a single product in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a single product in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent product = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// Update product While Type-checking Merge</span> type_ordinal product_type = product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>product_type == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> product_type<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a container in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a container in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">const</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> product_type<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind != CONTAINER && info<span class="Delimiter">.</span>kind != EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a container in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'merge' should yield a container in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> check_merge_call<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">,</span> product<span class="Delimiter">,</span> caller<span class="Delimiter">,</span> inst<span class="Delimiter">);</span> @@ -770,14 +749,14 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Normal">void</span> check_merge_call<span class="Delimiter">(</span><span class="Normal">const</span> vector<reagent>& ingredients<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& product<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">,</span> <span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> ingredient_index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> ingredient_index = <span class="Constant">0</span><span class="Delimiter">;</span> merge_check_state state<span class="Delimiter">;</span> state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>push<span class="Delimiter">(</span>merge_check_point<span class="Delimiter">(</span>product<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << ingredient_index << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index >= SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent& container = state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>top<span class="Delimiter">().</span>container<span class="Delimiter">;</span> @@ -794,7 +773,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>pop<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too many ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too many ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ++state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>top<span class="Delimiter">().</span>container_element_index<span class="Delimiter">;</span> @@ -810,7 +789,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Comment">// End valid_merge Cases</span> <span class="Normal">default</span>: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>container<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"incorrect type of ingredient "</span> << ingredient_index << <span class="Constant">" in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"incorrect type of ingredient "</span> << ingredient_index << <span class="Constant">" in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> cerr << <span class="Constant">" expected "</span> << debug_string<span class="Delimiter">(</span>container<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> cerr << <span class="Constant">" got "</span> << debug_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -821,7 +800,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>pop<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too many ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too many ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ++state<span class="Delimiter">.</span>data<span class="Delimiter">.</span>top<span class="Delimiter">().</span>container_element_index<span class="Delimiter">;</span> @@ -846,3 +825,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/031address.cc.html b/html/031address.cc.html index abcd5945..12b53a7b 100644 --- a/html/031address.cc.html +++ b/html/031address.cc.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 031address.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.Identifier { color: #fcb165; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Instructions can read from addresses pointing at other locations using the</span> <span class="Comment">//: 'lookup' property.</span> @@ -38,7 +46,7 @@ def main [ ] <span class="traceContains">+mem: storing 34 in location 3</span> -<span class="Delimiter">:(before "long long int base = x.value" following "vector<double> read_memory(reagent x)")</span> +<span class="Delimiter">:(before "End Preprocess read_memory(x)")</span> canonize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Comment">//: similarly, write to addresses pointing at other locations using the</span> @@ -50,10 +58,10 @@ def main [ ] <span class="traceContains">+mem: storing 34 in location 2</span> -<span class="Delimiter">:(before "long long int base = x.value" following "void write_memory(reagent x, vector<double> data)")</span> +<span class="Delimiter">:(before "End Preprocess write_memory(x)")</span> canonize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << <span class="Constant">"can't write to location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">"can't write to location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -217,7 +225,7 @@ def main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">3</span>:number<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:number ] -<span class="traceContains">+parse: ingredient: 1: ("address" "number"), {"lookup": ()}</span> +<span class="traceContains">+parse: ingredient: {1: ("address" "number"), "lookup": ()}</span> <span class="traceContains">+mem: storing 34 in location 3</span> <span class="Delimiter">:(before "End Parsing reagent")</span> @@ -247,7 +255,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">//: grab an address, and then dump its value at intervals</span> <span class="Comment">//: useful for tracking down memory corruption (writing to an out-of-bounds address)</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> foo = -<span class="Constant">1</span><span class="Delimiter">;</span> +<span class="Normal">int</span> foo = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> _FOO<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> @@ -268,3 +276,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/032array.cc.html b/html/032array.cc.html index d7409028..b5ce1f19 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 032array.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Arrays contain a variable number of elements of the same type. Their value</span> <span class="Comment">//: starts with the length of the array.</span> <span class="Comment">//:</span> @@ -47,7 +55,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> CREATE_ARRAY: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'create-array' needs one product and no ingredients but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'create-array' needs one product and no ingredients but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent product = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -57,12 +65,12 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"create array of what? "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"create array of what? "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// 'create-array' will need to check properties rather than types</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"create array of what size? "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"create array of what size? "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_integer<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -75,14 +83,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> CREATE_ARRAY: <span class="Delimiter">{</span> reagent product = current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>product<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = product<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> array_size = to_integer<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name<span class="Delimiter">);</span> + <span class="Normal">int</span> base_address = product<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> array_size = to_integer<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name<span class="Delimiter">);</span> <span class="Comment">// initialize array size, so that size_of will work</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base_address<span class="Delimiter">,</span> array_size<span class="Delimiter">);</span> <span class="Comment">// in array elements</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>product<span class="Delimiter">);</span> <span class="Comment">// in locations</span> + <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>product<span class="Delimiter">);</span> <span class="Comment">// in locations</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"creating array of size "</span> << size << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Comment">// initialize array</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i <= size_of<span class="Delimiter">(</span>product<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i <= size_of<span class="Delimiter">(</span>product<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base_address+i<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// dummy product; doesn't actually do anything</span> @@ -147,14 +155,14 @@ def main [ <span class="Delimiter">:(scenario container_contains_array)</span> container foo [ - x:array:number:<span class="Constant">3</span> + <span class="Normal">x</span>:array:number:<span class="Constant">3</span> ] $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario container_disallows_dynamic_array_element)</span> <span class="Special">% Hide_errors = true;</span> container foo [ - x:array:number + <span class="Normal">x</span>:array:number ] <span class="traceContains">+error: container 'foo' cannot determine size of element x</span> @@ -203,7 +211,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> INDEX: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'index' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'index' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -227,10 +235,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> INDEX: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>base<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"base address is "</span> << base_address << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent offset = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -241,7 +249,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"invalid index "</span> << no_scientific<span class="Delimiter">(</span>offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> src = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + <span class="Normal">int</span> src = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"address to copy is "</span> << src << end<span class="Delimiter">();</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"its type is "</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> element_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> reagent tmp<span class="Delimiter">;</span> @@ -347,7 +355,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> INDEX_ADDRESS: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'index-address' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'index-address' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -372,9 +380,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> INDEX_ADDRESS: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>base<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent offset = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -385,7 +393,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"invalid index "</span> << no_scientific<span class="Delimiter">(</span>offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + <span class="Normal">int</span> result = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -455,7 +463,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> LENGTH: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'length' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'length' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent x = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -471,7 +479,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span reagent x = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -502,3 +510,4 @@ recipe_ordinal r = current_instruction<span class="Delimiter">().</span>operatio </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index ea287b64..9b8d00f0 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 033exclusive_container.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Exclusive containers contain exactly one of a fixed number of 'variants'</span> <span class="Comment">//: of different types.</span> <span class="Comment">//:</span> @@ -61,11 +69,11 @@ def main [ <span class="Normal">if</span> <span class="Delimiter">(</span>t<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// size of an exclusive container is the size of its largest variant</span> <span class="Comment">// (So like containers, it can't contain arrays.)</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < t<span class="Delimiter">.</span>size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < t<span class="Delimiter">.</span>size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent tmp<span class="Delimiter">;</span> tmp<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*type<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>variant_type<span class="Delimiter">(</span>tmp<span class="Delimiter">,</span> i<span class="Delimiter">));</span> + <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>variant_type<span class="Delimiter">(</span>tmp<span class="Delimiter">,</span> i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>size > result<span class="Delimiter">)</span> result = size<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// ...+1 for its tag.</span> @@ -108,7 +116,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> MAYBE_CONVERT: <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'maybe-convert' expects exactly 2 ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'maybe-convert' expects exactly 2 ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -127,7 +135,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span reagent& offset = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> populate_value<span class="Delimiter">(</span>offset<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset<span class="Delimiter">.</span>value >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid tag "</span> << offset<span class="Delimiter">.</span>value << <span class="Constant">" in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid tag "</span> << offset<span class="Delimiter">.</span>value << <span class="Constant">" in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent variant = variant_type<span class="Delimiter">(</span>base<span class="Delimiter">,</span> offset<span class="Delimiter">.</span>value<span class="Delimiter">);</span> @@ -142,14 +150,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> MAYBE_CONVERT: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>base<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> tag = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>tag == <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base_address<span class="Delimiter">)))</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> tag = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> result<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>tag == <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base_address<span class="Delimiter">)))</span> <span class="Delimiter">{</span> result = base_address+<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> @@ -161,7 +169,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">const</span> reagent variant_type<span class="Delimiter">(</span><span class="Normal">const</span> reagent& canonized_base<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> tag<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">const</span> reagent variant_type<span class="Delimiter">(</span><span class="Normal">const</span> reagent& canonized_base<span class="Delimiter">,</span> <span class="Normal">int</span> tag<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>tag >= <span class="Constant">0</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>!get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> @@ -186,12 +194,12 @@ def main [ <span class="Delimiter">:(scenario exclusive_container)</span> exclusive-container foo [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] <span class="traceContains">+parse: --- defining exclusive-container foo</span> -<span class="traceContains">+parse: element: x: "number"</span> -<span class="traceContains">+parse: element: y: "number"</span> +<span class="traceContains">+parse: element: {x: "number"}</span> +<span class="traceContains">+parse: element: {y: "number"}</span> <span class="Delimiter">:(before "End Command Handlers")</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>command == <span class="Constant">"exclusive-container"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -203,22 +211,22 @@ exclusive-container foo [ <span class="Delimiter">:(scenario exclusive_container_contains_array)</span> exclusive-container foo [ - x:array:number:<span class="Constant">3</span> + <span class="Normal">x</span>:array:number:<span class="Constant">3</span> ] $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario exclusive_container_disallows_dynamic_array_element)</span> <span class="Special">% Hide_errors = true;</span> exclusive-container foo [ - x:array:number + <span class="Normal">x</span>:array:number ] <span class="traceContains">+error: container 'foo' cannot determine size of element x</span> <span class="SalientComment">//:: To construct exclusive containers out of variant types, use 'merge'.</span> <span class="Delimiter">:(scenario lift_to_exclusive_container)</span> exclusive-container foo [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ @@ -235,11 +243,11 @@ def main [ <span class="Delimiter">:(scenario merge_handles_exclusive_container)</span> exclusive-container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - z:number + <span class="Normal">z</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">34</span> @@ -251,11 +259,11 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_requires_literal_tag_for_exclusive_container)</span> <span class="Special">% Hide_errors = true;</span> exclusive-container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - z:number + <span class="Normal">z</span>:number ] def main [ local-scope @@ -275,7 +283,7 @@ def main [ reagent ingredient = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">);</span> <span class="Comment">// unnecessary copy just to keep this function from modifying caller</span> populate_value<span class="Delimiter">(</span>ingredient<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient<span class="Delimiter">.</span>value >= SIZE<span class="Delimiter">(</span>container_info<span class="Delimiter">.</span>elements<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid tag at "</span> << ingredient_index << <span class="Constant">" for "</span> << container_info<span class="Delimiter">.</span>name << <span class="Constant">" in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid tag at "</span> << ingredient_index << <span class="Constant">" for "</span> << container_info<span class="Delimiter">.</span>name << <span class="Constant">" in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent variant = variant_type<span class="Delimiter">(</span>container<span class="Delimiter">,</span> ingredient<span class="Delimiter">.</span>value<span class="Delimiter">);</span> @@ -289,12 +297,12 @@ def main [ <span class="Delimiter">:(scenario merge_check_container_containing_exclusive_container)</span> container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] exclusive-container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">34</span> @@ -307,12 +315,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_container_containing_exclusive_container_2)</span> <span class="Special">% Hide_errors = true;</span> container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] exclusive-container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> @@ -321,12 +329,12 @@ def main [ <span class="Delimiter">:(scenario merge_check_exclusive_container_containing_container)</span> exclusive-container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">34</span> @@ -338,12 +346,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_exclusive_container_containing_container_2)</span> exclusive-container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">23</span> @@ -353,12 +361,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_exclusive_container_containing_container_3)</span> <span class="Special">% Hide_errors = true;</span> exclusive-container foo [ - x:number - y:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:bar ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">23</span> @@ -368,25 +376,25 @@ def main [ <span class="Comment">//: Since the different variants of an exclusive-container might have</span> <span class="Comment">//: different sizes, relax the size mismatch check for 'merge' instructions.</span> <span class="Delimiter">:(before "End size_mismatch(x) Cases")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation == MERGE +<span class="Normal">if</span> <span class="Delimiter">(</span>current_step_index<span class="Delimiter">()</span> < SIZE<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>steps<span class="Delimiter">())</span> + && current_instruction<span class="Delimiter">().</span>operation == MERGE && !current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent x = current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Identifier">return</span> size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> - <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario merge_exclusive_container_with_mismatched_sizes)</span> container foo [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] exclusive-container bar [ - x:number - y:foo + <span class="Normal">x</span>:number + <span class="Normal">y</span>:foo ] def main [ @@ -404,3 +412,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/034call.cc.html b/html/034call.cc.html index bf98e18e..17a302a6 100644 --- a/html/034call.cc.html +++ b/html/034call.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 034call.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: So far the recipes we define can't run each other. Let's fix that.</span> <span class="Delimiter">:(scenario calling_recipe)</span> @@ -49,12 +57,12 @@ def f [ ] <span class="traceContains">+run: f</span> <span class="Comment"># running f</span> -<span class="traceContains">+run: 4:number <- copy 0</span> -<span class="traceContains">+run: 5:number <- copy 0</span> +<span class="traceContains">+run: {4: "number"} <- copy {0: "literal"}</span> +<span class="traceContains">+run: {5: "number"} <- copy {0: "literal"}</span> <span class="Comment"># back out to main</span> -<span class="traceContains">+run: 1:number <- copy 0</span> -<span class="traceContains">+run: 2:number <- copy 0</span> -<span class="traceContains">+run: 3:number <- copy 0</span> +<span class="traceContains">+run: {1: "number"} <- copy {0: "literal"}</span> +<span class="traceContains">+run: {2: "number"} <- copy {0: "literal"}</span> +<span class="traceContains">+run: {3: "number"} <- copy {0: "literal"}</span> <span class="Delimiter">:(before "struct routine {")</span> <span class="Comment">// Everytime a recipe runs another, we interrupt it and start running the new</span> @@ -62,7 +70,7 @@ def f [ <span class="Comment">// This requires maintaining a 'stack' of interrupted recipes or 'calls'.</span> <span class="Normal">struct</span> call <span class="Delimiter">{</span> recipe_ordinal running_recipe<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> running_step_index<span class="Delimiter">;</span> + <span class="Normal">int</span> running_step_index<span class="Delimiter">;</span> <span class="Comment">// End call Fields</span> call<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> running_recipe = r<span class="Delimiter">;</span> @@ -101,8 +109,8 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="SalientComment">//:: now update routine's helpers</span> -<span class="Delimiter">:(replace{} "inline long long int& current_step_index()")</span> -<span class="Normal">inline</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Delimiter">:(replace{} "inline int& current_step_index()")</span> +<span class="Normal">inline</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> current_call<span class="Delimiter">().</span>running_step_index<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -124,7 +132,7 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="Delimiter">:(after "Defined Recipe Checks")</span> <span class="Comment">// not a primitive; check that it's present in the book of recipes</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"undefined operation in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"undefined operation in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(replace{} "default:" following "End Primitive Recipe Implementations")</span> @@ -160,7 +168,7 @@ def main [ <span class="Delimiter">:(scenario calling_undefined_recipe_handles_missing_result)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number<span class="Special"> <- </span>foo + <span class="Normal">x</span>:number<span class="Special"> <- </span>foo ] <span class="traceContains">+error: main: undefined operation in 'x:number <- foo '</span> @@ -171,6 +179,7 @@ def main [ <span class="Identifier">return</span> calls<span class="Delimiter">.</span>empty<span class="Delimiter">();</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(replace{} "inline const vector<instruction>& routine::steps() const")</span> <span class="Normal">inline</span> <span class="Normal">const</span> vector<instruction>& routine::steps<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> @@ -195,3 +204,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/035call_ingredient.cc.html b/html/035call_ingredient.cc.html index 6e2aa88a..d9f7cee3 100644 --- a/html/035call_ingredient.cc.html +++ b/html/035call_ingredient.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 035call_ingredient.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Calls can take ingredients just like primitives. To access a recipe's</span> <span class="Comment">//: ingredients, use 'next-ingredient'.</span> @@ -49,12 +57,12 @@ def f [ <span class="Delimiter">:(before "End call Fields")</span> vector<vector<<span class="Normal">double</span>> > ingredient_atoms<span class="Delimiter">;</span> vector<reagent> ingredients<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> next_ingredient_to_process<span class="Delimiter">;</span> +<span class="Normal">int</span> next_ingredient_to_process<span class="Delimiter">;</span> <span class="Delimiter">:(before "End call Constructor")</span> next_ingredient_to_process = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Call Housekeeping")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> reagent ingredient = call_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>ingredient<span class="Delimiter">);</span> @@ -68,7 +76,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> NEXT_INGREDIENT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'next-ingredient' didn't expect any ingredients in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'next-ingredient' didn't expect any ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -102,8 +110,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">if</span> <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// pad the first product with sufficient zeros to match its type</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -167,7 +175,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> INGREDIENT: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'ingredient' expects exactly one ingredient, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'ingredient' expects exactly one ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && !is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -178,7 +186,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> INGREDIENT: <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> < SIZE<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> < SIZE<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">))</span> <span class="Delimiter">{</span> current_call<span class="Delimiter">().</span>next_ingredient_to_process = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span> current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>at<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>next_ingredient_to_process<span class="Delimiter">));</span> @@ -198,3 +206,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/036call_reply.cc.html b/html/036call_reply.cc.html index 2160c6b7..4302e313 100644 --- a/html/036call_reply.cc.html +++ b/html/036call_reply.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 036call_reply.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Calls can also generate products, using 'reply' or 'return'.</span> <span class="Delimiter">:(scenario reply)</span> @@ -62,7 +70,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// just in case 'main' returns a value, drop it for now</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">goto</span> stop_running_current_routine<span class="Delimiter">;</span> <span class="Normal">const</span> instruction& caller_instruction = current_instruction<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result "</span> << i << <span class="Constant">" is "</span> << to_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Comment">// make reply products available to caller</span> @@ -93,13 +101,13 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_types_of_reply_instructions<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check types of reply instructions in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& caller_instruction = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>operation < MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> caller_instruction<span class="Delimiter">.</span>operation<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& reply_inst = callee<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>operation != REPLY<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// check types with the caller</span> @@ -107,7 +115,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few values replied from "</span> << callee<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent lhs = reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>lhs<span class="Delimiter">);</span> reagent rhs = caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> @@ -120,20 +128,20 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Comment">// check that any reply ingredients with /same-as-ingredient connect up</span> <span class="Comment">// the corresponding ingredient and product in the caller.</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same-as-ingredient"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> string_tree* tmp = property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same-as-ingredient"</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!tmp || tmp<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'same-as-ingredient' metadata should take exactly one value in "</span> << to_string<span class="Delimiter">(</span>reply_inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'same-as-ingredient' metadata should take exactly one value in "</span> << to_original_string<span class="Delimiter">(</span>reply_inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> ingredient_index = to_integer<span class="Delimiter">(</span>tmp<span class="Delimiter">-></span>value<span class="Delimiter">);</span> + <span class="Normal">int</span> ingredient_index = to_integer<span class="Delimiter">(</span>tmp<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index >= SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few ingredients in '"</span> << to_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few ingredients in '"</span> << to_original_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_dummy<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> && !is_literal<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">))</span> && caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name != caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> << <span class="Constant">"' should write to "</span> << caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>original_string << <span class="Constant">" rather than "</span> << caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << to_original_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> << <span class="Constant">"' should write to "</span> << caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>original_string << <span class="Constant">" rather than "</span> << caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -192,7 +200,7 @@ string to_string<span class="Delimiter">(</span><span class="Normal">const</span <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> out << <span class="Constant">"["</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> out << no_scientific<span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -272,3 +280,4 @@ def test1 [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/037new.cc.html b/html/037new.cc.html index 4f181562..c932c8af 100644 --- a/html/037new.cc.html +++ b/html/037new.cc.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 037new.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.CommentedCode { color: #6c6c6c; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Creating space for new variables at runtime.</span> <span class="Comment">//: Mu has two primitives for managing allocations:</span> @@ -83,13 +91,14 @@ def main [ <span class="traceContains">+mem: storing 0 in location 3</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Memory_allocated_until = Reserved_for_tests<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Initial_memory_per_routine = <span class="Constant">100000</span><span class="Delimiter">;</span> +<span class="Normal">const</span> <span class="Normal">int</span> Reserved_for_tests = <span class="Constant">1000</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Memory_allocated_until = Reserved_for_tests<span class="Delimiter">;</span> +<span class="Normal">int</span> Initial_memory_per_routine = <span class="Constant">100000</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Memory_allocated_until = Reserved_for_tests<span class="Delimiter">;</span> Initial_memory_per_routine = <span class="Constant">100000</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> alloc<span class="Delimiter">,</span> alloc_max<span class="Delimiter">;</span> +<span class="Normal">int</span> alloc<span class="Delimiter">,</span> alloc_max<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> alloc = Memory_allocated_until<span class="Delimiter">;</span> Memory_allocated_until += Initial_memory_per_routine<span class="Delimiter">;</span> @@ -109,7 +118,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> NEW: <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> || SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'new' requires one or two ingredients, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'new' requires one or two ingredients, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// End NEW Check Special-cases</span> @@ -123,7 +132,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!product_of_new_is_valid<span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product of 'new' has incorrect type: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product of 'new' has incorrect type: "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -153,7 +162,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">:(code)</span> <span class="Normal">void</span> transform_new_to_allocate<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- convert 'new' to 'allocate' for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Comment">// Convert 'new' To 'allocate'</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"new"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -178,7 +187,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> ALLOCATE: <span class="Delimiter">{</span> <span class="Comment">// compute the space we need</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> size = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// array</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"array size is "</span> << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> @@ -192,13 +201,13 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// compute the region of memory to return</span> <span class="Comment">// really crappy at the moment</span> ensure_space<span class="Delimiter">(</span>size<span class="Delimiter">);</span> - <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Normal">const</span> <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"new alloc: "</span> << result << end<span class="Delimiter">();</span> <span class="Comment">// save result</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Comment">// initialize allocated space</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address = result<span class="Delimiter">;</span> address < result+size<span class="Delimiter">;</span> ++address<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> address = result<span class="Delimiter">;</span> address < result+size<span class="Delimiter">;</span> ++address<span class="Delimiter">)</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// initialize array length</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -227,10 +236,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="CommentedCode">//? :(before "End Globals")</span> -<span class="CommentedCode">//? long long int Total_alloc = 0;</span> -<span class="CommentedCode">//? long long int Num_alloc = 0;</span> -<span class="CommentedCode">//? long long int Total_free = 0;</span> -<span class="CommentedCode">//? long long int Num_free = 0;</span> +<span class="CommentedCode">//? int Total_alloc = 0;</span> +<span class="CommentedCode">//? int Num_alloc = 0;</span> +<span class="CommentedCode">//? int Total_free = 0;</span> +<span class="CommentedCode">//? int Num_free = 0;</span> <span class="CommentedCode">//? :(before "End Setup")</span> <span class="CommentedCode">//? Total_alloc = Num_alloc = Total_free = Num_free = 0;</span> <span class="CommentedCode">//? :(before "End Teardown")</span> @@ -239,7 +248,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="CommentedCode">//? cerr << SIZE(Memory) << '\n';</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> ensure_space<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> ensure_space<span class="Delimiter">(</span><span class="Normal">int</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>size > Initial_memory_per_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> tb_shutdown<span class="Delimiter">();</span> cerr << <span class="Constant">"can't allocate "</span> << size << <span class="Constant">" locations, that's too much compared to "</span> << Initial_memory_per_routine << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> @@ -276,7 +285,7 @@ def main [ <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span><span class="Normal">new</span> number:type <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw</span> ] -<span class="traceContains">+run: 1:address:shared:array:number/raw <- new number:type, 5</span> +<span class="traceContains">+run: {1: ("address" "shared" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"}</span> <span class="traceContains">+mem: array size is 5</span> <span class="Comment"># don't forget the extra location for array size, and the second extra location for the refcount</span> <span class="traceContains">+mem: storing 7 in location 3</span> @@ -287,7 +296,7 @@ def main [ <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span><span class="Normal">new</span> number:type <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw</span> ] -<span class="traceContains">+run: 1:address:shared:array:number/raw <- new number:type, 0</span> +<span class="traceContains">+run: {1: ("address" "shared" "array" "number"), "raw": ()} <- new {number: "type"}, {0: "literal"}</span> <span class="traceContains">+mem: array size is 0</span> <span class="Comment"># one location for array size, and one for the refcount</span> <span class="traceContains">+mem: storing 2 in location 3</span> @@ -316,10 +325,8 @@ def main [ <span class="Comment"># both allocations should have returned the same address</span> <span class="traceContains">+mem: storing 1 in location 4</span> -<span class="Delimiter">:(before "End Globals")</span> -map<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Free_list<span class="Delimiter">;</span> -<span class="Delimiter">:(before "End Setup")</span> -Free_list<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> +<span class="Delimiter">:(before "End routine Fields")</span> +map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">int</span>> free_list<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> ABANDON<span class="Delimiter">,</span> @@ -328,7 +335,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> ABANDON: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'abandon' requires one ingredient, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'abandon' requires one ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent types = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -341,14 +348,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> ABANDON: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> address = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"address to abandon is "</span> << address << end<span class="Delimiter">();</span> reagent types = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"value of ingredient is "</span> << types<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> canonize<span class="Delimiter">(</span>types<span class="Delimiter">);</span> <span class="Comment">// lookup_memory without drop_one_lookup {</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"value of ingredient after canonization is "</span> << types<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address_location = types<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> address_location = types<span class="Delimiter">.</span>value<span class="Delimiter">;</span> types<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> types<span class="Delimiter">.</span>value<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> drop_from_type<span class="Delimiter">(</span>types<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> drop_from_type<span class="Delimiter">(</span>types<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> @@ -361,25 +368,26 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> abandon<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> abandon<span class="Delimiter">(</span><span class="Normal">int</span> address<span class="Delimiter">,</span> <span class="Normal">int</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"saving in free-list of size "</span> << size << end<span class="Delimiter">();</span> <span class="CommentedCode">//? Total_free += size;</span> <span class="CommentedCode">//? Num_free++;</span> <span class="CommentedCode">//? cerr << "abandon: " << size << '\n';</span> <span class="Comment">// clear memory</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = address<span class="Delimiter">;</span> curr < address+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> curr = address<span class="Delimiter">;</span> curr < address+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// append existing free list to address</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Free_list<span class="Delimiter">,</span> size<span class="Delimiter">));</span> - put<span class="Delimiter">(</span>Free_list<span class="Delimiter">,</span> size<span class="Delimiter">,</span> address<span class="Delimiter">);</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>free_list<span class="Delimiter">,</span> size<span class="Delimiter">));</span> + put<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>free_list<span class="Delimiter">,</span> size<span class="Delimiter">,</span> address<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "ensure_space(size)" following "case ALLOCATE")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Free_list<span class="Delimiter">,</span> size<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>free_list<span class="Delimiter">,</span> size<span class="Delimiter">))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"picking up space from free-list of size "</span> << size << end<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = get_or_insert<span class="Delimiter">(</span>Free_list<span class="Delimiter">,</span> size<span class="Delimiter">);</span> - put<span class="Delimiter">(</span>Free_list<span class="Delimiter">,</span> size<span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = result+<span class="Constant">1</span><span class="Delimiter">;</span> curr < result+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = get_or_insert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>free_list<span class="Delimiter">,</span> size<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"new alloc from free list: "</span> << result << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>free_list<span class="Delimiter">,</span> size<span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">));</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> curr = result+<span class="Constant">1</span><span class="Delimiter">;</span> curr < result+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"memory in free list was not zeroed out: "</span> << curr << <span class="Constant">'/'</span> << result << <span class="Constant">"; somebody wrote to us after free!!!</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// always fatal</span> @@ -422,7 +430,7 @@ def main [ abandon <span class="Constant">1</span>:address:shared:number ] <span class="Comment"># reuse</span> -<span class="traceContains">+run: abandon 1:address:shared:number</span> +<span class="traceContains">+run: abandon {1: ("address" "shared" "number")}</span> <span class="traceContains">+mem: resetting location 1</span> <span class="SalientComment">//:: Manage refcounts when copying addresses.</span> @@ -434,54 +442,55 @@ def main [ <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+run: 1:address:shared:number <- copy 1000/unsafe</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- copy {1000: "literal", "unsafe": ()}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> -<span class="traceContains">+run: 2:address:shared:number <- copy 1:address:shared:number</span> +<span class="traceContains">+run: {2: ("address" "shared" "number")} <- copy {1: ("address" "shared" "number")}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> -<span class="traceContains">+run: 1:address:shared:number <- copy 0</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- copy {0: "literal"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> -<span class="traceContains">+run: 2:address:shared:number <- copy 0</span> +<span class="traceContains">+run: {2: ("address" "shared" "number")} <- copy {0: "literal"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 1 -> 0</span> <span class="Comment"># the /unsafe corrupts memory but fortunately we won't be running any more 'new' in this scenario</span> <span class="traceContains">+mem: automatically abandoning 1000</span> -<span class="Delimiter">:(before "End write_memory(reagent x, long long int base) Special-cases")</span> +<span class="Delimiter">:(before "End write_memory(reagent x) Special-cases")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// compute old address of x, as well as new address we want to write in</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> old_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">);</span> + <span class="Normal">int</span> old_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>data<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> new_address = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> new_address = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// decrement refcount of old address</span> <span class="Normal">if</span> <span class="Delimiter">(</span>old_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> old_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">);</span> + <span class="Normal">int</span> old_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"decrementing refcount of "</span> << old_address << <span class="Constant">": "</span> << old_refcount << <span class="Constant">" -> "</span> << <span class="Delimiter">(</span>old_refcount-<span class="Constant">1</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">,</span> old_refcount-<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// perform the write</span> - trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << base << end<span class="Delimiter">();</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << x<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> <span class="Comment">// increment refcount of new address</span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> new_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> + <span class="Normal">int</span> new_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>new_refcount >= <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// == 0 only when new_address == old_address</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"incrementing refcount of "</span> << new_address << <span class="Constant">": "</span> << new_refcount << <span class="Constant">" -> "</span> << <span class="Delimiter">(</span>new_refcount+<span class="Constant">1</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> new_address<span class="Delimiter">,</span> new_refcount+<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// abandon old address if necessary</span> <span class="Comment">// do this after all refcount updates are done just in case old and new are identical</span> + assert<span class="Delimiter">(</span>old_address >= <span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>old_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">)</span> >= <span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>old_address && get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// lookup_memory without drop_one_lookup {</span> - trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"automatically abandoning "</span> << old_address << end<span class="Delimiter">();</span> - trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"computing size to abandon at "</span> << x<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> - x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> - drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> - drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> - <span class="Comment">// }</span> - abandon<span class="Delimiter">(</span>old_address<span class="Delimiter">,</span> size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> - <span class="Delimiter">}</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">)</span> > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Comment">// lookup_memory without drop_one_lookup {</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"automatically abandoning "</span> << old_address << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"computing size to abandon at "</span> << x<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> + x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>old_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> + <span class="Comment">// }</span> + abandon<span class="Delimiter">(</span>old_address<span class="Delimiter">,</span> size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -492,9 +501,9 @@ def main [ <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: automatically abandoning 1000</span> <span class="Delimiter">:(scenario refcounts_3)</span> @@ -509,13 +518,13 @@ def foo [ <span class="Comment"># return does NOT yet decrement refcount; memory must be explicitly managed</span> <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> -<span class="traceContains">+run: 2:address:shared:number <- next-ingredient</span> +<span class="traceContains">+run: {2: ("address" "shared" "number")} <- next-ingredient</span> <span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> -<span class="traceContains">+run: 2:address:shared:number <- copy 0</span> +<span class="traceContains">+run: {2: ("address" "shared" "number")} <- copy {0: "literal"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> -<span class="traceContains">+run: 1:address:shared:number <- copy 0</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- copy {0: "literal"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 1 -> 0</span> <span class="traceContains">+mem: automatically abandoning 1000</span> @@ -525,9 +534,9 @@ def main [ <span class="Comment"># idempotent copies leave refcount unchanged</span> <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:number ] -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> -<span class="traceContains">+run: 1:address:shared:number <- copy 1:address:shared:number</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- copy {1: ("address" "shared" "number")}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 1 -> 0</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> @@ -542,13 +551,26 @@ def main [ def foo [ <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>next-ingredient ] -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> -<span class="traceContains">+run: 2:address:shared:number <- next-ingredient</span> +<span class="traceContains">+run: {2: ("address" "shared" "number")} <- next-ingredient</span> <span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> -<span class="traceContains">+run: 1:address:shared:number <- new number:type</span> +<span class="traceContains">+run: {1: ("address" "shared" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> +<span class="Delimiter">:(scenario refcounts_array)</span> +def main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">30</span> + <span class="Comment"># allocate an array</span> + <span class="Constant">10</span>:address:shared:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">20</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">10</span>:address:shared:array:number + <span class="Comment"># allocate another array in its place, implicitly freeing the previous allocation</span> + <span class="Constant">10</span>:address:shared:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">25</span> +] +<span class="traceContains">+run: {10: ("address" "shared" "array" "number")} <- new {number: "type"}, {20: "literal"}</span> +<span class="Comment"># abandoned array is of old size (20, not 25)</span> +<span class="traceContains">+abandon: saving in free-list of size 22</span> + <span class="SalientComment">//:: Extend 'new' to handle a unicode string literal argument.</span> <span class="Delimiter">:(scenario new_string)</span> @@ -577,25 +599,26 @@ def main [ <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">));</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"new string alloc: "</span> << products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> new_mu_string<span class="Delimiter">(</span><span class="Normal">const</span> string& contents<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> new_mu_string<span class="Delimiter">(</span><span class="Normal">const</span> string& contents<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// allocate an array just large enough for it</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> string_length = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span> + <span class="Normal">int</span> string_length = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span> <span class="CommentedCode">//? Total_alloc += string_length+1;</span> <span class="CommentedCode">//? Num_alloc++;</span> ensure_space<span class="Delimiter">(</span>string_length+<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// don't forget the extra location for array size</span> <span class="Comment">// initialize string</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> <span class="Comment">// initialize refcount</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc++<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// store length</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc++<span class="Delimiter">,</span> string_length<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">const</span> <span class="Normal">char</span>* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < string_length<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < string_length<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">uint32_t</span> curr_character<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>curr < SIZE<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> tb_utf8_char_to_unicode<span class="Delimiter">(</span>&curr_character<span class="Delimiter">,</span> &raw_contents[curr]<span class="Delimiter">);</span> @@ -648,10 +671,10 @@ def main [ <span class="Comment">//: helpers</span> <span class="Delimiter">:(code)</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> unicode_length<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> unicode_length<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> <span class="Normal">char</span>* in = s<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// carefully bounds-check on the string</span> <span class="Comment">// before accessing its raw pointer</span> ++result<span class="Delimiter">;</span> @@ -660,13 +683,13 @@ def main [ <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -string read_mu_string<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +string read_mu_string<span class="Delimiter">(</span><span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> address++<span class="Delimiter">;</span> <span class="Comment">// skip refcount</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">);</span> + <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>size == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> ostringstream tmp<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = address+<span class="Constant">1</span><span class="Delimiter">;</span> curr <= address+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> curr = address+<span class="Constant">1</span><span class="Delimiter">;</span> curr <= address+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> tmp << to_unicode<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)));</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> tmp<span class="Delimiter">.</span>str<span class="Delimiter">();</span> @@ -678,3 +701,4 @@ string read_mu_string<span class="Delimiter">(</span><span class="Normal">long</ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/038location_array.cc.html b/html/038location_array.cc.html index a1b0c5ee..9e77007e 100644 --- a/html/038location_array.cc.html +++ b/html/038location_array.cc.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 038location_array.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Comment { color: #9090ff; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } +.cSpecial { color: #008000; } .Delimiter { color: #800080; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Comment { color: #9090ff; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> TO_LOCATION_ARRAY<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> @@ -30,7 +38,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> TO_LOCATION_ARRAY: <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_shared_address_of_array_of_numbers<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product of 'to-location-array' has incorrect type: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product of 'to-location-array' has incorrect type: "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -49,10 +57,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> TO_LOCATION_ARRAY: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> array_size = SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> allocation_size = array_size + <span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">int</span> array_size = SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">int</span> allocation_size = array_size + <span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> ensure_space<span class="Delimiter">(</span>allocation_size<span class="Delimiter">);</span> - <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Normal">const</span> <span class="Normal">int</span> result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Comment">// initialize array refcount</span> @@ -60,10 +68,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// initialize array length</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result+<span class="Constant">1</span><span class="Delimiter">,</span> array_size<span class="Delimiter">);</span> <span class="Comment">// now copy over data</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < array_size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < array_size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result+<span class="Constant">2</span>+i<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/040brace.cc.html b/html/040brace.cc.html index a56b2e8d..6077150d 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 040brace.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #800080; } .Special { color: #c00000; } -.Constant { color: #00a0a0; } .Identifier { color: #fcb165; } -.Delimiter { color: #800080; } -.Comment { color: #9090ff; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Structured programming</span> <span class="Comment">//:</span> <span class="Comment">//: Our jump recipes are quite inconvenient to use, so mu provides a</span> @@ -65,22 +73,22 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> transform_braces<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> <span class="Normal">int</span> OPEN = <span class="Constant">0</span><span class="Delimiter">,</span> CLOSE = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// use signed integer for step index because we'll be doing arithmetic on it</span> - list<pair<<span class="Normal">int</span><span class="Comment">/*</span><span class="Comment">OPEN/CLOSE</span><span class="Comment">*/</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">step</span><span class="Comment">*/</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> > braces<span class="Delimiter">;</span> + list<pair<<span class="Normal">int</span><span class="Comment">/*</span><span class="Comment">OPEN/CLOSE</span><span class="Comment">*/</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">step</span><span class="Comment">*/</span><span class="Normal">int</span>> > braces<span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- transform braces for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="CommentedCode">//? cerr << "--- transform braces for recipe " << get(Recipe, r).name << '\n';</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label == <span class="Constant">"{"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"push (open, "</span> << index << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> - braces<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<<span class="Normal">int</span><span class="Delimiter">,</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>OPEN<span class="Delimiter">,</span> index<span class="Delimiter">));</span> + braces<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<<span class="Normal">int</span><span class="Delimiter">,</span><span class="Normal">int</span>><span class="Delimiter">(</span>OPEN<span class="Delimiter">,</span> index<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label == <span class="Constant">"}"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"push (close, "</span> << index << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> - braces<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<<span class="Normal">int</span><span class="Delimiter">,</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>CLOSE<span class="Delimiter">,</span> index<span class="Delimiter">));</span> + braces<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<<span class="Normal">int</span><span class="Delimiter">,</span><span class="Normal">int</span>><span class="Delimiter">(</span>CLOSE<span class="Delimiter">,</span> index<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - stack<<span class="Comment">/*</span><span class="Comment">step</span><span class="Comment">*/</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> open_braces<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + stack<<span class="Comment">/*</span><span class="Comment">step</span><span class="Comment">*/</span><span class="Normal">int</span>> open_braces<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label == <span class="Constant">"{"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> open_braces<span class="Delimiter">.</span>push<span class="Delimiter">(</span>index<span class="Delimiter">);</span> @@ -160,9 +168,9 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Comment">// returns a signed integer not just so that we can return -1 but also to</span> <span class="Comment">// enable future signed arithmetic</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> matching_brace<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index<span class="Delimiter">,</span> <span class="Normal">const</span> list<pair<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> >& braces<span class="Delimiter">,</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> matching_brace<span class="Delimiter">(</span><span class="Normal">int</span> index<span class="Delimiter">,</span> <span class="Normal">const</span> list<pair<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">int</span>> >& braces<span class="Delimiter">,</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">int</span> stacksize = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>list<pair<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> >::const_iterator p = braces<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != braces<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>list<pair<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">int</span>> >::const_iterator p = braces<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != braces<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>second < index<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> stacksize += <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first ? <span class="Constant">1</span> : -<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>stacksize == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> @@ -416,3 +424,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/041jump_target.cc.html b/html/041jump_target.cc.html index 6fb67d0a..ced08c8d 100644 --- a/html/041jump_target.cc.html +++ b/html/041jump_target.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 041jump_target.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.traceAbsent { color: #c00000; } -.Special { color: #c00000; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.traceAbsent { color: #c00000; } +.cSpecial { color: #008000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Support jumps to special labels called 'targets'. Targets must be in the</span> <span class="Comment">//: same recipe as the jump, and must be unique in that recipe. Targets always</span> <span class="Comment">//: start with a '+'.</span> @@ -50,8 +58,8 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">:(code)</span> <span class="Normal">void</span> transform_labels<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> offset<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> offset<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>label<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && inst<span class="Delimiter">.</span>label<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'+'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>offset<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -64,7 +72,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"jump"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> @@ -93,7 +101,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> replace_offset<span class="Delimiter">(</span>reagent& x<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">const</span><span class="Comment">*/</span> map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& offset<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> current_offset<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> replace_offset<span class="Delimiter">(</span>reagent& x<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">const</span><span class="Comment">*/</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>& offset<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">int</span> current_offset<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"jump target must be offset or label but is "</span> << x<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// no jump by default</span> @@ -208,3 +216,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/042name.cc.html b/html/042name.cc.html index a8ff796e..67b00f78 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -3,37 +3,45 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 042name.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.CommentedCode { color: #6c6c6c; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Constant { color: #00a0a0; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.CommentedCode { color: #6c6c6c; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Identifier { color: #fcb165; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: A big convenience high-level languages provide is the ability to name memory</span> <span class="Comment">//: locations. In mu, a transform called 'transform_names' provides this</span> <span class="Comment">//: convenience.</span> <span class="Delimiter">:(scenario transform_names)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+name: assign x 1</span> <span class="traceContains">+mem: storing 0 in location 1</span> @@ -42,7 +50,7 @@ def main [ <span class="Delimiter">:(scenario transform_names_fails_on_use_before_define)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number<span class="Special"> <- </span>copy y:number + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy y:number ] <span class="traceContains">+error: main: use before set: y</span> <span class="Comment"># todo: detect conditional defines</span> @@ -51,11 +59,16 @@ def main [ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>transform_names<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(before "End Globals")</span> -map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> > Name<span class="Delimiter">;</span> -<span class="Delimiter">:(after "Clear Other State For Recently_added_recipes")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - Name<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span class="Delimiter">}</span> +map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> > Name<span class="Delimiter">;</span> + +<span class="Comment">//: the Name map is a global, so save it before tests and reset it for every</span> +<span class="Comment">//: test, just to be safe.</span> +<span class="Delimiter">:(before "End Globals")</span> +map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> > Name_snapshot<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End save_snapshots")</span> +Name_snapshot = Name<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End restore_snapshots")</span> +Name = Name_snapshot<span class="Delimiter">;</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> transform_names<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -64,15 +77,15 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" <span class="CommentedCode">//? cerr << "--- transform names for recipe " << caller.name << '\n';</span> <span class="Normal">bool</span> names_used = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">bool</span> numeric_locations_used = <span class="Constant">false</span><span class="Delimiter">;</span> - map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& names = Name[r]<span class="Delimiter">;</span> + map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>& names = Name[r]<span class="Delimiter">;</span> <span class="Comment">// store the indices 'used' so far in the map</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>& curr_idx = names[<span class="Constant">""</span>]<span class="Delimiter">;</span> + <span class="Normal">int</span>& curr_idx = names[<span class="Constant">""</span>]<span class="Delimiter">;</span> ++curr_idx<span class="Delimiter">;</span> <span class="Comment">// avoid using index 0, benign skip in some other cases</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Comment">// End transform_names(inst) Special-cases</span> <span class="Comment">// map names to addresses</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> @@ -80,7 +93,7 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" <span class="Normal">if</span> <span class="Delimiter">(</span>!already_transformed<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> names<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"use before set: "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> v = lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">);</span> + <span class="Normal">int</span> v = lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>v >= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>v<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -89,7 +102,7 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> @@ -99,7 +112,7 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" names[inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>name] = curr_idx<span class="Delimiter">;</span> curr_idx += size_of<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">));</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> v = lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> r<span class="Delimiter">);</span> + <span class="Normal">int</span> v = lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>v >= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>v<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -116,7 +129,7 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" <span class="Normal">bool</span> is_disqualified<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">mutable</span><span class="Comment">*/</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End Null-type is_disqualified Exceptions</span> - raise << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"missing type for "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"missing type for "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> @@ -126,28 +139,27 @@ map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class=" <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">bool</span> already_transformed<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& names<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> already_transformed<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>& names<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> contains_key<span class="Delimiter">(</span>names<span class="Delimiter">,</span> r<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal default_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal default_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> Name[default_recipe][r<span class="Delimiter">.</span>name]<span class="Delimiter">;</span> <span class="Delimiter">}</span> -type_ordinal skip_addresses<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +type_ordinal skip_addresses<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> type_ordinal address = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> type_ordinal shared = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> <span class="Normal">for</span> <span class="Delimiter">(;</span> type<span class="Delimiter">;</span> type = type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value != address && type<span class="Delimiter">-></span>value != shared<span class="Delimiter">)</span> <span class="Identifier">return</span> type<span class="Delimiter">-></span>value<span class="Delimiter">;</span> <span class="Delimiter">}</span> - raise << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"expected a container"</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">int</span> find_element_name<span class="Delimiter">(</span><span class="Normal">const</span> type_ordinal t<span class="Delimiter">,</span> <span class="Normal">const</span> string& name<span class="Delimiter">,</span> <span class="Normal">const</span> string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_info& container = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> t<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>container<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>container<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>container<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == name<span class="Delimiter">)</span> <span class="Identifier">return</span> i<span class="Delimiter">;</span> raise << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"unknown element "</span> << name << <span class="Constant">" in container "</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> t<span class="Delimiter">).</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> @@ -187,7 +199,7 @@ def main [ <span class="Delimiter">:(scenario transform_names_passes_raw)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number/<span class="Special">raw <- </span>copy <span class="Constant">0</span> + <span class="Normal">x</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">0</span> ] <span class="traceAbsent">-name: assign x 1</span> <span class="traceContains">+error: can't write to location 0 in 'x:number/raw <- copy 0'</span> @@ -196,28 +208,28 @@ def main [ <span class="Delimiter">:(scenario transform_names_fails_when_mixing_names_and_numeric_locations)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] <span class="traceContains">+error: main: mixing variable names and numeric addresses</span> <span class="Delimiter">:(scenario transform_names_fails_when_mixing_names_and_numeric_locations_2)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Constant">1</span>:number<span class="Special"> <- </span>copy x:number ] <span class="traceContains">+error: main: mixing variable names and numeric addresses</span> <span class="Delimiter">:(scenario transform_names_does_not_fail_when_mixing_names_and_raw_locations)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number/<span class="Special">raw</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number/<span class="Special">raw</span> ] <span class="traceAbsent">-error: main: mixing variable names and numeric addresses</span> $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario transform_names_does_not_fail_when_mixing_names_and_literals)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> ] <span class="traceAbsent">-error: main: mixing variable names and numeric addresses</span> $error: <span class="Constant">0</span> @@ -226,9 +238,9 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario transform_names_transforms_container_elements)</span> def main [ - p:address:point<span class="Special"> <- </span>copy <span class="Constant">0</span> - a:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> y:offset - b:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> x:offset + <span class="Normal">p</span>:address:point<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">a</span>:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> y:offset + <span class="Normal">b</span>:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> x:offset ] <span class="traceContains">+name: element y of type point is at offset 1</span> <span class="traceContains">+name: element x of type point is at offset 0</span> @@ -237,14 +249,16 @@ def main [ <span class="Comment">// replace element names of containers with offsets</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"get"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"get-address"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"exactly 2 ingredients expected in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"exactly 2 ingredients expected in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"expected ingredient 1 of "</span> << <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"get"</span> ? <span class="Constant">"'get'"</span> : <span class="Constant">"'get-address'"</span><span class="Delimiter">)</span> << <span class="Constant">" to have type 'offset'; got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// since first non-address in base type must be a container, we don't have to canonize</span> - type_ordinal base_type = skip_addresses<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">);</span> + type_ordinal base_type = skip_addresses<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>base_type == -<span class="Constant">1</span><span class="Delimiter">)</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"expected a container in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// otherwise we'll raise an error elsewhere</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>find_element_name<span class="Delimiter">(</span>base_type<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">));</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"name"</span><span class="Delimiter">)</span> << <span class="Constant">"element "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name << <span class="Constant">" of type "</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>name << <span class="Constant">" is at offset "</span> << no_scientific<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>value<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> @@ -256,8 +270,8 @@ def main [ <span class="Delimiter">:(scenarios transform)</span> <span class="Delimiter">:(scenario transform_names_handles_containers)</span> def main [ - a:point<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe - b:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe + <span class="Normal">a</span>:point<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe + <span class="Normal">b</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe ] <span class="traceContains">+name: assign a 1</span> <span class="traceContains">+name: assign b 3</span> @@ -279,13 +293,15 @@ def main [ <span class="Comment">// convert variant names of exclusive containers</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"maybe-convert"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"exactly 2 ingredients expected in '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"exactly 2 ingredients expected in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> assert<span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// since first non-address in base type must be an exclusive container, we don't have to canonize</span> - type_ordinal base_type = skip_addresses<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">);</span> + type_ordinal base_type = skip_addresses<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>base_type == -<span class="Constant">1</span><span class="Delimiter">)</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"expected an exclusive-container in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// otherwise we'll raise an error elsewhere</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>find_element_name<span class="Delimiter">(</span>base_type<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">));</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"name"</span><span class="Delimiter">)</span> << <span class="Constant">"variant "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name << <span class="Constant">" of type "</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>name << <span class="Constant">" has tag "</span> << no_scientific<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>value<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> @@ -295,3 +311,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/043space.cc.html b/html/043space.cc.html index ab2144de..c4783e1e 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -3,29 +3,39 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 043space.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.SalientComment { color: #00ffff; } +.cSpecial { color: #008000; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Spaces help isolate recipes from each other. You can create them at will,</span> <span class="Comment">//: and all addresses in arguments are implicitly based on the 'default-space'</span> <span class="Comment">//: (unless they have the /raw property)</span> @@ -73,7 +83,7 @@ def main [ <span class="SalientComment">//:: now implement space support</span> <span class="Delimiter">:(before "End call Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> default_space<span class="Delimiter">;</span> +<span class="Normal">int</span> default_space<span class="Delimiter">;</span> <span class="Delimiter">:(before "End call Constructor")</span> default_space = <span class="Constant">0</span><span class="Delimiter">;</span> @@ -84,22 +94,22 @@ default_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">)</span> || is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>initialized<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">": reagent not initialized: "</span> << x<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">": reagent not initialized: "</span> << x<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>address<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value<span class="Delimiter">,</span> space_base<span class="Delimiter">(</span>x<span class="Delimiter">)));</span> x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span> assert<span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">));</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// temporary stub; will be replaced in a later layer</span> <span class="Identifier">return</span> current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> address<span class="Delimiter">(</span><span class="Normal">int</span> offset<span class="Delimiter">,</span> <span class="Normal">int</span> base<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>offset >= <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> offset<span class="Delimiter">;</span> <span class="Comment">// raw</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">);</span> + <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset >= size<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// todo: test</span> raise << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << size << <span class="Constant">" at "</span> << base << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -110,7 +120,7 @@ default_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="SalientComment">//:: reads and writes to the 'default-space' variable have special behavior</span> -<span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> +<span class="Delimiter">:(after "void write_memory(reagent x, const vector<double>& data)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type @@ -189,8 +199,8 @@ tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>pus <span class="Delimiter">:(scenario new_default_space)</span> def main [ <span class="Normal">new</span>-<span class="Normal">default</span>-space - x:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - y:number<span class="Special"> <- </span>copy <span class="Constant">3</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">y</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span> ] <span class="Comment"># allocate space for x and y, as well as the chaining slot at 0</span> <span class="traceContains">+mem: array size is 3</span> @@ -216,7 +226,7 @@ def main [ raise << <span class="Constant">"no space allocated for default-space in recipe "</span> << current_recipe_name<span class="Delimiter">()</span> << <span class="Constant">"; are you using names?</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> +<span class="Delimiter">:(after "void write_memory(reagent x, const vector<double>& data)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"number-of-locals"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"can't write to special name 'number-of-locals'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -233,12 +243,21 @@ def main [ ] def foo [ local-scope - x:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Identifier">return</span> <span class="Normal">default</span>-space:address:shared:array:location ] <span class="Comment"># both calls to foo should have received the same default-space</span> <span class="traceContains">+mem: storing 1 in location 3</span> +<span class="Delimiter">:(code)</span> <span class="Comment">// pending test</span> +<span class="CommentedCode">//? :(scenario local_scope_frees_up_allocations)</span> +<span class="CommentedCode">//? def main [</span> +<span class="CommentedCode">//? local-scope</span> +<span class="CommentedCode">//? x:address:shared:array:character <- new [abc]</span> +<span class="CommentedCode">//? ]</span> +<span class="CommentedCode">//? +mem: clearing x:address:shared:array:character</span> + +<span class="Comment">//: todo: do this in a transform, rather than magically in the reply instruction</span> <span class="Delimiter">:(after "Falling Through End Of Recipe")</span> try_reclaim_locals<span class="Delimiter">();</span> <span class="Delimiter">:(after "Starting Reply")</span> @@ -255,16 +274,47 @@ try_reclaim_locals<span class="Delimiter">();</span> <span class="Normal">void</span> try_reclaim_locals<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// only reclaim routines starting with 'local-scope'</span> <span class="Normal">const</span> recipe_ordinal r = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> current_recipe_name<span class="Delimiter">());</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Normal">const</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">const</span> recipe& exiting_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>exiting_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Normal">const</span> instruction& inst = exiting_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>old_name != <span class="Constant">"local-scope"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Comment">// reclaim any local variables unless they're being returned</span> + <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">: this isn't working yet. Doesn't handle address:shared stored in</span> + <span class="Comment">// containers created by 'copy' or 'merge'. We'd end up deleting the address</span> + <span class="Comment">// even if some container containing it was returned.</span> + <span class="Comment">// This might doom our whole refcounting-based approach :/</span> +<span class="CommentedCode">//? vector<double> zero;</span> +<span class="CommentedCode">//? zero.push_back(0);</span> +<span class="CommentedCode">//? for (int i = /*leave default space for last*/1; i < SIZE(exiting_recipe.steps); ++i) {</span> +<span class="CommentedCode">//? const instruction& inst = exiting_recipe.steps.at(i);</span> +<span class="CommentedCode">//? for (int i = 0; i < SIZE(inst.products); ++i) {</span> +<span class="CommentedCode">//? if (!is_mu_address(inst.products.at(i))) continue;</span> +<span class="CommentedCode">//? // local variables only</span> +<span class="CommentedCode">//? if (has_property(inst.products.at(i), "space")) continue;</span> +<span class="CommentedCode">//? if (has_property(inst.products.at(i), "lookup")) continue;</span> +<span class="CommentedCode">//? if (escaping(inst.products.at(i))) continue;</span> +<span class="CommentedCode">//? trace(9999, "mem") << "clearing " << inst.products.at(i).original_string << end();</span> +<span class="CommentedCode">//? write_memory(inst.products.at(i), zero);</span> +<span class="CommentedCode">//? }</span> +<span class="CommentedCode">//? }</span> abandon<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">array length</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">number-of-locals</span><span class="Comment">*/</span>Name[r][<span class="Constant">""</span>]<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Comment">// is this reagent one of the values returned by the current (reply) instruction?</span> +<span class="Normal">bool</span> escaping<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// nothing escapes when you fall through past end of recipe</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>current_step_index<span class="Delimiter">()</span> >= SIZE<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>steps<span class="Delimiter">()))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>r == current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + <span class="Normal">void</span> rewrite_default_space_instruction<span class="Delimiter">(</span>instruction& curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> - raise << to_string<span class="Delimiter">(</span>curr<span class="Delimiter">)</span> << <span class="Constant">" can't take any ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << to_original_string<span class="Delimiter">(</span>curr<span class="Delimiter">)</span> << <span class="Constant">" can't take any ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> curr<span class="Delimiter">.</span>name = <span class="Constant">"new"</span><span class="Delimiter">;</span> curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"location:type"</span><span class="Delimiter">));</span> curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"number-of-locals:literal"</span><span class="Delimiter">));</span> @@ -305,7 +355,7 @@ Hide_missing_default_space_errors = <span class="Constant">false</span><span cla <span class="Delimiter">:(code)</span> <span class="Normal">bool</span> contains_non_special_name<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = Name[r]<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Name[r]<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = Name[r]<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Name[r]<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"stash_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// generated by rewrite_stashes_to_text (cross-layer)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_special_name<span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> @@ -322,7 +372,7 @@ Hide_missing_default_space_errors = <span class="Constant">false</span><span cla <span class="Delimiter">}</span> <span class="Normal">bool</span> <span class="Normal">operator</span><<span class="Delimiter">(</span><span class="Normal">const</span> reagent& a<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& b<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> aspace = <span class="Constant">0</span><span class="Delimiter">,</span> bspace = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> aspace = <span class="Constant">0</span><span class="Delimiter">,</span> bspace = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>a<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">))</span> aspace = to_integer<span class="Delimiter">(</span>property<span class="Delimiter">(</span>a<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">)-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>b<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">))</span> bspace = to_integer<span class="Delimiter">(</span>property<span class="Delimiter">(</span>b<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">)-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>aspace != bspace<span class="Delimiter">)</span> <span class="Identifier">return</span> aspace < bspace<span class="Delimiter">;</span> @@ -331,3 +381,4 @@ Hide_missing_default_space_errors = <span class="Constant">false</span><span cla </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index fbd6b3ea..7badc275 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 044space_surround.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: So far you can have global variables by not setting default-space, and</span> <span class="Comment">//: local variables by setting default-space. You can isolate variables</span> <span class="Comment">//: between those extremes by creating 'surrounding' spaces.</span> @@ -58,21 +66,21 @@ def dummy [ <span class="Comment"># just for the /names: property above</span> <span class="Comment">//: lifetime, surrounding allows managing shorter lifetimes inside a longer</span> <span class="Comment">//: one.</span> -<span class="Delimiter">:(replace{} "long long int space_base(const reagent& x)")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base = current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Delimiter">:(replace{} "int space_base(const reagent& x)")</span> +<span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> base = current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Identifier">return</span> space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index<span class="Delimiter">(</span>x<span class="Delimiter">),</span> base<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> space_index<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> base<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">int</span> space_index<span class="Delimiter">,</span> <span class="Normal">int</span> base<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>space_index == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> base<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index-<span class="Constant">1</span><span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">))</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">int</span> result = space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index-<span class="Constant">1</span><span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">))</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> space_index<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> space_index<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first == <span class="Constant">"space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second || x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">-></span>right<span class="Delimiter">)</span> raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"/space metadata should take exactly one value in "</span> << x<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -84,8 +92,9 @@ def dummy [ <span class="Comment"># just for the /names: property above</span> <span class="Delimiter">:(scenario permit_space_as_variable_name)</span> def main [ - space:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Normal">space</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/045closure_name.cc.html b/html/045closure_name.cc.html index 944b31b5..d7f38829 100644 --- a/html/045closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 045closure_name.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .traceContains { color: #008000; } -.Identifier { color: #fcb165; } -.Constant { color: #00a0a0; } -.Special { color: #c00000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Writing to a literal (not computed) address of 0 in a recipe chains two</span> <span class="Comment">//: spaces together. When a variable has a property of /space:1, it looks up</span> <span class="Comment">//: the variable in the chained/surrounding space. /space:2 looks up the</span> @@ -40,16 +48,16 @@ def main [ def <span class="Normal">new</span>-counter [ <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span> location:type<span class="Delimiter">,</span> <span class="Constant">30</span> - x:number<span class="Special"> <- </span>copy <span class="Constant">23</span> - y:number<span class="Special"> <- </span>copy <span class="Constant">3</span> <span class="Comment"># variable that will be incremented</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> + <span class="Normal">y</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span> <span class="Comment"># variable that will be incremented</span> <span class="Identifier">return</span> <span class="Normal">default</span>-space:address:shared:array:location ] def increment-counter [ <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span> location:type<span class="Delimiter">,</span> <span class="Constant">30</span> <span class="Constant">0</span>:address:shared:array:location/names:<span class="Normal">new</span>-counter<span class="Special"> <- </span>next-ingredient <span class="Comment"># outer space must be created by 'new-counter' above</span> - y:number/space:<span class="Constant">1</span><span class="Special"> <- </span>add y:number/space:<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span> <span class="Comment"># increment</span> - y:number<span class="Special"> <- </span>copy <span class="Constant">234</span> <span class="Comment"># dummy</span> + <span class="Normal">y</span>:number/space:<span class="Constant">1</span><span class="Special"> <- </span>add y:number/space:<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span> <span class="Comment"># increment</span> + <span class="Normal">y</span>:number<span class="Special"> <- </span>copy <span class="Constant">234</span> <span class="Comment"># dummy</span> <span class="Identifier">return</span> y:number/space:<span class="Constant">1</span> ] @@ -69,10 +77,10 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> collect_surrounding_spaces<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- collect surrounding spaces for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="CommentedCode">//? cerr << "--- collect surrounding spaces for recipe " << get(Recipe, r).name << '\n';</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>name != <span class="Constant">"0"</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> type_tree* type = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>type<span class="Delimiter">;</span> @@ -117,15 +125,15 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Comment">//: Once surrounding spaces are available, transform_names uses them to handle</span> <span class="Comment">//: /space properties.</span> -<span class="Delimiter">:(replace{} "long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe)")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal default_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Delimiter">:(replace{} "int lookup_name(const reagent& r, const recipe_ordinal default_recipe)")</span> +<span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal default_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_property<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Name[default_recipe]<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> raise << <span class="Constant">"name not found: "</span> << x<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> Name[default_recipe][x<span class="Delimiter">.</span>name]<span class="Delimiter">;</span> <span class="Delimiter">}</span> string_tree* p = property<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!p || p<span class="Delimiter">-></span>right<span class="Delimiter">)</span> raise << <span class="Constant">"/space property should have exactly one (non-negative integer) value</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> n = to_integer<span class="Delimiter">(</span>p<span class="Delimiter">-></span>value<span class="Delimiter">);</span> + <span class="Normal">int</span> n = to_integer<span class="Delimiter">(</span>p<span class="Delimiter">-></span>value<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>n >= <span class="Constant">0</span><span class="Delimiter">);</span> recipe_ordinal surrounding_recipe = lookup_surrounding_recipe<span class="Delimiter">(</span>default_recipe<span class="Delimiter">,</span> n<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>surrounding_recipe == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> @@ -136,11 +144,11 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Comment">// If the recipe we need to lookup this name in doesn't have names done yet,</span> <span class="Comment">// recursively call transform_names on it.</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">,</span> set<recipe_ordinal>& done<span class="Delimiter">,</span> vector<recipe_ordinal>& path<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> lookup_name<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">,</span> set<recipe_ordinal>& done<span class="Delimiter">,</span> vector<recipe_ordinal>& path<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Name[r]<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> Name[r][x<span class="Delimiter">.</span>name]<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>done<span class="Delimiter">,</span> r<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << <span class="Constant">"can't compute address of "</span> << to_string<span class="Delimiter">(</span>x<span class="Delimiter">)</span> << <span class="Constant">" because "</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>path<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>path<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << path<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Constant">1</span><span class="Delimiter">)</span> << <span class="Constant">" requires computing names of "</span> << path<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> raise << path<span class="Delimiter">.</span>at<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>path<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">)</span> << <span class="Constant">" requires computing names of "</span> << r << <span class="Constant">"..ad infinitum</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -153,7 +161,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Identifier">return</span> Name[r][x<span class="Delimiter">.</span>name]<span class="Delimiter">;</span> <span class="Delimiter">}</span> -recipe_ordinal lookup_surrounding_recipe<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> n<span class="Delimiter">)</span> <span class="Delimiter">{</span> +recipe_ordinal lookup_surrounding_recipe<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">,</span> <span class="Normal">int</span> n<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>n == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> r<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Surrounding_space<span class="Delimiter">,</span> r<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << <span class="Constant">"don't know surrounding recipe of "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -164,8 +172,8 @@ recipe_ordinal lookup_surrounding_recipe<span class="Delimiter">(</span><span cl <span class="Delimiter">}</span> <span class="Comment">//: weaken use-before-set detection just a tad</span> -<span class="Delimiter">:(replace{} "bool already_transformed(const reagent& r, const map<string, long long int>& names)")</span> -<span class="Normal">bool</span> already_transformed<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& names<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Delimiter">:(replace{} "bool already_transformed(const reagent& r, const map<string, int>& names)")</span> +<span class="Normal">bool</span> already_transformed<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>>& names<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> string_tree* p = property<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"space"</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!p || p<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -181,10 +189,11 @@ recipe_ordinal lookup_surrounding_recipe<span class="Delimiter">(</span><span cl <span class="Special">% Hide_errors = true;</span> def f [ local-scope - x:number/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Normal">x</span>:number/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">34</span> ] <span class="traceContains">+error: don't know surrounding recipe of f</span> <span class="traceContains">+error: f: can't find a place to store x</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/046global.cc.html b/html/046global.cc.html index c92132a0..6fce3f17 100644 --- a/html/046global.cc.html +++ b/html/046global.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 046global.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: So far we have local variables, and we can nest local variables of short</span> <span class="Comment">//: lifetimes inside longer ones. Now let's support 'global' variables that</span> <span class="Comment">//: last for the life of a routine. If we create multiple routines they won't</span> @@ -63,10 +71,10 @@ def main [ <span class="Comment">//: writes to this variable go to a field in the current routine</span> <span class="Delimiter">:(before "End routine Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> global_space<span class="Delimiter">;</span> +<span class="Normal">int</span> global_space<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> global_space = <span class="Constant">0</span><span class="Delimiter">;</span> -<span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> +<span class="Delimiter">:(after "void write_memory(reagent x, const vector<double>& data)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type @@ -87,7 +95,7 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">//: now marking variables as /space:global looks them up inside this field</span> -<span class="Delimiter">:(after "long long int space_base(const reagent& x)")</span> +<span class="Delimiter">:(after "int space_base(const reagent& x)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> raise << <span class="Constant">"routine has no global space</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -100,7 +108,7 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(scenario global_space_with_names)</span> def main [ global-space:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span> location:type<span class="Delimiter">,</span> <span class="Constant">10</span> - x:number<span class="Special"> <- </span>copy <span class="Constant">23</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">1</span>:number/space:global<span class="Special"> <- </span>copy <span class="Constant">24</span> ] <span class="Comment"># don't complain about mixing numeric addresses and names</span> @@ -113,7 +121,7 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(code)</span> <span class="Normal">bool</span> is_global<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first == <span class="Constant">"space"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second && x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"global"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -122,3 +130,4 @@ $error: <span class="Constant">0</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/047check_type_by_name.cc.html b/html/047check_type_by_name.cc.html index 0c69601e..a3300f78 100644 --- a/html/047check_type_by_name.cc.html +++ b/html/047check_type_by_name.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 047check_type_by_name.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Constant { color: #00a0a0; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Some simple sanity checks for types, and also attempts to guess them where</span> <span class="Comment">//: they aren't provided.</span> <span class="Comment">//:</span> @@ -35,8 +43,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(scenario transform_fails_on_reusing_name_with_different_type)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> - x:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span> ] <span class="traceContains">+error: main: x used with multiple types</span> @@ -48,15 +56,15 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- deduce types for recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> set<reagent> known<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> deduce_missing_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">));</span> - check_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">);</span> + check_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> caller<span class="Delimiter">);</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> deduce_missing_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">));</span> - check_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> r<span class="Delimiter">);</span> + check_type<span class="Delimiter">(</span>known<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> caller<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -68,7 +76,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" <= "</span> << names_to_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> check_type<span class="Delimiter">(</span>set<reagent>& known<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> check_type<span class="Delimiter">(</span>set<reagent>& known<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// if you use raw locations you're probably doing something unsafe</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// might get filled in by other logic later</span> @@ -77,16 +85,16 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa known<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>known<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">)-></span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>type<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" used with multiple types</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" used with multiple types</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" can't be just an array. What is it an array of?</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" can't be just an array. What is it an array of?</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << <span class="Constant">" can't determine the size of array variable "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">". Either allocate it separately and make the type of "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" address:shared:..., or specify the length of the array in the type of "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << caller<span class="Delimiter">.</span>name << <span class="Constant">" can't determine the size of array variable "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">". Either allocate it separately and make the type of "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" address:shared:..., or specify the length of the array in the type of "</span> << x<span class="Delimiter">.</span>name << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -94,19 +102,19 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">:(scenario transform_fills_in_missing_types)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> - y:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">y</span>:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> <span class="Constant">1</span> ] <span class="Delimiter">:(scenario transform_fills_in_missing_types_in_product)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> x<span class="Special"> <- </span>copy <span class="Constant">2</span> ] <span class="Delimiter">:(scenario transform_fills_in_missing_types_in_product_and_ingredient)</span> def main [ - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> x<span class="Special"> <- </span>add x<span class="Delimiter">,</span> <span class="Constant">1</span> ] <span class="traceContains">+mem: storing 2 in location 1</span> @@ -115,14 +123,14 @@ def main [ <span class="Special">% Hide_errors = true;</span> def main [ x<span class="Special"> <- </span>copy <span class="Constant">1</span> - x:number<span class="Special"> <- </span>copy <span class="Constant">2</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">2</span> ] <span class="traceContains">+error: main: missing type for x in 'x <- copy 1'</span> <span class="Delimiter">:(scenario typo_in_address_type_fails)</span> <span class="Special">% Hide_errors = true;</span> def main [ - y:address:shared:charcter<span class="Special"> <- </span><span class="Normal">new</span> character:type + <span class="Normal">y</span>:address:shared:charcter<span class="Special"> <- </span><span class="Normal">new</span> character:type *y<span class="Special"> <- </span>copy <span class="Constant">67</span> ] <span class="traceContains">+error: main: unknown type charcter in 'y:address:shared:charcter <- new character:type'</span> @@ -130,7 +138,7 @@ def main [ <span class="Delimiter">:(scenario array_type_without_size_fails)</span> <span class="Special">% Hide_errors = true;</span> def main [ - x:array:number<span class="Special"> <- </span>merge <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">12</span><span class="Delimiter">,</span> <span class="Constant">13</span> + <span class="Normal">x</span>:array:number<span class="Special"> <- </span>merge <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">12</span><span class="Delimiter">,</span> <span class="Constant">13</span> ] <span class="traceContains">+error: main can't determine the size of array variable x. Either allocate it separately and make the type of x address:shared:..., or specify the length of the array in the type of x.</span> @@ -141,11 +149,12 @@ def foo [ <span class="Comment"># dummy</span> def main [ local-scope <span class="Constant">0</span>:address:shared:array:location/names:foo<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># specify surrounding space</span> - x:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span>/<span class="Constant">true</span> - x:number/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Normal">x</span>:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span>/<span class="Constant">true</span> + <span class="Normal">x</span>:number/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">34</span> x/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">35</span> ] $error: <span class="Constant">0</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 397186c9..aa172588 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -3,30 +3,38 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 050scenario.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } -.Identifier { color: #fcb165; } .cSpecial { color: #008000; } +.traceContains { color: #008000; } .SalientComment { color: #00ffff; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Mu scenarios. This will get long, but these are the tests we want to</span> <span class="Comment">//: support in this layer.</span> @@ -72,10 +80,10 @@ scenario foo [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">13</span> ] trace-should-contain [ - a: a b c + <span class="Normal">a</span>: a b c ] trace-should-<span class="Normal">not</span>-contain [ - a: x y z + <span class="Normal">a</span>: x y z ] ] @@ -124,26 +132,26 @@ scenario foo [ <span class="Comment"># ']' in comment</span> <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+run: 1:number <- copy 0</span> +<span class="traceContains">+run: {1: "number"} <- copy {0: "literal"}</span> <span class="Delimiter">:(scenario read_scenario_with_bracket_in_comment_in_nested_string)</span> scenario foo [ <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [<span class="Comment"># not a comment]</span> ] -<span class="traceContains">+run: 1:address:shared:array:character <- new [# not a comment]</span> +<span class="traceContains">+run: {1: ("address" "shared" "array" "character")} <- new {"# not a comment": "literal-string"}</span> <span class="SalientComment">//:: Run scenarios when we run 'mu test'.</span> <span class="Comment">//: Treat the text of the scenario as a regular series of instructions.</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Num_core_mu_tests = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Num_core_mu_tests = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(after "Check For .mu Files")</span> Num_core_mu_tests = SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Tests")</span> Hide_missing_default_space_errors = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">time_t</span> mu_time<span class="Delimiter">;</span> time<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> cerr << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">Mu tests: "</span> << ctime<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << i << ": " << Scenarios.at(i).name << '\n';</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i == Num_core_mu_tests<span class="Delimiter">)</span> <span class="Delimiter">{</span> time<span class="Delimiter">(</span>&t<span class="Delimiter">);</span> @@ -155,7 +163,7 @@ cerr << <span class="Constant">"</span><span class="cSpecial">\n</spa <span class="Comment">//: Convenience: run a single named scenario.</span> <span class="Delimiter">:(after "Test Runs")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == argv[argc-<span class="Constant">1</span>]<span class="Delimiter">)</span> <span class="Delimiter">{</span> run_mu_scenario<span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Passed<span class="Delimiter">)</span> cerr << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> @@ -309,7 +317,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">void</span> check_memory<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> in >> std::noskipws<span class="Delimiter">;</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> locations_checked<span class="Delimiter">;</span> + set<<span class="Normal">int</span>> locations_checked<span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -318,7 +326,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span check_type<span class="Delimiter">(</span>lhs<span class="Delimiter">,</span> in<span class="Delimiter">);</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address = to_integer<span class="Delimiter">(</span>lhs<span class="Delimiter">);</span> + <span class="Normal">int</span> address = to_integer<span class="Delimiter">(</span>lhs<span class="Delimiter">);</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> string _assign<span class="Delimiter">;</span> in >> _assign<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>_assign == <span class="Constant">"<-"</span><span class="Delimiter">);</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> @@ -370,7 +378,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span assert<span class="Delimiter">(</span>_assign == <span class="Constant">"<-"</span><span class="Delimiter">);</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> string literal = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> address = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Comment">// exclude quoting brackets</span> assert<span class="Delimiter">(</span>*literal<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">);</span> literal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>literal<span class="Delimiter">.</span>begin<span class="Delimiter">());</span> assert<span class="Delimiter">(</span>*--literal<span class="Delimiter">.</span>end<span class="Delimiter">()</span> == <span class="Constant">']'</span><span class="Delimiter">);</span> literal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>--literal<span class="Delimiter">.</span>end<span class="Delimiter">());</span> @@ -381,7 +389,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << <span class="Constant">"don't know how to check memory for "</span> << lhs << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> check_string<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">,</span> <span class="Normal">const</span> string& literal<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> check_string<span class="Delimiter">(</span><span class="Normal">int</span> address<span class="Delimiter">,</span> <span class="Normal">const</span> string& literal<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"checking string length at "</span> << address << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>literal<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> @@ -395,7 +403,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ++address<span class="Delimiter">;</span> <span class="Comment">// now skip length</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>literal<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>literal<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"checking location "</span> << address+i << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address+i<span class="Delimiter">)</span> != literal<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -487,8 +495,8 @@ def main [ <span class="Special">% Hide_errors = true;</span> def main [ trace-should-contain [ - a: b - a: d + <span class="Normal">a</span>: b + <span class="Normal">a</span>: d ] ] <span class="traceContains">+error: missing [b] in trace with label a</span> @@ -515,7 +523,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span Trace_stream<span class="Delimiter">-></span>newline<span class="Delimiter">();</span> vector<trace_line> expected_lines = parse_trace<span class="Delimiter">(</span>expected<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>expected_lines<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr_expected_line = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> curr_expected_line = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>label != p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>contents != trim<span class="Delimiter">(</span>p<span class="Delimiter">-></span>contents<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -532,10 +540,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span vector<trace_line> parse_trace<span class="Delimiter">(</span><span class="Normal">const</span> string& expected<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<string> buf = split<span class="Delimiter">(</span>expected<span class="Delimiter">,</span> <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> vector<trace_line> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>buf<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>buf<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> = trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> delim = buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>find<span class="Delimiter">(</span><span class="Constant">": "</span><span class="Delimiter">);</span> + <span class="Normal">int</span> delim = buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>find<span class="Delimiter">(</span><span class="Constant">": "</span><span class="Delimiter">);</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>trace_line<span class="Delimiter">(</span>trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> delim<span class="Delimiter">)),</span> trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>substr<span class="Delimiter">(</span>delim+<span class="Constant">2</span><span class="Delimiter">))));</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> @@ -549,8 +557,8 @@ def main [ trace <span class="Constant">1</span><span class="Delimiter">,</span> [a]<span class="Delimiter">,</span> [b] ] trace-should-contain [ - a: b - a: d + <span class="Normal">a</span>: b + <span class="Normal">a</span>: d ] ] <span class="traceContains">+error: missing [d] in trace with label a</span> @@ -562,7 +570,7 @@ def main [ trace <span class="Constant">1</span><span class="Delimiter">,</span> [a]<span class="Delimiter">,</span> [b] ] trace-should-contain [ - a: b + <span class="Normal">a</span>: b ] ] <span class="traceAbsent">-error: missing [b] in trace with label a</span> @@ -580,7 +588,7 @@ def main [ trace <span class="Constant">1</span><span class="Delimiter">,</span> [a]<span class="Delimiter">,</span> [b] ] trace-should-<span class="Normal">not</span>-contain [ - a: b + <span class="Normal">a</span>: b ] ] <span class="traceContains">+error: unexpected [b] in trace with label a</span> @@ -606,7 +614,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">bool</span> check_trace_missing<span class="Delimiter">(</span><span class="Normal">const</span> string& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> Trace_stream<span class="Delimiter">-></span>newline<span class="Delimiter">();</span> vector<trace_line> lines = parse_trace<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span>lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>label<span class="Delimiter">,</span> lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>contents<span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << <span class="Constant">"unexpected ["</span> << lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>contents << <span class="Constant">"] in trace with label "</span> << lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>label << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> Passed = <span class="Constant">false</span><span class="Delimiter">;</span> @@ -620,7 +628,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Special">% Scenario_testing_scenario = true;</span> def main [ trace-should-<span class="Normal">not</span>-contain [ - a: b + <span class="Normal">a</span>: b ] ] <span class="traceAbsent">-error: unexpected [b] in trace with label a</span> @@ -634,8 +642,8 @@ def main [ trace <span class="Constant">1</span><span class="Delimiter">,</span> [a]<span class="Delimiter">,</span> [d] ] trace-should-<span class="Normal">not</span>-contain [ - a: b - a: d + <span class="Normal">a</span>: b + <span class="Normal">a</span>: d ] ] <span class="traceContains">+error: unexpected [d] in trace with label a</span> @@ -655,7 +663,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> CHECK_TRACE_COUNT_FOR_LABEL: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'check-trace-for-label' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'check-trace-for-label' requires exactly two ingredients, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -671,9 +679,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> CHECK_TRACE_COUNT_FOR_LABEL: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> expected_count = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> expected_count = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> string label = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> count = trace_count<span class="Delimiter">(</span>label<span class="Delimiter">);</span> + <span class="Normal">int</span> count = trace_count<span class="Delimiter">(</span>label<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>count != expected_count<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// genuine test in a mu file</span> @@ -725,3 +733,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/051scenario_test.mu.html b/html/051scenario_test.mu.html index 387a9fd7..436a3def 100644 --- a/html/051scenario_test.mu.html +++ b/html/051scenario_test.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 051scenario_test.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># tests for 'scenario' in previous layer</span> <span class="muScenario">scenario</span> first_scenario_in_mu [ @@ -93,3 +101,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html index f698a972..4ffcaebf 100644 --- a/html/052tangle.cc.html +++ b/html/052tangle.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 052tangle.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.Identifier { color: #fcb165; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Allow code for recipes to be pulled in from multiple places and inserted</span> <span class="Comment">//: at special labels called 'waypoints'. Unlike jump targets, a recipe can</span> <span class="Comment">//: have multiple ambiguous waypoints with the same name. Any 'before' and</span> @@ -95,12 +103,12 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span <span class="Delimiter">:(code)</span> <span class="Normal">void</span> insert_fragments<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">bool</span> made_progress = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> pass = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> pass = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>made_progress<span class="Delimiter">)</span> <span class="Delimiter">{</span> made_progress = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// create a new vector because insertions invalidate iterators</span> vector<instruction> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>is_label || !is_waypoint<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> || inst<span class="Delimiter">.</span>tangle_done<span class="Delimiter">)</span> <span class="Delimiter">{</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> @@ -132,12 +140,12 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span <span class="Comment">// so we'll keep jump targets local to the specific before/after fragment</span> <span class="Comment">// that introduces them.</span> set<string> jump_targets<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = patch<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label && is_jump_target<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span> jump_targets<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">);</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction inst = patch<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>jump_targets<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span> @@ -145,7 +153,7 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span base<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent& x = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name == <span class="Constant">"label"</span> && contains_key<span class="Delimiter">(</span>jump_targets<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> @@ -444,3 +452,4 @@ $mem: <span class="Constant">2</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/054dilated_reagent.cc.html b/html/053dilated_reagent.cc.html index c7124c12..cf7d75dc 100644 --- a/html/054dilated_reagent.cc.html +++ b/html/053dilated_reagent.cc.html @@ -2,30 +2,38 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 054dilated_reagent.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 053dilated_reagent.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } .Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } -.Error { color: #ffffff; background-color: #ff6060; } +.Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } .PreProc { color: #800080; } -.traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } -.Comment { color: #9090ff; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: An alternative syntax for reagents that permits whitespace in properties,</span> <span class="Comment">//: grouped by brackets. We'll use this ability in the next layer, when we</span> <span class="Comment">//: generalize types from lists to trees of properties.</span> @@ -35,7 +43,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color def main [ <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: bar<span class="Delimiter">}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> ] -<span class="traceContains">+parse: product: 1: "number", {"foo": "bar"}</span> +<span class="traceContains">+parse: product: {1: "number", "foo": "bar"}</span> <span class="Delimiter">:(scenario load_trailing_space_after_curly_bracket)</span> def main [ @@ -49,7 +57,7 @@ def main [ def main [ <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: bar<span class="Delimiter">}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># test comment</span> ] -<span class="traceContains">+parse: product: 1: "number", {"foo": "bar"}</span> +<span class="traceContains">+parse: product: {1: "number", "foo": "bar"}</span> $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario dilated_reagent_with_comment_immediately_following)</span> @@ -72,7 +80,7 @@ $error: <span class="Constant">0</span> <span class="Comment">// reagents should remain all on one line.</span> <span class="Normal">bool</span> start_of_dilated_reagent<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="Constant">'{'</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> pos = in<span class="Delimiter">.</span>tellg<span class="Delimiter">();</span> + <span class="Normal">int</span> pos = in<span class="Delimiter">.</span>tellg<span class="Delimiter">();</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Comment">// slurp '{'</span> skip_whitespace_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Normal">char</span> next = in<span class="Delimiter">.</span>peek<span class="Delimiter">();</span> @@ -161,3 +169,4 @@ string slurp_key<span class="Delimiter">(</span>istream& in<span class="Deli </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/053rewrite_stash.cc.html b/html/053rewrite_stash.cc.html deleted file mode 100644 index 23278083..00000000 --- a/html/053rewrite_stash.cc.html +++ /dev/null @@ -1,78 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 053rewrite_stash.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> -<meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> -<style type="text/css"> -<!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } -body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } -.Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } -.Comment { color: #9090ff; } ---> -</style> -</head> -<body> -<pre> -<span class="Comment">//: when encountering other types, try to convert them to strings using</span> -<span class="Comment">//: 'to-text'</span> - -<span class="Delimiter">:(before "End Instruction Inserting/Deleting Transforms")</span> -Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>rewrite_stashes_to_text<span class="Delimiter">);</span> - -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> rewrite_stashes_to_text<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- rewrite 'stash' instructions in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>contains_named_locations<span class="Delimiter">(</span>caller<span class="Delimiter">))</span> - rewrite_stashes_to_text_named<span class="Delimiter">(</span>caller<span class="Delimiter">);</span> - <span class="Comment">// in recipes without named locations, 'stash' is still not extensible</span> -<span class="Delimiter">}</span> - -<span class="Normal">bool</span> contains_named_locations<span class="Delimiter">(</span><span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> - <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> - <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -<span class="Normal">void</span> rewrite_stashes_to_text_named<span class="Delimiter">(</span>recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">static</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> stash_instruction_idx = <span class="Constant">0</span><span class="Delimiter">;</span> - vector<instruction> new_instructions<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"stash"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - instruction def<span class="Delimiter">;</span> - def<span class="Delimiter">.</span>name = <span class="Constant">"to-text-line"</span><span class="Delimiter">;</span> - def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> - ostringstream ingredient_name<span class="Delimiter">;</span> - ingredient_name << <span class="Constant">"stash_"</span> << stash_instruction_idx << <span class="Constant">'_'</span> << j << <span class="Constant">":address:shared:array:character"</span><span class="Delimiter">;</span> - def<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">()));</span> - new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>def<span class="Delimiter">);</span> - inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>clear<span class="Delimiter">();</span> <span class="Comment">// reclaim old memory</span> - inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> = reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">());</span> - <span class="Delimiter">}</span> - <span class="Delimiter">}</span> - new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> - <span class="Delimiter">}</span> - new_instructions<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> -<span class="Delimiter">}</span> -</pre> -</body> -</html> diff --git a/html/055parse_tree.cc.html b/html/054parse_tree.cc.html index a9f6091d..e4e4760e 100644 --- a/html/055parse_tree.cc.html +++ b/html/054parse_tree.cc.html @@ -2,27 +2,35 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 055parse_tree.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 054parse_tree.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Special { color: #c00000; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">// So far instructions can only contain linear lists of properties. Now we add</span> <span class="Comment">// support for more complex trees of properties in dilated reagents. This will</span> <span class="Comment">// come in handy later for expressing complex types, like "a dictionary from</span> @@ -32,7 +40,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color def main [ <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: <span class="Delimiter">(</span>bar <span class="Delimiter">(</span>baz quux<span class="Delimiter">))}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> ] -<span class="traceContains">+parse: product: 1: "number", {"foo": ("bar" ("baz" "quux"))}</span> +<span class="traceContains">+parse: product: {1: "number", "foo": ("bar" ("baz" "quux"))}</span> <span class="Delimiter">:(before "End Parsing Reagent Property(value)")</span> value = parse_string_tree<span class="Delimiter">(</span>value<span class="Delimiter">);</span> @@ -92,7 +100,7 @@ container foo [ ] container bar [ ] -<span class="traceContains">+parse: product: 1: ("foo" ("address" "array" "character") ("bar" "number"))</span> +<span class="traceContains">+parse: product: {1: ("foo" ("address" "array" "character") ("bar" "number"))}</span> <span class="Delimiter">:(scenario dilated_reagent_in_static_array)</span> def main [ @@ -109,7 +117,7 @@ def main [ <span class="Delimiter">:(scenario dilated_reagent_with_new)</span> def main [ - x:address:shared:address:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> + <span class="Normal">x</span>:address:shared:address:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> ] <span class="traceContains">+new: size of ("address" "number") is 1</span> @@ -125,3 +133,4 @@ type_name = parse_string_tree<span class="Delimiter">(</span>type_name<span clas </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/056recipe_header.cc.html b/html/055recipe_header.cc.html index 259f06c3..52ee83d5 100644 --- a/html/056recipe_header.cc.html +++ b/html/055recipe_header.cc.html @@ -2,31 +2,39 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 056recipe_header.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 055recipe_header.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.Error { color: #ffffff; background-color: #ff6060; } .cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Identifier { color: #fcb165; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Error { color: #ffffff; background-color: #ff6060; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Advanced notation for the common/easy case where a recipe takes some fixed</span> <span class="Comment">//: number of ingredients and yields some fixed number of products.</span> @@ -37,7 +45,7 @@ def main [ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimiter">-></span> z:number [ local-scope load-ingredients - z:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y + <span class="Normal">z</span>:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Identifier">return</span> z ] <span class="traceContains">+mem: storing 8 in location 1</span> @@ -83,7 +91,7 @@ def main [ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimiter">-></span> z:number<span class="Delimiter">,</span> [ local-scope load-ingredients - z:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y + <span class="Normal">z</span>:number<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Identifier">return</span> z ] <span class="traceContains">+mem: storing 8 in location 1</span> @@ -130,10 +138,10 @@ def main <span class="Comment"># comment</span> <span class="Delimiter">:(after "Begin debug_string(recipe x)")</span> out << <span class="Constant">"ingredients:</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">" "</span> << debug_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> out << <span class="Constant">"products:</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">" "</span> << debug_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Comment">//: If a recipe never mentions any ingredients or products, assume it has a header.</span> @@ -147,7 +155,7 @@ def test [ <span class="Delimiter">:(before "End Recipe Body(result)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!result<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Delimiter">{</span> result<span class="Delimiter">.</span>has_header = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = result<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">((</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> && !inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> || <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"return"</span> && !inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> @@ -169,7 +177,7 @@ def test [ <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"load-ingredients"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> curr<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> recipe_ordinal op = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"next-ingredient-without-typechecking"</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> curr<span class="Delimiter">.</span>operation = op<span class="Delimiter">;</span> curr<span class="Delimiter">.</span>name = <span class="Constant">"next-ingredient-without-typechecking"</span><span class="Delimiter">;</span> curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> @@ -200,8 +208,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">else</span> <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// pad the first product with sufficient zeros to match its type</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -240,7 +248,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_calls_against_header<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check calls inside recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation < MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">);</span> @@ -248,17 +256,17 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// ingredients coerced from call to callee</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_unique_address<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"avoid passing non-shared addresses into calls, like ingredient "</span> << i << <span class="Constant">" at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"avoid passing non-shared addresses into calls, like ingredient "</span> << i << <span class="Constant">" at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// products coerced from callee to call</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_unique_address<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"avoid getting non-shared addresses out of calls, like product "</span> << i << <span class="Constant">" at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"avoid getting non-shared addresses out of calls, like product "</span> << i << <span class="Constant">" at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -305,7 +313,7 @@ def foo <span class="Delimiter">-></span> x:address:number [ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimiter">-></span> z:number [ local-scope load-ingredients - z:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe + <span class="Normal">z</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe <span class="Identifier">return</span> z ] <span class="traceContains">+error: add2: replied with the wrong type at 'return z'</span> @@ -318,16 +326,16 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">const</span> recipe& caller_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller_recipe<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- checking reply instructions against header for "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name != <span class="Constant">"reply"</span> && inst<span class="Delimiter">.</span>name != <span class="Constant">"return"</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"replied with the wrong number of products at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"replied with the wrong number of products at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"replied with the wrong type at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"replied with the wrong type at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -337,7 +345,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa def add2 x:number<span class="Delimiter">,</span> y:number [ local-scope load-ingredients - z:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe + <span class="Normal">z</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe <span class="Identifier">return</span> z ] <span class="traceContains">+error: add2: replied with the wrong number of products at 'return z'</span> @@ -363,7 +371,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">if</span> <span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- checking reply instructions against header for "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">))</span> raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" can't repeat in the ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">,</span> i<span class="Delimiter">);</span> @@ -394,18 +402,18 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">if</span> <span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- deduce types from header for "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> map<string<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree*> header_type<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> put<span class="Delimiter">(</span>header_type<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"type of "</span> << caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" is "</span> << names_to_string<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> put<span class="Delimiter">(</span>header_type<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"type of "</span> << caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" is "</span> << names_to_string<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -413,7 +421,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>header_type<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">));</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"type of "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" is "</span> << names_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">" product: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> @@ -448,7 +456,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa recipe& caller_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller_recipe<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- fill in reply ingredients from header for recipe "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"return"</span><span class="Delimiter">)</span> add_header_products<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">);</span> @@ -466,7 +474,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> add_header_products<span class="Delimiter">(</span>instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"return"</span><span class="Delimiter">);</span> <span class="Comment">// collect any products with the same names as ingredients</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// if the ingredient is missing, add it from the header</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> == i<span class="Delimiter">)</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> @@ -502,7 +510,7 @@ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimite load-ingredients z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y ] -<span class="traceContains">+transform: instruction: reply z:number</span> +<span class="traceContains">+transform: instruction: reply {z: "number"}</span> <span class="traceContains">+mem: storing 8 in location 1</span> <span class="Delimiter">:(scenario reply_on_fallthrough_already_exists)</span> @@ -515,7 +523,7 @@ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimite z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Comment"># no type for z</span> <span class="Identifier">return</span> z ] -<span class="traceContains">+transform: instruction: return z</span> +<span class="traceContains">+transform: instruction: return {z: ()}</span> <span class="traceAbsent">-transform: instruction: reply z:number</span> <span class="traceContains">+mem: storing 8 in location 1</span> @@ -538,3 +546,4 @@ def add2 x:number<span class="Delimiter">,</span> y:number <span class="Delimite </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/057static_dispatch.cc.html b/html/056static_dispatch.cc.html index e1e9c603..116970e1 100644 --- a/html/057static_dispatch.cc.html +++ b/html/056static_dispatch.cc.html @@ -2,29 +2,37 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 057static_dispatch.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 056static_dispatch.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Transform to maintain multiple variants of a recipe depending on the</span> <span class="Comment">//: number and types of the ingredients and products. Allows us to use nice</span> <span class="Comment">//: names like 'print' or 'length' in many mutually extensible ways.</span> @@ -48,13 +56,13 @@ def test a:number<span class="Delimiter">,</span> b:number <span class="Delimite map<string<span class="Delimiter">,</span> vector<recipe_ordinal> > Recipe_variants<span class="Delimiter">;</span> <span class="Delimiter">:(before "End One-time Setup")</span> put<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">,</span> vector<recipe_ordinal><span class="Delimiter">());</span> <span class="Comment">// since we manually added main to Recipe_ordinal</span> -<span class="Delimiter">:(before "Clear Other State For Recently_added_recipes")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> vector<recipe_ordinal> >::iterator p = Recipe_variants<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe_variants<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> Recently_added_recipes<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> p<span class="Delimiter">-></span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != Recently_added_recipes<span class="Delimiter">.</span>end<span class="Delimiter">())</span> - p<span class="Delimiter">-></span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// just leave a ghost</span> - <span class="Delimiter">}</span> -<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Globals")</span> +map<string<span class="Delimiter">,</span> vector<recipe_ordinal> > Recipe_variants_snapshot<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End save_snapshots")</span> +Recipe_variants_snapshot = Recipe_variants<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End restore_snapshots")</span> +Recipe_variants = Recipe_variants_snapshot<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Load Recipe Header(result)")</span> <span class="Comment">// there can only ever be one variant for main</span> @@ -81,7 +89,7 @@ put<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</spa <span class="Delimiter">:(code)</span> string matching_variant_name<span class="Delimiter">(</span><span class="Normal">const</span> recipe& rr<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> vector<recipe_ordinal>& variants = get_or_insert<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> rr<span class="Delimiter">.</span>name<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">const</span> recipe& candidate = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!all_reagents_match<span class="Delimiter">(</span>rr<span class="Delimiter">,</span> candidate<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -93,12 +101,12 @@ string matching_variant_name<span class="Delimiter">(</span><span class="Normal" <span class="Normal">bool</span> all_reagents_match<span class="Delimiter">(</span><span class="Normal">const</span> recipe& r1<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& r2<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>r2<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>r2<span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!deeply_equal_type_names<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> r2<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!deeply_equal_type_names<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> r2<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -130,7 +138,7 @@ Literal_type_names<span class="Delimiter">.</span>insert<span class="Delimiter"> <span class="Delimiter">}</span> string next_unused_recipe_name<span class="Delimiter">(</span><span class="Normal">const</span> string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> <span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> <span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> out << recipe_name << <span class="Constant">'_'</span> << i<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> out<span class="Delimiter">.</span>str<span class="Delimiter">()))</span> @@ -155,9 +163,9 @@ def test a:number<span class="Delimiter">,</span> b:number <span class="Delimite <span class="Comment">//: support recipe headers in a previous transform to fill in missing types</span> <span class="Delimiter">:(before "End check_or_set_invalid_types")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> check_or_set_invalid_types<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"recipe header ingredient"</span><span class="Delimiter">);</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> check_or_set_invalid_types<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"recipe header product"</span><span class="Delimiter">);</span> <span class="Comment">//: after filling in all missing types (because we'll be introducing 'blank' types in this transform in a later layer, for shape-shifting recipes)</span> @@ -177,7 +185,7 @@ list<call> resolve_stack<span class="Delimiter">;</span> <span class="Normal">void</span> resolve_ambiguous_calls<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe& caller_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- resolve ambiguous calls for recipe "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>non_ghost_size<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>name<span class="Delimiter">))</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -214,14 +222,14 @@ string best_variant<span class="Delimiter">(</span>instruction& inst<span cl <span class="Comment">// error messages</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>name<span class="Delimiter">)</span> >= MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// we currently don't check types for primitive variants</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"failed to find a matching call for '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"failed to find a matching call for '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span>list<call>::iterator p = <span class="Comment">/*</span><span class="Comment">skip</span><span class="Comment">*/</span>++resolve_stack<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != resolve_stack<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& specializer_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> p<span class="Delimiter">-></span>running_recipe<span class="Delimiter">);</span> <span class="Normal">const</span> instruction& specializer_inst = specializer_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>p<span class="Delimiter">-></span>running_step_index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>specializer_recipe<span class="Delimiter">.</span>name != <span class="Constant">"interactive"</span><span class="Delimiter">)</span> - raise << <span class="Constant">" (from '"</span> << to_string<span class="Delimiter">(</span>specializer_inst<span class="Delimiter">)</span> << <span class="Constant">"' in "</span> << specializer_recipe<span class="Delimiter">.</span>name << <span class="Constant">")</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">" (from '"</span> << to_original_string<span class="Delimiter">(</span>specializer_inst<span class="Delimiter">)</span> << <span class="Constant">"' in "</span> << specializer_recipe<span class="Delimiter">.</span>name << <span class="Constant">")</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Normal">else</span> - raise << <span class="Constant">" (from '"</span> << to_string<span class="Delimiter">(</span>specializer_inst<span class="Delimiter">)</span> << <span class="Constant">"')</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">" (from '"</span> << to_original_string<span class="Delimiter">(</span>specializer_inst<span class="Delimiter">)</span> << <span class="Constant">"')</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Comment">// One special-case to help with the rewrite_stash transform. (cross-layer)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>specializer_inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"stash_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction stash_inst<span class="Delimiter">;</span> @@ -240,7 +248,7 @@ string best_variant<span class="Delimiter">(</span>instruction& inst<span cl <span class="Comment">// phase 1</span> vector<recipe_ordinal> strictly_matching_variants<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<recipe_ordinal> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_header_reagents_strictly_match<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> @@ -250,13 +258,13 @@ vector<recipe_ordinal> strictly_matching_variants<span class="Delimiter">( <span class="Delimiter">}</span> <span class="Normal">bool</span> all_header_reagents_strictly_match<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: product "</span> << i << end<span class="Delimiter">();</span> @@ -269,7 +277,7 @@ vector<recipe_ordinal> strictly_matching_variants<span class="Delimiter">( <span class="Comment">// phase 3</span> vector<recipe_ordinal> strictly_matching_variants_except_literal_against_boolean<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<recipe_ordinal> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict except literals-against-booleans) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_header_reagents_strictly_match_except_literal_against_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> @@ -279,13 +287,13 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_b <span class="Delimiter">}</span> <span class="Normal">bool</span> all_header_reagents_strictly_match_except_literal_against_boolean<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match_except_literal_against_boolean<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match_except_literal_against_boolean<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: product "</span> << i << end<span class="Delimiter">();</span> @@ -298,7 +306,7 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_b <span class="Comment">// phase 4</span> vector<recipe_ordinal> matching_variants<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<recipe_ordinal> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_header_reagents_match<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> @@ -308,13 +316,13 @@ vector<recipe_ordinal> matching_variants<span class="Delimiter">(</span><s <span class="Delimiter">}</span> <span class="Normal">bool</span> all_header_reagents_match<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: product "</span> << i << end<span class="Delimiter">();</span> @@ -327,11 +335,11 @@ vector<recipe_ordinal> matching_variants<span class="Delimiter">(</span><s <span class="Comment">// tie-breaker for each phase</span> <span class="Normal">const</span> recipe& best_variant<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& candidates<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!candidates<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min_score = <span class="Constant">999</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min_index = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> min_score = <span class="Constant">999</span><span class="Delimiter">;</span> + <span class="Normal">int</span> min_index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& candidate = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> score = abs<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> + <span class="Normal">int</span> score = abs<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> + abs<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>score < <span class="Constant">999</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>score < min_score<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -342,16 +350,16 @@ vector<recipe_ordinal> matching_variants<span class="Delimiter">(</span><s <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>min_index<span class="Delimiter">));</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> non_ghost_size<span class="Delimiter">(</span>vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">int</span> non_ghost_size<span class="Delimiter">(</span>vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != -<span class="Constant">1</span><span class="Delimiter">)</span> ++result<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">bool</span> next_stash<span class="Delimiter">(</span><span class="Normal">const</span> call& c<span class="Delimiter">,</span> instruction* stash_inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& specializer_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> c<span class="Delimiter">.</span>running_recipe<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = c<span class="Delimiter">.</span>running_step_index<span class="Delimiter">;</span> + <span class="Normal">int</span> index = c<span class="Delimiter">.</span>running_step_index<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>++index<span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>specializer_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = specializer_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"stash"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -431,31 +439,31 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_first_use)</span> def main [ - x:address:shared:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type + <span class="Normal">x</span>:address:shared:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type test x ] container foo [ - x:number + <span class="Normal">x</span>:number ] def test a:address:shared:foo <span class="Delimiter">-></span> z:number [ local-scope load-ingredients - z:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset + <span class="Normal">z</span>:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset ] $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_second_use)</span> def main [ - x:address:shared:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type + <span class="Normal">x</span>:address:shared:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type test x ] def test a:address:shared:foo <span class="Delimiter">-></span> z:number [ local-scope load-ingredients - z:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset + <span class="Normal">z</span>:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset ] container foo [ - x:number + <span class="Normal">x</span>:number ] $error: <span class="Constant">0</span> @@ -475,7 +483,7 @@ def foo x:number <span class="Delimiter">-></span> y:number [ <span class="Special">% Hide_errors = true;</span> def main [ local-scope - x:character<span class="Special"> <- </span>copy <span class="Constant">10</span>/newline + <span class="Normal">x</span>:character<span class="Special"> <- </span>copy <span class="Constant">10</span>/newline <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo x ] def foo x:number <span class="Delimiter">-></span> y:number [ @@ -541,10 +549,10 @@ string header_label<span class="Delimiter">(</span>recipe_ordinal r<span class=" <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> ostringstream out<span class="Delimiter">;</span> out << <span class="Constant">"recipe "</span> << caller<span class="Delimiter">.</span>name<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">' '</span> << to_string<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" ->"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> out << <span class="Constant">' '</span> << to_string<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -575,7 +583,7 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario dispatch_errors_come_after_unknown_name_errors)</span> <span class="Special">% Hide_errors = true;</span> def main [ - y:number<span class="Special"> <- </span>foo x + <span class="Normal">y</span>:number<span class="Special"> <- </span>foo x ] def foo a:number <span class="Delimiter">-></span> b:number [ local-scope @@ -595,3 +603,4 @@ def foo a:boolean <span class="Delimiter">-></span> b:number [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/058shape_shifting_container.cc.html b/html/057shape_shifting_container.cc.html index d11c40fc..821572e9 100644 --- a/html/058shape_shifting_container.cc.html +++ b/html/057shape_shifting_container.cc.html @@ -2,35 +2,43 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 058shape_shifting_container.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 057shape_shifting_container.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } -.Comment { color: #9090ff; } .traceContains { color: #008000; } .Special { color: #c00000; } -.Constant { color: #00a0a0; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Comment { color: #9090ff; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">//:: Container definitions can contain 'type ingredients'</span> <span class="Delimiter">:(scenario size_of_shape_shifting_container)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:number<span class="Special"> <- </span>merge <span class="Constant">12</span><span class="Delimiter">,</span> <span class="Constant">13</span> @@ -45,8 +53,8 @@ def main [ <span class="Delimiter">:(scenario size_of_shape_shifting_container_2)</span> <span class="Comment"># multiple type ingredients</span> container foo:_a:_b [ - x:_a - y:_b + <span class="Normal">x</span>:_a + <span class="Normal">y</span>:_b ] def main [ <span class="Constant">1</span>:foo:number:boolean<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">1</span>/<span class="Constant">true</span> @@ -55,8 +63,8 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario size_of_shape_shifting_container_3)</span> container foo:_a:_b [ - x:_a - y:_b + <span class="Normal">x</span>:_a + <span class="Normal">y</span>:_b ] def main [ <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [abc] @@ -67,8 +75,8 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario size_of_shape_shifting_container_4)</span> container foo:_a:_b [ - x:_a - y:_b + <span class="Normal">x</span>:_a + <span class="Normal">y</span>:_b ] container bar:_a:_b [ <span class="Comment"># dilated element</span> @@ -108,7 +116,7 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> type_info& info = get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> next_type_ordinal = START_TYPE_INGREDIENTS<span class="Delimiter">;</span> + <span class="Normal">int</span> next_type_ordinal = START_TYPE_INGREDIENTS<span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> string curr = slurp_until<span class="Delimiter">(</span>in<span class="Delimiter">,</span> <span class="Constant">':'</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">.</span>find<span class="Delimiter">(</span>curr<span class="Delimiter">)</span> != info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> @@ -136,8 +144,8 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="Delimiter">:(scenario size_of_shape_shifting_exclusive_container)</span> exclusive-container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:number<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">34</span> @@ -155,16 +163,16 @@ $mem: <span class="Constant">7</span> <span class="Delimiter">:(code)</span> <span class="Comment">// shape-shifting version of size_of</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size_of_type_ingredient<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* element_template<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* rest_of_use<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> size_of_type_ingredient<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* element_template<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* rest_of_use<span class="Delimiter">)</span> <span class="Delimiter">{</span> type_tree* element_type = type_ingredient<span class="Delimiter">(</span>element_template<span class="Delimiter">,</span> rest_of_use<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!element_type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + <span class="Normal">int</span> result = size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> <span class="Normal">delete</span> element_type<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> type_tree* type_ingredient<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* element_template<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* rest_of_use<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> type_ingredient_index = element_template<span class="Delimiter">-></span>value - START_TYPE_INGREDIENTS<span class="Delimiter">;</span> + <span class="Normal">int</span> type_ingredient_index = element_template<span class="Delimiter">-></span>value - START_TYPE_INGREDIENTS<span class="Delimiter">;</span> <span class="Normal">const</span> type_tree* curr = rest_of_use<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>type_ingredient_index > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -181,8 +189,8 @@ type_tree* type_ingredient<span class="Delimiter">(</span><span class="Normal">c <span class="Delimiter">:(scenario get_on_shape_shifting_container)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:point<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span> @@ -193,7 +201,7 @@ def main [ <span class="Delimiter">:(before "End GET field Cases")</span> <span class="Normal">const</span> type_tree* type = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value >= START_TYPE_INGREDIENTS<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> + <span class="Normal">int</span> size = size_of_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!size<span class="Delimiter">)</span> raise << <span class="Constant">"illegal field type '"</span> << to_string<span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="Constant">"' seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> src += size<span class="Delimiter">;</span> @@ -202,8 +210,8 @@ def main [ <span class="Delimiter">:(scenario get_on_shape_shifting_container_2)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:point<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span> @@ -214,8 +222,8 @@ def main [ <span class="Delimiter">:(scenario get_on_shape_shifting_container_3)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:address:point<span class="Special"> <- </span>merge <span class="Constant">34</span>/unsafe<span class="Delimiter">,</span> <span class="Constant">48</span> @@ -225,12 +233,12 @@ def main [ <span class="Delimiter">:(scenario get_on_shape_shifting_container_inside_container)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] container bar [ - x:foo:point - y:number + <span class="Normal">x</span>:foo:point + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:bar<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span><span class="Delimiter">,</span> <span class="Constant">17</span> @@ -240,8 +248,8 @@ def main [ <span class="Delimiter">:(scenario get_on_complex_shape_shifting_container)</span> container foo:_a:_b [ - x:_a - y:_b + <span class="Normal">x</span>:_a + <span class="Normal">y</span>:_b ] def main [ <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [abc] @@ -266,6 +274,7 @@ def main [ <span class="Normal">bool</span> contains_type_ingredient<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value >= START_TYPE_INGREDIENTS<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + assert<span class="Delimiter">(</span>!is_type_ingredient_name<span class="Delimiter">(</span>type<span class="Delimiter">-></span>name<span class="Delimiter">));</span> <span class="Identifier">return</span> contains_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">)</span> || contains_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -280,7 +289,7 @@ def main [ replace_type_ingredients<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> callsite_type<span class="Delimiter">,</span> container_info<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>value < START_TYPE_INGREDIENTS<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> type_ingredient_index = element_type<span class="Delimiter">-></span>value-START_TYPE_INGREDIENTS<span class="Delimiter">;</span> + <span class="Normal">const</span> <span class="Normal">int</span> type_ingredient_index = element_type<span class="Delimiter">-></span>value-START_TYPE_INGREDIENTS<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_nth_type<span class="Delimiter">(</span>callsite_type<span class="Delimiter">,</span> type_ingredient_index<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << <span class="Constant">"illegal type "</span> << names_to_string<span class="Delimiter">(</span>callsite_type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -292,7 +301,7 @@ def main [ <span class="Normal">bool</span> zig_left = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_tree* curr = callsite_type<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < type_ingredient_index<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < type_ingredient_index<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr && curr<span class="Delimiter">-></span>left<span class="Delimiter">)</span> <span class="Delimiter">{</span> replacement = curr<span class="Delimiter">-></span>left<span class="Delimiter">;</span> @@ -326,7 +335,7 @@ def main [ <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">bool</span> final_type_ingredient<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> type_ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& container_info<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> final_type_ingredient<span class="Delimiter">(</span><span class="Normal">int</span> type_ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& container_info<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> type_ordinal>::const_iterator p = container_info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != container_info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -502,7 +511,7 @@ def main [ CHECK<span class="Delimiter">(</span>!element<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">bool</span> has_nth_type<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* base<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> n<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> has_nth_type<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* base<span class="Delimiter">,</span> <span class="Normal">int</span> n<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>n >= <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>base == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>n == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> @@ -512,8 +521,8 @@ def main [ <span class="Delimiter">:(scenario get_on_shape_shifting_container_error)</span> <span class="Special">% Hide_errors = true;</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">10</span>:foo:point<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span> @@ -525,8 +534,8 @@ def main [ <span class="Delimiter">:(scenario get_address_on_shape_shifting_container)</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def main [ <span class="Constant">10</span>:foo:point<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span> @@ -537,7 +546,7 @@ def main [ <span class="Delimiter">:(before "End GET_ADDRESS field Cases")</span> <span class="Normal">const</span> type_tree* type = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value >= START_TYPE_INGREDIENTS<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = size_of_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> + <span class="Normal">int</span> size = size_of_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!size<span class="Delimiter">)</span> raise << <span class="Constant">"illegal type '"</span> << to_string<span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="Constant">"' seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> result += size<span class="Delimiter">;</span> @@ -548,12 +557,12 @@ def main [ <span class="Delimiter">:(scenario merge_check_shape_shifting_container_containing_exclusive_container)</span> container foo:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] exclusive-container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">34</span> @@ -566,12 +575,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_shape_shifting_container_containing_exclusive_container_2)</span> <span class="Special">% Hide_errors = true;</span> container foo:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] exclusive-container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> @@ -580,12 +589,12 @@ def main [ <span class="Delimiter">:(scenario merge_check_shape_shifting_exclusive_container_containing_container)</span> exclusive-container foo:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">23</span><span class="Delimiter">,</span> <span class="Constant">34</span> @@ -597,12 +606,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_shape_shifting_exclusive_container_containing_container_2)</span> exclusive-container foo:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">23</span> @@ -612,12 +621,12 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario merge_check_shape_shifting_exclusive_container_containing_container_3)</span> <span class="Special">% Hide_errors = true;</span> exclusive-container foo:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">23</span> @@ -633,3 +642,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/059shape_shifting_recipe.cc.html b/html/058shape_shifting_recipe.cc.html index 52b5ec4b..4b20f023 100644 --- a/html/059shape_shifting_recipe.cc.html +++ b/html/058shape_shifting_recipe.cc.html @@ -2,31 +2,39 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 059shape_shifting_recipe.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 058shape_shifting_recipe.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Todo { color: #000000; background-color: #ffff00; } -.cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .traceContains { color: #008000; } -.Comment { color: #9090ff; } +.cSpecial { color: #008000; } .Special { color: #c00000; } -.Constant { color: #00a0a0; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } +.Identifier { color: #fcb165; } +.Comment { color: #9090ff; } +.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">//:: Like container definitions, recipes too can contain type parameters.</span> <span class="Delimiter">:(scenario shape_shifting_recipe)</span> @@ -70,23 +78,6 @@ def foo a:_t <span class="Delimiter">-></span> result:_t [ <span class="Delimiter">:(before "End Matching Types For Literal(to)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient_name<span class="Delimiter">(</span>to<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span class="Comment">//: We'll be creating recipes without loading them from anywhere by</span> -<span class="Comment">//: *specializing* existing recipes.</span> -<span class="Comment">//:</span> -<span class="Comment">//: Keep track of these new recipes in a separate variable in addition to</span> -<span class="Comment">//: Recently_added_recipes, so that edit/ can clear them before reloading to</span> -<span class="Comment">//: regenerate errors.</span> -<span class="Delimiter">:(before "End Globals")</span> -vector<recipe_ordinal> Recently_added_shape_shifting_recipes<span class="Delimiter">;</span> -<span class="Delimiter">:(before "End Setup")</span> -Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - -<span class="Comment">//: make sure we don't clear any of these recipes when we start running tests</span> -<span class="Delimiter">:(before "End Loading .mu Files")</span> -Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -Recently_added_types<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Comment">//: save original name of specialized recipes</span> <span class="Delimiter">:(before "End recipe Fields")</span> string original_name<span class="Delimiter">;</span> @@ -106,7 +97,7 @@ candidates = strictly_matching_shape_shifting_variants<span class="Delimiter">(< <span class="Comment">// perform all transforms on the new specialization</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!variant<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"transforming new specialization: "</span> << variant<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Delimiter">(</span>*Transform<span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">))(</span>new_recipe_ordinal<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -130,7 +121,7 @@ candidates = strictly_matching_shape_shifting_variants<span class="Delimiter">(< <span class="Comment">// phase 2 of static dispatch</span> vector<recipe_ordinal> strictly_matching_shape_shifting_variants<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<recipe_ordinal> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!any_type_ingredient_in_header<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_concrete_header_reagents_strictly_match<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> @@ -148,13 +139,13 @@ vector<recipe_ordinal> strictly_matching_shape_shifting_variants<span clas trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"too few products"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!concrete_type_names_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"concrete-type match failed: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!concrete_type_names_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: product "</span> << i << end<span class="Delimiter">();</span> @@ -168,21 +159,21 @@ vector<recipe_ordinal> strictly_matching_shape_shifting_variants<span clas recipe_ordinal best_shape_shifting_variant<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& candidates<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!candidates<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Comment">// primary score</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> max_score = -<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> score = number_of_concrete_type_names<span class="Delimiter">(</span>candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + <span class="Normal">int</span> max_score = -<span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> score = number_of_concrete_type_names<span class="Delimiter">(</span>candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>score > -<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>score > max_score<span class="Delimiter">)</span> max_score = score<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// break any ties at max_score by a secondary score</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min_score2 = <span class="Constant">999</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> best_index = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> score1 = number_of_concrete_type_names<span class="Delimiter">(</span>candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + <span class="Normal">int</span> min_score2 = <span class="Constant">999</span><span class="Delimiter">;</span> + <span class="Normal">int</span> best_index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>candidates<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> score1 = number_of_concrete_type_names<span class="Delimiter">(</span>candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>score1 <= max_score<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>score1 != max_score<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">const</span> recipe& candidate = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> candidates<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> score2 = <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> + <span class="Normal">int</span> score2 = <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> + <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>candidate<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>score2 < <span class="Constant">999</span><span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>score2 < min_score2<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -195,11 +186,11 @@ recipe_ordinal best_shape_shifting_variant<span class="Delimiter">(</span><span <span class="Normal">bool</span> any_type_ingredient_in_header<span class="Delimiter">(</span>recipe_ordinal variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient_name<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient_name<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -212,23 +203,23 @@ recipe_ordinal best_shape_shifting_variant<span class="Delimiter">(</span><span <span class="Identifier">return</span> concrete_type_names_strictly_match<span class="Delimiter">(</span>to<span class="Delimiter">.</span>type<span class="Delimiter">,</span> from<span class="Delimiter">.</span>type<span class="Delimiter">,</span> from<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result += number_of_concrete_type_names<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> result += number_of_concrete_type_names<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> number_of_concrete_type_names<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> number_of_concrete_type_names<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>name<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && !is_type_ingredient_name<span class="Delimiter">(</span>type<span class="Delimiter">-></span>name<span class="Delimiter">))</span> result++<span class="Delimiter">;</span> result += number_of_concrete_type_names<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">);</span> @@ -272,8 +263,6 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Comment">// make a copy</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">));</span> - Recently_added_recipes<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_recipe_ordinal<span class="Delimiter">);</span> - Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_recipe_ordinal<span class="Delimiter">);</span> put<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">));</span> recipe& new_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">);</span> new_recipe<span class="Delimiter">.</span>name = new_name<span class="Delimiter">;</span> @@ -298,16 +287,16 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Normal">void</span> compute_type_names<span class="Delimiter">(</span>recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"compute type names: "</span> << variant<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> map<string<span class="Delimiter">,</span> type_tree*> type_names<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = variant<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">" instruction: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -330,8 +319,8 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Delimiter">}</span> <span class="Normal">void</span> compute_type_ingredient_mappings<span class="Delimiter">(</span><span class="Normal">const</span> recipe& exemplar<span class="Delimiter">,</span> <span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree*>& mappings<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller_recipe<span class="Delimiter">,</span> <span class="Normal">bool</span>* error<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> limit = min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>exemplar<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < limit<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> limit = min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>exemplar<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < limit<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> reagent& exemplar_reagent = exemplar<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> reagent ingredient = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>ingredient<span class="Delimiter">);</span> @@ -339,15 +328,16 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla accumulate_type_ingredients<span class="Delimiter">(</span>exemplar_reagent<span class="Delimiter">,</span> ingredient<span class="Delimiter">,</span> mappings<span class="Delimiter">,</span> exemplar<span class="Delimiter">,</span> inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">,</span> error<span class="Delimiter">);</span> <span class="Delimiter">}</span> limit = min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>exemplar<span class="Delimiter">.</span>products<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < limit<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < limit<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> reagent& exemplar_reagent = exemplar<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> reagent product = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>product<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> canonize_type<span class="Delimiter">(</span>product<span class="Delimiter">);</span> accumulate_type_ingredients<span class="Delimiter">(</span>exemplar_reagent<span class="Delimiter">,</span> product<span class="Delimiter">,</span> mappings<span class="Delimiter">,</span> exemplar<span class="Delimiter">,</span> inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">,</span> error<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">inline</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">inline</span> <span class="Normal">int</span> min<span class="Delimiter">(</span><span class="Normal">int</span> a<span class="Delimiter">,</span> <span class="Normal">int</span> b<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> <span class="Delimiter">(</span>a < b<span class="Delimiter">)</span> ? a : b<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -360,7 +350,8 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Normal">if</span> <span class="Delimiter">(</span>!exemplar_type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!refinement_type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// todo: make this smarter; only flag an error if exemplar_type contains some *new* type ingredient</span> - raise << maybe<span class="Delimiter">(</span>exemplar<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"missing type ingredient in "</span> << exemplar_reagent<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>exemplar<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"missing type ingredient for "</span> << exemplar_reagent<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">" (called from '"</span> << to_original_string<span class="Delimiter">(</span>call_instruction<span class="Delimiter">)</span> << <span class="Constant">"')</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_type_ingredient_name<span class="Delimiter">(</span>exemplar_type<span class="Delimiter">-></span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -379,7 +370,7 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!deeply_equal_type_names<span class="Delimiter">(</span>get<span class="Delimiter">(</span>mappings<span class="Delimiter">,</span> exemplar_type<span class="Delimiter">-></span>name<span class="Delimiter">),</span> curr_refinement_type<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"no call found for '"</span> << to_string<span class="Delimiter">(</span>call_instruction<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"no call found for '"</span> << to_original_string<span class="Delimiter">(</span>call_instruction<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> *error = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Normal">delete</span> curr_refinement_type<span class="Delimiter">;</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -401,18 +392,18 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Comment">// update its header</span> <span class="Normal">if</span> <span class="Delimiter">(</span>mappings<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"replacing in recipe header ingredients"</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> replace_type_ingredients<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> mappings<span class="Delimiter">,</span> new_recipe<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"replacing in recipe header products"</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> replace_type_ingredients<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> mappings<span class="Delimiter">,</span> new_recipe<span class="Delimiter">);</span> <span class="Comment">// update its body</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"replacing in instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> replace_type_ingredients<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">),</span> mappings<span class="Delimiter">,</span> new_recipe<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> replace_type_ingredients<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">),</span> mappings<span class="Delimiter">,</span> new_recipe<span class="Delimiter">);</span> <span class="Comment">// special-case for new: replace type ingredient in first ingredient *value*</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"new"</span> && inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>type<span class="Delimiter">-></span>name != <span class="Constant">"literal-string"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -492,13 +483,8 @@ type_tree* parse_type_tree<span class="Delimiter">(</span>istream& in<span c in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="Constant">'('</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - string type_name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">))</span> - put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> - type_tree* result = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">));</span> - <span class="Identifier">return</span> result<span class="Delimiter">;</span> - <span class="Delimiter">}</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="Constant">'('</span><span class="Delimiter">)</span> + <span class="Identifier">return</span> <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>next_word<span class="Delimiter">(</span>in<span class="Delimiter">),</span> <span class="Constant">0</span><span class="Delimiter">);</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Comment">// skip '('</span> type_tree* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> type_tree** curr = &result<span class="Delimiter">;</span> @@ -508,14 +494,8 @@ type_tree* parse_type_tree<span class="Delimiter">(</span>istream& in<span c skip_whitespace_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'('</span><span class="Delimiter">)</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>left = parse_type_tree<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - <span class="Normal">else</span> <span class="Delimiter">{</span> + <span class="Normal">else</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!is_type_ingredient_name<span class="Delimiter">((</span>*curr<span class="Delimiter">)-></span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>name<span class="Delimiter">))</span> - put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>name<span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> - <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>value = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>name<span class="Delimiter">);</span> - <span class="Delimiter">}</span> - <span class="Delimiter">}</span> curr = &<span class="Delimiter">(</span>*curr<span class="Delimiter">)-></span>right<span class="Delimiter">;</span> <span class="Delimiter">}</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Comment">// skip ')'</span> @@ -545,15 +525,15 @@ string inspect<span class="Delimiter">(</span><span class="Normal">const</span> <span class="Delimiter">}</span> <span class="Normal">void</span> ensure_all_concrete_types<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">const</span><span class="Comment">*/</span> recipe& new_recipe<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& exemplar<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> ensure_all_concrete_types<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> exemplar<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> ensure_all_concrete_types<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> exemplar<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = new_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> ensure_all_concrete_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">),</span> exemplar<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> ensure_all_concrete_types<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">),</span> exemplar<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -602,19 +582,19 @@ def bar a:foo:_t <span class="Delimiter">-></span> result:_t [ result<span class="Special"> <- </span>get a<span class="Delimiter">,</span> x:offset ] container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] <span class="traceContains">+mem: storing 14 in location 20</span> <span class="traceContains">+mem: storing 15 in location 21</span> <span class="Delimiter">:(scenario shape_shifting_recipe_nested)</span> container c:_a:_b [ - a:_a - b:_b + <span class="Normal">a</span>:_a + <span class="Normal">b</span>:_b ] def main [ - s:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [abc] + <span class="Normal">s</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [abc] <span class="Delimiter">{</span>x: <span class="Delimiter">(</span>c <span class="Delimiter">(</span>address shared array character<span class="Delimiter">)</span> number<span class="Delimiter">)}</span><span class="Special"> <- </span>merge s<span class="Delimiter">,</span> <span class="Constant">34</span> foo x ] @@ -631,12 +611,12 @@ def main [ def bar a:foo:_t <span class="Delimiter">-></span> result:_t [ local-scope load-ingredients - x:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> result<span class="Special"> <- </span>get a<span class="Delimiter">,</span> x:offset <span class="Comment"># shouldn't collide with other variable</span> ] container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] <span class="traceContains">+mem: storing 14 in location 20</span> <span class="traceContains">+mem: storing 15 in location 21</span> @@ -656,8 +636,8 @@ def main [ <span class="Constant">11</span>:foo:point<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:foo:point ] container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] def bar x:number <span class="Delimiter">-></span> result:address:shared:foo:_t [ local-scope @@ -682,13 +662,53 @@ def bar x:number <span class="Delimiter">-></span> result:address:shared:foo: ] <span class="Comment"># container defined after use</span> container foo:_t [ - x:_t - y:number + <span class="Normal">x</span>:_t + <span class="Normal">y</span>:number ] <span class="traceContains">+mem: storing 0 in location 11</span> <span class="traceContains">+mem: storing 0 in location 12</span> <span class="traceContains">+mem: storing 0 in location 13</span> +<span class="Delimiter">:(scenario shape_shifting_recipe_called_with_dummy)</span> +def main [ + _<span class="Special"> <- </span>bar <span class="Constant">34</span> +] +def bar x:_t <span class="Delimiter">-></span> result:address:shared:_t [ + local-scope + load-ingredients + result<span class="Special"> <- </span>copy <span class="Constant">0</span> +] +$error: <span class="Constant">0</span> + +<span class="Delimiter">:(code)</span> +<span class="Comment">// this one needs a little more fine-grained control</span> +<span class="Normal">void</span> test_shape_shifting_new_ingredient_does_not_pollute_global_namespace<span class="Delimiter">()</span> <span class="Delimiter">{</span> + Trace_file = <span class="Constant">"shape_shifting_new_ingredient_does_not_pollute_global_namespace"</span><span class="Delimiter">;</span> + + <span class="Comment">// if you specialize a shape-shifting recipe that allocates a type-ingredient..</span> + transform<span class="Delimiter">(</span><span class="Constant">"def barz x:_elem [</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" load-ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" y:address:shared:number <- new _elem:type</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"def fooz [</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" barz 34</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> + <span class="Comment">// ..and if you then try to load a new shape-shifting container with that</span> + <span class="Comment">// type-ingredient</span> + run<span class="Delimiter">(</span><span class="Constant">"container foo:_elem [</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" x:_elem</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" y:number</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> + <span class="Comment">// then it should work as usual</span> + reagent callsite<span class="Delimiter">(</span><span class="Constant">"x:foo:point"</span><span class="Delimiter">);</span> + reagent element = element_type<span class="Delimiter">(</span>callsite<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>element<span class="Delimiter">.</span>name<span class="Delimiter">,</span> <span class="Constant">"x"</span><span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name<span class="Delimiter">,</span> <span class="Constant">"point"</span><span class="Delimiter">);</span> + CHECK<span class="Delimiter">(</span>!element<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + <span class="Delimiter">:(scenario shape_shifting_recipe_supports_compound_types)</span> def main [ <span class="Constant">1</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type @@ -707,8 +727,8 @@ def bar a:_t <span class="Delimiter">-></span> result:_t [ <span class="Delimiter">:(scenario shape_shifting_recipe_error)</span> <span class="Special">% Hide_errors = true;</span> def main [ - a:number<span class="Special"> <- </span>copy <span class="Constant">3</span> - b:address:shared:number<span class="Special"> <- </span>foo a + <span class="Normal">a</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span> + <span class="Normal">b</span>:address:shared:number<span class="Special"> <- </span>foo a ] def foo a:_t <span class="Delimiter">-></span> b:_t [ load-ingredients @@ -722,7 +742,7 @@ def main [ ] def foo [ local-scope - x:number<span class="Special"> <- </span>next-ingredient <span class="Comment"># ensure no header</span> + <span class="Normal">x</span>:number<span class="Special"> <- </span>next-ingredient <span class="Comment"># ensure no header</span> <span class="Constant">1</span>:number/<span class="Special">raw <- </span>bar x <span class="Comment"># call a shape-shifting recipe</span> ] def bar x:_elem <span class="Delimiter">-></span> y:_elem [ @@ -801,8 +821,8 @@ def foo x:_elem<span class="Delimiter">,</span> y:_elem [ <span class="Delimiter">:(scenario multiple_shape_shifting_variants)</span> <span class="Comment"># try to call two different shape-shifting recipes with the same name</span> def main [ - e1:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> - e2:d2:number<span class="Special"> <- </span>merge <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">5</span> + <span class="Normal">e1</span>:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> + <span class="Normal">e2</span>:d2:number<span class="Special"> <- </span>merge <span class="Constant">4</span><span class="Delimiter">,</span> <span class="Constant">5</span> <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo e1 <span class="Constant">2</span>:number/<span class="Special">raw <- </span>foo e2 ] @@ -819,11 +839,11 @@ def foo a:d2:_elem <span class="Delimiter">-></span> b:number [ ] <span class="Comment"># the shape-shifting containers they use</span> container d1:_elem [ - x:_elem + <span class="Normal">x</span>:_elem ] container d2:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] <span class="traceContains">+mem: storing 34 in location 1</span> <span class="traceContains">+mem: storing 35 in location 2</span> @@ -831,8 +851,8 @@ container d2:_elem [ <span class="Delimiter">:(scenario multiple_shape_shifting_variants_2)</span> <span class="Comment"># static dispatch between shape-shifting variants, _including pointer lookups_</span> def main [ - e1:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> - e2:address:shared:d2:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>d2 number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> + <span class="Normal">e1</span>:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> + <span class="Normal">e2</span>:address:shared:d2:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>d2 number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo e1 <span class="Constant">2</span>:number/<span class="Special">raw <- </span>foo *e2 <span class="Comment"># different from previous scenario</span> ] @@ -847,11 +867,11 @@ def foo a:d2:_elem <span class="Delimiter">-></span> b:number [ <span class="Identifier">return</span> <span class="Constant">35</span> ] container d1:_elem [ - x:_elem + <span class="Normal">x</span>:_elem ] container d2:_elem [ - x:number - y:_elem + <span class="Normal">x</span>:number + <span class="Normal">y</span>:_elem ] <span class="traceContains">+mem: storing 34 in location 1</span> <span class="traceContains">+mem: storing 35 in location 2</span> @@ -859,7 +879,7 @@ container d2:_elem [ <span class="Delimiter">:(scenario missing_type_in_shape_shifting_recipe)</span> <span class="Special">% Hide_errors = true;</span> def main [ - a:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> + <span class="Normal">a</span>:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> foo a ] def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ @@ -869,7 +889,7 @@ def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ <span class="Identifier">return</span> <span class="Constant">34</span> ] container d1:_elem [ - x:_elem + <span class="Normal">x</span>:_elem ] <span class="traceContains">+error: foo: unknown type for e (check the name for typos)</span> <span class="traceContains">+error: specializing foo: missing type for e</span> @@ -878,7 +898,7 @@ container d1:_elem [ <span class="Delimiter">:(scenario missing_type_in_shape_shifting_recipe_2)</span> <span class="Special">% Hide_errors = true;</span> def main [ - a:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> + <span class="Normal">a</span>:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> foo a ] def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ @@ -888,7 +908,7 @@ def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ <span class="Identifier">return</span> <span class="Constant">34</span> ] container d1:_elem [ - x:_elem + <span class="Normal">x</span>:_elem ] <span class="traceContains">+error: foo: unknown type for e (check the name for typos)</span> <span class="traceContains">+error: specializing foo: missing type for e</span> @@ -905,7 +925,7 @@ def foo x:_elem <span class="Delimiter">-></span> y:number [ load-ingredients <span class="Delimiter">{</span> <span class="Identifier">break</span> - y:number<span class="Special"> <- </span>foo x + <span class="Normal">y</span>:number<span class="Special"> <- </span>foo x <span class="Delimiter">}</span> <span class="Identifier">return</span> y ] @@ -1004,3 +1024,4 @@ def foo x:address:shared:_elem <span class="Delimiter">-></span> y:number [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/060immutable.cc.html b/html/060immutable.cc.html index 3c476b3c..508306b3 100644 --- a/html/060immutable.cc.html +++ b/html/060immutable.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 060immutable.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Todo { color: #000000; background-color: #ffff00; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Addresses passed into of a recipe are meant to be immutable unless they're</span> <span class="Comment">//: also products. This layer will start enforcing this check.</span> <span class="Comment">//:</span> @@ -33,13 +41,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(scenario can_modify_value_ingredients)</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type foo *p ] def foo p:point [ local-scope load-ingredients - x:address:number<span class="Special"> <- </span>get-address p<span class="Delimiter">,</span> x:offset + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address p<span class="Delimiter">,</span> x:offset *x<span class="Special"> <- </span>copy <span class="Constant">34</span> ] $error: <span class="Constant">0</span> @@ -47,13 +55,13 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario can_modify_ingredients_that_are_also_products)</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type p<span class="Special"> <- </span>foo p ] def foo p:address:shared:point <span class="Delimiter">-></span> p:address:shared:point [ local-scope load-ingredients - x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset *x<span class="Special"> <- </span>copy <span class="Constant">34</span> ] $error: <span class="Constant">0</span> @@ -61,19 +69,19 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario ignore_literal_ingredients_for_immutability_checks)</span> def main [ local-scope - p:address:shared:d1<span class="Special"> <- </span><span class="Normal">new</span> d1:type - q:number<span class="Special"> <- </span>foo p + <span class="Normal">p</span>:address:shared:d1<span class="Special"> <- </span><span class="Normal">new</span> d1:type + <span class="Normal">q</span>:number<span class="Special"> <- </span>foo p ] def foo p:address:shared:d1 <span class="Delimiter">-></span> q:number [ local-scope load-ingredients - x:address:shared:d1<span class="Special"> <- </span><span class="Normal">new</span> d1:type - y:address:number<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> p:offset <span class="Comment"># ignore this 'p'</span> + <span class="Normal">x</span>:address:shared:d1<span class="Special"> <- </span><span class="Normal">new</span> d1:type + <span class="Normal">y</span>:address:number<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> p:offset <span class="Comment"># ignore this 'p'</span> q<span class="Special"> <- </span>copy <span class="Constant">34</span> ] container d1 [ - p:number - q:number + <span class="Normal">p</span>:number + <span class="Normal">q</span>:number ] $error: <span class="Constant">0</span> @@ -81,7 +89,7 @@ $error: <span class="Constant">0</span> <span class="Special">% Hide_errors = true;</span> def main [ local-scope - x:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Normal">x</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type foo x ] def foo x:address:shared:number [ @@ -95,13 +103,13 @@ def foo x:address:shared:number [ <span class="Special">% Hide_errors = true;</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type foo p ] def foo p:address:shared:point [ local-scope load-ingredients - x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset *x<span class="Special"> <- </span>copy <span class="Constant">34</span> ] <span class="traceContains">+error: foo: cannot modify ingredient p after instruction 'x:address:number <- get-address *p, x:offset' because it's not also a product of foo</span> @@ -110,7 +118,7 @@ def foo p:address:shared:point [ <span class="Special">% Hide_errors = true;</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type foo p ] def foo p:address:shared:point [ @@ -121,7 +129,7 @@ def foo p:address:shared:point [ def bar p:address:shared:point <span class="Delimiter">-></span> p:address:shared:point [ local-scope load-ingredients - x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset *x<span class="Special"> <- </span>copy <span class="Constant">34</span> ] <span class="traceContains">+error: foo: cannot modify ingredient p at instruction 'bar p' because it's not also a product of foo</span> @@ -130,35 +138,35 @@ def bar p:address:shared:point <span class="Delimiter">-></span> p:address:sh <span class="Special">% Hide_errors = true;</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type foo p ] def foo p:address:shared:point [ local-scope load-ingredients - q:address:shared:point<span class="Special"> <- </span>copy p - x:address:number<span class="Special"> <- </span>get-address *q<span class="Delimiter">,</span> x:offset + <span class="Normal">q</span>:address:shared:point<span class="Special"> <- </span>copy p + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address *q<span class="Delimiter">,</span> x:offset ] <span class="traceContains">+error: foo: cannot modify q after instruction 'x:address:number <- get-address *q, x:offset' because that would modify ingredient p which is not also a product of foo</span> <span class="Delimiter">:(scenario can_modify_copies_of_mutable_ingredients)</span> def main [ local-scope - p:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type + <span class="Normal">p</span>:address:shared:point<span class="Special"> <- </span><span class="Normal">new</span> point:type foo p ] def foo p:address:shared:point <span class="Delimiter">-></span> p:address:shared:point [ local-scope load-ingredients - q:address:shared:point<span class="Special"> <- </span>copy p - x:address:number<span class="Special"> <- </span>get-address *q<span class="Delimiter">,</span> x:offset + <span class="Normal">q</span>:address:shared:point<span class="Special"> <- </span>copy p + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>get-address *q<span class="Delimiter">,</span> x:offset ] $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients)</span> <span class="Special">% Hide_errors = true;</span> container foo [ - x:address:shared:array:number <span class="Comment"># contains an address</span> + <span class="Normal">x</span>:address:shared:array:number <span class="Comment"># contains an address</span> ] def main [ <span class="Comment"># don't run anything</span> @@ -166,15 +174,15 @@ def main [ def foo a:address:shared:foo [ local-scope load-ingredients - x:address:shared:array:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset <span class="Comment"># just a regular get of the container</span> - y:address:number<span class="Special"> <- </span>index-address *x<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># but then index-address on the result</span> + <span class="Normal">x</span>:address:shared:array:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset <span class="Comment"># just a regular get of the container</span> + <span class="Normal">y</span>:address:number<span class="Special"> <- </span>index-address *x<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># but then index-address on the result</span> *y<span class="Special"> <- </span>copy <span class="Constant">34</span> ] <span class="traceContains">+error: foo: cannot modify x after instruction 'y:address:number <- index-address *x, 0' because that would modify ingredient a which is not also a product of foo</span> <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_2)</span> container foo [ - x:address:shared:array:number <span class="Comment"># contains an address</span> + <span class="Normal">x</span>:address:shared:array:number <span class="Comment"># contains an address</span> ] def main [ <span class="Comment"># don't run anything</span> @@ -182,9 +190,9 @@ def main [ def foo a:address:shared:foo [ local-scope load-ingredients - b:foo<span class="Special"> <- </span>merge <span class="Constant">0</span> <span class="Comment"># completely unrelated to 'a'</span> - x:address:shared:array:number<span class="Special"> <- </span>get b<span class="Delimiter">,</span> x:offset <span class="Comment"># just a regular get of the container</span> - y:address:number<span class="Special"> <- </span>index-address *x<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># but then index-address on the result</span> + <span class="Normal">b</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span> <span class="Comment"># completely unrelated to 'a'</span> + <span class="Normal">x</span>:address:shared:array:number<span class="Special"> <- </span>get b<span class="Delimiter">,</span> x:offset <span class="Comment"># just a regular get of the container</span> + <span class="Normal">y</span>:address:number<span class="Special"> <- </span>index-address *x<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># but then index-address on the result</span> *y<span class="Special"> <- </span>copy <span class="Constant">34</span> ] $error: <span class="Constant">0</span> @@ -192,7 +200,7 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_3)</span> <span class="Special">% Hide_errors = true;</span> container foo [ - x:number + <span class="Normal">x</span>:number ] def main [ <span class="Comment"># don't run anything</span> @@ -200,7 +208,7 @@ def main [ def foo a:address:shared:array:address:number [ local-scope load-ingredients - x:address:number<span class="Special"> <- </span>index *a<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># just a regular index of the array</span> + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>index *a<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># just a regular index of the array</span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># but then modify the result</span> ] <span class="Comment"># +error: foo: cannot modify x in instruction '*x <- copy 34' because that would modify ingredient a which is not also a product of foo</span> @@ -208,7 +216,7 @@ def foo a:address:shared:array:address:number [ <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_4)</span> container foo [ - x:address:shared:array:number <span class="Comment"># contains an address</span> + <span class="Normal">x</span>:address:shared:array:number <span class="Comment"># contains an address</span> ] def main [ <span class="Comment"># don't run anything</span> @@ -216,25 +224,25 @@ def main [ def foo a:address:shared:array:address:number [ local-scope load-ingredients - b:address:shared:array:address:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> <span class="Comment"># completely unrelated to 'a'</span> - x:address:number<span class="Special"> <- </span>index *b<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># just a regular index of the array</span> + <span class="Normal">b</span>:address:shared:array:address:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> <span class="Comment"># completely unrelated to 'a'</span> + <span class="Normal">x</span>:address:number<span class="Special"> <- </span>index *b<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># just a regular index of the array</span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># but then modify the result</span> ] $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario can_traverse_immutable_ingredients)</span> container test-list [ - next:address:shared:test-list + <span class="Normal">next</span>:address:shared:test-list ] def main [ local-scope - p:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type + <span class="Normal">p</span>:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type foo p ] def foo p:address:shared:test-list [ local-scope load-ingredients - p2:address:shared:test-list<span class="Special"> <- </span>bar p + <span class="Normal">p2</span>:address:shared:test-list<span class="Special"> <- </span>bar p ] def bar x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list [ local-scope @@ -245,7 +253,7 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario handle_optional_ingredients_in_immutability_checks)</span> def main [ - k:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Normal">k</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type test k ] <span class="Comment"># recipe taking an immutable address ingredient</span> @@ -258,20 +266,20 @@ def test k:address:shared:number [ def foo <span class="Delimiter">-></span> [ local-scope load-ingredients - k:address:shared:number<span class="Delimiter">,</span> found?:boolean<span class="Special"> <- </span>next-ingredient + <span class="Normal">k</span>:address:shared:number<span class="Delimiter">,</span> found?:boolean<span class="Special"> <- </span>next-ingredient ] $error: <span class="Constant">0</span> <span class="Comment">//: when checking for immutable ingredients, remember to take space into account</span> <span class="Delimiter">:(scenario check_space_of_reagents_in_immutability_checks)</span> def main [ - a:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span>-closure - b:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Normal">a</span>:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span>-closure + <span class="Normal">b</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type run-closure b:address:shared:number<span class="Delimiter">,</span> a:address:shared:array:location ] def <span class="Normal">new</span>-closure [ <span class="Normal">new</span>-<span class="Normal">default</span>-space - x:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Normal">x</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Identifier">return</span> <span class="Normal">default</span>-space ] def run-closure x:address:shared:number<span class="Delimiter">,</span> s:address:shared:array:location [ @@ -294,14 +302,14 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check mutability of ingredients in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip check for old-style recipes calling next-ingredient directly</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> reagent& current_ingredient = caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_address<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// will be copied</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_present_in_products<span class="Delimiter">(</span>caller<span class="Delimiter">,</span> current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not expected to be immutable</span> <span class="Comment">// End Immutable Ingredients Special-cases</span> set<reagent> immutable_vars<span class="Delimiter">;</span> immutable_vars<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> check_immutable_ingredient_in_instruction<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">,</span> current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">,</span> caller<span class="Delimiter">);</span> update_aliases<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">);</span> @@ -310,12 +318,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Normal">void</span> update_aliases<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">)</span> <span class="Delimiter">{</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> + set<<span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// primitive recipe</span> <span class="Normal">switch</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">case</span> COPY: - <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> current_ingredient_and_aliases<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Normal">case</span> GET: @@ -331,23 +339,23 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span class="Comment">// defined recipe</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> contained_in_product_indices = scan_contained_in_product_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_indices<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = contained_in_product_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != contained_in_product_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + set<<span class="Normal">int</span>> contained_in_product_indices = scan_contained_in_product_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_indices<span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = contained_in_product_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != contained_in_product_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> current_ingredient_and_aliases<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> scan_contained_in_product_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>& ingredient_indices<span class="Delimiter">)</span> <span class="Delimiter">{</span> +set<<span class="Normal">int</span>> scan_contained_in_product_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<<span class="Normal">int</span>>& ingredient_indices<span class="Delimiter">)</span> <span class="Delimiter">{</span> set<reagent> selected_ingredients<span class="Delimiter">;</span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p >= SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// optional immutable ingredient</span> selected_ingredients<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">));</span> <span class="Delimiter">}</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + set<<span class="Normal">int</span>> result<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> reagent& current_product = callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Comment">// </span><span class="Todo">TODO</span> <span class="Normal">const</span> string_tree* contained_in_name = property<span class="Delimiter">(</span>current_product<span class="Delimiter">,</span> <span class="Constant">"contained-in"</span><span class="Delimiter">);</span> @@ -361,18 +369,18 @@ set<<span class="Normal">long</span> <span class="Normal">long</span> <span c <span class="Delimiter">:(scenario immutability_infects_contained_in_variables)</span> <span class="Special">% Hide_errors = true;</span> container test-list [ - next:address:shared:test-list + <span class="Normal">next</span>:address:shared:test-list ] def main [ local-scope - p:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type + <span class="Normal">p</span>:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type foo p ] def foo p:address:shared:test-list [ <span class="Comment"># p is immutable</span> local-scope load-ingredients - p2:address:shared:test-list<span class="Special"> <- </span>test-next p <span class="Comment"># p2 is immutable</span> - p3:address:address:shared:test-list<span class="Special"> <- </span>get-address *p2<span class="Delimiter">,</span> next:offset <span class="Comment"># signal modification of p2</span> + <span class="Normal">p2</span>:address:shared:test-list<span class="Special"> <- </span>test-next p <span class="Comment"># p2 is immutable</span> + <span class="Normal">p3</span>:address:address:shared:test-list<span class="Special"> <- </span>get-address *p2<span class="Delimiter">,</span> next:offset <span class="Comment"># signal modification of p2</span> ] def test-next x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list/contained-in:x [ local-scope @@ -384,18 +392,18 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: <span class="Delimiter">:(code)</span> <span class="Normal">void</span> check_immutable_ingredient_in_instruction<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">,</span> <span class="Normal">const</span> string& original_ingredient_name<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// first check if the instruction is directly modifying something it shouldn't</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"lookup"</span><span class="Delimiter">)</span> && current_ingredient_and_aliases<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != current_ingredient_and_aliases<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" in instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" in instruction '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Comment">// check if there's any indirect modification going on</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> + set<<span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_indices<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// ingredient not found in call</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> current_ingredient_index = *p<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> <span class="Normal">int</span> current_ingredient_index = *p<span class="Delimiter">;</span> reagent current_ingredient = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>current_ingredient_index<span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">);</span> <span class="Normal">const</span> string& current_ingredient_name = current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">;</span> @@ -404,9 +412,9 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation == GET_ADDRESS || inst<span class="Delimiter">.</span>operation == INDEX_ADDRESS<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// only reason to use get-address or index-address is to modify, so stop right there</span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_name == original_ingredient_name<span class="Delimiter">)</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify ingredient "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify ingredient "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Normal">else</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because that would modify ingredient "</span> << original_ingredient_name << <span class="Constant">" which is not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because that would modify ingredient "</span> << original_ingredient_name << <span class="Constant">" which is not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> @@ -414,15 +422,15 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_address<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// making a copy is ok</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_modified_in_recipe<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">,</span> current_ingredient_index<span class="Delimiter">,</span> caller<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_name == original_ingredient_name<span class="Delimiter">)</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify ingredient "</span> << current_ingredient_name << <span class="Constant">" at instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify ingredient "</span> << current_ingredient_name << <span class="Constant">" at instruction '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because it's not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Normal">else</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because that would modify ingredient "</span> << original_ingredient_name << <span class="Constant">" which is not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify "</span> << current_ingredient_name << <span class="Constant">" after instruction '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' because that would modify ingredient "</span> << original_ingredient_name << <span class="Constant">" which is not also a product of "</span> << caller<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">bool</span> is_modified_in_recipe<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> is_modified_in_recipe<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">,</span> <span class="Normal">int</span> ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!callee<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"can't check mutability of ingredients in "</span> << callee<span class="Delimiter">.</span>name << <span class="Constant">" because it uses 'next-ingredient' directly, rather than a recipe header.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -433,7 +441,7 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: <span class="Delimiter">}</span> <span class="Normal">bool</span> is_present_in_products<span class="Delimiter">(</span><span class="Normal">const</span> recipe& callee<span class="Delimiter">,</span> <span class="Normal">const</span> string& ingredient_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == ingredient_name<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -441,16 +449,16 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: <span class="Delimiter">}</span> <span class="Normal">bool</span> is_present_in_ingredients<span class="Delimiter">(</span><span class="Normal">const</span> recipe& callee<span class="Delimiter">,</span> <span class="Normal">const</span> string& ingredient_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == ingredient_name<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> ingredient_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& ingredient_names<span class="Delimiter">)</span> <span class="Delimiter">{</span> - set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +set<<span class="Normal">int</span>> ingredient_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& ingredient_names<span class="Delimiter">)</span> <span class="Delimiter">{</span> + set<<span class="Normal">int</span>> result<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_names<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != ingredient_names<span class="Delimiter">.</span>end<span class="Delimiter">())</span> result<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> @@ -472,17 +480,17 @@ set<<span class="Normal">long</span> <span class="Normal">long</span> <span c <span class="Delimiter">:(scenarios transform)</span> <span class="Delimiter">:(scenario can_modify_contained_in_addresses)</span> container test-list [ - next:address:shared:test-list + <span class="Normal">next</span>:address:shared:test-list ] def main [ local-scope - p:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type + <span class="Normal">p</span>:address:shared:test-list<span class="Special"> <- </span><span class="Normal">new</span> test-list:type foo p ] def foo p:address:shared:test-list <span class="Delimiter">-></span> p:address:shared:test-list [ local-scope load-ingredients - p2:address:shared:test-list<span class="Special"> <- </span>test-next p + <span class="Normal">p2</span>:address:shared:test-list<span class="Special"> <- </span>test-next p p<span class="Special"> <- </span>test-remove p2<span class="Delimiter">,</span> p ] def test-next x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list [ @@ -493,7 +501,7 @@ def test-next x:address:shared:test-list <span class="Delimiter">-></span> y: def test-remove x:address:shared:test-list/contained-in:from<span class="Delimiter">,</span> from:address:shared:test-list <span class="Delimiter">-></span> from:address:shared:test-list [ local-scope load-ingredients - x2:address:address:shared:test-list<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> next:offset <span class="Comment"># pretend modification</span> + <span class="Normal">x2</span>:address:address:shared:test-list<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> next:offset <span class="Comment"># pretend modification</span> ] $error: <span class="Constant">0</span> @@ -509,3 +517,4 @@ $error: <span class="Constant">0</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/061recipe.cc.html b/html/061recipe.cc.html index 46e47107..b89a4a24 100644 --- a/html/061recipe.cc.html +++ b/html/061recipe.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 061recipe.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: So far we've been calling a fixed recipe in each instruction, but we'd</span> <span class="Comment">//: also like to make the recipe a variable, pass recipes to "higher-order"</span> <span class="Comment">//: recipes, return recipes from recipes and so on.</span> @@ -133,7 +141,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_indirect_calls_against_header<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check 'call' instructions inside recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation != CALL<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// error raised above</span> @@ -143,12 +151,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">if</span> <span class="Delimiter">(</span>!callee_header<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i-<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span> << <span class="Constant">" has the wrong type at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i-<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span> << <span class="Constant">" has the wrong type at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> - raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -225,3 +233,4 @@ def f x:boolean <span class="Delimiter">-></span> y:boolean [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/062scheduler.cc.html b/html/062scheduler.cc.html index a81f8841..93810126 100644 --- a/html/062scheduler.cc.html +++ b/html/062scheduler.cc.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 062scheduler.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Run a second routine concurrently using 'start-running', without any</span> <span class="Comment">//: guarantees on how the operations in each are interleaved with each other.</span> @@ -46,9 +54,9 @@ def f2 [ <span class="Comment">//: first, add a deadline to run(routine)</span> <span class="Comment">//: these changes are ugly and brittle; just close your nose and get through the next few lines</span> <span class="Delimiter">:(replace "void run_current_routine()")</span> -<span class="Normal">void</span> run_current_routine<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> time_slice<span class="Delimiter">)</span> -<span class="Delimiter">:(replace "while (!Current_routine->completed())" following "void run_current_routine(long long int time_slice)")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> ninstrs = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Normal">void</span> run_current_routine<span class="Delimiter">(</span><span class="Normal">int</span> time_slice<span class="Delimiter">)</span> +<span class="Delimiter">:(replace "while (!Current_routine->completed())" following "void run_current_routine(int time_slice)")</span> +<span class="Normal">int</span> ninstrs = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>state == RUNNING && ninstrs < time_slice<span class="Delimiter">)</span> <span class="Delimiter">:(after "Running One Instruction")</span> ninstrs++<span class="Delimiter">;</span> @@ -68,8 +76,8 @@ state = RUNNING<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Globals")</span> vector<routine*> Routines<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Current_routine_index = <span class="Constant">0</span><span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Scheduling_interval = <span class="Constant">500</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Current_routine_index = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Scheduling_interval = <span class="Constant">500</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Scheduling_interval = <span class="Constant">500</span><span class="Delimiter">;</span> Routines<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> @@ -99,7 +107,7 @@ Routines<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Normal">bool</span> all_routines_done<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state == RUNNING<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -111,7 +119,7 @@ Routines<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Normal">void</span> skip_to_next_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!Routines<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> assert<span class="Delimiter">(</span>Current_routine_index < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Delimiter">(</span>Current_routine_index+<span class="Constant">1</span><span class="Delimiter">)</span>%SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> i != Current_routine_index<span class="Delimiter">;</span> i = <span class="Delimiter">(</span>i+<span class="Constant">1</span><span class="Delimiter">)</span>%SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Delimiter">(</span>Current_routine_index+<span class="Constant">1</span><span class="Delimiter">)</span>%SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> i != Current_routine_index<span class="Delimiter">;</span> i = <span class="Delimiter">(</span>i+<span class="Constant">1</span><span class="Delimiter">)</span>%SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state == RUNNING<span class="Delimiter">)</span> <span class="Delimiter">{</span> Current_routine_index = i<span class="Delimiter">;</span> Current_routine = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> @@ -131,7 +139,7 @@ string current_routine_label<span class="Delimiter">()</span> <span class="Delim <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Teardown")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Normal">delete</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> Routines<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> @@ -145,7 +153,7 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Comment">// pass in commandline args as ingredients to main</span> <span class="Comment">// todo: test this</span> Current_routine = main_routine<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<<span class="Normal">double</span>> arg<span class="Delimiter">;</span> arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>arg<span class="Delimiter">);</span> @@ -158,9 +166,9 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Comment">//: 'start-running' will return a unique id for the routine that was created.</span> <span class="Comment">//: routine id is a number, but don't do any arithmetic on it</span> <span class="Delimiter">:(before "End routine Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id<span class="Delimiter">;</span> +<span class="Normal">int</span> id<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Next_routine_id = <span class="Constant">1</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Next_routine_id = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Next_routine_id = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> @@ -170,7 +178,7 @@ Next_routine_id++<span class="Delimiter">;</span> <span class="Comment">//: routines save the routine that spawned them</span> <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// todo: really should be routine_id, but that's less efficient.</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> parent_index<span class="Delimiter">;</span> <span class="Comment">// only < 0 if there's no parent_index</span> +<span class="Normal">int</span> parent_index<span class="Delimiter">;</span> <span class="Comment">// only < 0 if there's no parent_index</span> <span class="Delimiter">:(before "End routine Constructor")</span> parent_index = -<span class="Constant">1</span><span class="Delimiter">;</span> @@ -195,7 +203,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span routine* new_routine = <span class="Normal">new</span> routine<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> new_routine<span class="Delimiter">-></span>parent_index = Current_routine_index<span class="Delimiter">;</span> <span class="Comment">// populate ingredients</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> new_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> reagent ingredient = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>ingredient<span class="Delimiter">);</span> @@ -214,9 +222,9 @@ def f1 [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: 1:number <- copy 0</span> +<span class="traceContains">+run: {1: "number"} <- copy {0: "literal"}</span> <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: 2:number <- copy 0</span> +<span class="traceContains">+run: {2: "number"} <- copy {0: "literal"}</span> <span class="Delimiter">:(scenario scheduler_interleaves_routines)</span> <span class="Special">% Scheduling_interval = 1;</span> @@ -230,15 +238,15 @@ def f2 [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: start-running f2</span> +<span class="traceContains">+run: start-running {f2: "recipe-literal"}</span> <span class="traceContains">+schedule: f2</span> -<span class="traceContains">+run: 3:number <- copy 0</span> +<span class="traceContains">+run: {3: "number"} <- copy {0: "literal"}</span> <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: 1:number <- copy 0</span> +<span class="traceContains">+run: {1: "number"} <- copy {0: "literal"}</span> <span class="traceContains">+schedule: f2</span> -<span class="traceContains">+run: 4:number <- copy 0</span> +<span class="traceContains">+run: {4: "number"} <- copy {0: "literal"}</span> <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: 2:number <- copy 0</span> +<span class="traceContains">+run: {2: "number"} <- copy {0: "literal"}</span> <span class="Delimiter">:(scenario start_running_takes_ingredients)</span> def f1 [ @@ -330,7 +338,7 @@ def f1 [ <span class="traceAbsent">-schedule: f1</span> <span class="Delimiter">:(before "End Scheduler Cleanup")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state == COMPLETED<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>parent_index < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// root thread</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_completed_parent<span class="Delimiter">(</span>i<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -339,8 +347,8 @@ def f1 [ <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">bool</span> has_completed_parent<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> routine_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = routine_index<span class="Delimiter">;</span> j >= <span class="Constant">0</span><span class="Delimiter">;</span> j = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)-></span>parent_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> has_completed_parent<span class="Delimiter">(</span><span class="Normal">int</span> routine_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = routine_index<span class="Delimiter">;</span> j >= <span class="Constant">0</span><span class="Delimiter">;</span> j = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)-></span>parent_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)-></span>state == COMPLETED<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -371,7 +379,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> ROUTINE_STATE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'routine-state' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'routine-state' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -382,9 +390,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> ROUTINE_STATE: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = -<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> result = -<span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id == id<span class="Delimiter">)</span> <span class="Delimiter">{</span> result = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state<span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -404,7 +412,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> RESTART: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'restart' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'restart' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -415,8 +423,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> RESTART: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id == id<span class="Delimiter">)</span> <span class="Delimiter">{</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state = RUNNING<span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -432,7 +440,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> STOP: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'stop' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'stop' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -443,8 +451,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> STOP: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id == id<span class="Delimiter">)</span> <span class="Delimiter">{</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state = COMPLETED<span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -463,7 +471,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> _DUMP_ROUTINES: <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << i << <span class="Constant">": "</span> << Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id << <span class="Constant">' '</span> << Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state << <span class="Constant">' '</span> << Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>parent_index << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -503,7 +511,7 @@ DISCONTINUED<span class="Delimiter">,</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End routine Fields")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> limit<span class="Delimiter">;</span> +<span class="Normal">int</span> limit<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> limit = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">/*</span><span class="Comment"> no limit </span><span class="Comment">*/</span> @@ -514,7 +522,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> LIMIT_TIME: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'limit-time' requires exactly two ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'limit-time' requires exactly two ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -529,8 +537,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> LIMIT_TIME: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> id = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id == id<span class="Delimiter">)</span> <span class="Delimiter">{</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>limit = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -561,3 +569,4 @@ def f2 [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/063wait.cc.html b/html/063wait.cc.html index 4dcffd9b..da1acf6a 100644 --- a/html/063wait.cc.html +++ b/html/063wait.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 063wait.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } -.Identifier { color: #fcb165; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Routines can be put in a 'waiting' state, from which it will be ready to</span> <span class="Comment">//: run again when a specific memory location changes its value. This is mu's</span> <span class="Comment">//: basic technique for orchestrating the order in which different routines</span> @@ -49,7 +57,7 @@ def f2 [ WAITING<span class="Delimiter">,</span> <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// only if state == WAITING</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> waiting_on_location<span class="Delimiter">;</span> +<span class="Normal">int</span> waiting_on_location<span class="Delimiter">;</span> <span class="Normal">int</span> old_value_of_waiting_location<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> waiting_on_location = old_value_of_waiting_location = <span class="Constant">0</span><span class="Delimiter">;</span> @@ -78,7 +86,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">//: scheduler tweak to get routines out of that state</span> <span class="Delimiter">:(before "End Scheduler State Transitions")</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state != WAITING<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_location && get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_location<span class="Delimiter">)</span> != Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>old_value_of_waiting_location<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -111,7 +119,7 @@ def f2 [ <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// only if state == WAITING</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> waiting_on_routine<span class="Delimiter">;</span> +<span class="Normal">int</span> waiting_on_routine<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> waiting_on_routine = <span class="Constant">0</span><span class="Delimiter">;</span> @@ -122,7 +130,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> WAIT_FOR_ROUTINE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'wait-for-routine' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'wait-for-routine' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -134,7 +142,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> WAIT_FOR_ROUTINE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == Current_routine<span class="Delimiter">-></span>id<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"routine can't wait for itself! "</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"routine can't wait for itself! "</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> Current_routine<span class="Delimiter">-></span>state = WAITING<span class="Delimiter">;</span> @@ -147,12 +155,12 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// Wake up any routines waiting for other routines to go to sleep.</span> <span class="Comment">// Important: this must come after the scheduler loop above giving routines</span> <span class="Comment">// waiting for locations to change a chance to wake up.</span> -<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state != WAITING<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_routine<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_routine<span class="Delimiter">;</span> + <span class="Normal">int</span> id = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_routine<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>id != Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id<span class="Delimiter">);</span> <span class="Comment">// routine can't wait on itself</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)-></span>id == id && Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)-></span>state != RUNNING<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"schedule"</span><span class="Delimiter">)</span> << <span class="Constant">"waking up routine "</span> << Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id << end<span class="Delimiter">();</span> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state = RUNNING<span class="Delimiter">;</span> @@ -171,7 +179,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> SWITCH: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> id = some_other_running_routine<span class="Delimiter">();</span> + <span class="Normal">int</span> id = some_other_running_routine<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>id<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>id != Current_routine<span class="Delimiter">-></span>id<span class="Delimiter">);</span> Current_routine<span class="Delimiter">-></span>state = WAITING<span class="Delimiter">;</span> @@ -181,8 +189,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> some_other_running_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> some_other_running_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Routines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i == Current_routine_index<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != Current_routine<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>id != Current_routine<span class="Delimiter">-></span>id<span class="Delimiter">);</span> @@ -194,3 +202,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/064rewrite_literal_string.cc.html b/html/064rewrite_literal_string.cc.html new file mode 100644 index 00000000..b91323f7 --- /dev/null +++ b/html/064rewrite_literal_string.cc.html @@ -0,0 +1,111 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 064rewrite_literal_string.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } +.traceContains { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: allow using literal strings anywhere that will accept immutable strings</span> + +<span class="Delimiter">:(scenario passing_literals_to_recipes)</span> +def main [ + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo [abc] +] +def foo x:address:shared:array:character <span class="Delimiter">-></span> n:number [ + local-scope + load-ingredients + n<span class="Special"> <- </span>length *x +] +<span class="traceContains">+mem: storing 3 in location 1</span> + +<span class="Delimiter">:(before "End Instruction Inserting/Deleting Transforms")</span> +initialize_transform_rewrite_literal_string_to_text<span class="Delimiter">();</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>rewrite_literal_string_to_text<span class="Delimiter">);</span> + +<span class="Delimiter">:(before "End Globals")</span> +set<string> recipes_taking_literal_strings<span class="Delimiter">;</span> +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> initialize_transform_rewrite_literal_string_to_text<span class="Delimiter">()</span> <span class="Delimiter">{</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"$print"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"trace"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"stash"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"assert"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"new"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"assume-console"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"memory-should-contain"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"trace-should-contain"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"trace-should-not-contain"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"check-trace-count-for-label"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"screen-should-contain"</span><span class="Delimiter">);</span> + recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"screen-should-contain-in-color"</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> rewrite_literal_string_to_text<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- rewrite literal strings in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>contains_numeric_locations<span class="Delimiter">(</span>caller<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + vector<instruction> new_instructions<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>recipes_taking_literal_strings<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name<span class="Delimiter">)</span> == recipes_taking_literal_strings<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + instruction def<span class="Delimiter">;</span> + ostringstream ingredient_name<span class="Delimiter">;</span> + ingredient_name << inst<span class="Delimiter">.</span>name << <span class="Constant">'_'</span> << i << <span class="Constant">'_'</span> << j << <span class="Constant">":address:shared:array:character"</span><span class="Delimiter">;</span> + def<span class="Delimiter">.</span>name = <span class="Constant">"new"</span><span class="Delimiter">;</span> + def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> + def<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">()));</span> + new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>def<span class="Delimiter">);</span> + inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>clear<span class="Delimiter">();</span> <span class="Comment">// reclaim old memory</span> + inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> = reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">());</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_instructions<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Normal">bool</span> contains_numeric_locations<span class="Delimiter">(</span><span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/070text.mu.html b/html/070text.mu.html index 8c648a96..7681faeb 100644 --- a/html/070text.mu.html +++ b/html/070text.mu.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 070text.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } -.muControl { color: #c0a020; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># Some useful helpers for dealing with text (arrays of characters)</span> <span class="Comment"># to-text-line gets called implicitly in various places</span> @@ -34,6 +42,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color y<span class="Special"> <- </span>to-text x ] +<span class="Comment"># variant for arrays (since we can't pass them around otherwise)</span> +<span class="muRecipe">def</span> array-to-text-line x:address:shared:array:_elem<span class="muRecipe"> -> </span>y:address:shared:array:character [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + y<span class="Special"> <- </span>to-text *x +] + <span class="Comment"># to-text on text is just the identity function</span> <span class="muRecipe">def</span> to-text x:address:shared:array:character<span class="muRecipe"> -> </span>y:address:shared:array:character [ <span class="Constant">local-scope</span> @@ -1355,3 +1370,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/071channel.mu.html b/html/071channel.mu.html deleted file mode 100644 index 3c5bbc04..00000000 --- a/html/071channel.mu.html +++ /dev/null @@ -1,387 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 071channel.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> -<meta name="syntax" content="none"> -<meta name="settings" content="use_css"> -<style type="text/css"> -<!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } -body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.SalientComment { color: #00ffff; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.muRecipe { color: #ff8700; } -.muData { color: #ffff00; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muScenario { color: #00af00; } -.Comment { color: #9090ff; } ---> -</style> -</head> -<body> -<pre> -<span class="Comment"># Mu synchronizes using channels rather than locks, like Erlang and Go.</span> -<span class="Comment">#</span> -<span class="Comment"># The two ends of a channel will usually belong to different routines, but</span> -<span class="Comment"># each end should only be used by a single one. Don't try to read from or</span> -<span class="Comment"># write to it from multiple routines at once.</span> -<span class="Comment">#</span> -<span class="Comment"># The key property of channels is that writing to a full channel or reading</span> -<span class="Comment"># from an empty one will put the current routine in 'waiting' state until the</span> -<span class="Comment"># operation can be completed.</span> - -<span class="muScenario">scenario</span> channel [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:character, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">34</span> - ] -] - -<span class="muData">container</span> channel [ - <span class="Comment"># To avoid locking, writer and reader will never write to the same location.</span> - <span class="Comment"># So channels will include fields in pairs, one for the writer and one for the</span> - <span class="Comment"># reader.</span> - first-full:number <span class="Comment"># for write</span> - first-free:number <span class="Comment"># for read</span> - <span class="Comment"># A circular buffer contains values from index first-full up to (but not</span> - <span class="Comment"># including) index first-empty. The reader always modifies it at first-full,</span> - <span class="Comment"># while the writer always modifies it at first-empty.</span> - data:address:shared:array:character -] - -<span class="muRecipe">def</span> new-channel capacity:number<span class="muRecipe"> -> </span>result:address:shared:channel [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Constant">channel:type</span> - <span class="Comment"># result.first-full = 0</span> - full:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">first-full:offset</span> - *full<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Comment"># result.first-free = 0</span> - free:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">first-free:offset</span> - *free<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Comment"># result.data = new location[ingredient+1]</span> - capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="Comment"># unused slot for 'full?' below</span> - dest:address:address:shared:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> - *dest<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity -] - -<span class="muRecipe">def</span> write chan:address:shared:channel, val:character<span class="muRecipe"> -> </span>chan:address:shared:channel [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Delimiter">{</span> - <span class="Comment"># block if chan is full</span> - full:boolean<span class="Special"> <- </span>channel-full? chan - <span class="muControl">break-unless</span> full - full-address:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-full:offset</span> - wait-for-location *full-address - <span class="Delimiter">}</span> - <span class="Comment"># store val</span> - circular-buffer:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> - free:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-free:offset</span> - dest:address:character<span class="Special"> <- </span>index-address *circular-buffer, *free - *dest<span class="Special"> <- </span>copy val - <span class="Comment"># mark its slot as filled</span> - *free<span class="Special"> <- </span>add *free, <span class="Constant">1</span> - <span class="Delimiter">{</span> - <span class="Comment"># wrap free around to 0 if necessary</span> - len:number<span class="Special"> <- </span>length *circular-buffer - at-end?:boolean<span class="Special"> <- </span>greater-or-equal *free, len - <span class="muControl">break-unless</span> at-end? - *free<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">}</span> -] - -<span class="muRecipe">def</span> read chan:address:shared:channel<span class="muRecipe"> -> </span>result:character, chan:address:shared:channel [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Delimiter">{</span> - <span class="Comment"># block if chan is empty</span> - empty?:boolean<span class="Special"> <- </span>channel-empty? chan - <span class="muControl">break-unless</span> empty? - free-address:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-free:offset</span> - wait-for-location *free-address - <span class="Delimiter">}</span> - <span class="Comment"># read result</span> - full:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-full:offset</span> - circular-buffer:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> - result<span class="Special"> <- </span>index *circular-buffer, *full - <span class="Comment"># mark its slot as empty</span> - *full<span class="Special"> <- </span>add *full, <span class="Constant">1</span> - <span class="Delimiter">{</span> - <span class="Comment"># wrap full around to 0 if necessary</span> - len:number<span class="Special"> <- </span>length *circular-buffer - at-end?:boolean<span class="Special"> <- </span>greater-or-equal *full, len - <span class="muControl">break-unless</span> at-end? - *full<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">}</span> -] - -<span class="muRecipe">def</span> clear-channel chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Delimiter">{</span> - empty?:boolean<span class="Special"> <- </span>channel-empty? chan - <span class="muControl">break-if</span> empty? - _, chan<span class="Special"> <- </span>read chan - <span class="Delimiter">}</span> -] - -<span class="muScenario">scenario</span> channel-initialization [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-free</span> - ] -] - -<span class="muScenario">scenario</span> channel-write-increments-free [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free</span> - ] -] - -<span class="muScenario">scenario</span> channel-read-increments-full [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-full</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free</span> - ] -] - -<span class="muScenario">scenario</span> channel-wrap [ - run [ - <span class="Comment"># channel with just 1 slot</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - <span class="Comment"># write and read a value</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel - <span class="Comment"># first-free will now be 1</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - <span class="Comment"># write second value, verify that first-free wraps</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> - <span class="Comment"># read second value, verify that first-full wraps</span> - _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free after first write</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-full after first read</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-free after second write, wrapped</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full after second read, wrapped</span> - ] -] - -<span class="SalientComment">## helpers</span> - -<span class="Comment"># An empty channel has first-empty and first-full both at the same value.</span> -<span class="muRecipe">def</span> channel-empty? chan:address:shared:channel<span class="muRecipe"> -> </span>result:boolean [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Comment"># return chan.first-full == chan.first-free</span> - full:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-full:offset</span> - free:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-free:offset</span> - result<span class="Special"> <- </span>equal full, free -] - -<span class="Comment"># A full channel has first-empty just before first-full, wasting one slot.</span> -<span class="Comment"># (Other alternatives: <a href="https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)">https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)</a></span> -<span class="muRecipe">def</span> channel-full? chan:address:shared:channel<span class="muRecipe"> -> </span>result:boolean [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Comment"># tmp = chan.first-free + 1</span> - tmp:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-free:offset</span> - tmp<span class="Special"> <- </span>add tmp, <span class="Constant">1</span> - <span class="Delimiter">{</span> - <span class="Comment"># if tmp == chan.capacity, tmp = 0</span> - len:number<span class="Special"> <- </span>channel-capacity chan - at-end?:boolean<span class="Special"> <- </span>greater-or-equal tmp, len - <span class="muControl">break-unless</span> at-end? - tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">}</span> - <span class="Comment"># return chan.first-full == tmp</span> - full:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-full:offset</span> - result<span class="Special"> <- </span>equal full, tmp -] - -<span class="muRecipe">def</span> channel-capacity chan:address:shared:channel<span class="muRecipe"> -> </span>result:number [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - q:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> - result<span class="Special"> <- </span>length *q -] - -<span class="muScenario">scenario</span> channel-new-empty-not-full [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> - ] -] - -<span class="muScenario">scenario</span> channel-write-not-empty [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> - ] -] - -<span class="muScenario">scenario</span> channel-write-full [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># full?</span> - ] -] - -<span class="muScenario">scenario</span> channel-read-not-full [ - run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> - ] -] - -<span class="Comment"># helper for channels of characters in particular</span> -<span class="muRecipe">def</span> buffer-lines in:address:shared:channel, out:address:shared:channel<span class="muRecipe"> -> </span>out:address:shared:channel, in:address:shared:channel [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Comment"># repeat forever</span> - <span class="Delimiter">{</span> - line:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> - <span class="Comment"># read characters from 'in' until newline, copy into line</span> - <span class="Delimiter">{</span> -<span class="Constant"> +next-character</span> - c:character, in<span class="Special"> <- </span>read in - <span class="Comment"># drop a character on backspace</span> - <span class="Delimiter">{</span> - <span class="Comment"># special-case: if it's a backspace</span> - backspace?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">8</span> - <span class="muControl">break-unless</span> backspace? - <span class="Comment"># drop previous character</span> - <span class="Delimiter">{</span> - buffer-length:address:number<span class="Special"> <- </span>get-address *line, <span class="Constant">length:offset</span> - buffer-empty?:boolean<span class="Special"> <- </span>equal *buffer-length, <span class="Constant">0</span> - <span class="muControl">break-if</span> buffer-empty? - *buffer-length<span class="Special"> <- </span>subtract *buffer-length, <span class="Constant">1</span> - <span class="Delimiter">}</span> - <span class="Comment"># and don't append this one</span> - <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> - <span class="Delimiter">}</span> - <span class="Comment"># append anything else</span> - line<span class="Special"> <- </span>append line, c - line-done?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> - <span class="muControl">break-if</span> line-done? - <span class="Comment"># stop buffering on eof (currently only generated by fake console)</span> - eof?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">0/eof</span> - <span class="muControl">break-if</span> eof? - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="Comment"># copy line into 'out'</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - line-contents:address:shared:array:character<span class="Special"> <- </span>get *line, <span class="Constant">data:offset</span> - max:number<span class="Special"> <- </span>get *line, <span class="Constant">length:offset</span> - <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, max - <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *line-contents, i - out<span class="Special"> <- </span>write out, c - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> -] - -<span class="muScenario">scenario</span> buffer-lines-blocks-until-newline [ - run [ - <span class="Constant">1</span>:address:shared:channel/stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - <span class="Constant">2</span>:address:shared:channel/buffered-stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin - assert <span class="Constant">3</span>:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> init] - <span class="Comment"># buffer stdin into buffered-stdin, try to read from buffered-stdin</span> - <span class="Constant">4</span>:number/buffer-routine<span class="Special"> <- </span>start-running buffer-lines, <span class="Constant">1</span>:address:shared:channel/stdin, <span class="Constant">2</span>:address:shared:channel/buffered-stdin - wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin - assert <span class="Constant">5</span>:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> buffer-lines bring-up] - <span class="Comment"># write 'a'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - restart <span class="Constant">4</span>:number/buffer-routine - wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">6</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin - assert <span class="Constant">6</span>:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'a'] - <span class="Comment"># write 'b'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">98/b</span> - restart <span class="Constant">4</span>:number/buffer-routine - wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin - assert <span class="Constant">7</span>:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'b'] - <span class="Comment"># write newline</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10/newline</span> - restart <span class="Constant">4</span>:number/buffer-routine - wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">8</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin - <span class="Constant">9</span>:boolean/completed?<span class="Special"> <- </span>not <span class="Constant">8</span>:boolean - assert <span class="Constant">9</span>:boolean/completed?, [ -F buffer-lines-blocks-until-newline: channel should contain data <span class="muRecipe">after</span> writing newline] - trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> - ] - trace-should-contain [ - test: reached end - ] -] -</pre> -</body> -</html> diff --git a/html/071rewrite_stash.cc.html b/html/071rewrite_stash.cc.html new file mode 100644 index 00000000..689d8a1b --- /dev/null +++ b/html/071rewrite_stash.cc.html @@ -0,0 +1,151 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 071rewrite_stash.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } +.cSpecial { color: #008000; } +.traceContains { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: when encountering other types, try to convert them to strings using</span> +<span class="Comment">//: 'to-text'</span> + +<span class="Delimiter">:(scenarios transform)</span> +<span class="Delimiter">:(scenario rewrite_stashes_to_text)</span> +recipe main [ + local-scope + <span class="Normal">n</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + stash n +] +<span class="traceContains">+transform: {stash_2_0: ("address" "shared" "array" "character")} <- to-text-line {n: "number"}</span> +<span class="traceContains">+transform: stash {stash_2_0: ("address" "shared" "array" "character")}</span> + +<span class="Comment">//: special case: rewrite attempts to stash contents of most arrays to avoid</span> +<span class="Comment">//: passing addresses around</span> + +<span class="Delimiter">:(scenario rewrite_stashes_of_arrays)</span> +recipe main [ + local-scope + <span class="Normal">n</span>:address:shared:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">3</span> + stash *n +] +<span class="traceContains">+transform: {stash_2_0: ("address" "shared" "array" "character")} <- array-to-text-line {n: ("address" "shared" "array" "number")}</span> +<span class="traceContains">+transform: stash {stash_2_0: ("address" "shared" "array" "character")}</span> + +<span class="Delimiter">:(before "End Instruction Inserting/Deleting Transforms")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>rewrite_stashes_to_text<span class="Delimiter">);</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> rewrite_stashes_to_text<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- rewrite 'stash' instructions in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> + <span class="Comment">// in recipes without named locations, 'stash' is still not extensible</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>contains_numeric_locations<span class="Delimiter">(</span>caller<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + check_or_set_types_by_name<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// prerequisite</span> + rewrite_stashes_to_text<span class="Delimiter">(</span>caller<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> rewrite_stashes_to_text<span class="Delimiter">(</span>recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> + vector<instruction> new_instructions<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"stash"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>type<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + instruction def<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_address_of_array<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Delimiter">{</span> + def<span class="Delimiter">.</span>name = <span class="Constant">"array-to-text-line"</span><span class="Delimiter">;</span> + reagent tmp = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> + drop_one_lookup<span class="Delimiter">(</span>tmp<span class="Delimiter">);</span> + def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>tmp<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Normal">else</span> <span class="Delimiter">{</span> + def<span class="Delimiter">.</span>name = <span class="Constant">"to-text-line"</span><span class="Delimiter">;</span> + def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> + <span class="Delimiter">}</span> + ostringstream ingredient_name<span class="Delimiter">;</span> + ingredient_name << <span class="Constant">"stash_"</span> << i << <span class="Constant">'_'</span> << j << <span class="Constant">":address:shared:array:character"</span><span class="Delimiter">;</span> + def<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">()));</span> + trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << to_string<span class="Delimiter">(</span>def<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>def<span class="Delimiter">);</span> + inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>clear<span class="Delimiter">();</span> <span class="Comment">// reclaim old memory</span> + inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> = reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">());</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_instructions<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Normal">bool</span> is_address_of_array<span class="Delimiter">(</span>reagent x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!canonize_type<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Comment">//: Make sure that the new system is strictly better than just the 'stash'</span> +<span class="Comment">//: primitive by itself.</span> + +<span class="Delimiter">:(scenarios run)</span> +<span class="Delimiter">:(scenario rewrite_stash_continues_to_fall_back_to_default_implementation)</span> +<span class="Comment"># type without a to-text implementation</span> +container foo [ + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number +] +recipe main [ + local-scope + <span class="Normal">x</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> + stash x +] +<span class="traceContains">+app: 34 35</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +TO_TEXT<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"to-text"</span><span class="Delimiter">,</span> TO_TEXT<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> TO_TEXT: <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'to-text' requires a single ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +<span class="Normal">case</span> TO_TEXT: <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))));</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/072channel.mu.html b/html/072channel.mu.html new file mode 100644 index 00000000..ef0ad41b --- /dev/null +++ b/html/072channel.mu.html @@ -0,0 +1,425 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 072channel.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> +<meta name="syntax" content="none"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } +.muData { color: #ffff00; } +.SalientComment { color: #00ffff; } +.Delimiter { color: #800080; } +.muRecipe { color: #ff8700; } +.Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment"># Mu synchronizes using channels rather than locks, like Erlang and Go.</span> +<span class="Comment">#</span> +<span class="Comment"># The two ends of a channel will usually belong to different routines, but</span> +<span class="Comment"># each end should only be used by a single one. Don't try to read from or</span> +<span class="Comment"># write to it from multiple routines at once.</span> +<span class="Comment">#</span> +<span class="Comment"># The key property of channels is that writing to a full channel or reading</span> +<span class="Comment"># from an empty one will put the current routine in 'waiting' state until the</span> +<span class="Comment"># operation can be completed.</span> + +<span class="muScenario">scenario</span> channel [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + <span class="Constant">3</span>:number, <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:source:number + ] + memory-should-contain [ + <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">34</span> + ] +] + +<span class="muData">container</span> channel:_elem [ + <span class="Comment"># To avoid locking, writer and reader will never write to the same location.</span> + <span class="Comment"># So channels will include fields in pairs, one for the writer and one for the</span> + <span class="Comment"># reader.</span> + first-full:number <span class="Comment"># for write</span> + first-free:number <span class="Comment"># for read</span> + <span class="Comment"># A circular buffer contains values from index first-full up to (but not</span> + <span class="Comment"># including) index first-empty. The reader always modifies it at first-full,</span> + <span class="Comment"># while the writer always modifies it at first-empty.</span> + data:address:shared:array:_elem +] + +<span class="Comment"># Since channels have two ends, and since it's an error to use either end from</span> +<span class="Comment"># multiple routines, let's distinguish the ends.</span> + +<span class="muData">container</span> source:_elem [ + chan:address:shared:channel:_elem +] + +<span class="muData">container</span> sink:_elem [ + chan:address:shared:channel:_elem +] + +<span class="muRecipe">def</span> new-channel capacity:number<span class="muRecipe"> -> </span>in:address:shared:source:_elem, out:address:shared:sink:_elem [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + result:address:shared:channel:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(channel _elem): type<span class="Delimiter">}</span> + <span class="Comment"># result.first-full = 0</span> + full:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">first-full:offset</span> + *full<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Comment"># result.first-free = 0</span> + free:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">first-free:offset</span> + *free<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Comment"># result.data = new location[ingredient+1]</span> + capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="Comment"># unused slot for 'full?' below</span> + dest:address:address:shared:array:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + *dest<span class="Special"> <- </span>new <span class="Constant">_elem:type</span>, capacity + in<span class="Special"> <- </span>new <span class="Delimiter">{</span>(source _elem): type<span class="Delimiter">}</span> + chan:address:address:shared:channel:_elem<span class="Special"> <- </span>get-address *in, <span class="Constant">chan:offset</span> + *chan<span class="Special"> <- </span>copy result + out<span class="Special"> <- </span>new <span class="Delimiter">{</span>(sink _elem): type<span class="Delimiter">}</span> + chan:address:address:shared:channel:_elem<span class="Special"> <- </span>get-address *out, <span class="Constant">chan:offset</span> + *chan<span class="Special"> <- </span>copy result +] + +<span class="muRecipe">def</span> write out:address:shared:sink:_elem, val:_elem<span class="muRecipe"> -> </span>out:address:shared:sink:_elem [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + chan:address:shared:channel:_elem<span class="Special"> <- </span>get *out, <span class="Constant">chan:offset</span> + <span class="Delimiter">{</span> + <span class="Comment"># block if chan is full</span> + full:boolean<span class="Special"> <- </span>channel-full? chan + <span class="muControl">break-unless</span> full + full-address:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-full:offset</span> + wait-for-location *full-address + <span class="Delimiter">}</span> + <span class="Comment"># store val</span> + circular-buffer:address:shared:array:_elem<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + free:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-free:offset</span> + dest:address:_elem<span class="Special"> <- </span>index-address *circular-buffer, *free + *dest<span class="Special"> <- </span>copy val + <span class="Comment"># mark its slot as filled</span> + *free<span class="Special"> <- </span>add *free, <span class="Constant">1</span> + <span class="Delimiter">{</span> + <span class="Comment"># wrap free around to 0 if necessary</span> + len:number<span class="Special"> <- </span>length *circular-buffer + at-end?:boolean<span class="Special"> <- </span>greater-or-equal *free, len + <span class="muControl">break-unless</span> at-end? + *free<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Delimiter">}</span> +] + +<span class="muRecipe">def</span> read in:address:shared:source:_elem<span class="muRecipe"> -> </span>result:_elem, in:address:shared:source:_elem [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + chan:address:shared:channel:_elem<span class="Special"> <- </span>get *in, <span class="Constant">chan:offset</span> + <span class="Delimiter">{</span> + <span class="Comment"># block if chan is empty</span> + empty?:boolean<span class="Special"> <- </span>channel-empty? chan + <span class="muControl">break-unless</span> empty? + free-address:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-free:offset</span> + wait-for-location *free-address + <span class="Delimiter">}</span> + <span class="Comment"># read result</span> + full:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-full:offset</span> + circular-buffer:address:shared:array:_elem<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + result<span class="Special"> <- </span>index *circular-buffer, *full + <span class="Comment"># mark its slot as empty</span> + *full<span class="Special"> <- </span>add *full, <span class="Constant">1</span> + <span class="Delimiter">{</span> + <span class="Comment"># wrap full around to 0 if necessary</span> + len:number<span class="Special"> <- </span>length *circular-buffer + at-end?:boolean<span class="Special"> <- </span>greater-or-equal *full, len + <span class="muControl">break-unless</span> at-end? + *full<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Delimiter">}</span> +] + +<span class="muRecipe">def</span> clear in:address:shared:source:_elem<span class="muRecipe"> -> </span>in:address:shared:source:_elem [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + chan:address:shared:channel:_elem<span class="Special"> <- </span>get *in, <span class="Constant">chan:offset</span> + <span class="Delimiter">{</span> + empty?:boolean<span class="Special"> <- </span>channel-empty? chan + <span class="muControl">break-if</span> empty? + _, in<span class="Special"> <- </span>read in + <span class="Delimiter">}</span> +] + +<span class="muScenario">scenario</span> channel-initialization [ + run [ + <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">2</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:channel:number, <span class="Constant">first-full:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:channel:number, <span class="Constant">first-free:offset</span> + ] + memory-should-contain [ + <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-free</span> + ] +] + +<span class="muScenario">scenario</span> channel-write-increments-free [ + run [ + _, <span class="Constant">1</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">1</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:number, <span class="Constant">34</span> + <span class="Constant">2</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:sink:number, <span class="Constant">chan:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:channel:character, <span class="Constant">first-full:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:channel:character, <span class="Constant">first-free:offset</span> + ] + memory-should-contain [ + <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free</span> + ] +] + +<span class="muScenario">scenario</span> channel-read-increments-full [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:source:number + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-full:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-free:offset</span> + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-full</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free</span> + ] +] + +<span class="muScenario">scenario</span> channel-wrap [ + run [ + <span class="Comment"># channel with just 1 slot</span> + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Comment"># write and read a value</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:source:number + <span class="Comment"># first-free will now be 1</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-free:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-free:offset</span> + <span class="Comment"># write second value, verify that first-free wraps</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + <span class="Constant">6</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-free:offset</span> + <span class="Comment"># read second value, verify that first-full wraps</span> + _, <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:source:number + <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:channel:number, <span class="Constant">first-full:offset</span> + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free after first write</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-full after first read</span> + <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-free after second write, wrapped</span> + <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full after second read, wrapped</span> + ] +] + +<span class="SalientComment">## helpers</span> + +<span class="Comment"># An empty channel has first-empty and first-full both at the same value.</span> +<span class="muRecipe">def</span> channel-empty? chan:address:shared:channel:_elem<span class="muRecipe"> -> </span>result:boolean [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + <span class="Comment"># return chan.first-full == chan.first-free</span> + full:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-full:offset</span> + free:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-free:offset</span> + result<span class="Special"> <- </span>equal full, free +] + +<span class="Comment"># A full channel has first-empty just before first-full, wasting one slot.</span> +<span class="Comment"># (Other alternatives: <a href="https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)">https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)</a></span> +<span class="muRecipe">def</span> channel-full? chan:address:shared:channel:_elem<span class="muRecipe"> -> </span>result:boolean [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + <span class="Comment"># tmp = chan.first-free + 1</span> + tmp:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-free:offset</span> + tmp<span class="Special"> <- </span>add tmp, <span class="Constant">1</span> + <span class="Delimiter">{</span> + <span class="Comment"># if tmp == chan.capacity, tmp = 0</span> + len:number<span class="Special"> <- </span>capacity chan + at-end?:boolean<span class="Special"> <- </span>greater-or-equal tmp, len + <span class="muControl">break-unless</span> at-end? + tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Delimiter">}</span> + <span class="Comment"># return chan.first-full == tmp</span> + full:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-full:offset</span> + result<span class="Special"> <- </span>equal full, tmp +] + +<span class="muRecipe">def</span> capacity chan:address:shared:channel:_elem<span class="muRecipe"> -> </span>result:number [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + q:address:shared:array:_elem<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + result<span class="Special"> <- </span>length *q +] + +<span class="muScenario">scenario</span> channel-new-empty-not-full [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">3</span>:address:shared:channel:number + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">3</span>:address:shared:channel:number + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> + ] +] + +<span class="muScenario">scenario</span> channel-write-not-empty [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">3</span>:address:shared:channel:number + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">3</span>:address:shared:channel:number + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> + ] +] + +<span class="muScenario">scenario</span> channel-write-full [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">3</span>:address:shared:channel:number + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">3</span>:address:shared:channel:number + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># full?</span> + ] +] + +<span class="muScenario">scenario</span> channel-read-not-full [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">3</span>:address:shared:channel:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:number, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:source:number<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:source:number + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">3</span>:address:shared:channel:number + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">3</span>:address:shared:channel:number + ] + memory-should-contain [ + <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> + <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># full?</span> + ] +] + +<span class="Comment"># helper for channels of characters in particular</span> +<span class="muRecipe">def</span> buffer-lines in:address:shared:source:character, buffered-out:address:shared:sink:character<span class="muRecipe"> -> </span>buffered-out:address:shared:sink:character, in:address:shared:source:character [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + <span class="Comment"># repeat forever</span> + <span class="Delimiter">{</span> + line:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> + <span class="Comment"># read characters from 'in' until newline, copy into line</span> + <span class="Delimiter">{</span> +<span class="Constant"> +next-character</span> + c:character, in<span class="Special"> <- </span>read in + <span class="Comment"># drop a character on backspace</span> + <span class="Delimiter">{</span> + <span class="Comment"># special-case: if it's a backspace</span> + backspace?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">8</span> + <span class="muControl">break-unless</span> backspace? + <span class="Comment"># drop previous character</span> + <span class="Delimiter">{</span> + buffer-length:address:number<span class="Special"> <- </span>get-address *line, <span class="Constant">length:offset</span> + buffer-empty?:boolean<span class="Special"> <- </span>equal *buffer-length, <span class="Constant">0</span> + <span class="muControl">break-if</span> buffer-empty? + *buffer-length<span class="Special"> <- </span>subtract *buffer-length, <span class="Constant">1</span> + <span class="Delimiter">}</span> + <span class="Comment"># and don't append this one</span> + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> + <span class="Delimiter">}</span> + <span class="Comment"># append anything else</span> + line<span class="Special"> <- </span>append line, c + line-done?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + <span class="muControl">break-if</span> line-done? + <span class="Comment"># stop buffering on eof (currently only generated by fake console)</span> + eof?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">0/eof</span> + <span class="muControl">break-if</span> eof? + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="Comment"># copy line into 'buffered-out'</span> + i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + line-contents:address:shared:array:character<span class="Special"> <- </span>get *line, <span class="Constant">data:offset</span> + max:number<span class="Special"> <- </span>get *line, <span class="Constant">length:offset</span> + <span class="Delimiter">{</span> + done?:boolean<span class="Special"> <- </span>greater-or-equal i, max + <span class="muControl">break-if</span> done? + c:character<span class="Special"> <- </span>index *line-contents, i + buffered-out<span class="Special"> <- </span>write buffered-out, c + i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> +] + +<span class="muScenario">scenario</span> buffer-lines-blocks-until-newline [ + run [ + <span class="Constant">1</span>:address:shared:source:number, <span class="Constant">2</span>:address:shared:sink:number<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + _, <span class="Constant">3</span>:address:shared:sink:number/buffered-stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + <span class="Constant">4</span>:address:shared:channel:number/buffered-stdin<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:source:number, <span class="Constant">chan:offset</span> + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">4</span>:address:shared:channel:character/buffered-stdin + assert <span class="Constant">5</span>:boolean, <span class="Constant">[ </span> +<span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after init]</span> + <span class="Comment"># buffer stdin into buffered-stdin, try to read from buffered-stdin</span> + <span class="Constant">6</span>:number/buffer-routine<span class="Special"> <- </span>start-running buffer-lines, <span class="Constant">1</span>:address:shared:source:character/stdin, <span class="Constant">3</span>:address:shared:sink:character/buffered-stdin + wait-for-routine <span class="Constant">6</span>:number/buffer-routine + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">4</span>:address:shared:channel:character/buffered-stdin + assert <span class="Constant">7</span>:boolean, <span class="Constant">[ </span> +<span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up]</span> + <span class="Comment"># write 'a'</span> + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">97/a</span> + restart <span class="Constant">6</span>:number/buffer-routine + wait-for-routine <span class="Constant">6</span>:number/buffer-routine + <span class="Constant">8</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">4</span>:address:shared:channel:character/buffered-stdin + assert <span class="Constant">8</span>:boolean, <span class="Constant">[ </span> +<span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after writing 'a']</span> + <span class="Comment"># write 'b'</span> + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">98/b</span> + restart <span class="Constant">6</span>:number/buffer-routine + wait-for-routine <span class="Constant">6</span>:number/buffer-routine + <span class="Constant">9</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">4</span>:address:shared:channel:character/buffered-stdin + assert <span class="Constant">9</span>:boolean, <span class="Constant">[ </span> +<span class="Constant">F buffer-lines-blocks-until-newline: channel should be empty after writing 'b']</span> + <span class="Comment"># write newline</span> + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">10/newline</span> + restart <span class="Constant">6</span>:number/buffer-routine + wait-for-routine <span class="Constant">6</span>:number/buffer-routine + <span class="Constant">10</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">4</span>:address:shared:channel:character/buffered-stdin + <span class="Constant">11</span>:boolean/completed?<span class="Special"> <- </span>not <span class="Constant">10</span>:boolean + assert <span class="Constant">11</span>:boolean/completed?, <span class="Constant">[ </span> +<span class="Constant">F buffer-lines-blocks-until-newline: channel should contain data after writing newline]</span> + trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> + ] + trace-should-contain [ + test: reached end + ] +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/072array.mu.html b/html/073array.mu.html index e97ceeac..8cafa8d5 100644 --- a/html/072array.mu.html +++ b/html/073array.mu.html @@ -2,27 +2,35 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 072array.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 073array.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } -.Special { color: #c00000; } .Constant { color: #00a0a0; } -.muScenario { color: #00af00; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="muScenario">scenario</span> array-from-args [ run [ <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new-array <span class="Constant">0</span>, <span class="Constant">1</span>, <span class="Constant">2</span> @@ -66,3 +74,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/073list.mu.html b/html/074list.mu.html index edb8aac8..76b64ad5 100644 --- a/html/073list.mu.html +++ b/html/074list.mu.html @@ -2,28 +2,36 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 073list.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 074list.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muScenario { color: #00af00; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># A list links up multiple objects together to make them easier to manage.</span> <span class="Comment">#</span> <span class="Comment"># The objects must be of the same type. If you want to store multiple types in</span> @@ -109,11 +117,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color next:address:shared:list:_elem<span class="Special"> <- </span>rest in nextn:number<span class="Special"> <- </span>copy next <span class="muControl">return-unless</span> next - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> - buf<span class="Special"> <- </span>append buf, space:character - s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[-> ]</span> - n:number<span class="Special"> <- </span>length *s - buf<span class="Special"> <- </span>append buf, s + buf<span class="Special"> <- </span>append buf, <span class="Constant">[ -> ]</span> <span class="Comment"># and recurse</span> remaining:number, optional-ingredient-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> @@ -130,33 +134,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># past recursion depth; insert ellipses and stop</span> - s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[...]</span> - append buf, s -] - -<span class="muScenario">scenario</span> stash-on-list-converts-to-text [ - run [ - x:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> - x<span class="Special"> <- </span>push <span class="Constant">5</span>, x - x<span class="Special"> <- </span>push <span class="Constant">6</span>, x - stash <span class="Constant">[foo foo]</span>, x - ] - trace-should-contain [ - app: foo foo <span class="Constant">6</span><span class="muRecipe"> -> </span><span class="Constant">5</span><span class="muRecipe"> -> </span><span class="Constant">4</span> - ] -] - -<span class="muScenario">scenario</span> stash-handles-list-with-cycle [ - run [ - x:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> - y:address:address:shared:list:number<span class="Special"> <- </span>get-address *x, <span class="Constant">next:offset</span> - *y<span class="Special"> <- </span>copy x - stash <span class="Constant">[foo foo]</span>, x - ] - trace-should-contain [ - app: foo foo <span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span><span class="Constant">4</span><span class="muRecipe"> -> </span>... - ] + append buf, <span class="Constant">[...]</span> ] </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/074random.cc.html b/html/075random.cc.html index e92c6895..770671e3 100644 --- a/html/074random.cc.html +++ b/html/075random.cc.html @@ -2,29 +2,37 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 074random.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 075random.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.PreProc { color: #800080; } -.traceContains { color: #008000; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .Special { color: #c00000; } -.cSpecial { color: #008000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } -.Constant { color: #00a0a0; } .Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> RANDOM<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> @@ -63,7 +71,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> ROUND: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'round' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'round' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -90,3 +98,4 @@ def main [ </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/075duplex_list.mu.html b/html/076duplex_list.mu.html index c88f2335..5b3e3b78 100644 --- a/html/075duplex_list.mu.html +++ b/html/076duplex_list.mu.html @@ -2,28 +2,36 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 075duplex_list.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 076duplex_list.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muScenario { color: #00af00; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># A doubly linked list permits bidirectional traversal.</span> <span class="muData">container</span> duplex-list:_elem [ @@ -553,3 +561,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/076stream.mu.html b/html/077stream.mu.html index 18041177..5bf82f66 100644 --- a/html/076stream.mu.html +++ b/html/077stream.mu.html @@ -2,25 +2,33 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 076stream.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 077stream.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># new type to help incrementally read texts (arrays of characters)</span> <span class="muData">container</span> stream [ index:number @@ -65,3 +73,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/077hash.cc.html b/html/078hash.cc.html index f158257c..02349fc2 100644 --- a/html/077hash.cc.html +++ b/html/078hash.cc.html @@ -2,29 +2,37 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 077hash.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 078hash.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.traceContains { color: #008000; } -.Special { color: #c00000; } -.CommentedCode { color: #6c6c6c; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.Special { color: #c00000; } +.traceContains { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">// A universal hash function that can handle objects of any type.</span> <span class="Comment">//</span> <span class="Comment">// The way it's currently implemented, two objects will have the same hash if</span> @@ -42,7 +50,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> HASH: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'hash' takes exactly one ingredient rather than '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'hash' takes exactly one ingredient rather than '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -93,7 +101,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">size_t</span> hash_mu_string<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> string input = read_mu_string<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>input<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>input<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> h = hash_iter<span class="Delimiter">(</span>h<span class="Delimiter">,</span> <span class="Normal">static_cast</span><<span class="Normal">size_t</span>><span class="Delimiter">(</span>input<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)));</span> <span class="CommentedCode">//? cerr << i << ": " << h << '\n';</span> <span class="Delimiter">}</span> @@ -101,11 +109,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Normal">size_t</span> hash_mu_array<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">);</span> + <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">);</span> reagent elem = r<span class="Delimiter">;</span> <span class="Normal">delete</span> elem<span class="Delimiter">.</span>type<span class="Delimiter">;</span> elem<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*array_element<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">));</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i=<span class="Constant">0</span><span class="Delimiter">,</span> address = r<span class="Delimiter">.</span>value+<span class="Constant">1</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">,</span> address += size_of<span class="Delimiter">(</span>elem<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i=<span class="Constant">0</span><span class="Delimiter">,</span> address = r<span class="Delimiter">.</span>value+<span class="Constant">1</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">,</span> address += size_of<span class="Delimiter">(</span>elem<span class="Delimiter">))</span> <span class="Delimiter">{</span> reagent tmp = elem<span class="Delimiter">;</span> tmp<span class="Delimiter">.</span>value = address<span class="Delimiter">;</span> h = hash<span class="Delimiter">(</span>h<span class="Delimiter">,</span> tmp<span class="Delimiter">);</span> @@ -123,9 +131,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">size_t</span> hash_mu_container<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address = r<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> address = r<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent element = element_type<span class="Delimiter">(</span>r<span class="Delimiter">,</span> i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>element<span class="Delimiter">,</span> <span class="Constant">"ignore-for-hash"</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> element<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>address+offset<span class="Delimiter">);</span> @@ -144,7 +152,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">size_t</span> hash_mu_exclusive_container<span class="Delimiter">(</span><span class="Normal">size_t</span> h<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> tag = get<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">);</span> + <span class="Normal">int</span> tag = get<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">);</span> reagent variant = variant_type<span class="Delimiter">(</span>r<span class="Delimiter">,</span> tag<span class="Delimiter">);</span> <span class="Comment">// todo: move this error to container definition time</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>variant<span class="Delimiter">,</span> <span class="Constant">"ignore-for-hash"</span><span class="Delimiter">))</span> @@ -167,8 +175,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(scenario hash_container_checks_all_elements)</span> container foo [ - x:number - y:character + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">97</span>/a @@ -184,12 +192,12 @@ def main [ <span class="Delimiter">:(scenario hash_exclusive_container_checks_all_elements)</span> exclusive-container foo [ - x:bar - y:number + <span class="Normal">x</span>:bar + <span class="Normal">y</span>:number ] container bar [ - a:number - b:number + <span class="Normal">a</span>:number + <span class="Normal">b</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> @@ -205,8 +213,8 @@ def main [ <span class="Delimiter">:(scenario hash_can_ignore_container_elements)</span> container foo [ - x:number - y:character/ignore-<span class="Normal">for</span>-hash + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character/ignore-<span class="Normal">for</span>-hash ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">97</span>/a @@ -285,12 +293,12 @@ def main [ <span class="Delimiter">:(scenario hash_container_depends_only_on_elements)</span> container foo [ - x:number - y:character + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character ] container bar [ - x:number - y:character + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">97</span>/a @@ -306,9 +314,9 @@ def main [ <span class="Delimiter">:(scenario hash_container_depends_only_on_elements_2)</span> container foo [ - x:number - y:character - z:address:shared:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character + <span class="Normal">z</span>:address:shared:number ] def main [ <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span><span class="Normal">new</span> number:type @@ -328,13 +336,13 @@ def main [ <span class="Delimiter">:(scenario hash_container_depends_only_on_elements_3)</span> container foo [ - x:number - y:character - z:bar + <span class="Normal">x</span>:number + <span class="Normal">y</span>:character + <span class="Normal">z</span>:bar ] container bar [ - x:number - y:number + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">97</span>/a<span class="Delimiter">,</span> <span class="Constant">47</span><span class="Delimiter">,</span> <span class="Constant">48</span> @@ -350,12 +358,12 @@ def main [ <span class="Delimiter">:(scenario hash_exclusive_container_ignores_tag)</span> exclusive-container foo [ - x:bar - y:number + <span class="Normal">x</span>:bar + <span class="Normal">y</span>:number ] container bar [ - a:number - b:number + <span class="Normal">a</span>:number + <span class="Normal">b</span>:number ] def main [ <span class="Constant">1</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span>/x<span class="Delimiter">,</span> <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> @@ -389,7 +397,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> HASH_OLD: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'hash_old' takes exactly one ingredient rather than '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'hash_old' takes exactly one ingredient rather than '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -403,7 +411,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span string input = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">size_t</span> h = <span class="Constant">0</span> <span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>input<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>input<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> h += <span class="Normal">static_cast</span><<span class="Normal">size_t</span>><span class="Delimiter">(</span>input<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> h += <span class="Delimiter">(</span>h<<<span class="Constant">10</span><span class="Delimiter">);</span> h ^= <span class="Delimiter">(</span>h>><span class="Constant">6</span><span class="Delimiter">);</span> @@ -420,3 +428,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/078table.mu.html b/html/079table.mu.html index 00505480..ab009967 100644 --- a/html/078table.mu.html +++ b/html/079table.mu.html @@ -2,28 +2,36 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 078table.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<title>Mu - 079table.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.muRecipe { color: #ff8700; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } .muData { color: #ffff00; } .Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muScenario { color: #00af00; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># A table is like an array, except that its keys are not integers but</span> <span class="Comment"># arbitrary types.</span> @@ -113,3 +121,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/080display.cc.html b/html/080display.cc.html index 33fb161d..9b2a4acf 100644 --- a/html/080display.cc.html +++ b/html/080display.cc.html @@ -3,32 +3,40 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 080display.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; } +.cSpecial { color: #008000; } +.Comment { color: #9090ff; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } -.Comment { color: #9090ff; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Take charge of the text-mode display and console.</span> <span class="SalientComment">//:: Display management</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Display_row = <span class="Constant">0</span><span class="Delimiter">,</span> Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Display_row = <span class="Constant">0</span><span class="Delimiter">,</span> Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">bool</span> Autodisplay = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -43,8 +51,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> OPEN_CONSOLE: <span class="Delimiter">{</span> tb_init<span class="Delimiter">();</span> Display_row = Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> height = tb_height<span class="Delimiter">();</span> + <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span> + <span class="Normal">int</span> height = tb_height<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>width > <span class="Constant">222</span> || height > <span class="Constant">222</span><span class="Delimiter">)</span> tb_shutdown<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>width > <span class="Constant">222</span><span class="Delimiter">)</span> raise << <span class="Constant">"sorry, mu doesn't support windows wider than 222 characters. Please resize your window.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -109,8 +117,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> CLEAR_LINE_ON_DISPLAY: <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> x = Display_column<span class="Delimiter">;</span> x < width<span class="Delimiter">;</span> ++x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> x = Display_column<span class="Delimiter">;</span> x < width<span class="Delimiter">;</span> ++x<span class="Delimiter">)</span> <span class="Delimiter">{</span> tb_change_cell<span class="Delimiter">(</span>x<span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> <span class="Delimiter">}</span> tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> @@ -125,7 +133,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'print-character-to-display' requires at least one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'print-character-to-display' requires at least one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -149,9 +157,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span> <span class="Normal">int</span> h=tb_height<span class="Delimiter">(),</span> w=tb_width<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> height = <span class="Delimiter">(</span>h >= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> width = <span class="Delimiter">(</span>w >= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> c = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> height = <span class="Delimiter">(</span>h >= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> width = <span class="Delimiter">(</span>w >= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> c = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">int</span> color = TB_BLACK<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> color = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> @@ -211,7 +219,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> MOVE_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'move-cursor-on-display' requires two ingredients, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'move-cursor-on-display' requires two ingredients, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -244,7 +252,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> MOVE_CURSOR_DOWN_ON_DISPLAY: <span class="Delimiter">{</span> <span class="Normal">int</span> h=tb_height<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> height = <span class="Delimiter">(</span>h >= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> height = <span class="Delimiter">(</span>h >= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row < height-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> Display_row++<span class="Delimiter">;</span> tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> @@ -282,7 +290,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> MOVE_CURSOR_RIGHT_ON_DISPLAY: <span class="Delimiter">{</span> <span class="Normal">int</span> w=tb_width<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> width = <span class="Delimiter">(</span>w >= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> width = <span class="Delimiter">(</span>w >= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Display_column < width-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> Display_column++<span class="Delimiter">;</span> tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> @@ -527,3 +535,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/081print.mu.html b/html/081print.mu.html index 27196aa8..ba9a2b06 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 081print.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muScenario { color: #00af00; } -.CommentedCode { color: #6c6c6c; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># Wrappers around print primitives that take a 'screen' object and are thus</span> <span class="Comment"># easier to test.</span> @@ -748,3 +756,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/082scenario_screen.cc.html b/html/082scenario_screen.cc.html index 4bc94f75..5bf73b8d 100644 --- a/html/082scenario_screen.cc.html +++ b/html/082scenario_screen.cc.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 082scenario_screen.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .traceAbsent { color: #c00000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } +.cSpecial { color: #008000; } .traceContains { color: #008000; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Clean syntax to manipulate and check the screen in scenarios.</span> <span class="Comment">//: Instructions 'assume-screen' and 'screen-should-contain' implicitly create</span> <span class="Comment">//: a variable called 'screen' that is accessible inside other 'run'</span> @@ -37,7 +45,7 @@ scenario screen-in-scenario [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -52,9 +60,9 @@ scenario screen-in-scenario-unicode-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red <span class="Constant">2</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -70,9 +78,9 @@ scenario screen-in-scenario-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red <span class="Constant">2</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white ] <span class="Comment"># screen-should-contain shows everything</span> screen-should-contain [ @@ -105,7 +113,7 @@ scenario screen-in-scenario-error [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -124,7 +132,7 @@ scenario screen-in-scenario-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a - screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">screen</span>:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a<span class="Delimiter">,</span> <span class="Constant">1</span>/red ] screen-should-contain-in-color <span class="Constant">2</span>/green<span class="Delimiter">,</span> [ <span class="Comment"># 01234</span> @@ -143,7 +151,7 @@ scenario screen-in-scenario-color [ <span class="Delimiter">:(scenario convert_names_does_not_fail_when_mixing_special_names_and_numeric_locations)</span> <span class="Special">% Scenario_testing_scenario = true;</span> def main [ - screen:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number + <span class="Normal">screen</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] <span class="traceAbsent">-error: mixing variable names and numeric addresses in main</span> $error: <span class="Constant">0</span> @@ -153,8 +161,8 @@ $error: <span class="Constant">0</span> <span class="Comment">// Scenarios may not define default-space, so they should fit within the</span> <span class="Comment">// initial area of memory reserved for tests. We'll put the predefined</span> <span class="Comment">// variables available to them at the end of that region.</span> -<span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Max_variables_in_scenarios = Reserved_for_tests-<span class="Constant">100</span><span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Next_predefined_global_for_scenarios = Max_variables_in_scenarios<span class="Delimiter">;</span> +<span class="Normal">const</span> <span class="Normal">int</span> Max_variables_in_scenarios = Reserved_for_tests-<span class="Constant">100</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Next_predefined_global_for_scenarios = Max_variables_in_scenarios<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> assert<span class="Delimiter">(</span>Next_predefined_global_for_scenarios < Reserved_for_tests<span class="Delimiter">);</span> <span class="Delimiter">:(after "transform_all()" following "case RUN:")</span> @@ -165,7 +173,7 @@ assert<span class="Delimiter">(</span>Name[tmp_recipe<span class="Delimiter">.</ <span class="Delimiter">:(before "End Globals")</span> <span class="Comment">// Scenario Globals.</span> -<span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> SCREEN = Next_predefined_global_for_scenarios++<span class="Delimiter">;</span> +<span class="Normal">const</span> <span class="Normal">int</span> SCREEN = Next_predefined_global_for_scenarios++<span class="Delimiter">;</span> <span class="Comment">// End Scenario Globals.</span> <span class="Delimiter">:(before "End Special Scenario Variable Names(r)")</span> Name[r][<span class="Constant">"screen"</span>] = SCREEN<span class="Delimiter">;</span> @@ -217,8 +225,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Types")</span> <span class="Comment">// scan an array of characters in a unicode-aware, bounds-checked manner</span> <span class="Normal">struct</span> raw_string_stream <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index<span class="Delimiter">;</span> - <span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> max<span class="Delimiter">;</span> + <span class="Normal">int</span> index<span class="Delimiter">;</span> + <span class="Normal">const</span> <span class="Normal">int</span> max<span class="Delimiter">;</span> <span class="Normal">const</span> <span class="Normal">char</span>* buf<span class="Delimiter">;</span> raw_string_stream<span class="Delimiter">(</span><span class="Normal">const</span> string&<span class="Delimiter">);</span> @@ -231,23 +239,23 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(code)</span> <span class="Normal">void</span> check_screen<span class="Delimiter">(</span><span class="Normal">const</span> string& expected_contents<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">int</span> color<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> <span class="Comment">// not supported</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Normal">int</span> data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"data"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>data_offset >= <span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> + <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> + <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> <span class="Normal">int</span> width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-columns"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> + <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> <span class="Normal">int</span> height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-rows"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> + <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> raw_string_stream cursor<span class="Delimiter">(</span>expected_contents<span class="Delimiter">);</span> <span class="Comment">// todo: too-long expected_contents should fail</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> addr = screen_data_start+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> addr = screen_data_start+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> cursor<span class="Delimiter">.</span>skip_whitespace_and_comments<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>at_end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>get<span class="Delimiter">()</span> == <span class="Constant">'.'</span><span class="Delimiter">);</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> column = <span class="Constant">0</span><span class="Delimiter">;</span> column < screen_width<span class="Delimiter">;</span> ++column<span class="Delimiter">,</span> addr+= <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> column = <span class="Constant">0</span><span class="Delimiter">;</span> column < screen_width<span class="Delimiter">;</span> ++column<span class="Delimiter">,</span> addr+= <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> <span class="Normal">int</span> cell_color_offset = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Normal">uint32_t</span> curr = cursor<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)</span> == <span class="Constant">0</span> && isspace<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -366,20 +374,20 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(code)</span> <span class="Normal">void</span> dump_screen<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> <span class="Comment">// not supported</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Normal">int</span> width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-columns"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> + <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> <span class="Normal">int</span> height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-rows"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> + <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> <span class="Normal">int</span> data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"data"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>data_offset >= <span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> + <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> + <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> assert<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_start<span class="Delimiter">)</span> == screen_width*screen_height<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = screen_data_start+<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// skip length</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> curr = screen_data_start+<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// skip length</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << <span class="Constant">'.'</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> col < screen_width<span class="Delimiter">;</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> col < screen_width<span class="Delimiter">;</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">))</span> cerr << to_unicode<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)));</span> <span class="Normal">else</span> @@ -392,3 +400,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/083scenario_screen_test.mu.html b/html/083scenario_screen_test.mu.html index a829f738..d5c7b2f5 100644 --- a/html/083scenario_screen_test.mu.html +++ b/html/083scenario_screen_test.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 083scenario_screen_test.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># To check our support for screens in scenarios, rewrite tests from print.mu</span> <span class="muScenario">scenario</span> print-character-at-top-left-2 [ @@ -54,3 +62,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/084console.mu.html b/html/084console.mu.html index c93444a7..13bc38b6 100644 --- a/html/084console.mu.html +++ b/html/084console.mu.html @@ -3,26 +3,34 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 084console.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># Wrappers around interaction primitives that take a potentially fake object</span> <span class="Comment"># and are thus easier to test.</span> @@ -97,7 +105,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> *c, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span> ] -<span class="muRecipe">def</span> send-keys-to-channel console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen [ +<span class="muRecipe">def</span> send-keys-to-channel console:address:shared:console, chan:address:shared:sink:character, screen:address:shared:screen<span class="muRecipe"> -> </span>console:address:shared:console, chan:address:shared:sink:character, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -134,3 +142,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html index 3cbbfe16..66ca7b81 100644 --- a/html/085scenario_console.cc.html +++ b/html/085scenario_console.cc.html @@ -3,26 +3,34 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 085scenario_console.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +.cSpecial { color: #008000; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Clean syntax to manipulate and check the console in scenarios.</span> <span class="Comment">//: Instruction 'assume-console' implicitly creates a variable called</span> <span class="Comment">//: 'console' that is accessible inside other 'run' instructions in the</span> @@ -55,7 +63,7 @@ scenario keyboard-in-scenario [ ] <span class="Delimiter">:(before "End Scenario Globals")</span> -<span class="Normal">const</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> CONSOLE = Next_predefined_global_for_scenarios++<span class="Delimiter">;</span> +<span class="Normal">const</span> <span class="Normal">int</span> CONSOLE = Next_predefined_global_for_scenarios++<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Special Scenario Variable Names(r)")</span> Name[r][<span class="Constant">"console"</span>] = CONSOLE<span class="Delimiter">;</span> @@ -77,15 +85,15 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span istringstream in<span class="Delimiter">(</span><span class="Constant">"["</span> + current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name + <span class="Constant">"]"</span><span class="Delimiter">);</span> recipe r<span class="Delimiter">;</span> slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> num_events = count_events<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + <span class="Normal">int</span> num_events = count_events<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// initialize the events like in new-fake-console</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = <span class="Comment">/*</span><span class="Comment">space for refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span> + num_events*size_of_event<span class="Delimiter">();</span> + <span class="Normal">int</span> size = <span class="Comment">/*</span><span class="Comment">space for refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span> + num_events*size_of_event<span class="Delimiter">();</span> ensure_space<span class="Delimiter">(</span>size<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> event_data_address = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Normal">int</span> event_data_address = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> <span class="Comment">// store length</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> num_events<span class="Delimiter">);</span> Current_routine<span class="Delimiter">-></span>alloc += <span class="Comment">/*</span><span class="Comment">skip refcount and length</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& curr = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"left-click"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'left-click' event starting at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> @@ -120,9 +128,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'type' event starting at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> <span class="Normal">const</span> string& contents = curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span class="Normal">const</span> <span class="Normal">char</span>* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> num_keyboard_events = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num_keyboard_events<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> num_keyboard_events = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span> + <span class="Normal">int</span> curr = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num_keyboard_events<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'text' tag at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'text' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Normal">uint32_t</span> curr_character<span class="Delimiter">;</span> @@ -141,14 +149,16 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing console in "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> Current_routine<span class="Delimiter">-></span>alloc += size_of_console<span class="Delimiter">();</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> + <span class="Normal">int</span> console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing console data in "</span> << console_address+<span class="Constant">2</span> << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> event_data_address<span class="Delimiter">);</span> + <span class="Comment">// increment refcount for event data</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> event_data_address<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Globals")</span> -map<string<span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Key<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> Key<span class="Delimiter">;</span> <span class="Delimiter">:(before "End One-time Setup")</span> initialize_key_names<span class="Delimiter">();</span> <span class="Delimiter">:(code)</span> @@ -273,22 +283,22 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << <span class="Constant">"console not initialized</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> console_data = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Constant">1</span><span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_data<span class="Delimiter">);</span> <span class="Comment">// array size</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">,</span> curr = console_data+<span class="Constant">1</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">,</span> curr+=size_of_event<span class="Delimiter">())</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> + <span class="Normal">int</span> console_data = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Normal">int</span> size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_data<span class="Delimiter">);</span> <span class="Comment">// array size</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">,</span> curr = console_data+<span class="Constant">1</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">,</span> curr+=size_of_event<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)</span> != <span class="Comment">/*</span><span class="Comment">text</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr+<span class="Constant">1</span><span class="Delimiter">)</span> != ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> n = <span class="Constant">0</span><span class="Delimiter">;</span> n < size_of_event<span class="Delimiter">();</span> ++n<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> n = <span class="Constant">0</span><span class="Delimiter">;</span> n < size_of_event<span class="Delimiter">();</span> ++n<span class="Delimiter">)</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr+n<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span>n<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> count_events<span class="Delimiter">(</span><span class="Normal">const</span> recipe& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> count_events<span class="Delimiter">(</span><span class="Normal">const</span> recipe& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& curr = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"type"</span><span class="Delimiter">)</span> result += unicode_length<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> @@ -298,9 +308,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size_of_event<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> size_of_event<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// memoize result if already computed</span> - <span class="Normal">static</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">static</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> type_tree* type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">"event"</span><span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"event"</span><span class="Delimiter">));</span> result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">);</span> @@ -308,9 +318,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> size_of_console<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> size_of_console<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// memoize result if already computed</span> - <span class="Normal">static</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">static</span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"console"</span><span class="Delimiter">));</span> type_tree* type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">"console"</span><span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"console"</span><span class="Delimiter">));</span> @@ -321,3 +331,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/086scenario_console_test.mu.html b/html/086scenario_console_test.mu.html index d195dc69..f2f5bc91 100644 --- a/html/086scenario_console_test.mu.html +++ b/html/086scenario_console_test.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 086scenario_console_test.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># To check our support for consoles in scenarios, rewrite tests from</span> <span class="Comment"># scenario_console.mu</span> <span class="Comment"># Tests for console interface.</span> @@ -48,3 +56,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/087file.cc.html b/html/087file.cc.html new file mode 100644 index 00000000..71b7461f --- /dev/null +++ b/html/087file.cc.html @@ -0,0 +1,62 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 087file.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } +.Delimiter { color: #800080; } +.SalientComment { color: #00ffff; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="SalientComment">//:: Interacting with the file-system</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +OPEN_FILE_FOR_READING<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"open-file-for-reading"</span><span class="Delimiter">,</span> OPEN_FILE_FOR_READING<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> OPEN_FILE_FOR_READING: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +<span class="Normal">case</span> OPEN_FILE_FOR_READING: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +OPEN_FILE_FOR_WRITING<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"open-file-for-reading"</span><span class="Delimiter">,</span> OPEN_FILE_FOR_WRITING<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> OPEN_FILE_FOR_WRITING: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +<span class="Normal">case</span> OPEN_FILE_FOR_WRITING: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/090trace_browser.cc.html b/html/090trace_browser.cc.html index 8677b9d2..7fe976a3 100644 --- a/html/090trace_browser.cc.html +++ b/html/090trace_browser.cc.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 090trace_browser.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.cSpecial { color: #008000; } -.Identifier { color: #fcb165; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: A debugging helper that lets you zoom in/out on a trace.</span> <span class="Comment">//: browse the trace we just created</span> @@ -48,23 +56,23 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Globals")</span> -set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Visible<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Last_printed_row = <span class="Constant">0</span><span class="Delimiter">;</span> -map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Trace_index<span class="Delimiter">;</span> <span class="Comment">// screen row -> trace index</span> +set<<span class="Normal">int</span>> Visible<span class="Delimiter">;</span> +<span class="Normal">int</span> Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Normal">int</span> Last_printed_row = <span class="Constant">0</span><span class="Delimiter">;</span> +map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">int</span>> Trace_index<span class="Delimiter">;</span> <span class="Comment">// screen row -> trace index</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> cerr << <span class="Constant">"computing min depth to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">int</span> min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> <span class="Delimiter">}</span> cerr << <span class="Constant">"min depth is "</span> << min_depth << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> cerr << <span class="Constant">"computing lines to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>depth == min_depth<span class="Delimiter">)</span> Visible<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -78,7 +86,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Normal">do</span> <span class="Delimiter">{</span> tb_poll_event<span class="Delimiter">(</span>&event<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">while</span> <span class="Delimiter">(</span>event<span class="Delimiter">.</span>type != TB_EVENT_KEY<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> + <span class="Normal">int</span> key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'q'</span> || key == <span class="Constant">'Q'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'j'</span> || key == TB_KEY_ARROW_DOWN<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor one line down</span> @@ -135,8 +143,8 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Normal">if</span> <span class="Delimiter">(</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// expand lines under current by one level</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> start_index = get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> start_index = get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> + <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// simultaneously compute end_index and min_depth</span> <span class="Normal">int</span> min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -145,7 +153,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla assert<span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth > Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> + <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> <span class="Comment">// mark as visible all intervening indices at min_depth</span> <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index<span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> @@ -158,8 +166,8 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Normal">if</span> <span class="Delimiter">(</span>key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// collapse all lines under current</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">));</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> start_index = get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> start_index = get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> + <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// end_index is the next line at a depth same as or lower than start_index</span> <span class="Normal">int</span> initial_depth = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -167,7 +175,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth <= initial_depth<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> + <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> <span class="Comment">// mark as visible all intervening indices at min_depth</span> <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> Visible<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>index<span class="Delimiter">);</span> @@ -180,7 +188,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Comment">// update Trace_indices for each screen_row on the basis of Top_of_screen and Visible</span> <span class="Normal">void</span> refresh_screen_rows<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> Trace_index<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = Top_of_screen<span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">()</span> && index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++screen_row<span class="Delimiter">,</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// skip lines without depth for now</span> @@ -195,14 +203,14 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Delimiter">}</span> <span class="Normal">void</span> render<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> screen_row<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> screen_row<span class="Delimiter">));</span> ostringstream out<span class="Delimiter">;</span> out << std::setw<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">)</span> << curr_line<span class="Delimiter">.</span>depth << <span class="Constant">' '</span> << curr_line<span class="Delimiter">.</span>label << <span class="Constant">": "</span> << curr_line<span class="Delimiter">.</span>contents<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>screen_row < tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> delta = lines_hidden<span class="Delimiter">(</span>screen_row<span class="Delimiter">);</span> + <span class="Normal">int</span> delta = lines_hidden<span class="Delimiter">(</span>screen_row<span class="Delimiter">);</span> <span class="Comment">// home-brew escape sequence for red</span> <span class="Normal">if</span> <span class="Delimiter">(</span>delta > <span class="Constant">999</span><span class="Delimiter">)</span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> out << <span class="Constant">" ("</span> << delta << <span class="Constant">")"</span><span class="Delimiter">;</span> @@ -220,7 +228,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla tb_present<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> lines_hidden<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> lines_hidden<span class="Delimiter">(</span><span class="Normal">int</span> screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> screen_row<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> screen_row+<span class="Constant">1</span><span class="Delimiter">))</span> <span class="Identifier">return</span> SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">)</span> - get<span class="Delimiter">(</span>Trace_index<span class="Delimiter">,</span> screen_row<span class="Delimiter">);</span> @@ -229,7 +237,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Delimiter">}</span> <span class="Normal">void</span> render_line<span class="Delimiter">(</span><span class="Normal">int</span> screen_row<span class="Delimiter">,</span> <span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">int</span> color = TB_WHITE<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>col = <span class="Constant">0</span><span class="Delimiter">;</span> col < tb_width<span class="Delimiter">()</span> && col < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">char</span> c = s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>col<span class="Delimiter">);</span> <span class="Comment">// todo: unicode</span> @@ -274,3 +282,4 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/091run_interactive.cc.html b/html/091run_interactive.cc.html index c75f2931..101756eb 100644 --- a/html/091run_interactive.cc.html +++ b/html/091run_interactive.cc.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 091run_interactive.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } +* { font-size: 12pt; font-size: 1em; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } .traceContains { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Helper for various programming environments: run arbitrary mu code and</span> <span class="Comment">//: return some result in string form.</span> @@ -56,7 +64,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> RUN_INTERACTIVE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'run-interactive' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'run-interactive' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -88,26 +96,24 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Tracing")</span> trace_stream* Save_trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span> string Save_trace_file<span class="Delimiter">;</span> -vector<recipe_ordinal> Save_recently_added_recipes<span class="Delimiter">;</span> -vector<recipe_ordinal> Save_recently_added_shape_shifting_recipes<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> Track_most_recent_products = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">:(code)</span> <span class="Comment">// reads a string, tries to call it as code (treating it as a test), saving</span> <span class="Comment">// all errors.</span> <span class="Comment">// returns true if successfully called (no errors found during load and transform)</span> -<span class="Normal">bool</span> run_interactive<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> run_interactive<span class="Delimiter">(</span><span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"interactive"</span><span class="Delimiter">)</span> && get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"interactive"</span><span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// try to sandbox the run as best you can</span> <span class="Comment">// todo: test this</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Current_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < Reserved_for_tests<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < Reserved_for_tests<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> Memory<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Delimiter">}</span> string command = trim<span class="Delimiter">(</span>strip_comments<span class="Delimiter">(</span>read_mu_string<span class="Delimiter">(</span>address<span class="Delimiter">)));</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>command<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> Name[get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"interactive"</span><span class="Delimiter">)</span>]<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - run_code_begin<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">snapshot_recently_added_recipes</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span> + run_code_begin<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">should_stash_snapshots</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>command<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// don't kill the current routine on parse errors</span> routine* save_current_routine = Current_routine<span class="Delimiter">;</span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> @@ -134,16 +140,22 @@ Track_most_recent_products = <span class="Constant">false</span><span class="Del <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> run_code_begin<span class="Delimiter">(</span><span class="Normal">bool</span> snapshot_recently_added_recipes<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Comment">//: Carefully update all state to exactly how it was -- including snapshots.</span> + +<span class="Delimiter">:(before "End Globals")</span> +map<string<span class="Delimiter">,</span> recipe_ordinal> Recipe_ordinal_snapshot_stash<span class="Delimiter">;</span> +map<recipe_ordinal<span class="Delimiter">,</span> recipe> Recipe_snapshot_stash<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> type_ordinal> Type_ordinal_snapshot_stash<span class="Delimiter">;</span> +map<type_ordinal<span class="Delimiter">,</span> type_info> Type_snapshot_stash<span class="Delimiter">;</span> +map<recipe_ordinal<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> > Name_snapshot_stash<span class="Delimiter">;</span> +map<string<span class="Delimiter">,</span> vector<recipe_ordinal> > Recipe_variants_snapshot_stash<span class="Delimiter">;</span> +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> run_code_begin<span class="Delimiter">(</span><span class="Normal">bool</span> should_stash_snapshots<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// stuff to undo later, in run_code_end()</span> Hide_errors = <span class="Constant">true</span><span class="Delimiter">;</span> Disable_redefine_checks = <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>snapshot_recently_added_recipes<span class="Delimiter">)</span> <span class="Delimiter">{</span> - Save_recently_added_recipes = Recently_added_recipes<span class="Delimiter">;</span> - Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - Save_recently_added_shape_shifting_recipes = Recently_added_shape_shifting_recipes<span class="Delimiter">;</span> - Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Delimiter">}</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>should_stash_snapshots<span class="Delimiter">)</span> + stash_snapshots<span class="Delimiter">();</span> Save_trace_stream = Trace_stream<span class="Delimiter">;</span> Save_trace_file = Trace_file<span class="Delimiter">;</span> Trace_file = <span class="Constant">""</span><span class="Delimiter">;</span> @@ -160,13 +172,28 @@ Track_most_recent_products = <span class="Constant">false</span><span class="Del Trace_file = Save_trace_file<span class="Delimiter">;</span> Save_trace_file<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"interactive"</span><span class="Delimiter">));</span> <span class="Comment">// keep past sandboxes from inserting errors</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!Save_recently_added_recipes<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - clear_recently_added_recipes<span class="Delimiter">();</span> - Recently_added_recipes = Save_recently_added_recipes<span class="Delimiter">;</span> - Save_recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - Recently_added_shape_shifting_recipes = Save_recently_added_shape_shifting_recipes<span class="Delimiter">;</span> - Save_recently_added_shape_shifting_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Delimiter">}</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!Recipe_snapshot_stash<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> + unstash_snapshots<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + +<span class="Comment">// keep sync'd with save_snapshots and restore_snapshots</span> +<span class="Normal">void</span> stash_snapshots<span class="Delimiter">()</span> <span class="Delimiter">{</span> + Recipe_ordinal_snapshot_stash = Recipe_ordinal_snapshot<span class="Delimiter">;</span> + Recipe_snapshot_stash = Recipe_snapshot<span class="Delimiter">;</span> + Type_ordinal_snapshot_stash = Type_ordinal_snapshot<span class="Delimiter">;</span> + Type_snapshot_stash = Type_snapshot<span class="Delimiter">;</span> + Name_snapshot_stash = Name_snapshot<span class="Delimiter">;</span> + Recipe_variants_snapshot_stash = Recipe_variants_snapshot<span class="Delimiter">;</span> + save_snapshots<span class="Delimiter">();</span> +<span class="Delimiter">}</span> +<span class="Normal">void</span> unstash_snapshots<span class="Delimiter">()</span> <span class="Delimiter">{</span> + restore_snapshots<span class="Delimiter">();</span> + Recipe_ordinal_snapshot = Recipe_ordinal_snapshot_stash<span class="Delimiter">;</span> Recipe_ordinal_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Recipe_snapshot = Recipe_snapshot_stash<span class="Delimiter">;</span> Recipe_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Type_ordinal_snapshot = Type_ordinal_snapshot_stash<span class="Delimiter">;</span> Type_ordinal_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Type_snapshot = Type_snapshot_stash<span class="Delimiter">;</span> Type_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Name_snapshot = Name_snapshot_stash<span class="Delimiter">;</span> Name_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Recipe_variants_snapshot = Recipe_variants_snapshot_stash<span class="Delimiter">;</span> Recipe_variants_snapshot_stash<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Load Recipes")</span> @@ -187,8 +214,6 @@ load<span class="Delimiter">(</span>string<span class="Delimiter">(</span> <span class="Constant">"$cleanup-run-interactive</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"return output, errors, screen, stashes, completed?</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> -transform_all<span class="Delimiter">();</span> -Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Comment">//: adjust errors in the sandbox</span> <span class="Delimiter">:(after "string maybe(string s)")</span> @@ -304,9 +329,9 @@ def main [ def main [ <span class="Comment"># try to interactively add 2 and 2</span> <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [ - x:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [a] - y:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [b] - z:address:shared:array:character<span class="Special"> <- </span>append x:address:shared:array:character<span class="Delimiter">,</span> y:address:shared:array:character + <span class="Normal">x</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [a] + <span class="Normal">y</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [b] + <span class="Normal">z</span>:address:shared:array:character<span class="Special"> <- </span>append x:address:shared:array:character<span class="Delimiter">,</span> y:address:shared:array:character ] <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">2</span>:address:shared:array:character/lookup @@ -334,38 +359,13 @@ get x:number<span class="Delimiter">,</span> foo:offset] def main [ <span class="Comment"># 2 instructions, with a comment after the first</span> <span class="Constant">1</span>:address:shared:array:number<span class="Special"> <- </span><span class="Normal">new</span> [a:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abc</span> -b:number<span class="Special"> <- </span>copy <span class="Constant">0</span> +<span class="Normal">b</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="Constant">2</span>:address:shared:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character ] <span class="Comment"># no errors</span> <span class="traceContains">+mem: storing 0 in location 3</span> -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> test_run_interactive_cleans_up_any_created_specializations<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Comment">// define a generic recipe</span> - assert<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"foo"</span><span class="Delimiter">));</span> - load<span class="Delimiter">(</span><span class="Constant">"recipe foo x:_elem -> n:number [</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" return 34</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> - assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// foo</span> - assert<span class="Delimiter">(</span>variant_count<span class="Delimiter">(</span><span class="Constant">"foo"</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">);</span> - <span class="Comment">// run-interactive a call that specializes this recipe</span> - run<span class="Delimiter">(</span><span class="Constant">"recipe main [</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" 1:number/raw <- copy 0</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" 2:address:shared:array:character <- new [foo 1:number/raw]</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" run-interactive 2:address:shared:array:character</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> - assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// foo, main</span> - <span class="Comment">// check that number of variants doesn't change</span> - CHECK_EQ<span class="Delimiter">(</span>variant_count<span class="Delimiter">(</span><span class="Constant">"foo"</span><span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span class="Delimiter">}</span> - -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> variant_count<span class="Delimiter">(</span>string recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> recipe_name<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Identifier">return</span> non_ghost_size<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> recipe_name<span class="Delimiter">));</span> -<span class="Delimiter">}</span> - <span class="Delimiter">:(before "End Globals")</span> string Most_recent_products<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> @@ -377,7 +377,7 @@ Most_recent_products = <span class="Constant">""</span><span class="De <span class="Delimiter">:(code)</span> <span class="Normal">void</span> track_most_recent_products<span class="Delimiter">(</span><span class="Normal">const</span> instruction& instruction<span class="Delimiter">,</span> <span class="Normal">const</span> vector<vector<<span class="Normal">double</span>> >& products<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// string</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i < SIZE<span class="Delimiter">(</span>instruction<span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -385,7 +385,7 @@ Most_recent_products = <span class="Constant">""</span><span class="De tb_shutdown<span class="Delimiter">();</span> cerr << read_mu_string<span class="Delimiter">(</span>trace_error_contents<span class="Delimiter">())</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> cerr << SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="Constant">": "</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> cerr << no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> << <span class="Constant">' '</span><span class="Delimiter">;</span> cerr << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -395,7 +395,7 @@ Most_recent_products = <span class="Constant">""</span><span class="De <span class="Delimiter">}</span> <span class="Comment">// End Record Product Special-cases</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> out << no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> << <span class="Constant">' '</span><span class="Delimiter">;</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -405,7 +405,7 @@ Most_recent_products = <span class="Constant">""</span><span class="De <span class="Delimiter">:(code)</span> string strip_comments<span class="Delimiter">(</span>string in<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> result << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -417,14 +417,14 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> stringified_value_of_location<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> stringified_value_of_location<span class="Delimiter">(</span><span class="Normal">int</span> address<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// convert to string</span> ostringstream out<span class="Delimiter">;</span> out << no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">));</span> <span class="Identifier">return</span> new_mu_string<span class="Delimiter">(</span>out<span class="Delimiter">.</span>str<span class="Delimiter">());</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> trace_error_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> trace_error_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -438,7 +438,7 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim <span class="Identifier">return</span> new_mu_string<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> trace_app_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span class="Normal">int</span> trace_app_contents<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -453,8 +453,8 @@ string strip_comments<span class="Delimiter">(</span>string in<span class="Delim <span class="Delimiter">}</span> <span class="Normal">void</span> truncate<span class="Delimiter">(</span>string& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>x<span class="Delimiter">)</span> > <span class="Constant">512</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - x<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">512</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>x<span class="Delimiter">)</span> > <span class="Constant">1024</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + x<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">1024</span><span class="Delimiter">);</span> *x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> *++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> *++++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> @@ -471,7 +471,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'reload' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'reload' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -482,34 +482,22 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> - <span class="Comment">// clear any containers in advance</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - Type_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> - Type<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_types<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> vector<recipe_ordinal> >::iterator p = Recipe_variants<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Recipe_variants<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> - vector<recipe_ordinal>& variants = p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>end<span class="Delimiter">())</span> - variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// ghost</span> - <span class="Delimiter">}</span> - <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_shape_shifting_recipes<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - Recipe_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> - Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Delimiter">}</span> - Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + <span class="Comment">// conundrum: need to support repeated reloads of the same code, but not</span> + <span class="Comment">// wipe out state for the current test</span> + <span class="Comment">// hacky solution: subset of restore_snapshots() without restoring recipes {</span> + <span class="Comment">// can't yet define containers in a test that runs 'reload'</span> + Type_ordinal = Type_ordinal_snapshot<span class="Delimiter">;</span> + Type = Type_snapshot<span class="Delimiter">;</span> + <span class="Comment">// can't yet create new specializations of shape-shifting recipes in a test</span> + <span class="Comment">// that runs 'reload'</span> + Recipe_variants = Recipe_variants_snapshot<span class="Delimiter">;</span> + Name = Name_snapshot<span class="Delimiter">;</span> + <span class="Comment">// }</span> string code = read_mu_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - run_code_begin<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">snapshot_recently_added_recipes</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span> + run_code_begin<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">should_stash_snapshots</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span> routine* save_current_routine = Current_routine<span class="Delimiter">;</span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> vector<recipe_ordinal> recipes_reloaded = load<span class="Delimiter">(</span>code<span class="Delimiter">);</span> - <span class="Comment">// clear a few things from previous runs</span> - <span class="Comment">// ad hoc list; we've probably missed a few</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>recipes_reloaded<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - Name<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>recipes_reloaded<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> transform_all<span class="Delimiter">();</span> Trace_stream<span class="Delimiter">-></span>newline<span class="Delimiter">();</span> <span class="Comment">// flush trace</span> Current_routine = save_current_routine<span class="Delimiter">;</span> @@ -522,7 +510,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(scenario reload_continues_past_error)</span> def main [ local-scope - x:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [recipe foo [ + <span class="Normal">x</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [recipe foo [ get <span class="Constant">1234</span>:number<span class="Delimiter">,</span> foo:offset ]] reload x @@ -530,31 +518,28 @@ def main [ ] <span class="traceContains">+mem: storing 34 in location 1</span> -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> test_reload_cleans_up_any_created_specializations<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Comment">// define a generic recipe and a call to it</span> - assert<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"foo"</span><span class="Delimiter">));</span> - assert<span class="Delimiter">(</span>variant_count<span class="Delimiter">(</span><span class="Constant">"foo"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Comment">// a call that specializes this recipe</span> - run<span class="Delimiter">(</span><span class="Constant">"recipe main [</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" x:address:shared:array:character <- new [recipe foo x:_elem -> n:number [</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"load-ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"return 34</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"recipe main2 [</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"load-ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"x:number <- copy 34</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"foo x:number</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"]]</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" reload x</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> - <span class="Comment">// check that number of variants includes specialization</span> - assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">)</span> == <span class="Constant">4</span><span class="Delimiter">);</span> <span class="Comment">// foo, main, main2, foo specialization</span> - CHECK_EQ<span class="Delimiter">(</span>variant_count<span class="Delimiter">(</span><span class="Constant">"foo"</span><span class="Delimiter">),</span> <span class="Constant">2</span><span class="Delimiter">);</span> -<span class="Delimiter">}</span> +<span class="Delimiter">:(scenario reload_can_repeatedly_load_container_definitions)</span> +<span class="Comment"># define a container and try to create it (merge requires knowing container size)</span> +def main [ + local-scope + <span class="Normal">x</span>:address:shared:array:character<span class="Special"> <- </span><span class="Normal">new</span> [ + container foo [ + <span class="Normal">x</span>:number + <span class="Normal">y</span>:number + ] + recipe bar [ + local-scope + <span class="Normal">x</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> + ] + ] + <span class="Comment"># save warning addresses in locations of type 'number' to avoid spurious changes to them due to 'abandon'</span> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>reload x + <span class="Constant">2</span>:number/<span class="Special">raw <- </span>reload x +] +<span class="Comment"># no errors on either load</span> +<span class="traceContains">+mem: storing 0 in location 1</span> +<span class="traceContains">+mem: storing 0 in location 2</span> </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/092persist.cc.html b/html/092persist.cc.html index 96158666..ba2f2f25 100644 --- a/html/092persist.cc.html +++ b/html/092persist.cc.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 092persist.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Identifier { color: #fcb165; } -.cSpecial { color: #008000; } -.Normal { color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.cSpecial { color: #008000; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Dead simple persistence.</span> <span class="Comment">//: 'restore' - reads string from a file</span> <span class="Comment">//: 'save' - writes string to a file</span> @@ -33,7 +41,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> RESTORE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'restore' requires exactly one ingredient, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'restore' requires exactly one ingredient, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> string filename<span class="Delimiter">;</span> @@ -97,7 +105,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> SAVE: <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'save' requires exactly two ingredients, but got "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'save' requires exactly two ingredients, but got "</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -147,3 +155,4 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/998check_type_pointers.cc.html b/html/998check_type_pointers.cc.html index 4db30d6c..2d6d03fc 100644 --- a/html/998check_type_pointers.cc.html +++ b/html/998check_type_pointers.cc.html @@ -3,21 +3,29 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 998check_type_pointers.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.CommentedCode { color: #6c6c6c; } +* { font-size: 12pt; font-size: 1em; } .Comment { color: #9090ff; } +.CommentedCode { color: #6c6c6c; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: enable this when tracking down null types</span> <span class="Comment">//: (but it interferes with edit/; since recipes created in the environment</span> <span class="Comment">//: can raise warnings here which will stop running the entire environment)</span> @@ -57,3 +65,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/999spaces.cc.html b/html/999spaces.cc.html index 1513e987..f72dcc82 100644 --- a/html/999spaces.cc.html +++ b/html/999spaces.cc.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 999spaces.cc</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } +.Comment { color: #9090ff; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } -.Comment { color: #9090ff; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment">//: Since different layers all carve out different parts of various namespaces</span> <span class="Comment">//: (recipes, memory, etc.) for their own use, there's no previous place where</span> <span class="Comment">//: we can lay out the big picture of what uses what. So we'll do that here</span> @@ -111,3 +119,4 @@ assert<span class="Delimiter">(</span>Max_callstack_depth == <span class="Consta </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/channel.mu.html b/html/channel.mu.html index afacb437..c320fdf2 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - channel.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: communicating between routines using channels</span> -<span class="muRecipe">def</span> producer chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ +<span class="muRecipe">def</span> producer chan:address:shared:channel:character<span class="muRecipe"> -> </span>chan:address:shared:channel:character [ <span class="Comment"># produce characters 1 to 5 on a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -36,19 +44,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[produce: ]</span>, n, <span class="Constant">[ </span> <span class="Constant">]</span> - chan:address:shared:channel<span class="Special"> <- </span>write chan, n + chan<span class="Special"> <- </span>write chan, n n<span class="Special"> <- </span>add n, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> consumer chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ +<span class="muRecipe">def</span> consumer chan:address:shared:channel:character<span class="muRecipe"> -> </span>chan:address:shared:channel:character [ <span class="Comment"># consume and print integers from a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> - n:character, chan:address:shared:channel<span class="Special"> <- </span>read chan + n:character, chan<span class="Special"> <- </span>read chan <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[consume: ]</span>, n:character, <span class="Constant">[ </span> <span class="Constant">]</span> @@ -58,7 +66,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> main [ <span class="Constant">local-scope</span> - chan:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3</span> + chan:address:shared:channel:character<span class="Special"> <- </span>new-channel <span class="Constant">3</span> <span class="Comment"># create two background 'routines' that communicate by a channel</span> routine1:number<span class="Special"> <- </span>start-running producer, chan routine2:number<span class="Special"> <- </span>start-running consumer, chan @@ -68,3 +76,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index c04a31dd..6ab2dc38 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -3,29 +3,37 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - chessboard.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } -.CommentedCode { color: #6c6c6c; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } .Special { color: #c00000; } .muScenario { color: #00af00; } -.SalientComment { color: #00ffff; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># Chessboard program: you type in moves in algebraic notation, and it'll</span> <span class="Comment"># display the position after each move.</span> @@ -98,39 +106,34 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> board:address:shared:array:address:shared:array:character<span class="Special"> <- </span>initial-position <span class="Comment"># hook up stdin</span> - stdin:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - start-running send-keys-to-channel, console, stdin, screen + stdin-in:address:shared:source:character, stdin-out:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + start-running send-keys-to-channel, console, stdin-out, screen <span class="Comment"># buffer lines in stdin</span> - buffered-stdin:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - start-running buffer-lines, stdin, buffered-stdin + buffered-stdin-in:address:shared:source:character, buffered-stdin-out:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + start-running buffer-lines, stdin-in, buffered-stdin-out <span class="Delimiter">{</span> - msg:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> + print screen, <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> <span class="Constant">]</span> - print screen, msg cursor-to-next-line screen print-board screen, board cursor-to-next-line screen - msg<span class="Special"> <- </span>new <span class="Constant">[Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.</span> + print screen, <span class="Constant">[Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.</span> <span class="Constant">]</span> - print screen, msg cursor-to-next-line screen - msg<span class="Special"> <- </span>new <span class="Constant">[Hit 'q' to exit.</span> + print screen <span class="Constant">[Hit 'q' to exit.</span> <span class="Constant">]</span> - print screen, msg <span class="Delimiter">{</span> cursor-to-next-line screen - msg<span class="Special"> <- </span>new <span class="Constant">[move: ]</span> - screen<span class="Special"> <- </span>print screen, msg - m:address:shared:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin, screen + screen<span class="Special"> <- </span>print screen, <span class="Constant">[move: ]</span> + m:address:shared:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin-in, screen <span class="muControl">break-if</span> quit, <span class="Constant">+quit:label</span> - buffered-stdin<span class="Special"> <- </span>clear-channel buffered-stdin <span class="Comment"># cleanup after error. todo: test this?</span> + buffered-stdin-in<span class="Special"> <- </span>clear buffered-stdin-in <span class="Comment"># cleanup after error. todo: test this?</span> <span class="muControl">loop-if</span> error <span class="Delimiter">}</span> board<span class="Special"> <- </span>make-move board, m screen<span class="Special"> <- </span>clear-screen screen <span class="muControl">loop</span> <span class="Delimiter">}</span> - msg<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant"> +quit</span> ] @@ -185,8 +188,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># print rank number as a legend</span> rank:number<span class="Special"> <- </span>add row, <span class="Constant">1</span> print-integer screen, rank - s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ | ]</span> - print screen, s + print screen, <span class="Constant">[ | ]</span> <span class="Comment"># print each square in the row</span> col:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -204,12 +206,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print file letters as legend</span> - s<span class="Special"> <- </span>new <span class="Constant">[ +----------------]</span> - print screen, s - screen<span class="Special"> <- </span>cursor-to-next-line screen - s<span class="Special"> <- </span>new <span class="Constant">[ a b c d e f g h]</span> - screen<span class="Special"> <- </span>print screen, s - screen<span class="Special"> <- </span>cursor-to-next-line screen + print screen, <span class="Constant">[ +----------------]</span> + cursor-to-next-line screen + print screen, <span class="Constant">[ a b c d e f g h]</span> + cursor-to-next-line screen ] <span class="muRecipe">def</span> initial-position<span class="muRecipe"> -> </span>board:address:shared:array:address:shared:array:character [ @@ -269,7 +269,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># prints only error messages to screen</span> -<span class="muRecipe">def</span> read-move stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>result:address:shared:move, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ +<span class="muRecipe">def</span> read-move stdin:address:shared:source:character, screen:address:shared:screen<span class="muRecipe"> -> </span>result:address:shared:move, quit?:boolean, error?:boolean, stdin:address:shared:source:character, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> from-file:number, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin, screen @@ -299,7 +299,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># valid values for file: 0-7</span> -<span class="muRecipe">def</span> read-file stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>file:number, quit:boolean, error:boolean, stdin:address:shared:channel, screen:address:shared:screen [ +<span class="muRecipe">def</span> read-file stdin:address:shared:source:character, screen:address:shared:screen<span class="muRecipe"> -> </span>file:number, quit:boolean, error:boolean, stdin:address:shared:source:character, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin @@ -321,8 +321,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? - error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> - print screen, error-message + print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> file:number<span class="Special"> <- </span>subtract c, <span class="Constant">97/a</span> @@ -330,8 +329,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal file, <span class="Constant">0</span> <span class="muControl">break-if</span> above-min - error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[file too low: ]</span> - print screen, error-message + print screen, <span class="Constant">[file too low: ]</span> print screen, c cursor-to-next-line screen <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> @@ -339,8 +337,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> below-max:boolean<span class="Special"> <- </span>lesser-than file, <span class="Constant">8</span> <span class="muControl">break-if</span> below-max - error-message<span class="Special"> <- </span>new <span class="Constant">[file too high: ]</span> - print screen, error-message + print screen, <span class="Constant">[file too high: ]</span> print screen, c <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> @@ -348,7 +345,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># valid values: 0-7, -1 (quit), -2 (error)</span> -<span class="muRecipe">def</span> read-rank stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>rank:number, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ +<span class="muRecipe">def</span> read-rank stdin:address:shared:source:character, screen:address:shared:screen<span class="muRecipe"> -> </span>rank:number, quit?:boolean, error?:boolean, stdin:address:shared:source:character, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin @@ -365,8 +362,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10</span> <span class="Comment"># newline</span> <span class="muControl">break-unless</span> newline? - error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> - print screen, error-message + print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> rank:number<span class="Special"> <- </span>subtract c, <span class="Constant">49/'1'</span> @@ -374,16 +370,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal rank, <span class="Constant">0</span> <span class="muControl">break-if</span> above-min - error-message<span class="Special"> <- </span>new <span class="Constant">[rank too low: ]</span> - print screen, error-message + print screen, <span class="Constant">[rank too low: ]</span> print screen, c <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> below-max:boolean<span class="Special"> <- </span>lesser-or-equal rank, <span class="Constant">7</span> <span class="muControl">break-if</span> below-max - error-message<span class="Special"> <- </span>new <span class="Constant">[rank too high: ]</span> - print screen, error-message + print screen, <span class="Constant">[rank too high: ]</span> print screen, c <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> @@ -392,15 +386,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span class="Comment"># return true on error</span> -<span class="muRecipe">def</span> expect-from-channel stdin:address:shared:channel, expected:character, screen:address:shared:screen<span class="muRecipe"> -> </span>result:boolean, stdin:address:shared:channel, screen:address:shared:screen [ +<span class="muRecipe">def</span> expect-from-channel stdin:address:shared:source:character, expected:character, screen:address:shared:screen<span class="muRecipe"> -> </span>result:boolean, stdin:address:shared:source:character, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin <span class="Delimiter">{</span> match?:boolean<span class="Special"> <- </span>equal c, expected <span class="muControl">break-if</span> match? - s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[expected character not found]</span> - print screen, s + print screen, <span class="Constant">[expected character not found]</span> <span class="Delimiter">}</span> result<span class="Special"> <- </span>not match? ] @@ -408,67 +401,67 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-move-blocking [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen + <span class="Constant">1</span>:address:shared:source:character, <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + <span class="Constant">3</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:source:character, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]</span> <span class="Comment"># press 'a'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">97/a</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after rank 'a']</span> <span class="Comment"># press '2'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">50/'2'</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after file 'a2']</span> <span class="Comment"># press '-'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">45/'-'</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">45/'-'</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?/routine-state, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?/routine-state, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after hyphen 'a2-']</span> <span class="Comment"># press 'a'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">97/a</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?/routine-state, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?/routine-state, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after rank 'a2-a']</span> <span class="Comment"># press '4'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">52/'4'</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">52/'4'</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after file 'a2-a4']</span> <span class="Comment"># press 'newline'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10</span> <span class="Comment"># newline</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">10</span> <span class="Comment"># newline</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' now completes</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number - <span class="Constant">4</span>:boolean/completed?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">1/completed</span> - assert <span class="Constant">4</span>:boolean/completed?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number + <span class="Constant">5</span>:boolean/completed?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">1/completed</span> + assert <span class="Constant">5</span>:boolean/completed?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to terminate on newline]</span> trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> ] @@ -480,22 +473,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-move-quit [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen + <span class="Constant">1</span>:address:shared:source:character, <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + <span class="Constant">3</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel:character, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-quit: routine failed to pause after coming up (before any keys were pressed)]</span> <span class="Comment"># press 'q'</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">113/q</span> - restart <span class="Constant">2</span>:number/routine + <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">2</span>:address:shared:sink:character, <span class="Constant">113/q</span> + restart <span class="Constant">3</span>:number/routine <span class="Comment"># 'read-move' completes</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/completed?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">1/completed</span> - assert <span class="Constant">4</span>:boolean/completed?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/completed?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">1/completed</span> + assert <span class="Constant">5</span>:boolean/completed?, <span class="Constant">[ </span> <span class="Constant">F read-move-quit: routine failed to terminate on 'q']</span> trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> ] @@ -507,17 +500,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-move-illegal-file [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen + <span class="Constant">1</span>:address:shared:source:character, <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + <span class="Constant">3</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:source:character, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-file: routine failed to pause after coming up (before any keys were pressed)]</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span> - restart <span class="Constant">2</span>:number/routine - wait-for-routine <span class="Constant">2</span>:number + <span class="Constant">1</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:character, <span class="Constant">50/'2'</span> + restart <span class="Constant">3</span>:number/routine + wait-for-routine <span class="Constant">3</span>:number ] screen-should-contain [ <span class="Constant"> .file too low: 2 .</span> @@ -528,18 +521,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-move-illegal-rank [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen + <span class="Constant">1</span>:address:shared:source:character, <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + <span class="Constant">3</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:source:character, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-file: routine failed to pause after coming up (before any keys were pressed)]</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - restart <span class="Constant">2</span>:number/routine - wait-for-routine <span class="Constant">2</span>:number + <span class="Constant">1</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:character, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:character, <span class="Constant">97/a</span> + restart <span class="Constant">3</span>:number/routine + wait-for-routine <span class="Constant">3</span>:number ] screen-should-contain [ <span class="Constant"> .rank too high: a .</span> @@ -550,18 +543,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-move-empty [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen + <span class="Constant">1</span>:address:shared:source:character, <span class="Constant">2</span>:address:shared:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + <span class="Constant">3</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:source:character, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> - wait-for-routine <span class="Constant">2</span>:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id - <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> - assert <span class="Constant">4</span>:boolean/waiting?, <span class="Constant">[ </span> + wait-for-routine <span class="Constant">3</span>:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">3</span>:number/id + <span class="Constant">5</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">4</span>:number/routine-state, <span class="Constant">3/waiting</span> + assert <span class="Constant">5</span>:boolean/waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-file: routine failed to pause after coming up (before any keys were pressed)]</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> - restart <span class="Constant">2</span>:number/routine - wait-for-routine <span class="Constant">2</span>:number + <span class="Constant">1</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:character, <span class="Constant">10/newline</span> + <span class="Constant">1</span>:address:shared:sink:character<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:sink:character, <span class="Constant">97/a</span> + restart <span class="Constant">3</span>:number/routine + wait-for-routine <span class="Constant">3</span>:number ] screen-should-contain [ <span class="Constant"> .that's not enough .</span> @@ -618,3 +611,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/console.mu.html b/html/console.mu.html index 66e75380..3dcfef93 100644 --- a/html/console.mu.html +++ b/html/console.mu.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - console.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: reading events from keyboard or mouse</span> <span class="Comment">#</span> <span class="Comment"># Keeps printing 'a' until you press a key or click on the mouse.</span> @@ -41,3 +49,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/counters.mu.html b/html/counters.mu.html index 6b5dd5d4..bdb9cf58 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - counters.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: maintain multiple counters with isolated lexical scopes</span> <span class="Comment"># (spaces)</span> @@ -53,3 +61,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/display.mu.html b/html/display.mu.html index e260f143..dccab090 100644 --- a/html/display.mu.html +++ b/html/display.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - display.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: managing the display</span> <span class="muRecipe">def</span> main [ @@ -47,3 +55,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 94eedbe3..ce68b7be 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/001-editor.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } -.muControl { color: #c0a020; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } .Special { color: #c00000; } .muScenario { color: #00af00; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## the basic editor data structure, and how it displays text to the screen</span> <span class="Comment"># temporary main for this layer: just render the given text at the given</span> @@ -520,3 +528,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index b3f60287..c13b901b 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/002-typing.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.Special { color: #c00000; } .muScenario { color: #00af00; } -.muControl { color: #c0a020; } .Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## handling events from the keyboard, mouse, touch screen, ...</span> <span class="Comment"># temporary main: interactive editor</span> @@ -1070,3 +1078,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index ad5f74b2..28d802b2 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/003-shortcuts.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } +.Special { color: #c00000; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muScenario { color: #00af00; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## special shortcuts for manipulating the editor</span> <span class="Comment"># Some keys on the keyboard generate unicode characters, others generate</span> <span class="Comment"># terminfo key codes. We need to modify different places in the two cases.</span> @@ -3242,3 +3250,4 @@ gxy </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 582d5f40..ca1057c4 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/004-programming-environment.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muScenario { color: #00af00; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } .Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## putting the environment together out of editors</span> <span class="Comment">#</span> <span class="Comment"># Consists of one editor on the left for recipes and one on the right for the</span> @@ -60,8 +68,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start - run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> - print screen, run-button, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> + print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> @@ -412,8 +419,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start - run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> - print screen, run-button, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> + print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> @@ -661,3 +667,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 55e666cb..77cd3727 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/005-sandbox.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.muScenario { color: #00af00; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muData { color: #ffff00; } .Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## running code from the editor and creating sandboxes</span> <span class="Comment">#</span> <span class="Comment"># Running code in the sandbox editor prepends its contents to a list of</span> @@ -154,15 +162,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> do-run?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? - status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[running... ]</span> - screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> + screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> error?:boolean, env, screen<span class="Special"> <- </span>run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> screen<span class="Special"> <- </span>render-all screen, env <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ ]</span> - screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> + screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> @@ -250,7 +256,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># first clear previous versions, in case we deleted some sandbox</span> $system <span class="Constant">[rm lesson/[0-9]</span>* >/dev/null <span class="Constant">2</span>>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr @@ -355,7 +360,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> - suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> curr:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> @@ -368,7 +372,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *data<span class="Special"> <- </span>copy contents <span class="Comment"># restore expected output for sandbox if it exists</span> <span class="Delimiter">{</span> - filename<span class="Special"> <- </span>append filename, suffix + filename<span class="Special"> <- </span>append filename, <span class="Constant">[.out]</span> contents<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents <span class="Constant"> <end-restore-sandbox></span> @@ -390,8 +394,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - header:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[screen:]</span> - row<span class="Special"> <- </span>render screen, header, left, right, <span class="Constant">245/grey</span>, row + row<span class="Special"> <- </span>render screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row screen<span class="Special"> <- </span>move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> column:number<span class="Special"> <- </span>copy left @@ -995,3 +998,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/006-sandbox-edit.mu.html b/html/edit/006-sandbox-edit.mu.html index aaccb0f2..faf615af 100644 --- a/html/edit/006-sandbox-edit.mu.html +++ b/html/edit/006-sandbox-edit.mu.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/006-sandbox-edit.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } +.Special { color: #c00000; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } -.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } -.muScenario { color: #00af00; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## editing sandboxes after they've been created</span> <span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor [ @@ -315,3 +323,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 60ef1edb..cc950bca 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -3,27 +3,35 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/007-sandbox-delete.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } +.Special { color: #c00000; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } -.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } -.muScenario { color: #00af00; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## deleting sandboxes</span> <span class="muScenario">scenario</span> deleting-sandboxes [ @@ -335,3 +343,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/008-sandbox-test.mu.html b/html/edit/008-sandbox-test.mu.html index 150fbb18..2f012d7a 100644 --- a/html/edit/008-sandbox-test.mu.html +++ b/html/edit/008-sandbox-test.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/008-sandbox-test.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Delimiter { color: #800080; } -.muRecipe { color: #ff8700; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } .muData { color: #ffff00; } .Special { color: #c00000; } +.Delimiter { color: #800080; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } -.muScenario { color: #00af00; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## clicking on sandbox results to 'fix' them and turn sandboxes into tests</span> <span class="muScenario">scenario</span> sandbox-click-on-result-toggles-color-to-green [ @@ -120,7 +128,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> expected-response:address:shared:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response - filename<span class="Special"> <- </span>append filename, suffix + filename<span class="Special"> <- </span>append filename, <span class="Constant">[.out]</span> save filename, expected-response <span class="Delimiter">}</span> ] @@ -228,3 +236,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/009-sandbox-trace.mu.html b/html/edit/009-sandbox-trace.mu.html index fb91079e..6464866c 100644 --- a/html/edit/009-sandbox-trace.mu.html +++ b/html/edit/009-sandbox-trace.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/009-sandbox-trace.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Delimiter { color: #800080; } -.muRecipe { color: #ff8700; } +* { font-size: 12pt; font-size: 1em; } +.muScenario { color: #00af00; } .muData { color: #ffff00; } -.muControl { color: #c0a020; } .Special { color: #c00000; } +.Delimiter { color: #800080; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } -.muScenario { color: #00af00; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## clicking on the code typed into a sandbox toggles its trace</span> <span class="muScenario">scenario</span> sandbox-click-on-code-toggles-app-trace [ @@ -238,3 +246,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/010-errors.mu.html b/html/edit/010-errors.mu.html index d65f5c05..eb7f529b 100644 --- a/html/edit/010-errors.mu.html +++ b/html/edit/010-errors.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/010-errors.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } +.muData { color: #ffff00; } +.Special { color: #c00000; } .muScenario { color: #00af00; } -.muControl { color: #c0a020; } .Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } -.muData { color: #ffff00; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## handling malformed programs</span> <span class="muData">container</span> programming-environment-data [ @@ -43,8 +51,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> *recipe-errors - status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> - update-status screen, status, <span class="Constant">1/red</span> + update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -56,8 +63,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color recipe-errors:address:shared:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-errors - status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> - update-status screen, status, <span class="Constant">1/red</span> + update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] @@ -97,9 +103,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color error-index:number<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? - status-template:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found (_) ]</span> error-index-text:address:shared:array:character<span class="Special"> <- </span>to-text error-index - status:address:shared:array:character<span class="Special"> <- </span>interpolate status-template, error-index-text + status:address:shared:array:character<span class="Special"> <- </span>interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text update-status screen, status, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] @@ -277,8 +282,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> -<span class="Constant">z <- add x, [a]</span> -]] +<span class="Constant">y:address:number <- copy 0</span> +<span class="Constant">z <- add x, y</span> +<span class="Constant">]</span>] <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ @@ -290,10 +296,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .load-ingredients ┊0 x.</span> - <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> - <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> - <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .y:address:number <- copy 0 ┊foo 2 .</span> + <span class="Constant"> .z <- add x, y ┊foo_2: 'add' requires number ingredients, but go↩.</span> + <span class="Constant"> .] ┊t y .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] <span class="Comment"># now rerun everything</span> @@ -309,10 +315,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .load-ingredients ┊0 x.</span> - <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> - <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> - <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .y:address:number <- copy 0 ┊foo 2 .</span> + <span class="Constant"> .z <- add x, y ┊foo_3: 'add' requires number ingredients, but go↩.</span> + <span class="Constant"> .] ┊t y .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] ] @@ -724,3 +730,4 @@ _, c:number<span class="Special"> <- </span>divide-with-remainder a, b </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/edit/011-editor-undo.mu.html b/html/edit/011-editor-undo.mu.html index 87160bb0..99b13730 100644 --- a/html/edit/011-editor-undo.mu.html +++ b/html/edit/011-editor-undo.mu.html @@ -3,28 +3,36 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - edit/011-editor-undo.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muScenario { color: #00af00; } -.muControl { color: #c0a020; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } +.Special { color: #c00000; } +.muScenario { color: #00af00; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="SalientComment">## undo/redo</span> <span class="Comment"># for every undoable event, create a type of *operation* that contains all the</span> @@ -2100,3 +2108,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/example1.mu.html b/html/example1.mu.html index 7fb5e965..9e4c8948 100644 --- a/html/example1.mu.html +++ b/html/example1.mu.html @@ -3,22 +3,30 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - example1.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="muRecipe">def</span> example1 [ <span class="Constant">local-scope</span> a:number<span class="Special"> <- </span>add <span class="Constant">2</span>, <span class="Constant">2</span> @@ -27,3 +35,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/factorial.mu.html b/html/factorial.mu.html index 0d7ae988..370fa8e0 100644 --- a/html/factorial.mu.html +++ b/html/factorial.mu.html @@ -3,26 +3,34 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - factorial.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } -.muControl { color: #c0a020; } .Delimiter { color: #800080; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: compute the factorial of 5</span> <span class="muRecipe">def</span> main [ @@ -59,3 +67,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/fork.mu.html b/html/fork.mu.html index dc427385..3f847dc3 100644 --- a/html/fork.mu.html +++ b/html/fork.mu.html @@ -3,24 +3,32 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - fork.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Constant { color: #00a0a0; } -.Delimiter { color: #800080; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Delimiter { color: #800080; } +.Constant { color: #00a0a0; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: running multiple routines</span> <span class="muRecipe">def</span> main [ @@ -40,3 +48,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/global.mu.html b/html/global.mu.html index 5958e523..f155c7b7 100644 --- a/html/global.mu.html +++ b/html/global.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - global.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: creating and using global variables</span> <span class="muRecipe">def</span> main [ @@ -37,3 +45,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/screen.mu.html b/html/screen.mu.html index fd4f68ca..0152db56 100644 --- a/html/screen.mu.html +++ b/html/screen.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - screen.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: managing the display using 'screen' objects</span> <span class="Comment">#</span> <span class="Comment"># The zero screen below means 'use the real screen'. Tests can also use fake</span> @@ -52,3 +60,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/static_dispatch.mu.html b/html/static_dispatch.mu.html index 1bf21604..3e03b537 100644 --- a/html/static_dispatch.mu.html +++ b/html/static_dispatch.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - static_dispatch.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 12pt; font-size: 1em; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } -.Special { color: #c00000; } .Constant { color: #00a0a0; } -.muRecipe { color: #ff8700; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="muRecipe">def</span> test a:number<span class="muRecipe"> -> </span>b:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -44,3 +52,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/tangle.mu.html b/html/tangle.mu.html index f4e73bfc..a654161e 100644 --- a/html/tangle.mu.html +++ b/html/tangle.mu.html @@ -3,25 +3,33 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - tangle.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.muControl { color: #c0a020; } -.Special { color: #c00000; } -.Delimiter { color: #800080; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: constructing functions out of order</span> <span class="Comment">#</span> <span class="Comment"># We construct a factorial function with separate base and recursive cases.</span> @@ -61,3 +69,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/x.mu.html b/html/x.mu.html index 08091fed..eb124c22 100644 --- a/html/x.mu.html +++ b/html/x.mu.html @@ -3,23 +3,31 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - x.mu</title> -<meta name="Generator" content="Vim/7.3"> -<meta name="plugin-version" content="vim7.3_v6"> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> -<meta name="settings" content="use_css"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } -.Special { color: #c00000; } -.Constant { color: #00a0a0; } +* { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } --> </style> + +<script type='text/javascript'> +<!-- + +--> +</script> </head> <body> -<pre> +<pre id='vimCodeElement'> <span class="Comment"># example program: add two numbers</span> <span class="muRecipe">def</span> main [ @@ -31,3 +39,4 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </pre> </body> </html> +<!-- vim: set foldmethod=manual : --> |