diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-15 01:01:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-15 01:01:58 -0700 |
commit | 0ca56ed853c3d9bc8c26d1b014d8b665363fc2d0 (patch) | |
tree | abd2d2e4b65c34797a635aeb2f7d06c9d65c7bf9 | |
parent | 36b927a63cb25e9fc64cf4ae079b32d23d528b1b (diff) | |
download | mu-0ca56ed853c3d9bc8c26d1b014d8b665363fc2d0.tar.gz |
3355
49 files changed, 1704 insertions, 980 deletions
diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 199ac486..52a1b264 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -139,7 +139,7 @@ string slurp_quoted<span class="Delimiter">(</span>istream& in<span class="D <span class="Delimiter">}</span> <span class="Delimiter">:(after "Parsing reagent(string s)")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>s<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>starts_with<span class="Delimiter">(</span>s<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>*s<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">']'</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// unbalanced bracket; handled elsewhere</span> name = s<span class="Delimiter">;</span> <span class="Comment">// delete [] delimiters</span> diff --git a/html/016dilated_reagent.cc.html b/html/016dilated_reagent.cc.html index 60593460..3454ae68 100644 --- a/html/016dilated_reagent.cc.html +++ b/html/016dilated_reagent.cc.html @@ -128,7 +128,7 @@ string slurp_balanced_bracket<span class="Delimiter">(</span>istream& in<spa <span class="Delimiter">}</span> <span class="Delimiter">:(after "Parsing reagent(string s)")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>s<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>starts_with<span class="Delimiter">(</span>s<span class="Delimiter">,</span> <span class="Constant">"{"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>properties<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> in >> std::noskipws<span class="Delimiter">;</span> diff --git a/html/017parse_tree.cc.html b/html/017parse_tree.cc.html index 0acbc8cc..c9cfae37 100644 --- a/html/017parse_tree.cc.html +++ b/html/017parse_tree.cc.html @@ -40,6 +40,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment">// the first element of a type tree is always an atom, and left and right</span> <span class="Comment">// pointers of non-atoms are never NULL. All type trees are 'dotted' in lisp</span> <span class="Comment">// parlance.</span> +<span class="Comment">//</span> +<span class="Comment">// For now you can't use the simpler 'colon-based' representation inside type</span> +<span class="Comment">// trees. Once you start typing parens, keep on typing parens.</span> <span class="Delimiter">:(scenarios load)</span> <span class="Delimiter">:(scenario dilated_reagent_with_nested_brackets)</span> @@ -56,7 +59,7 @@ type_names = parse_string_tree<span class="Delimiter">(</span>type_names<span cl <span class="Delimiter">:(code)</span> string_tree* parse_string_tree<span class="Delimiter">(</span>string_tree* s<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>s<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">-></span>value<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="Identifier">return</span> s<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!starts_with<span class="Delimiter">(</span>s<span class="Delimiter">-></span>value<span class="Delimiter">,</span> <span class="Constant">"("</span><span class="Delimiter">))</span> <span class="Identifier">return</span> s<span class="Delimiter">;</span> string_tree* result = parse_string_tree<span class="Delimiter">(</span>s<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">delete</span> s<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> diff --git a/html/018type_abbreviations.cc.html b/html/018type_abbreviations.cc.html index 5f2ff869..a025de1d 100644 --- a/html/018type_abbreviations.cc.html +++ b/html/018type_abbreviations.cc.html @@ -14,12 +14,12 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.Special { color: #c00000; } -.traceContains { color: #008000; } .cSpecial { color: #008000; } +.traceContains { color: #008000; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } -.SalientComment { color: #00ffff; } +.Special { color: #c00000; } .Identifier { color: #fcb165; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } --> @@ -33,96 +33,199 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </head> <body> <pre id='vimCodeElement'> -<span class="Comment">//: For convenience, make some common types shorter.</span> -<span class="Comment">//:</span> -<span class="Comment">//: a) Rewrite '&t' to 'address:t' and '@t' to 'array:type' (with the</span> -<span class="Comment">//: ability to chain any combination of the two). This is not extensible.</span> -<span class="Comment">//:</span> -<span class="Comment">//: b) Provide a facility to create new type names out of old ones.</span> - -<span class="SalientComment">//:: a) expanding '&' and '@'</span> +<span class="Comment">//: For convenience, allow Mu types to be abbreviated.</span> -<span class="Delimiter">:(scenarios load)</span> -<span class="Delimiter">:(scenario abbreviations_for_address_and_array)</span> +<span class="Delimiter">:(scenarios transform)</span> +<span class="Delimiter">:(scenario type_abbreviations)</span> +type foo = number def main [ - f <span class="Constant">1</span>:&number <span class="Comment"># abbreviation for 'address:number'</span> - f <span class="Constant">2</span>:@number <span class="Comment"># abbreviation for 'array:number'</span> - f <span class="Constant">3</span>:&@number <span class="Comment"># combining '&' and '@'</span> - f <span class="Constant">4</span>:&&@&@number <span class="Comment"># ..any number of times</span> - f <span class="Constant">5</span>:array:&number:<span class="Constant">3</span> <span class="Comment"># abbreviations take precedence over ':'</span> - f <span class="Delimiter">{</span><span class="Constant">6</span>: <span class="Delimiter">(</span>array &number <span class="Constant">3</span><span class="Delimiter">)}</span> <span class="Comment"># support for dilated reagents and more complex parse trees</span> - f <span class="Constant">7</span>:@number:<span class="Constant">3</span> <span class="Comment"># *not* the same as array:number:3</span> + <span class="Normal">a</span>:foo<span class="Special"> <- </span>copy <span class="Constant">34</span> ] -<span class="traceContains">+parse: ingredient: {1: ("address" "number")}</span> -<span class="traceContains">+parse: ingredient: {2: ("array" "number")}</span> -<span class="traceContains">+parse: ingredient: {3: ("address" "array" "number")}</span> -<span class="traceContains">+parse: ingredient: {4: ("address" "address" "array" "address" "array" "number")}</span> -<span class="traceContains">+parse: ingredient: {5: ("array" ("address" "number") "3")}</span> -<span class="traceContains">+parse: ingredient: {6: ("array" ("address" "number") "3")}</span> -<span class="Comment"># not what you want</span> -<span class="traceContains">+parse: ingredient: {7: (("array" "number") "3")}</span> - -<span class="Delimiter">:(scenario abbreviation_error)</span> +<span class="traceContains">+transform: product type after expanding abbreviations: "number"</span> + +<span class="Delimiter">:(before "End Globals")</span> +map<string<span class="Delimiter">,</span> type_tree*> Type_abbreviations<span class="Delimiter">,</span> Type_abbreviations_snapshot<span class="Delimiter">;</span> + +<span class="SalientComment">//:: Defining type abbreviations.</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">"type"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + load_type_abbreviations<span class="Delimiter">(</span>in<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> load_type_abbreviations<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + string new_type_name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">)</span> || !new_type_name<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">)</span> || new_type_name<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"incomplete 'type' statement; must be of the form 'type <new type name> = <type expression>'</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> + string arrow = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">)</span> || !arrow<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>arrow<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"incomplete 'type' statement 'type "</span> << new_type_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="Normal">if</span> <span class="Delimiter">(</span>arrow != <span class="Constant">"="</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type "</span> << new_type_name << <span class="Constant">' '</span> << arrow << <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>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"incomplete 'type' statement 'type "</span> << new_type_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> + string old = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>old<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"incomplete 'type' statement 'type "</span> << new_type_name << <span class="Constant">" ='</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">"'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type "</span> << new_type_name << <span class="Constant">' '</span> << arrow << <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>contains_key<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> new_type_name<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"'type' conflict: '"</span> << new_type_name << <span class="Constant">"' defined as both '"</span> << names_to_string_without_quotes<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> new_type_name<span class="Delimiter">))</span> << <span class="Constant">"' and '"</span> << old << <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> + trace<span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"type"</span><span class="Delimiter">)</span> << <span class="Constant">"alias "</span> << new_type_name << <span class="Constant">" = "</span> << old << end<span class="Delimiter">();</span> + type_tree* old_type = new_type_tree<span class="Delimiter">(</span>old<span class="Delimiter">);</span> + put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> new_type_name<span class="Delimiter">,</span> old_type<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +type_tree* new_type_tree<span class="Delimiter">(</span><span class="Normal">const</span> string& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + string_tree* type_names = starts_with<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"("</span><span class="Delimiter">)</span> ? parse_string_tree<span class="Delimiter">(</span>x<span class="Delimiter">)</span> : parse_string_list<span class="Delimiter">(</span>x<span class="Delimiter">);</span> + type_tree* result = new_type_tree<span class="Delimiter">(</span>type_names<span class="Delimiter">);</span> + <span class="Normal">delete</span> type_names<span class="Delimiter">;</span> + expand_type_abbreviations<span class="Delimiter">(</span>result<span class="Delimiter">);</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +string_tree* parse_string_list<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> + <span class="Identifier">return</span> parse_property_list<span class="Delimiter">(</span>in<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(scenario type_error1)</span> <span class="Special">% Hide_errors = true;</span> +type foo +<span class="traceContains">+error: incomplete 'type' statement 'type foo'</span> + +<span class="Delimiter">:(scenario type_error2)</span> +<span class="Special">% Hide_errors = true;</span> +type foo = +<span class="traceContains">+error: incomplete 'type' statement 'type foo ='</span> + +<span class="Delimiter">:(scenario type_error3)</span> +<span class="Special">% Hide_errors = true;</span> +type foo bar baz +<span class="traceContains">+error: 'type' statements must be of the form 'type <new type name> = <type expression>' but got 'type foo bar'</span> + +<span class="Delimiter">:(scenario type_conflict_error)</span> +<span class="Special">% Hide_errors = true;</span> +type foo = bar +type foo = baz +<span class="traceContains">+error: 'type' conflict: 'foo' defined as both 'bar' and 'baz'</span> + +<span class="Delimiter">:(scenario type_abbreviation_for_compound)</span> +type foo = address:number def main [ - f <span class="Constant">1</span>:&&@& <span class="Comment"># abbreviations without payload</span> + <span class="Normal">a</span>:foo<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="traceContains">+error: invalid type abbreviation &&@&</span> +<span class="traceContains">+transform: product type after expanding abbreviations: ("address" "number")</span> -<span class="Delimiter">:(before "End Parsing Reagent Type Property(type_names)")</span> -string_tree* new_type_names = replace_address_and_array_symbols<span class="Delimiter">(</span>type_names<span class="Delimiter">);</span> -<span class="Normal">delete</span> type_names<span class="Delimiter">;</span> -type_names = new_type_names<span class="Delimiter">;</span> -<span class="Delimiter">:(before "End Parsing Dilated Reagent Type Property(type_names)")</span> -string_tree* new_type_names = replace_address_and_array_symbols<span class="Delimiter">(</span>type_names<span class="Delimiter">);</span> -<span class="Normal">delete</span> type_names<span class="Delimiter">;</span> -type_names = new_type_names<span class="Delimiter">;</span> +<span class="Comment">//: cleaning up type abbreviations between tests and before exiting</span> +<span class="Delimiter">:(before "End save_snapshots")</span> +Type_abbreviations_snapshot = Type_abbreviations<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End restore_snapshots")</span> +restore_type_abbreviations<span class="Delimiter">();</span> +<span class="Delimiter">:(before "End One-time Setup")</span> +atexit<span class="Delimiter">(</span>clear_type_abbreviations<span class="Delimiter">);</span> <span class="Delimiter">:(code)</span> -<span class="Comment">// simple version; lots of unnecessary allocations; always creates a new pointer</span> -string_tree* replace_address_and_array_symbols<span class="Delimiter">(</span>string_tree* orig<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>orig == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>orig<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> - <span class="Identifier">return</span> replace_address_and_array_symbols<span class="Delimiter">(</span>orig<span class="Delimiter">-></span>value<span class="Delimiter">);</span> - <span class="Identifier">return</span> <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>replace_address_and_array_symbols<span class="Delimiter">(</span>orig<span class="Delimiter">-></span>left<span class="Delimiter">),</span> - replace_address_and_array_symbols<span class="Delimiter">(</span>orig<span class="Delimiter">-></span>right<span class="Delimiter">));</span> +<span class="Normal">void</span> restore_type_abbreviations<span class="Delimiter">()</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> type_tree*>::iterator p = Type_abbreviations<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type_abbreviations<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>!contains_key<span class="Delimiter">(</span>Type_abbreviations_snapshot<span class="Delimiter">,</span> p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> + <span class="Normal">delete</span> p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + Type_abbreviations<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + Type_abbreviations = Type_abbreviations_snapshot<span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Normal">void</span> clear_type_abbreviations<span class="Delimiter">()</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> type_tree*>::iterator p = Type_abbreviations<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type_abbreviations<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> + <span class="Normal">delete</span> p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> + Type_abbreviations<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Comment">// todo: unicode</span> -string_tree* replace_address_and_array_symbols<span class="Delimiter">(</span><span class="Normal">const</span> string& type_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>type_name<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>type_name<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> != <span class="Constant">'&'</span> && type_name<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="Identifier">return</span> <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">);</span> - string_tree* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> - string_tree* curr = <span class="Constant">NULL</span><span class="Delimiter">;</span> - <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>i < SIZE<span class="Delimiter">(</span>type_name<span class="Delimiter">))</span> <span class="Delimiter">{</span> - string_tree* new_node = <span class="Constant">NULL</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>type_name<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == <span class="Constant">'&'</span><span class="Delimiter">)</span> - new_node = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span><span class="Constant">"address"</span><span class="Delimiter">);</span> - <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type_name<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == <span class="Constant">'@'</span><span class="Delimiter">)</span> - new_node = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span><span class="Constant">"array"</span><span class="Delimiter">);</span> - <span class="Normal">else</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> - result = curr = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>new_node<span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">);</span> - <span class="Normal">else</span> <span class="Delimiter">{</span> - curr<span class="Delimiter">-></span>right = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>new_node<span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">);</span> - curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> +<span class="SalientComment">//:: A few default abbreviations.</span> + +<span class="Delimiter">:(before "End Mu Types Initialization")</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"&"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"address"</span><span class="Delimiter">));</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"@"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"array"</span><span class="Delimiter">));</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"num"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"number"</span><span class="Delimiter">));</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"bool"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"boolean"</span><span class="Delimiter">));</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"char"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"character"</span><span class="Delimiter">));</span> + +<span class="Delimiter">:(scenario use_type_abbreviations_when_declaring_type_abbreviations)</span> +type foo = &:num +def main [ + <span class="Normal">a</span>:foo<span class="Special"> <- </span>copy <span class="Constant">0</span> +] +<span class="traceContains">+transform: product type after expanding abbreviations: ("address" "number")</span> + +<span class="SalientComment">//:: Expand type aliases before running.</span> +<span class="Comment">//: We'll do this in a transform so that we don't need to define abbreviations</span> +<span class="Comment">//: before we use them.</span> + +<span class="Delimiter">:(scenario abbreviations_for_address_and_array)</span> +def main [ + f <span class="Constant">1</span>:&:number <span class="Comment"># abbreviation for 'address:number'</span> + f <span class="Constant">2</span>:@:number <span class="Comment"># abbreviation for 'array:number'</span> + f <span class="Constant">3</span>:&:@:number <span class="Comment"># combining '&' and '@'</span> + f <span class="Constant">4</span>:&:&:@:&:@:number <span class="Comment"># ..any number of times</span> + f <span class="Delimiter">{</span><span class="Constant">5</span>: <span class="Delimiter">(</span>array <span class="Delimiter">(</span>& number<span class="Delimiter">)</span> <span class="Constant">3</span><span class="Delimiter">)}</span> <span class="Comment"># support for dilated reagents and more complex parse trees</span> +] +def f [ +] +<span class="traceContains">+transform: --- expand type abbreviations in recipe 'main'</span> +<span class="traceContains">+transform: ingredient type after expanding abbreviations: ("address" "number")</span> +<span class="traceContains">+transform: ingredient type after expanding abbreviations: ("array" "number")</span> +<span class="traceContains">+transform: ingredient type after expanding abbreviations: ("address" "array" "number")</span> +<span class="traceContains">+transform: ingredient type after expanding abbreviations: ("address" "address" "array" "address" "array" "number")</span> +<span class="traceContains">+transform: ingredient type after expanding abbreviations: ("array" ("address" "number") "3")</span> + +<span class="Delimiter">:(before "Transform.push_back(update_instruction_operations)")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>expand_type_abbreviations<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> +<span class="Comment">// Begin Type Modifying Transforms</span> +<span class="Comment">// End Type Modifying Transforms</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> expand_type_abbreviations<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">"--- expand type abbreviations in recipe '"</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">"'"</span> << end<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> + 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">"instruction '"</span> << inst<span class="Delimiter">.</span>original_string << end<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 < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + expand_type_abbreviations<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> + 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">"ingredient type after expanding abbreviations: "</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">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> + expand_type_abbreviations<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> + 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">"product type after expanding abbreviations: "</span> << names_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>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - ++i<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>i < SIZE<span class="Delimiter">(</span>type_name<span class="Delimiter">))</span> - curr<span class="Delimiter">-></span>right = <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">.</span>substr<span class="Delimiter">(</span>i<span class="Delimiter">));</span> - <span class="Normal">else</span> - raise << <span class="Constant">"invalid type abbreviation "</span> << type_name << <span class="Constant">"</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="Comment">// End Expand Type Abbreviations(caller)</span> <span class="Delimiter">}</span> -<span class="SalientComment">//:: b) extensible type abbreviations</span> - -<span class="Delimiter">:(before "End Globals")</span> -map<string<span class="Delimiter">,</span> type_tree*> Type_abbreviations<span class="Delimiter">;</span> +<span class="Normal">void</span> expand_type_abbreviations<span class="Delimiter">(</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="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> + expand_type_abbreviations<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">);</span> + expand_type_abbreviations<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<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>contains_key<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> type<span class="Delimiter">-></span>name<span class="Delimiter">))</span> + *type = type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> type<span class="Delimiter">-></span>name<span class="Delimiter">));</span> +<span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/020run.cc.html b/html/020run.cc.html index bf415da3..a4ddb087 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -94,10 +94,8 @@ map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> run_current_routine<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> run_current_routine<span class="Delimiter">()</span> -<span class="Delimiter">{</span> <span class="Comment">// curly on a separate line, because later layers will modify function header</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>completed<span class="Delimiter">())</span> <span class="Comment">// later layers will modify condition</span> - <span class="Delimiter">{</span> +<span class="Normal">void</span> run_current_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> + <span class="Normal">while</span> <span class="Delimiter">(</span>should_continue_running<span class="Delimiter">(</span>Current_routine<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// beware: later layers modify Current_routine here</span> <span class="Comment">// Running One Instruction</span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span> ++current_step_index<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span>Initial_callstack_depth + Trace_stream<span class="Delimiter">-></span>callstack_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << end<span class="Delimiter">();</span> @@ -140,6 +138,11 @@ map<string<span class="Delimiter">,</span> <span class="Normal">int</span>> <span class="Normal">stop_running_current_routine</span>:<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Normal">bool</span> should_continue_running<span class="Delimiter">(</span><span class="Normal">const</span> routine* current_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>current_routine == Current_routine<span class="Delimiter">);</span> <span class="Comment">// argument passed in just to make caller readable above</span> + <span class="Identifier">return</span> !Current_routine<span class="Delimiter">-></span>completed<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + <span class="Normal">bool</span> should_copy_ingredients<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// End should_copy_ingredients Special-cases</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> diff --git a/html/030container.cc.html b/html/030container.cc.html index cb41b4fd..38136c79 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -210,7 +210,7 @@ type_info t = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</ <span class="Comment">//: precompute Container_metadata before we need size_of</span> <span class="Comment">//: also store a copy in each reagent in each instruction in each recipe</span> -<span class="Delimiter">:(after "Begin Instruction Modifying Transforms")</span> <span class="Comment">// needs to happen before transform_names, therefore after Type Modifying Transforms below</span> +<span class="Delimiter">:(after "End Type Modifying Transforms")</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>compute_container_sizes<span class="Delimiter">);</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -457,8 +457,9 @@ 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">"first ingredient of 'get' should be a container, but got '"</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>original_string << <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">const</span> type_tree* base_root_type = base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>atom ? base<span class="Delimiter">.</span>type : base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!base_root_type<span class="Delimiter">-></span>atom || base_root_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> + <span class="Comment">// Update GET base_type in Check</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != CONTAINER<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">"first ingredient of 'get' should be a container, but got '"</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>original_string << <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> @@ -472,14 +473,14 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">else</span> offset_value = offset<span class="Delimiter">.</span>value<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_root_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>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid offset '"</span> << offset_value << <span class="Constant">"' for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<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">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>value<span class="Delimiter">).</span>elements<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">"invalid offset '"</span> << offset_value << <span class="Constant">"' for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<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">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> <span class="Identifier">break</span><span class="Delimiter">;</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> 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 GET product in Check</span> - <span class="Normal">const</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_root_type because later layers will introduce compound types</span> + <span class="Normal">const</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>product<span class="Delimiter">,</span> element<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 "</span> << base<span class="Delimiter">.</span>original_string << <span class="Constant">", "</span> << offset<span class="Delimiter">.</span>original_string << <span class="Constant">"' should write to "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" but '"</span> << product<span class="Delimiter">.</span>name << <span class="Constant">"' has type "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -495,13 +496,14 @@ 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">"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">const</span> type_tree* base_root_type = root_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">);</span> + <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> + <span class="Comment">// Update GET base_type in Run</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_root_type<span class="Delimiter">-></span>value<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">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>value<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> assert<span class="Delimiter">(</span>base<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">);</span> <span class="Normal">int</span> src = base_address + base<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>offset<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<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> - reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset<span class="Delimiter">);</span> <span class="Comment">// not just base_root_type because later layers will introduce compound types</span> + reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> element<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>src<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> << names_to_string<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Comment">// Read element</span> @@ -600,8 +602,9 @@ 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">"first ingredient of 'put' should be a container, but got '"</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>original_string << <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">const</span> type_tree* base_root_type = base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>atom ? base<span class="Delimiter">.</span>type : base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!base_root_type<span class="Delimiter">-></span>atom || base_root_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> + <span class="Comment">// Update PUT base_type in Check</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != CONTAINER<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">"first ingredient of 'put' should be a container, but got '"</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>original_string << <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> @@ -614,8 +617,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<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_root_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>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid offset '"</span> << offset_value << <span class="Constant">"' for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_root_type<span class="Delimiter">-></span>value<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">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>value<span class="Delimiter">).</span>elements<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">"invalid offset '"</span> << offset_value << <span class="Constant">"' for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<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">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -623,7 +626,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span offset_value = offset<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">const</span> reagent& value = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> - <span class="Normal">const</span> reagent& element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_root_type because later layers will introduce compound types</span> + <span class="Normal">const</span> reagent& element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>element<span class="Delimiter">,</span> value<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">"'put "</span> << base<span class="Delimiter">.</span>original_string << <span class="Constant">", "</span> << offset<span class="Delimiter">.</span>original_string << <span class="Constant">"' should write to "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" but '"</span> << value<span class="Delimiter">.</span>name << <span class="Constant">"' has type "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>value<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -645,9 +648,10 @@ 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">"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">const</span> type_tree* base_root_type = root_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">);</span> + <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> + <span class="Comment">// Update PUT base_type in Run</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_root_type<span class="Delimiter">-></span>value<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">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>value<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">int</span> address = base_address + base<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>offset<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<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 to is "</span> << address << end<span class="Delimiter">();</span> <span class="Comment">// optimization: directly write the element rather than updating 'product'</span> @@ -813,8 +817,33 @@ container foo [ ] <span class="traceContains">+error: container 'foo' contains multiple elements on a single line. Containers and exclusive containers must only contain elements, one to a line, no code.</span> -<span class="Comment">//: ensure scenarios are consistent by always starting them at the same type</span> -<span class="Comment">//: number.</span> +<span class="Comment">//: support type abbreviations in container definitions</span> + +<span class="Delimiter">:(scenario type_abbreviations_in_containers)</span> +type foo = number +container bar [ + <span class="Normal">x</span>:foo +] +def main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">2</span>:foo<span class="Special"> <- </span>get <span class="Constant">1</span>:bar/unsafe<span class="Delimiter">,</span> <span class="Constant">0</span>:offset +] +<span class="traceContains">+mem: storing 34 in location 2</span> + +<span class="Delimiter">:(after "Transform.push_back(expand_type_abbreviations)")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>expand_type_abbreviations_in_containers<span class="Delimiter">);</span> +<span class="Delimiter">:(code)</span> +<span class="Comment">// extremely inefficient; we process all types over and over again, once for every single recipe</span> +<span class="Comment">// but it doesn't seem to cause any noticeable slowdown</span> +<span class="Normal">void</span> expand_type_abbreviations_in_containers<span class="Delimiter">(</span>unused <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<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">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> + expand_type_abbreviations<span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<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="Delimiter">}</span> +<span class="Delimiter">}</span> + +<span class="Comment">//: ensure scenarios are consistent by always starting new container</span> +<span class="Comment">//: declarations at the same type number</span> <span class="Delimiter">:(before "End Setup")</span> <span class="Comment">//: for tests</span> Next_type_ordinal = <span class="Constant">1000</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Test Run Initialization")</span> @@ -856,10 +885,8 @@ container bar [ ] $error: <span class="Constant">0</span> -<span class="Delimiter">:(after "Begin Instruction Modifying Transforms")</span> -<span class="Comment">// Begin Type Modifying Transforms</span> +<span class="Delimiter">:(before "End Type Modifying Transforms")</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_or_set_invalid_types<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> -<span class="Comment">// End Type Modifying Transforms</span> <span class="Delimiter">:(code)</span> <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> diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index 5068a365..01cdfbfb 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -144,8 +144,9 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'maybe-convert' should be an exclusive-container, but got '"</span> << base<span class="Delimiter">.</span>original_string << <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">const</span> type_tree* root_type = base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>atom ? base<span class="Delimiter">.</span>type : base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!root_type<span class="Delimiter">-></span>atom || root_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> + <span class="Comment">// Update MAYBE_CONVERT base_type in Check</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<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">"first ingredient of 'maybe-convert' should be an exclusive-container, but got '"</span> << base<span class="Delimiter">.</span>original_string << <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> @@ -162,7 +163,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// Update MAYBE_CONVERT product in Check</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> root_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <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_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> << inst<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> diff --git a/html/035lookup.cc.html b/html/035lookup.cc.html index 43b6ffb1..a06d93c6 100644 --- a/html/035lookup.cc.html +++ b/html/035lookup.cc.html @@ -515,7 +515,7 @@ def main [ <span class="Delimiter">:(before "End Parsing reagent")</span> <span class="Delimiter">{</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>!name<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && name<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">while</span> <span class="Delimiter">(</span>starts_with<span class="Delimiter">(</span>name<span class="Delimiter">,</span> <span class="Constant">"*"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> name<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</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><span class="Constant">"lookup"</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> diff --git a/html/041jump_target.cc.html b/html/041jump_target.cc.html index 045e3680..8fb25054 100644 --- a/html/041jump_target.cc.html +++ b/html/041jump_target.cc.html @@ -61,7 +61,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa 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>starts_with<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<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> put<span class="Delimiter">(</span>offset<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">,</span> i<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -123,7 +123,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Normal">bool</span> is_jump_target<span class="Delimiter">(</span>string label<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</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="Identifier">return</span> starts_with<span class="Delimiter">(</span>label<span class="Delimiter">,</span> <span class="Constant">"+"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario break_to_label)</span> diff --git a/html/047check_type_by_name.cc.html b/html/047check_type_by_name.cc.html index 507c7c2d..c7927417 100644 --- a/html/047check_type_by_name.cc.html +++ b/html/047check_type_by_name.cc.html @@ -48,7 +48,7 @@ def main [ ] <span class="traceContains">+error: main: 'x' used with multiple types</span> -<span class="Delimiter">:(after "Begin Instruction Modifying Transforms")</span> +<span class="Delimiter">:(after "Transform.push_back(expand_type_abbreviations)")</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_or_set_types_by_name<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(code)</span> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 7281a95b..7554e95a 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -121,7 +121,7 @@ scenario parse_scenario<span class="Delimiter">(</span>istream& in<span clas <span class="Comment">// inside comments</span> result<span class="Delimiter">.</span>to_run = slurp_quoted<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Comment">// delete [] delimiters</span> - assert<span class="Delimiter">(</span>result<span class="Delimiter">.</span>to_run<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> + assert<span class="Delimiter">(</span>starts_with<span class="Delimiter">(</span>result<span class="Delimiter">.</span>to_run<span class="Delimiter">,</span> <span class="Constant">"["</span><span class="Delimiter">));</span> result<span class="Delimiter">.</span>to_run<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>result<span class="Delimiter">.</span>to_run<span class="Delimiter">.</span>at<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>to_run<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">)</span> == <span class="Constant">']'</span><span class="Delimiter">);</span> result<span class="Delimiter">.</span>to_run<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>to_run<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">);</span> diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index 3d785dc4..aa26c35c 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -179,6 +179,28 @@ def test [ 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">"recipe "</span> << result<span class="Delimiter">.</span>name << <span class="Constant">" has a header"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> +<span class="Comment">//: Support type abbreviations in headers.</span> + +<span class="Delimiter">:(scenario type_abbreviations_in_recipe_headers)</span> +type string = address:array:character +def main [ + local-scope + <span class="Normal">a</span>:string<span class="Special"> <- </span>foo + <span class="Constant">1</span>:character/<span class="Special">raw <- </span>index *a<span class="Delimiter">,</span> <span class="Constant">0</span> +] +def foo <span class="Delimiter">-></span> a:string [ + local-scope + load-ingredients + a<span class="Special"> <- </span><span class="Normal">new</span> [abc] +] +<span class="traceContains">+mem: storing 97 in location 1</span> + +<span class="Delimiter">:(before "End Expand Type Abbreviations(caller)")</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 < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + expand_type_abbreviations<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> +<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 < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + expand_type_abbreviations<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> + <span class="Comment">//: Rewrite 'load-ingredients' to instructions to create all reagents in the header.</span> <span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> @@ -258,8 +280,8 @@ def foo x:number <span class="Delimiter">-></span> y:number [ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_calls_against_header<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(code)</span> <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> + 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> << caller<span class="Delimiter">.</span>name << end<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> diff --git a/html/054static_dispatch.cc.html b/html/054static_dispatch.cc.html index d47162c6..8e4e06cb 100644 --- a/html/054static_dispatch.cc.html +++ b/html/054static_dispatch.cc.html @@ -103,14 +103,16 @@ string matching_variant_name<span class="Delimiter">(</span><span class="Normal" <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">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> + expand_type_abbreviations<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> + expand_type_abbreviations<span class="Delimiter">(</span>r2<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="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="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">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> + expand_type_abbreviations<span class="Delimiter">(</span>r1<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> + expand_type_abbreviations<span class="Delimiter">(</span>r2<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="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="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -646,6 +648,22 @@ def foo a:boolean <span class="Delimiter">-></span> b:number [ <span class="traceContains">+error: main: missing type for 'x' in 'y:number <- foo x'</span> <span class="traceContains">+error: main: failed to find a matching call for 'y:number <- foo x'</span> +<span class="Delimiter">:(scenario override_methods_with_type_abbreviations)</span> +type string = address:array:character +def main [ + local-scope + <span class="Normal">s</span>:address:array:character<span class="Special"> <- </span><span class="Normal">new</span> [abc] + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo s +] +def foo a:address:array:character <span class="Delimiter">-></span> result:number [ + <span class="Identifier">return</span> <span class="Constant">34</span> +] +<span class="Comment"># identical to previous variant once you take type abbreviation into account</span> +def! foo a:string <span class="Delimiter">-></span> result:number [ + <span class="Identifier">return</span> <span class="Constant">35</span> +] +<span class="traceContains">+mem: storing 35 in location 1</span> + <span class="Delimiter">:(before "End Includes")</span> <span class="Normal">using</span> std::abs<span class="Delimiter">;</span> </pre> diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index cb17f5bb..d6bc71c3 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -44,6 +44,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(before "End is_mu_exclusive_container(type) Special-cases")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Identifier">return</span> is_mu_exclusive_container<span class="Delimiter">(</span>root_type<span class="Delimiter">(</span>type<span class="Delimiter">));</span> +<span class="Comment">// a few calls to root_type() without the assertion (for better error handling)</span> +<span class="Delimiter">:(after "Update GET base_type in Check")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> base_type = base_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> +<span class="Delimiter">:(after "Update GET base_type in Run")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> base_type = base_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> +<span class="Delimiter">:(after "Update PUT base_type in Check")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> base_type = base_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> +<span class="Delimiter">:(after "Update PUT base_type in Run")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> base_type = base_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> +<span class="Delimiter">:(after "Update MAYBE_CONVERT base_type in Check")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> base_type = base_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> <span class="Delimiter">:(scenario size_of_shape_shifting_container)</span> container foo:_t [ @@ -187,7 +198,7 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n raise << container_name << <span class="Constant">": empty type ingredients not permitted</span><span class="cSpecial">\n</span><span class="Constant">"</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">if</span> <span class="Delimiter">(</span>curr<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>!starts_with<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"_"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << container_name << <span class="Constant">": type ingredient '"</span> << curr << <span class="Constant">"' must begin with an underscore</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -216,7 +227,7 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> <span class="Normal">bool</span> is_type_ingredient_name<span class="Delimiter">(</span><span class="Normal">const</span> string& type<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> !type<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && type<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="Identifier">return</span> starts_with<span class="Delimiter">(</span>type<span class="Delimiter">,</span> <span class="Constant">"_"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Container Type Checks")</span> diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index f03430ff..347be81a 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -62,8 +62,13 @@ def foo a:_t <span class="Delimiter">-></span> result:_t [ <span class="Comment">//: be rewriting such instructions to *specializations* with the type</span> <span class="Comment">//: ingredients filled in.</span> +<span class="Comment">//: One exception (and this makes things very ugly): we need to expand type</span> +<span class="Comment">//: abbreviations in shape-shifting recipes because we need them types for</span> +<span class="Comment">//: deciding which variant to specialize.</span> + <span class="Delimiter">:(before "End Transform Checks")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>any_type_ingredient_in_header<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">recipe_ordinal</span><span class="Comment">*/</span>p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +r<span class="Delimiter">.</span>transformed_until = t<span class="Delimiter">;</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>Transform<span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">)</span> != <span class="Normal">static_cast</span><transform_fn><span class="Delimiter">(</span>expand_type_abbreviations<span class="Delimiter">)</span> && any_type_ingredient_in_header<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">recipe_ordinal</span><span class="Comment">*/</span>p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">:(after "Running One Instruction")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_step_index == <span class="Constant">0</span> diff --git a/html/058to_text.cc.html b/html/058to_text.cc.html new file mode 100644 index 00000000..c79ad7fc --- /dev/null +++ b/html/058to_text.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 - 058to_text.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; } +.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 id='vimCodeElement'> +<span class="Comment">//: Primitive to convert any type to text (array of characters).</span> +<span class="Comment">//: Later layers will allow us to override this to do something smarter for</span> +<span class="Comment">//: specific types.</span> + +<span class="Delimiter">:(before "End Mu Types Initialization")</span> +put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"text"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"address:array:character"</span><span class="Delimiter">));</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> << inst<span class="Delimiter">.</span>original_string << <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="Comment">// can handle any type</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/059to_text.mu.html b/html/059to_text.mu.html new file mode 100644 index 00000000..deaacdf7 --- /dev/null +++ b/html/059to_text.mu.html @@ -0,0 +1,66 @@ +<!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 - 059to_text.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; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } +.Comment { color: #9090ff; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment"># A couple of variants of `to-text` that we'll use implicitly in stashes (see</span> +<span class="Comment"># later layers).</span> +<span class="Comment">#</span> +<span class="Comment"># Mu code might specialize them to be smarter, but I don't anticipate any need</span> +<span class="Comment"># beyond specializing `to-text` itself.</span> + +<span class="Comment"># 'shorter' variant of to-text, when you want to enable some sort of trimming</span> +<span class="Comment"># define it to be identical to 'to-text' by default</span> +<span class="muRecipe">def</span> to-text-line x:_elem<span class="muRecipe"> -> </span>y:text [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + 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:array:_elem<span class="muRecipe"> -> </span>y:text [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + y<span class="Special"> <- </span>to-text *x +] + +<span class="muScenario">scenario</span> to-text-line-early-warning-for-static-dispatch [ + x:text<span class="Special"> <- </span>to-text-line <span class="Constant">34</span> + <span class="Comment"># just ensure there were no errors</span> +] + +<span class="muScenario">scenario</span> array-to-text-line-early-warning-for-static-dispatch [ + n:address:array:number<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> + x:text<span class="Special"> <- </span>array-to-text-line n + <span class="Comment"># just ensure there were no errors</span> +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/061text.mu.html b/html/061text.mu.html index 268d4275..e1a99fc8 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -34,22 +34,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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> -<span class="Comment"># define it to be identical to 'to-text' by default</span> -<span class="muRecipe">def</span> to-text-line x:_elem<span class="muRecipe"> -> </span>y:address: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"># variant for arrays (since we can't pass them around otherwise)</span> -<span class="muRecipe">def</span> array-to-text-line x:address:array:_elem<span class="muRecipe"> -> </span>y:address:array:character [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - y<span class="Special"> <- </span>to-text *x -] - -<span class="muRecipe">def</span> equal a:address:array:character, b:address:array:character<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> equal a:text, b:text<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> a-len:number<span class="Special"> <- </span>length *a @@ -83,7 +68,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-reflexive [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, x ] memory-should-contain [ @@ -94,8 +79,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-identical [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -106,8 +91,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-distinct-lengths [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -124,8 +109,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-with-empty [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -136,8 +121,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-common-lengths-but-distinct [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abd]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -148,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># A new type to help incrementally construct texts.</span> <span class="muData">container</span> buffer [ length:number - data:address:array:character + data:text ] <span class="muRecipe">def</span> new-buffer capacity:number<span class="muRecipe"> -> </span>result:address:buffer [ @@ -161,7 +146,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># capacity not provided</span> capacity<span class="Special"> <- </span>copy <span class="Constant">10</span> <span class="Delimiter">}</span> - data:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity + data:text<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, data <span class="muControl">return</span> result ] @@ -170,10 +155,10 @@ 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"># double buffer size</span> - olddata:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + olddata:text<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> oldlen:number<span class="Special"> <- </span>length *olddata newlen:number<span class="Special"> <- </span>multiply oldlen, <span class="Constant">2</span> - newdata:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, newlen + newdata:text<span class="Special"> <- </span>new <span class="Constant">character:type</span>, newlen *in<span class="Special"> <- </span>put *in, <span class="Constant">data:offset</span>, newdata <span class="Comment"># copy old contents</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -191,7 +176,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>get *in, <span class="Constant">length:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:text<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> capacity:number<span class="Special"> <- </span>length *s result<span class="Special"> <- </span>greater-or-equal len, capacity ] @@ -200,7 +185,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> append buf:address:buffer, x:_elem<span class="muRecipe"> -> </span>buf:address:buffer [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - text:address:array:character<span class="Special"> <- </span>to-text x + text:text<span class="Special"> <- </span>to-text x len:number<span class="Special"> <- </span>length *text i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -233,7 +218,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-unless</span> full? in<span class="Special"> <- </span>grow-buffer in <span class="Delimiter">}</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:text<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> *s<span class="Special"> <- </span>put-index *s, len, c len<span class="Special"> <- </span>add len, <span class="Constant">1</span> *in<span class="Special"> <- </span>put *in, <span class="Constant">length:offset</span>, len @@ -243,20 +228,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ <span class="Constant">local-scope</span> x:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> - s1:address:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + s1:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> c:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> x<span class="Special"> <- </span>append x, c c:character<span class="Special"> <- </span>copy <span class="Constant">98/b</span> x<span class="Special"> <- </span>append x, c c:character<span class="Special"> <- </span>copy <span class="Constant">99/c</span> x<span class="Special"> <- </span>append x, c - s2:address:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + s2:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal s1, s2 <span class="Constant">11</span>:array:character/<span class="Special">raw <- </span>copy *s2 <span class="Constant"> +buffer-filled</span> c:character<span class="Special"> <- </span>copy <span class="Constant">100/d</span> x<span class="Special"> <- </span>append x, c - s3:address:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + s3:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> <span class="Constant">20</span>:boolean/<span class="Special">raw <- </span>equal s1, s3 <span class="Constant">21</span>:number/<span class="Special">raw <- </span>get *x, <span class="Constant">length:offset</span> <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s3 @@ -300,7 +285,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x<span class="Special"> <- </span>append x, c c:character<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> x<span class="Special"> <- </span>append x, c - s:address:array:character<span class="Special"> <- </span>buffer-to-array x + s:text<span class="Special"> <- </span>buffer-to-array x <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *s ] memory-should-contain [ @@ -310,7 +295,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> buffer-to-array in:address:buffer<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> buffer-to-array in:address:buffer<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -319,7 +304,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0</span> <span class="Delimiter">}</span> len:number<span class="Special"> <- </span>get *in, <span class="Constant">length:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:text<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> <span class="Comment"># we can't just return s because it is usually the wrong length</span> result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -333,7 +318,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> append a:address:array:character, b:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> append a:text, b:text<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># handle null addresses</span> @@ -376,9 +361,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-append-1 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> - z:address:array:character<span class="Special"> <- </span>append x, y + x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> + z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -389,9 +374,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-append-null [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>copy <span class="Constant">0</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> - z:address:array:character<span class="Special"> <- </span>append x, y + x:text<span class="Special"> <- </span>copy <span class="Constant">0</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> + z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -402,9 +387,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-append-null-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> - y:address:array:character<span class="Special"> <- </span>copy <span class="Constant">0</span> - z:address:array:character<span class="Special"> <- </span>append x, y + x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> + y:text<span class="Special"> <- </span>copy <span class="Constant">0</span> + z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -415,7 +400,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-character-in-text [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">98/b</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *x ] @@ -424,7 +409,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> replace s:address:array:character, oldc:character, newc:character, from:number/optional<span class="muRecipe"> -> </span>s:address:array:character [ +<span class="muRecipe">def</span> replace s:text, oldc:character, newc:character, from:number/optional<span class="muRecipe"> -> </span>s:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>length *s @@ -439,7 +424,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-character-at-start [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">97/a</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *x ] @@ -451,7 +436,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-character-at-end [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">99/c</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *x ] @@ -463,7 +448,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-character-missing [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">100/d</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *x ] @@ -475,7 +460,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-all-characters [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[banana]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[banana]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">97/a</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *x ] @@ -485,7 +470,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># replace underscores in first with remaining args</span> -<span class="muRecipe">def</span> interpolate template:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> interpolate template:text<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># consume just the template</span> <span class="Comment"># compute result-len, space to allocate for result</span> @@ -493,7 +478,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result-len:number<span class="Special"> <- </span>copy tem-len <span class="Delimiter">{</span> <span class="Comment"># while ingredients remain</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + a:text, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="muControl">break-unless</span> arg-received? <span class="Comment"># result-len = result-len + arg.length - 1 (for the 'underscore' being replaced)</span> a-len:number<span class="Special"> <- </span>length *a @@ -509,7 +494,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="Comment"># while arg received</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + a:text, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="muControl">break-unless</span> arg-received? <span class="Comment"># copy template into result until '_'</span> <span class="Delimiter">{</span> @@ -561,9 +546,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> interpolate-works [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc_ghi]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - z:address:array:character<span class="Special"> <- </span>interpolate x, y + x:text<span class="Special"> <- </span>new <span class="Constant">[abc_ghi]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> + z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -574,9 +559,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> interpolate-at-start [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[_, hello!]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - z:address:array:character<span class="Special"> <- </span>interpolate x, y + x:text<span class="Special"> <- </span>new <span class="Constant">[_, hello!]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -587,9 +572,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> interpolate-at-end [ run [ - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[hello, _]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - z:address:array:character<span class="Special"> <- </span>interpolate x, y + x:text<span class="Special"> <- </span>new <span class="Constant">[hello, _]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ @@ -659,7 +644,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result<span class="Special"> <- </span>equal c, <span class="Constant">12288/ideographic-space</span> ] -<span class="muRecipe">def</span> trim s:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> trim s:text<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>length *s @@ -691,7 +676,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># result = new character[end+1 - start]</span> new-len:number<span class="Special"> <- </span>subtract end, start, <span class="Constant">-1</span> - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, new-len + result:text<span class="Special"> <- </span>new <span class="Constant">character:type</span>, new-len <span class="Comment"># copy the untrimmed parts between start and end</span> i:number<span class="Special"> <- </span>copy start j:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -711,8 +696,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-unmodified [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>trim x + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -723,8 +708,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-left [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> - y:address:array:character<span class="Special"> <- </span>trim x + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> + y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -735,8 +720,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-right [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc ]</span> - y:address:array:character<span class="Special"> <- </span>trim x + x:text<span class="Special"> <- </span>new <span class="Constant">[abc ]</span> + y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -747,8 +732,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-left-right [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc ]</span> - y:address:array:character<span class="Special"> <- </span>trim x + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc ]</span> + y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -759,9 +744,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-newline-tab [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc</span> <span class="Constant">]</span> - y:address:array:character<span class="Special"> <- </span>trim x + y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -769,7 +754,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> find-next text:address:array:character, pattern:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ +<span class="muRecipe">def</span> find-next text:text, pattern:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>length *text @@ -788,7 +773,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -799,7 +784,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-empty [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -810,7 +795,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-initial [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -821,7 +806,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-final [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -832,7 +817,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-missing [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -843,7 +828,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-invalid-index [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">4/start-index</span> ] memory-should-contain [ @@ -854,7 +839,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-first [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -865,7 +850,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next-second [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">3/start-index</span> ] memory-should-contain [ @@ -875,7 +860,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># search for a pattern of multiple characters</span> <span class="Comment"># fairly dumb algorithm</span> -<span class="muRecipe">def</span> find-next text:address:array:character, pattern:address:array:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ +<span class="muRecipe">def</span> find-next text:text, pattern:text, idx:number<span class="muRecipe"> -> </span>next-index:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> first:character<span class="Special"> <- </span>index *pattern, <span class="Constant">0</span> @@ -898,8 +883,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-text-1 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -910,8 +895,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-text-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">1</span> ] memory-should-contain [ @@ -922,8 +907,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-no-match [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bd]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -934,8 +919,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-suffix-match [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[cd]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[cd]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -946,8 +931,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-suffix-match-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[cde]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[cde]</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -956,7 +941,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># checks if pattern matches at index 'idx'</span> -<span class="muRecipe">def</span> match-at text:address:array:character, pattern:address:array:character, idx:number<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> match-at text:text, pattern:text, idx:number<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> pattern-len:number<span class="Special"> <- </span>length *pattern @@ -990,8 +975,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-checks-pattern-at-index [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ab]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1002,7 +987,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-reflexive [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ @@ -1013,8 +998,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-outside-bounds [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ @@ -1025,8 +1010,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-empty-pattern [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1037,8 +1022,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-empty-pattern-outside-bound [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ @@ -1049,8 +1034,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-empty-text [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1061,7 +1046,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-empty-against-empty [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ @@ -1072,8 +1057,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-inside-bounds [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">1</span> ] memory-should-contain [ @@ -1084,8 +1069,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> match-at-inside-bounds-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bc]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1093,7 +1078,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> split s:address:array:character, delim:character<span class="muRecipe"> -> </span>result:address:array:address:array:character [ +<span class="muRecipe">def</span> split s:text, delim:character<span class="muRecipe"> -> </span>result:address:array:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># empty text? return empty array</span> @@ -1126,7 +1111,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-if</span> done? end:number<span class="Special"> <- </span>find-next s, delim, start <span class="Comment"># copy start..end into result[curr-result]</span> - dest:address:array:character<span class="Special"> <- </span>copy-range s, start, end + dest:text<span class="Special"> <- </span>copy-range s, start, end *result<span class="Special"> <- </span>put-index *result, curr-result, dest <span class="Comment"># slide over to next slice</span> start<span class="Special"> <- </span>add end, <span class="Constant">1</span> @@ -1138,11 +1123,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-1 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> - y:address:array:address:array:character<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + y:address:array:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>length *y - a:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">0</span> - b:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">1</span> + a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> + b:text<span class="Special"> <- </span>index *y, <span class="Constant">1</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *a <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *b ] @@ -1156,12 +1141,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> - y:address:array:address:array:character<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> + y:address:array:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>length *y - a:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">0</span> - b:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">1</span> - c:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">2</span> + a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> + b:text<span class="Special"> <- </span>index *y, <span class="Constant">1</span> + c:text<span class="Special"> <- </span>index *y, <span class="Constant">2</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *a <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *b <span class="Constant">40</span>:array:character/<span class="Special">raw <- </span>copy *c @@ -1177,10 +1162,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-missing [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:address:array:character<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:address:array:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>length *y - a:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">0</span> + a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *a ] memory-should-contain [ @@ -1192,8 +1177,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-empty [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:address:array:address:array:character<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:address:array:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>length *y ] memory-should-contain [ @@ -1204,13 +1189,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-empty-piece [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> - y:address:array:address:array:character<span class="Special"> <- </span>split x:address:array:character, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> + y:address:array:text<span class="Special"> <- </span>split x:text, <span class="Constant">47/slash</span> <span class="Constant">10</span>:number/<span class="Special">raw <- </span>length *y - a:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">0</span> - b:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">1</span> - c:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">2</span> - d:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">3</span> + a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> + b:text<span class="Special"> <- </span>index *y, <span class="Constant">1</span> + c:text<span class="Special"> <- </span>index *y, <span class="Constant">2</span> + d:text<span class="Special"> <- </span>index *y, <span class="Constant">3</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *a <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *b <span class="Constant">40</span>:array:character/<span class="Special">raw <- </span>copy *c @@ -1225,7 +1210,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> split-first text:address:array:character, delim:character<span class="muRecipe"> -> </span>x:address:array:character, y:address:array:character [ +<span class="muRecipe">def</span> split-first text:text, delim:character<span class="muRecipe"> -> </span>x:text, y:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># empty text? return empty texts</span> @@ -1233,21 +1218,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> empty?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">0</span> <span class="muControl">break-unless</span> empty? - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="muControl">return</span> <span class="Delimiter">}</span> idx:number<span class="Special"> <- </span>find-next text, delim, <span class="Constant">0</span> - x:address:array:character<span class="Special"> <- </span>copy-range text, <span class="Constant">0</span>, idx + x:text<span class="Special"> <- </span>copy-range text, <span class="Constant">0</span>, idx idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - y:address:array:character<span class="Special"> <- </span>copy-range text, idx, len + y:text<span class="Special"> <- </span>copy-range text, idx, len ] <span class="muScenario">scenario</span> text-split-first [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> - y:address:array:character, z:address:array:character<span class="Special"> <- </span>split-first x, <span class="Constant">47/slash</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + y:text, z:text<span class="Special"> <- </span>split-first x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *y <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *z ] @@ -1257,7 +1242,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> copy-range buf:address:array:character, start:number, end:number<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> copy-range buf:text, start:number, end:number<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if end is out of bounds, trim it</span> @@ -1265,7 +1250,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color end:number<span class="Special"> <- </span>min len, end <span class="Comment"># allocate space for result</span> len<span class="Special"> <- </span>subtract end, start - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len + result:text<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len <span class="Comment"># copy start..end into result[curr-result]</span> src-idx:number<span class="Special"> <- </span>copy start dest-idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -1283,8 +1268,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-copy-copies-partial-text [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>copy-range x, <span class="Constant">1</span>, <span class="Constant">3</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -1295,8 +1280,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-copy-out-of-bounds [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>copy-range x, <span class="Constant">2</span>, <span class="Constant">4</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">2</span>, <span class="Constant">4</span> <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ @@ -1307,8 +1292,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-copy-out-of-bounds-2 [ run [ <span class="Constant">local-scope</span> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:address:array:character<span class="Special"> <- </span>copy-range x, <span class="Constant">3</span>, <span class="Constant">3</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">3</span>, <span class="Constant">3</span> <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ diff --git a/html/062rewrite_stash.cc.html b/html/062rewrite_stash.cc.html index 1d8adc6f..8ed4fa38 100644 --- a/html/062rewrite_stash.cc.html +++ b/html/062rewrite_stash.cc.html @@ -14,7 +14,6 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .Constant { color: #00a0a0; } -.cSpecial { color: #008000; } .traceContains { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } @@ -178,26 +177,6 @@ recipe main [ 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> << inst<span class="Delimiter">.</span>original_string << <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="Comment">// can handle any type</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> diff --git a/html/064list.mu.html b/html/064list.mu.html index 3b81c73b..5c24849e 100644 --- a/html/064list.mu.html +++ b/html/064list.mu.html @@ -292,7 +292,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> to-text in:address:list:_elem<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> to-text in:address:list:_elem<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> @@ -301,7 +301,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># variant of 'to-text' which stops printing after a few elements (and so is robust to cycles)</span> -<span class="muRecipe">def</span> to-text-line in:address:list:_elem<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> to-text-line in:address:list:_elem<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> diff --git a/html/066stream.mu.html b/html/066stream.mu.html index 28c4814c..02798ec8 100644 --- a/html/066stream.mu.html +++ b/html/066stream.mu.html @@ -74,7 +74,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> empty?:boolean<span class="Special"> <- </span>copy <span class="Constant">0/false</span> idx:number<span class="Special"> <- </span>get *in, <span class="Constant">index:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:array:_elem<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> len:number<span class="Special"> <- </span>length *s at-end?:boolean<span class="Special"> <- </span>greater-or-equal idx len <span class="Delimiter">{</span> @@ -85,11 +85,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color result<span class="Special"> <- </span>index *s, idx ] -<span class="muRecipe">def</span> read-line in:address:stream:character<span class="muRecipe"> -> </span>result:address:array:character, in:address:stream:character [ +<span class="muRecipe">def</span> read-line in:address:stream:character<span class="muRecipe"> -> </span>result:text, in:address:stream:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> idx:number<span class="Special"> <- </span>get *in, <span class="Constant">index:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:text<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> next-idx:number<span class="Special"> <- </span>find-next s, <span class="Constant">10/newline</span>, idx result<span class="Special"> <- </span>copy-range s, idx, next-idx idx<span class="Special"> <- </span>add next-idx, <span class="Constant">1</span> <span class="Comment"># skip newline</span> diff --git a/html/070table.mu.html b/html/070table.mu.html index baa33458..6292dd74 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -50,8 +50,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> table-read-write-non-integer [ run [ <span class="Constant">local-scope</span> - key:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - <span class="Delimiter">{</span>tab: (address table (address array character) number)<span class="Delimiter">}</span><span class="Special"> <- </span>new-table <span class="Constant">30</span> + key:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + <span class="Delimiter">{</span>tab: (address table text number)<span class="Delimiter">}</span><span class="Special"> <- </span>new-table <span class="Constant">30</span> put-index tab, key, <span class="Constant">34</span> <span class="Constant">1</span>:number/<span class="Special">raw <- </span>index tab, key ] diff --git a/html/071recipe.cc.html b/html/071recipe.cc.html index 47204f71..56f55901 100644 --- a/html/071recipe.cc.html +++ b/html/071recipe.cc.html @@ -212,22 +212,29 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> recipe from_reagent<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>atom && r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>atom && r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"recipe"</span><span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> recipe result_header<span class="Delimiter">;</span> <span class="Comment">// will contain only ingredients and products, nothing else</span> result_header<span class="Delimiter">.</span>has_header = <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name == <span class="Constant">"recipe"</span><span class="Delimiter">);</span> + <span class="Identifier">return</span> result_header<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + assert<span class="Delimiter">(</span>root_type<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">)-></span>name == <span class="Constant">"recipe"</span><span class="Delimiter">);</span> <span class="Normal">const</span> type_tree* curr = r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">nada</span><span class="Comment">*/</span><span class="Delimiter">;</span> curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">;</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">-></span>atom && curr<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"->"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Comment">// skip delimiter</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Identifier">goto</span> read_products<span class="Delimiter">;</span> <span class="Delimiter">}</span> result_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>next_recipe_reagent<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">));</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right && curr<span class="Delimiter">-></span>right<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> - result_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>next_recipe_reagent<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">));</span> - <span class="Identifier">return</span> result_header<span class="Delimiter">;</span> <span class="Comment">// no products</span> - <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(;</span> curr && !curr<span class="Delimiter">-></span>atom<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<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> + result_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>next_recipe_reagent<span class="Delimiter">(</span>curr<span class="Delimiter">));</span> + <span class="Identifier">return</span> result_header<span class="Delimiter">;</span> <span class="Comment">// no products</span> + <span class="Delimiter">}</span> + <span class="Normal">read_products</span>: + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">nada</span><span class="Comment">*/</span><span class="Delimiter">;</span> curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">;</span> curr=curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> result_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>next_recipe_reagent<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> @@ -236,8 +243,33 @@ recipe from_reagent<span class="Delimiter">(</span><span class="Normal">const</s <span class="Identifier">return</span> result_header<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Comment">// todo: unit test: 'recipe number' vs 'recipe -> number'</span> +<span class="Delimiter">:(before "End Unit Tests")</span> +<span class="Normal">void</span> test_from_reagent_atomic<span class="Delimiter">()</span> <span class="Delimiter">{</span> + reagent a<span class="Delimiter">(</span><span class="Constant">"{f: recipe}"</span><span class="Delimiter">);</span> + recipe r_header = from_reagent<span class="Delimiter">(</span>a<span class="Delimiter">);</span> + CHECK<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> + CHECK<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> +<span class="Delimiter">}</span> +<span class="Normal">void</span> test_from_reagent_non_atomic<span class="Delimiter">()</span> <span class="Delimiter">{</span> + reagent a<span class="Delimiter">(</span><span class="Constant">"{f: (recipe number -> number)}"</span><span class="Delimiter">);</span> + recipe r_header = from_reagent<span class="Delimiter">(</span>a<span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>products<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> +<span class="Normal">void</span> test_from_reagent_reads_ingredient_at_end<span class="Delimiter">()</span> <span class="Delimiter">{</span> + reagent a<span class="Delimiter">(</span><span class="Constant">"{f: (recipe number number)}"</span><span class="Delimiter">);</span> + recipe r_header = from_reagent<span class="Delimiter">(</span>a<span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> <span class="Constant">2</span><span class="Delimiter">);</span> + CHECK<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> +<span class="Delimiter">}</span> +<span class="Normal">void</span> test_from_reagent_reads_sole_ingredient_at_end<span class="Delimiter">()</span> <span class="Delimiter">{</span> + reagent a<span class="Delimiter">(</span><span class="Constant">"{f: (recipe number)}"</span><span class="Delimiter">);</span> + recipe r_header = from_reagent<span class="Delimiter">(</span>a<span class="Delimiter">);</span> + CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> + CHECK<span class="Delimiter">(</span>r_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(code)</span> reagent next_recipe_reagent<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">-></span>left<span class="Delimiter">)</span> <span class="Identifier">return</span> reagent<span class="Delimiter">(</span><span class="Constant">"recipe:"</span>+curr<span class="Delimiter">-></span>name<span class="Delimiter">);</span> reagent result<span class="Delimiter">;</span> diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 78ac7437..4af95f06 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -21,9 +21,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } -.CommentedCode { color: #6c6c6c; } -.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -53,14 +53,23 @@ def f2 [ <span class="traceContains">+schedule: f2</span> <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">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> +<span class="Delimiter">:(before "End Globals")</span> +<span class="Normal">int</span> Scheduling_interval = <span class="Constant">500</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "End routine Fields")</span> +<span class="Normal">int</span> instructions_run_this_scheduling_slice<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End routine Constructor")</span> +instructions_run_this_scheduling_slice = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "Running One Instruction")</span> + ++Current_routine<span class="Delimiter">-></span>instructions_run_this_scheduling_slice<span class="Delimiter">;</span> +<span class="Delimiter">:(replace{} "bool should_continue_running(const routine* current_routine)")</span> +<span class="Normal">bool</span> should_continue_running<span class="Delimiter">(</span><span class="Normal">const</span> routine* current_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>current_routine == Current_routine<span class="Delimiter">);</span> <span class="Comment">// argument passed in just to make caller readable above</span> + <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>state == RUNNING + && Current_routine<span class="Delimiter">-></span>instructions_run_this_scheduling_slice < Scheduling_interval<span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(after "stop_running_current_routine:")</span> +<span class="Comment">// Reset instructions_run_this_scheduling_slice</span> +Current_routine<span class="Delimiter">-></span>instructions_run_this_scheduling_slice = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">//: now the rest of the scheduler is clean</span> @@ -78,7 +87,6 @@ state = RUNNING<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Globals")</span> vector<routine*> Routines<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> @@ -97,7 +105,7 @@ Routines<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> assert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>state == RUNNING<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"schedule"</span><span class="Delimiter">)</span> << current_routine_label<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> <span class="CommentedCode">//? cerr << "schedule: " << current_routine_label() << '\n';</span> - run_current_routine<span class="Delimiter">(</span>Scheduling_interval<span class="Delimiter">);</span> + run_current_routine<span class="Delimiter">();</span> <span class="Comment">// Scheduler State Transitions</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>completed<span class="Delimiter">())</span> Current_routine<span class="Delimiter">-></span>state = COMPLETED<span class="Delimiter">;</span> @@ -615,11 +623,11 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End routine Fields")</span> -<span class="Normal">int</span> ninstrs<span class="Delimiter">;</span> +<span class="Normal">int</span> instructions_run<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> -ninstrs = <span class="Constant">0</span><span class="Delimiter">;</span> -<span class="Delimiter">:(after "stop_running_current_routine:")</span> -Current_routine<span class="Delimiter">-></span>ninstrs += ninstrs<span class="Delimiter">;</span> +instructions_run = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "Reset instructions_run_this_scheduling_slice")</span> +Current_routine<span class="Delimiter">-></span>instructions_run += Current_routine<span class="Delimiter">-></span>instructions_run_this_scheduling_slice<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> NUMBER_OF_INSTRUCTIONS<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> @@ -642,7 +650,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<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>ninstrs<span class="Delimiter">;</span> + result = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>instructions_run<span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> diff --git a/html/073wait.cc.html b/html/073wait.cc.html index 926c6b29..b99b8cc5 100644 --- a/html/073wait.cc.html +++ b/html/073wait.cc.html @@ -16,6 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .cSpecial { color: #008000; } .traceContains { color: #008000; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } @@ -40,18 +41,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(scenario wait_for_location)</span> def f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> start-running f2 - <span class="Constant">2</span>:location<span class="Special"> <- </span>copy <span class="Constant">1</span>/unsafe - wait-<span class="Normal">for</span>-location <span class="Constant">2</span>:location - <span class="Comment"># now wait for f2 to run and modify location 1 before using its value</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number + <span class="Constant">20</span>:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + wait-<span class="Normal">for</span>-reset-then-set <span class="Constant">20</span>:location + <span class="Comment"># wait for f2 to run and reset location 1</span> + <span class="Constant">30</span>:number<span class="Special"> <- </span>copy <span class="Constant">10</span>:number ] def f2 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">10</span>:location<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe ] -<span class="Comment"># if we got the synchronization wrong we'd be storing 0 in location 3</span> -<span class="traceContains">+mem: storing 34 in location 3</span> +<span class="traceContains">+schedule: f1</span> +<span class="traceContains">+run: waiting for location 10 to reset</span> +<span class="traceContains">+schedule: f2</span> +<span class="traceContains">+schedule: waking up routine 1</span> +<span class="traceContains">+schedule: f1</span> +<span class="traceContains">+mem: storing 1 in location 30</span> <span class="Comment">//: define the new state that all routines can be in</span> @@ -60,9 +65,8 @@ WAITING<span class="Delimiter">,</span> <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// only if state == WAITING</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> +waiting_on_location = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Mu Test Teardown")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Passed && any_routines_waiting<span class="Delimiter">())</span> <span class="Delimiter">{</span> @@ -94,30 +98,61 @@ waiting_on_location = old_value_of_waiting_location = <span class="Constant">0</ <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Comment">//: primitive recipe to put routines in that state</span> +<span class="Comment">//: Primitive recipe to put routines in that state.</span> +<span class="Comment">//: This primitive is also known elsewhere as compare-and-set (CAS). Used to</span> +<span class="Comment">//: build locks.</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -WAIT_FOR_LOCATION<span class="Delimiter">,</span> +WAIT_FOR_RESET_THEN_SET<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">"wait-for-location"</span><span class="Delimiter">,</span> WAIT_FOR_LOCATION<span class="Delimiter">);</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"wait-for-reset-then-set"</span><span class="Delimiter">,</span> WAIT_FOR_RESET_THEN_SET<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> WAIT_FOR_LOCATION: <span class="Delimiter">{</span> +<span class="Normal">case</span> WAIT_FOR_RESET_THEN_SET: <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-location' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"'wait-for-reset-then-set' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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_location<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">"'wait-for-location' requires a location ingredient, but got '"</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>original_string << <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">"'wait-for-reset-then-set' requires a location ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<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> WAIT_FOR_LOCATION: <span class="Delimiter">{</span> - <span class="Normal">int</span> loc = 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">case</span> WAIT_FOR_RESET_THEN_SET: <span class="Delimiter">{</span> + <span class="Normal">int</span> loc = <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> + 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">"wait: *"</span> << loc << <span class="Constant">" = "</span> << get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">)</span> << 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> loc<span class="Delimiter">)</span> == <span class="Constant">0</span><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">"location "</span> << loc << <span class="Constant">" is already 0; setting"</span> << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<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> + 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">"waiting for location "</span> << loc << <span class="Constant">" to reset"</span> << end<span class="Delimiter">();</span> Current_routine<span class="Delimiter">-></span>state = WAITING<span class="Delimiter">;</span> Current_routine<span class="Delimiter">-></span>waiting_on_location = loc<span class="Delimiter">;</span> - Current_routine<span class="Delimiter">-></span>old_value_of_waiting_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<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">"waiting for location "</span> << loc << <span class="Constant">" to change from "</span> << no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Comment">//: Counterpart to unlock a lock.</span> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +RESET<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">"reset"</span><span class="Delimiter">,</span> RESET<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> RESET: <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">"'reset' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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_location<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">"'reset' requires a location ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<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> RESET: <span class="Delimiter">{</span> + <span class="Normal">int</span> loc = <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> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">,</span> <span class="Constant">0</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">"reset: *"</span> << loc << <span class="Constant">" = "</span> << get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -126,17 +161,18 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Scheduler State Transitions")</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> - 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><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Normal">int</span> loc = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_location<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>loc && get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">)</span> == <span class="Constant">0</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">"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> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> loc<span class="Delimiter">,</span> <span class="Constant">1</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> - Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_location = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>old_value_of_waiting_location = <span class="Constant">0</span><span class="Delimiter">;</span> + Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>waiting_on_location = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Comment">//: primitive to help compute locations to wait for</span> -<span class="Comment">//: only supports elements inside containers, no arrays or containers within</span> -<span class="Comment">//: containers yet.</span> +<span class="Comment">//: Primitive to help compute locations to wait on.</span> +<span class="Comment">//: Only supports elements immediately inside containers; no arrays or</span> +<span class="Comment">//: containers within containers yet.</span> <span class="Delimiter">:(scenario get_location)</span> def main [ @@ -275,166 +311,219 @@ def main [ ] <span class="traceContains">+mem: storing 11 in location 21</span> -<span class="Comment">//: also allow waiting on a routine to block</span> -<span class="Comment">//: (just for tests; use wait_for_routine below wherever possible)</span> +<span class="Comment">//: allow waiting on a routine to complete</span> -<span class="Delimiter">:(scenario wait_for_routine_to_block)</span> +<span class="Delimiter">:(scenario wait_for_routine)</span> def f1 [ + <span class="Comment"># add a few routines to run</span> <span class="Constant">1</span>:number/routine<span class="Special"> <- </span>start-running f2 - wait-<span class="Normal">for</span>-routine-to-block <span class="Constant">1</span>:number/routine - <span class="Comment"># now wait for f2 to run and modify location 10 before using its value</span> - <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">10</span>:number + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running f3 + wait-<span class="Normal">for</span>-routine <span class="Constant">1</span>:number/routine + <span class="Comment"># now wait for f2 to *complete* and modify location 13 before using its value</span> + <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">13</span>:number ] def f2 [ - <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># just padding</span> + <span class="Normal">switch</span> <span class="Comment"># simulate a block; routine f1 shouldn't restart at this point</span> + <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> +] +def f3 [ + <span class="Comment"># padding routine just to help simulate the block in f2 using 'switch'</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: waiting for routine 2 to block</span> +<span class="traceContains">+run: waiting for routine 2</span> <span class="traceContains">+schedule: f2</span> -<span class="traceContains">+schedule: waking up blocked routine 1</span> +<span class="traceContains">+schedule: f3</span> +<span class="traceContains">+schedule: f2</span> +<span class="traceContains">+schedule: waking up routine 1</span> <span class="traceContains">+schedule: f1</span> -<span class="Comment"># if we got the synchronization wrong we'd be storing 0 in location 11</span> -<span class="traceContains">+mem: storing 34 in location 11</span> +<span class="Comment"># if we got the synchronization wrong we'd be storing 0 in location 20</span> +<span class="traceContains">+mem: storing 34 in location 20</span> <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// only if state == WAITING</span> -<span class="Normal">int</span> waiting_on_routine_to_block<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_to_block = <span class="Constant">0</span><span class="Delimiter">;</span> +waiting_on_routine = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -WAIT_FOR_ROUTINE_TO_BLOCK<span class="Delimiter">,</span> +WAIT_FOR_ROUTINE<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">"wait-for-routine-to-block"</span><span class="Delimiter">,</span> WAIT_FOR_ROUTINE_TO_BLOCK<span class="Delimiter">);</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"wait-for-routine"</span><span class="Delimiter">,</span> WAIT_FOR_ROUTINE<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> WAIT_FOR_ROUTINE_TO_BLOCK: <span class="Delimiter">{</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-to-block' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"'wait-for-routine' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"first ingredient of 'wait-for-routine-to-block' should be a routine id generated by 'start-running', but got '"</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>original_string << <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">"first ingredient of 'wait-for-routine' should be a routine id generated by 'start-running', but got '"</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>original_string << <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> WAIT_FOR_ROUTINE_TO_BLOCK: <span class="Delimiter">{</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_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> Current_routine<span class="Delimiter">-></span>state = WAITING<span class="Delimiter">;</span> - Current_routine<span class="Delimiter">-></span>waiting_on_routine_to_block = 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">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"waiting for routine "</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="Constant">" to block"</span> << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << Current_routine->id << ": waiting for routine " << ingredients.at(0).at(0) << " to block\n";</span> + Current_routine<span class="Delimiter">-></span>waiting_on_routine = 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">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"waiting for routine "</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> << end<span class="Delimiter">();</span> +<span class="CommentedCode">//? cerr << Current_routine->id << ": waiting for routine " << ingredients.at(0).at(0) << '\n';</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Scheduler State Transitions")</span> -<span class="Comment">// Wake up any routines waiting for other routines to stop running.</span> +<span class="Comment">// Wake up any routines waiting for other routines to complete.</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">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> routine* waiter = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!waiter<span class="Delimiter">-></span>waiting_on_routine_to_block<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">int</span> id = waiter<span class="Delimiter">-></span>waiting_on_routine_to_block<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!waiter<span class="Delimiter">-></span>waiting_on_routine<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Normal">int</span> id = waiter<span class="Delimiter">-></span>waiting_on_routine<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>id != waiter<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">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">const</span> routine* waitee = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>waitee<span class="Delimiter">-></span>id == id && waitee<span class="Delimiter">-></span>state != RUNNING<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// routine is WAITING or COMPLETED or DISCONTINUED</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 blocked routine "</span> << waiter<span class="Delimiter">-></span>id << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << id << " is now unblocked (" << waitee->state << "); waking up waiting routine " << waiter->id << '\n';</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>waitee<span class="Delimiter">-></span>id == id && waitee<span class="Delimiter">-></span>state != RUNNING && waitee<span class="Delimiter">-></span>state != WAITING<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// routine is COMPLETED or DISCONTINUED</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> << waiter<span class="Delimiter">-></span>id << end<span class="Delimiter">();</span> +<span class="CommentedCode">//? cerr << id << " is now done (" << waitee->state << "); waking up waiting routine " << waiter->id << '\n';</span> waiter<span class="Delimiter">-></span>state = RUNNING<span class="Delimiter">;</span> - waiter<span class="Delimiter">-></span>waiting_on_routine_to_block = <span class="Constant">0</span><span class="Delimiter">;</span> + waiter<span class="Delimiter">-></span>waiting_on_routine = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Comment">//: allow waiting on a routine to complete</span> +<span class="SalientComment">//:: helpers for manipulating routines in tests</span> +<span class="Comment">//:</span> +<span class="Comment">//: Managing arbitrary scenarios requires the ability to:</span> +<span class="Comment">//: a) stop the current routine (`switch`)</span> +<span class="Comment">//: b) restart a routine (`restart`)</span> +<span class="Comment">//: c) tell when a routine is blocked</span> +<span class="Comment">//:</span> +<span class="Comment">//: A routine is blocked either if it's waiting or if it explicitly signals</span> +<span class="Comment">//: that it's blocked (even as it periodically wakes up and polls for some</span> +<span class="Comment">//: event).</span> +<span class="Comment">//:</span> +<span class="Comment">//: Signalling blockedness might well be a huge hack. But Mu doesn't have Unix</span> +<span class="Comment">//: signals to avoid polling with, because signals are also pretty hacky.</span> -<span class="Delimiter">:(scenario wait_for_routine)</span> +<span class="Delimiter">:(before "End routine Fields")</span> +<span class="Normal">bool</span> blocked<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End routine Constructor")</span> +blocked = <span class="Constant">false</span><span class="Delimiter">;</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +CURRENT_ROUTINE_IS_BLOCKED<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">"current-routine-is-blocked"</span><span class="Delimiter">,</span> CURRENT_ROUTINE_IS_BLOCKED<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> CURRENT_ROUTINE_IS_BLOCKED: <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">"'current-routine-is-blocked' should have no ingredients, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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> CURRENT_ROUTINE_IS_BLOCKED: <span class="Delimiter">{</span> + Current_routine<span class="Delimiter">-></span>blocked = <span class="Constant">true</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 Declarations")</span> +CURRENT_ROUTINE_IS_UNBLOCKED<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">"current-routine-is-unblocked"</span><span class="Delimiter">,</span> CURRENT_ROUTINE_IS_UNBLOCKED<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> CURRENT_ROUTINE_IS_UNBLOCKED: <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">"'current-routine-is-unblocked' should have no ingredients, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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> CURRENT_ROUTINE_IS_UNBLOCKED: <span class="Delimiter">{</span> + Current_routine<span class="Delimiter">-></span>blocked = <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Comment">//: also allow waiting on a routine to block</span> +<span class="Comment">//: (just for tests; use wait_for_routine above wherever possible)</span> + +<span class="Delimiter">:(scenario wait_for_routine_to_block)</span> def f1 [ - <span class="Comment"># add a few routines to run</span> <span class="Constant">1</span>:number/routine<span class="Special"> <- </span>start-running f2 - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running f3 - wait-<span class="Normal">for</span>-routine <span class="Constant">1</span>:number/routine - <span class="Comment"># now wait for f2 to *complete* and modify location 13 before using its value</span> - <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">13</span>:number + wait-<span class="Normal">for</span>-routine-to-block <span class="Constant">1</span>:number/routine + <span class="Comment"># now wait for f2 to run and modify location 10 before using its value</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">10</span>:number ] def f2 [ - <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># just padding</span> - <span class="Normal">switch</span> <span class="Comment"># simulate a block; routine f1 shouldn't restart at this point</span> - <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> -] -def f3 [ - <span class="Comment"># padding routine just to help simulate the block in f2 using 'switch'</span> - <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> ] <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: waiting for routine 2</span> -<span class="traceContains">+schedule: f2</span> -<span class="traceContains">+schedule: f3</span> +<span class="traceContains">+run: waiting for routine 2 to block</span> <span class="traceContains">+schedule: f2</span> -<span class="traceContains">+schedule: waking up routine 1</span> +<span class="traceContains">+schedule: waking up routine 1 because routine 2 is blocked</span> <span class="traceContains">+schedule: f1</span> -<span class="Comment"># if we got the synchronization wrong we'd be storing 0 in location 20</span> -<span class="traceContains">+mem: storing 34 in location 20</span> +<span class="Comment"># if we got the synchronization wrong we'd be storing 0 in location 11</span> +<span class="traceContains">+mem: storing 34 in location 11</span> <span class="Delimiter">:(before "End routine Fields")</span> <span class="Comment">// only if state == WAITING</span> -<span class="Normal">int</span> waiting_on_routine<span class="Delimiter">;</span> +<span class="Normal">int</span> waiting_on_routine_to_block<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> -waiting_on_routine = <span class="Constant">0</span><span class="Delimiter">;</span> +waiting_on_routine_to_block = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -WAIT_FOR_ROUTINE<span class="Delimiter">,</span> +WAIT_FOR_ROUTINE_TO_BLOCK<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">"wait-for-routine"</span><span class="Delimiter">,</span> WAIT_FOR_ROUTINE<span class="Delimiter">);</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"wait-for-routine-to-block"</span><span class="Delimiter">,</span> WAIT_FOR_ROUTINE_TO_BLOCK<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">case</span> WAIT_FOR_ROUTINE_TO_BLOCK: <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> << inst<span class="Delimiter">.</span>original_string << <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">"'wait-for-routine-to-block' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"first ingredient of 'wait-for-routine' should be a routine id generated by 'start-running', but got '"</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>original_string << <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">"first ingredient of 'wait-for-routine-to-block' should be a routine id generated by 'start-running', but got '"</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>original_string << <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> WAIT_FOR_ROUTINE: <span class="Delimiter">{</span> +<span class="Normal">case</span> WAIT_FOR_ROUTINE_TO_BLOCK: <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_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> Current_routine<span class="Delimiter">-></span>state = WAITING<span class="Delimiter">;</span> - Current_routine<span class="Delimiter">-></span>waiting_on_routine = 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">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"waiting for routine "</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> << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << Current_routine->id << ": waiting for routine " << ingredients.at(0).at(0) << '\n';</span> + Current_routine<span class="Delimiter">-></span>waiting_on_routine_to_block = 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">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"waiting for routine "</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="Constant">" to block"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Scheduler State Transitions")</span> -<span class="Comment">// Wake up any routines waiting for other routines to complete.</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="Comment">// Wake up any routines waiting for other routines to stop running.</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> routine* waiter = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!waiter<span class="Delimiter">-></span>waiting_on_routine<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">int</span> id = waiter<span class="Delimiter">-></span>waiting_on_routine<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!waiter<span class="Delimiter">-></span>waiting_on_routine_to_block<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Normal">int</span> id = waiter<span class="Delimiter">-></span>waiting_on_routine_to_block<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>id != waiter<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">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">const</span> routine* waitee = Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>waitee<span class="Delimiter">-></span>id == id && waitee<span class="Delimiter">-></span>state != RUNNING && waitee<span class="Delimiter">-></span>state != WAITING<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// routine is COMPLETED or DISCONTINUED</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> << waiter<span class="Delimiter">-></span>id << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << id << " is now done (" << waitee->state << "); waking up waiting routine " << waiter->id << '\n';</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>waitee<span class="Delimiter">-></span>id != id<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>waitee<span class="Delimiter">-></span>state != RUNNING || waitee<span class="Delimiter">-></span>blocked<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> << waiter<span class="Delimiter">-></span>id << <span class="Constant">" because routine "</span> << waitee<span class="Delimiter">-></span>id << <span class="Constant">" is blocked"</span> << end<span class="Delimiter">();</span> waiter<span class="Delimiter">-></span>state = RUNNING<span class="Delimiter">;</span> - waiter<span class="Delimiter">-></span>waiting_on_routine = <span class="Constant">0</span><span class="Delimiter">;</span> + waiter<span class="Delimiter">-></span>waiting_on_routine_to_block = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -498,6 +587,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<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> <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> Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>state = RUNNING<span class="Delimiter">;</span> + Routines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)-></span>blocked = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -518,6 +608,32 @@ def f [ <span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">1</span> ] <span class="Comment"># shouldn't crash</span> + +<span class="Delimiter">:(scenario restart_blocked_routine)</span> +<span class="Special">% Scheduling_interval = 1;</span> +def main [ + local-scope + <span class="Normal">r</span>:number/routine-id<span class="Special"> <- </span>start-running f + wait-<span class="Normal">for</span>-routine-to-block r <span class="Comment"># get past the block in f below</span> + restart r + wait-<span class="Normal">for</span>-routine-to-block r <span class="Comment"># should run f to completion</span> +] +<span class="Comment"># function with one block</span> +def f [ + current-routine-is-blocked + <span class="Comment"># 8 instructions of padding, many more than 'main' above</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>add <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">1</span> +] +<span class="Comment"># make sure all of f ran</span> +<span class="traceContains">+mem: storing 8 in location 1</span> </pre> </body> </html> diff --git a/html/075channel.mu.html b/html/075channel.mu.html index 6f34b054..4912015e 100644 --- a/html/075channel.mu.html +++ b/html/075channel.mu.html @@ -21,6 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } +.CommentedCode { color: #6c6c6c; } .muControl { color: #c0a020; } --> </style> @@ -33,20 +34,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color </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 (currently) only be used by a single one. Don't try to read</span> -<span class="Comment"># from or write to it from multiple routines at once.</span> +<span class="Comment"># Mu synchronizes between routines using channels rather than locks, like</span> +<span class="Comment"># Erlang and Go.</span> <span class="Comment">#</span> <span class="Comment"># Key properties of channels:</span> <span class="Comment">#</span> -<span class="Comment"># a) Writing to a full channel or reading from an empty one will put the</span> -<span class="Comment"># current routine in 'waiting' state until the operation can be completed.</span> +<span class="Comment"># a) Writing to a full channel or reading from an empty one will put the</span> +<span class="Comment"># current routine in 'waiting' state until the operation can be completed.</span> <span class="Comment">#</span> -<span class="Comment"># b) Writing to a channel implicitly performs a deep copy, to prevent</span> -<span class="Comment"># addresses from being shared between routines, thereby causing race</span> -<span class="Comment"># conditions.</span> +<span class="Comment"># b) Writing to a channel implicitly performs a deep copy. This prevents</span> +<span class="Comment"># addresses from being shared between routines, and therefore eliminates all</span> +<span class="Comment"># possibility of race conditions.</span> <span class="muScenario">scenario</span> channel [ run [ @@ -62,9 +60,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <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> + lock:boolean <span class="Comment"># inefficient but simple: serialize all reads as well as writes</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> @@ -105,13 +101,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assert out, <span class="Constant">[write to null channel]</span> chan:address:channel:_elem<span class="Special"> <- </span>get *out, <span class="Constant">chan:offset</span> <span class="Constant"> <channel-write-initial></span> + <span class="Comment"># block until lock is acquired AND queue has room</span> + lock:location<span class="Special"> <- </span>get-location *chan, <span class="Constant">lock:offset</span> +<span class="CommentedCode">#? $print [write], 10/newline</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:location<span class="Special"> <- </span>get-location *chan, <span class="Constant">first-full:offset</span> - wait-for-location full-address +<span class="CommentedCode">#? $print [trying to acquire lock for writing], 10/newline</span> + wait-for-reset-then-set lock +<span class="CommentedCode">#? $print [lock acquired for writing], 10/newline</span> + full?:boolean<span class="Special"> <- </span>channel-full? chan + <span class="muControl">break-unless</span> full? +<span class="CommentedCode">#? $print [but channel is full; relinquishing lock], 10/newline</span> + <span class="Comment"># channel is full; relinquish lock and give a reader the opportunity to</span> + <span class="Comment"># create room on it</span> + reset lock + current-routine-is-blocked + switch <span class="Comment"># avoid spinlocking</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> + current-routine-is-unblocked +<span class="CommentedCode">#? $print [performing write], 10/newline</span> <span class="Comment"># store a deep copy of val</span> circular-buffer:address:array:_elem<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> free:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-free:offset</span> @@ -128,6 +136,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># write back</span> *chan<span class="Special"> <- </span>put *chan, <span class="Constant">first-free:offset</span>, free +<span class="CommentedCode">#? $print [relinquishing lock after writing], 10/newline</span> + reset lock ] <span class="muRecipe">def</span> read in:address:source:_elem<span class="muRecipe"> -> </span>result:_elem, eof?:boolean, in:address:source:_elem [ @@ -136,14 +146,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assert in, <span class="Constant">[read on null channel]</span> eof?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="Comment"># default result</span> chan:address:channel:_elem<span class="Special"> <- </span>get *in, <span class="Constant">chan:offset</span> + <span class="Comment"># block until lock is acquired AND queue has data</span> + lock:location<span class="Special"> <- </span>get-location *chan, <span class="Constant">lock:offset</span> +<span class="CommentedCode">#? $print [read], 10/newline</span> <span class="Delimiter">{</span> - <span class="Comment"># block if chan is empty</span> +<span class="CommentedCode">#? $print [trying to acquire lock for reading], 10/newline</span> + wait-for-reset-then-set lock +<span class="CommentedCode">#? $print [lock acquired for reading], 10/newline</span> empty?:boolean<span class="Special"> <- </span>channel-empty? chan <span class="muControl">break-unless</span> empty? +<span class="CommentedCode">#? $print [but channel is empty; relinquishing lock], 10/newline</span> + <span class="Comment"># channel is empty; relinquish lock and give a writer the opportunity to</span> + <span class="Comment"># add to it</span> + reset lock + current-routine-is-blocked <span class="Constant"> <channel-read-empty></span> - free-address:location<span class="Special"> <- </span>get-location *chan, <span class="Constant">first-free:offset</span> - wait-for-location free-address + switch <span class="Comment"># avoid spinlocking</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> + current-routine-is-unblocked <span class="Comment"># pull result off</span> full:number<span class="Special"> <- </span>get *chan, <span class="Constant">first-full:offset</span> circular-buffer:address:array:_elem<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> @@ -162,6 +183,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># write back</span> *chan<span class="Special"> <- </span>put *chan, <span class="Constant">first-full:offset</span>, full +<span class="CommentedCode">#? $print [relinquishing lock after reading], 10/newline</span> + reset lock ] <span class="muRecipe">def</span> clear in:address:source:_elem<span class="muRecipe"> -> </span>in:address:source:_elem [ @@ -344,6 +367,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> closed? empty-result:address:_elem<span class="Special"> <- </span>new <span class="Constant">_elem:type</span> + current-routine-is-unblocked <span class="muControl">return</span> *empty-result, <span class="Constant">1/true</span> <span class="Delimiter">}</span> ] @@ -424,7 +448,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:array:character<span class="Special"> <- </span>get *line, <span class="Constant">data:offset</span> + line-contents:text<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 diff --git a/html/081print.mu.html b/html/081print.mu.html index b6d2bd96..eecac93b 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -678,7 +678,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color show-display ] -<span class="muRecipe">def</span> print screen:address:screen, s:address:array:character<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> print screen:address:screen, s:text<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> @@ -709,8 +709,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ <span class="Constant">local-scope</span> fake-screen:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - fake-screen<span class="Special"> <- </span>print fake-screen, s:address:array:character + s:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + fake-screen<span class="Special"> <- </span>print fake-screen, s:text cell:address:array:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> <span class="Constant">10</span>:array:screen-cell/<span class="Special">raw <- </span>copy *cell ] @@ -743,7 +743,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> <span class="Comment"># todo: other bases besides decimal</span> - s:address:array:character<span class="Special"> <- </span>to-text n + s:text<span class="Special"> <- </span>to-text n screen<span class="Special"> <- </span>print screen, s, color, bg-color ] diff --git a/html/088file.mu.html b/html/088file.mu.html index e86201ed..435e3439 100644 --- a/html/088file.mu.html +++ b/html/088file.mu.html @@ -39,11 +39,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> file-mapping [ - name:address:array:character - contents:address:array:character + name:text + contents:text ] -<span class="muRecipe">def</span> start-reading fs:address:filesystem, filename:address:array:character<span class="muRecipe"> -> </span>contents:address:source:character [ +<span class="muRecipe">def</span> start-reading fs:address:filesystem, filename:text<span class="muRecipe"> -> </span>contents:address:source:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -64,11 +64,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-if</span> done? tmp:file-mapping<span class="Special"> <- </span>index *data, i i<span class="Special"> <- </span>add i, <span class="Constant">1</span> - curr-filename:address:array:character<span class="Special"> <- </span>get tmp, <span class="Constant">name:offset</span> + curr-filename:text<span class="Special"> <- </span>get tmp, <span class="Constant">name:offset</span> found?:boolean<span class="Special"> <- </span>equal filename, curr-filename <span class="muControl">loop-unless</span> found? contents:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">30</span> - curr-contents:address:array:character<span class="Special"> <- </span>get tmp, <span class="Constant">contents:offset</span> + curr-contents:text<span class="Special"> <- </span>get tmp, <span class="Constant">contents:offset</span> start-running transmit-from-text curr-contents, sink <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -88,7 +88,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file<span class="Special"> <- </span>$close-file file ] -<span class="muRecipe">def</span> transmit-from-text contents:address:array:character, sink:address:sink:character<span class="muRecipe"> -> </span>sink:address:sink:character [ +<span class="muRecipe">def</span> transmit-from-text contents:text, sink:address:sink:character<span class="muRecipe"> -> </span>sink:address:sink:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -104,7 +104,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink<span class="Special"> <- </span>close sink ] -<span class="muRecipe">def</span> start-writing fs:address:filesystem, filename:address:array:character<span class="muRecipe"> -> </span>sink:address:sink:character, routine-id:number [ +<span class="muRecipe">def</span> start-writing fs:address:filesystem, filename:text<span class="muRecipe"> -> </span>sink:address:sink:character, routine-id:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">30</span> @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file<span class="Special"> <- </span>$close-file file ] -<span class="muRecipe">def</span> transmit-to-fake-file fs:address:filesystem, filename:address:array:character, source:address:source:character<span class="muRecipe"> -> </span>fs:address:filesystem, source:address:source:character [ +<span class="muRecipe">def</span> transmit-to-fake-file fs:address:filesystem, filename:text, source:address:source:character<span class="muRecipe"> -> </span>fs:address:filesystem, source:address:source:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute new file contents</span> @@ -144,10 +144,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color buf<span class="Special"> <- </span>append buf, c <span class="muControl">loop</span> <span class="Delimiter">}</span> - contents:address:array:character<span class="Special"> <- </span>buffer-to-array buf + contents:text<span class="Special"> <- </span>buffer-to-array buf new-file-mapping:file-mapping<span class="Special"> <- </span>merge filename, contents <span class="Comment"># write to filesystem</span> - curr-filename:address:array:character<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr-filename:text<span class="Special"> <- </span>copy <span class="Constant">0</span> data:address:array:file-mapping<span class="Special"> <- </span>get *fs, <span class="Constant">data:offset</span> <span class="Comment"># replace file contents if it already exists</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> diff --git a/html/090scenario_filesystem_test.mu.html b/html/090scenario_filesystem_test.mu.html index dc20709d..094f5e5d 100644 --- a/html/090scenario_filesystem_test.mu.html +++ b/html/090scenario_filesystem_test.mu.html @@ -64,7 +64,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink<span class="Special"> <- </span>write sink, <span class="Constant">121/y</span> close sink wait-for-routine writer - contents-read-back:address:array:character<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> + contents-read-back:text<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal contents-read-back, <span class="Constant">[xy]</span> memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># file contents read back exactly match what was written</span> @@ -81,7 +81,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink<span class="Special"> <- </span>write sink, <span class="Constant">121/y</span> close sink wait-for-routine writer - contents-read-back:address:array:character<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> + contents-read-back:text<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal contents-read-back, <span class="Constant">[xy]</span> memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># file contents read back exactly match what was written</span> @@ -101,9 +101,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink<span class="Special"> <- </span>write sink, <span class="Constant">121/y</span> close sink wait-for-routine writer - contents-read-back:address:array:character<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> + contents-read-back:text<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[a]</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal contents-read-back, <span class="Constant">[xy]</span> - other-file-contents:address:array:character<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[b]</span> + other-file-contents:text<span class="Special"> <- </span>slurp filesystem, <span class="Constant">[b]</span> <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>equal other-file-contents, <span class="Constant">[bcd</span> <span class="Constant">]</span> memory-should-contain [ @@ -112,7 +112,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> slurp fs:address:filesystem, filename:address:array:character<span class="muRecipe"> -> </span>contents:address:array:character [ +<span class="muRecipe">def</span> slurp fs:address:filesystem, filename:text<span class="muRecipe"> -> </span>contents:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> source:address:source:character<span class="Special"> <- </span>start-reading fs, filename diff --git a/html/091socket.cc.html b/html/091socket.cc.html new file mode 100644 index 00000000..306f3a31 --- /dev/null +++ b/html/091socket.cc.html @@ -0,0 +1,206 @@ +<!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 - 091socket.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; } +.Delimiter { color: #800080; } +.Identifier { color: #fcb165; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.PreProc { color: #800080; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Delimiter">:(before "End Includes")</span> +<span class="PreProc">#include </span><span class="Constant"><unistd.h></span> +<span class="PreProc">#include </span><span class="Constant"><sys/socket.h></span> +<span class="PreProc">#include </span><span class="Constant"><netinet/in.h></span> + +<span class="Delimiter">:(before "End Types")</span> +<span class="Normal">struct</span> socket_t <span class="Delimiter">{</span> + <span class="Normal">int</span> fd<span class="Delimiter">;</span> + sockaddr_in addr<span class="Delimiter">;</span> + socket_t<span class="Delimiter">()</span> <span class="Delimiter">{</span> + fd = <span class="Constant">0</span><span class="Delimiter">;</span> + bzero<span class="Delimiter">(</span>&addr<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> + <span class="Delimiter">}</span> +<span class="Delimiter">};</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> server_socket<span class="Delimiter">(</span><span class="Normal">int</span> portno<span class="Delimiter">,</span> socket_t* server<span class="Delimiter">)</span> <span class="Delimiter">{</span> + server<span class="Delimiter">-></span>fd = socket<span class="Delimiter">(</span>AF_INET<span class="Delimiter">,</span> SOCK_STREAM<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Normal">int</span> dummy<span class="Delimiter">;</span> + setsockopt<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> SOL_SOCKET<span class="Delimiter">,</span> SO_REUSEADDR<span class="Delimiter">,</span> &dummy<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>dummy<span class="Delimiter">));</span> + server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_family = AF_INET<span class="Delimiter">;</span> + server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_addr<span class="Delimiter">.</span>s_addr = INADDR_ANY<span class="Delimiter">;</span> + server<span class="Delimiter">-></span>addr<span class="Delimiter">.</span>sin_port = htons<span class="Delimiter">(</span>portno<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>bind<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Delimiter">(</span><span class="Normal">struct</span> sockaddr*<span class="Delimiter">)</span>&server<span class="Delimiter">-></span>addr<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>server<span class="Delimiter">-></span>addr<span class="Delimiter">))</span> < <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + server<span class="Delimiter">-></span>fd = -<span class="Constant">1</span><span class="Delimiter">;</span> + raise << <span class="Constant">"Failed to bind server socket to port "</span> << portno << <span class="Constant">". Something's already using that port."</span> << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + listen<span class="Delimiter">(</span>server<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> <span class="Constant">5</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +_SOCKET<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">"$socket"</span><span class="Delimiter">,</span> _SOCKET<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> _SOCKET: <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">"'$socket' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"first ingredient of '$socket' should be a number, but got '"</span> << to_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="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">"'$socket' requires exactly one product, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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>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>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first product of '$socket' should be a number (file handle), but got '"</span> << to_string<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="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> _SOCKET: <span class="Delimiter">{</span> + <span class="Normal">int</span> port = 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> + socket_t server<span class="Delimiter">;</span> + server_socket<span class="Delimiter">(</span>port<span class="Delimiter">,</span> &server<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>server<span class="Delimiter">.</span>fd < <span class="Constant">0</span><span class="Delimiter">)</span> <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> + 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>server<span class="Delimiter">.</span>fd<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">void</span> session_socket<span class="Delimiter">(</span><span class="Normal">int</span> serverfd<span class="Delimiter">,</span> socket_t* session<span class="Delimiter">)</span> <span class="Delimiter">{</span> + socklen_t dummy = <span class="Normal">sizeof</span><span class="Delimiter">(</span>session<span class="Delimiter">-></span>addr<span class="Delimiter">);</span> + session<span class="Delimiter">-></span>fd = accept<span class="Delimiter">(</span>serverfd<span class="Delimiter">,</span> <span class="Delimiter">(</span><span class="Normal">struct</span> sockaddr*<span class="Delimiter">)</span>&session<span class="Delimiter">-></span>addr<span class="Delimiter">,</span> &dummy<span class="Delimiter">);</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +_ACCEPT<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">"$accept"</span><span class="Delimiter">,</span> _ACCEPT<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> _ACCEPT: <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">"'$accept' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"first ingredient of '$accept' should be a number, but got '"</span> << to_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="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">"'$accept' requires exactly one product, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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>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>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first product of '$accept' should be a number (file handle), but got '"</span> << to_string<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="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> _ACCEPT: <span class="Delimiter">{</span> + <span class="Normal">double</span> socket_fd = 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> + socket_t session<span class="Delimiter">;</span> + session_socket<span class="Delimiter">(</span>socket_fd<span class="Delimiter">,</span> &session<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>session<span class="Delimiter">.</span>fd<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> +_READ_FROM_SOCKET<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">"$read-from-socket"</span><span class="Delimiter">,</span> _READ_FROM_SOCKET<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> _READ_FROM_SOCKET: <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">"'$read-from-socket' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">"first ingredient of '$read-from-socket' should be a number, but got '"</span> << to_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="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">"'$read-from-socket' requires exactly one product, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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_character<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>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first product of '$read-from-socket' should be a character, but got '"</span> << to_string<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="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> _READ_FROM_SOCKET: <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">double</span> socket_fd = 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">char</span> single_char[<span class="Constant">2</span>]<span class="Delimiter">;</span> + bzero<span class="Delimiter">(</span>single_char<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>read<span class="Delimiter">(</span>socket_fd<span class="Delimiter">,</span> single_char<span class="Delimiter">,</span> <span class="Constant">1</span><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">"read from socket failed</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> + 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>single_char[<span class="Constant">0</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 Declarations")</span> +_CLOSE_SOCKET<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">"$close-socket"</span><span class="Delimiter">,</span> _CLOSE_SOCKET<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> _CLOSE_SOCKET: <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">"'$close-socket' requires exactly two ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <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">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">"first ingredient of '$close-socket' should be a character, but got '"</span> << to_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="Constant">"t</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> _CLOSE_SOCKET: <span class="Delimiter">{</span> + <span class="Normal">double</span> socket_fd = 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">double</span> session_fd = 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> + close<span class="Delimiter">(</span>socket_fd<span class="Delimiter">);</span> + close<span class="Delimiter">(</span>session_fd<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/channel.mu.html b/html/channel.mu.html index afa2f732..afe84b31 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -48,6 +48,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color n<span class="Special"> <- </span>add n, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> + close sink ] <span class="muRecipe">def</span> consumer source:address:source:character<span class="muRecipe"> -> </span>source:address:source:character [ diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 95eea356..72986d0c 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -98,10 +98,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## Here's how 'chessboard' is implemented.</span> +type board = address:array:address:array:character + <span class="muRecipe">def</span> chessboard screen:address:screen, console:address:console<span class="muRecipe"> -> </span>screen:address:screen, console:address:console [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - board:address:array:address:array:character<span class="Special"> <- </span>initial-position + board:board<span class="Special"> <- </span>initial-position <span class="Comment"># hook up stdin</span> stdin-in:address:source:character, stdin-out:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> start-running send-keys-to-channel, console, stdin-out, screen @@ -136,7 +138,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## a board is an array of files, a file is an array of characters (squares)</span> -<span class="muRecipe">def</span> new-board initial-position:address:array:character<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">def</span> new-board initial-position:address:array:character<span class="muRecipe"> -> </span>board:board [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert(length(initial-position) == 64)</span> @@ -173,7 +175,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> print-board screen:address:screen, board:address:array:address:array:character<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> print-board screen:address:screen, board:board<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> row:number<span class="Special"> <- </span>copy <span class="Constant">7</span> <span class="Comment"># start printing from the top of the board</span> @@ -209,7 +211,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color cursor-to-next-line screen ] -<span class="muRecipe">def</span> initial-position<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">def</span> initial-position<span class="muRecipe"> -> </span>board:board [ <span class="Constant">local-scope</span> <span class="Comment"># layout in memory (in raster order):</span> <span class="Comment"># R P _ _ _ _ p r</span> @@ -236,7 +238,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> run [ <span class="Constant">local-scope</span> - board:address:array:address:array:character<span class="Special"> <- </span>initial-position + board:board<span class="Special"> <- </span>initial-position screen:address:screen<span class="Special"> <- </span>print-board screen:address:screen, board ] screen-should-contain [ @@ -406,7 +408,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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> @@ -415,7 +417,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - waiting?<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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> @@ -424,7 +426,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - waiting?<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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> @@ -433,7 +435,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - waiting?<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <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> @@ -442,7 +444,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - waiting?<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <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> @@ -451,7 +453,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state<span class="Special"> <- </span>routine-state read-move-routine - waiting?<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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> @@ -479,7 +481,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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> @@ -507,9 +509,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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">F read-move-illegal-file: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">50/'2'</span> restart read-move-routine wait-for-routine-to-block read-move-routine @@ -529,9 +531,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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">F read-move-illegal-rank: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">97/a</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">97/a</span> restart read-move-routine @@ -552,9 +554,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine - waiting?:boolean<span class="Special"> <- </span>equal read-move-state, <span class="Constant">3/waiting</span> + waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert 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">F read-move-empty: routine failed to pause after coming up (before any keys were pressed)]</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">10/newline</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">97/a</span> restart read-move-routine @@ -566,7 +568,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> make-move board:address:array:address:array:character, m:address:move<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">def</span> make-move board:board, m:address:move<span class="muRecipe"> -> </span>board:board [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> from-file:number<span class="Special"> <- </span>get *m, <span class="Constant">from-file:offset</span> @@ -584,7 +586,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> run [ <span class="Constant">local-scope</span> - board:address:array:address:array:character<span class="Special"> <- </span>initial-position + board:board<span class="Special"> <- </span>initial-position move:address:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> *move<span class="Special"> <- </span>merge <span class="Constant">6/g</span>, <span class="Constant">1/'2'</span>, <span class="Constant">6/g</span>, <span class="Constant">3/'4'</span> board<span class="Special"> <- </span>make-move board, move diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 6118097e..8eec4b3f 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -37,7 +37,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># temporary main for this layer: just render the given text at the given</span> <span class="Comment"># screen dimensions, then stop</span> -<span class="muRecipe">def!</span> main text:address:array:character [ +<span class="muRecipe">def!</span> main text:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console @@ -51,8 +51,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-prints-text-to-screen [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> ] screen-should-contain [ <span class="Comment"># top line of screen reserved for menu</span> @@ -83,7 +83,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span> <span class="Comment"># top/left/right constrain the screen area available to the new editor</span> <span class="Comment"># right is exclusive</span> -<span class="muRecipe">def</span> new-editor s:address:array:character, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data, screen:address:screen [ +<span class="muRecipe">def</span> new-editor s:text, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> @@ -106,7 +106,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <editor-initialization></span> ] -<span class="muRecipe">def</span> insert-text editor:address:editor-data, text:address:array:character<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> insert-text editor:address:editor-data, text:text<span class="muRecipe"> -> </span>editor:address:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> @@ -292,9 +292,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -307,8 +307,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-handles-offsets [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor s:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -320,9 +320,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines-at-offset [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -335,8 +335,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-wraps-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -355,8 +355,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initially-wraps-barely-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span> <span class="Comment"># end of the line</span> @@ -377,8 +377,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initializes-empty-text [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> ] @@ -398,10 +398,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> render-colors-comments [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -479,10 +479,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> render-colors-assignment [ assume-screen <span class="Constant">8/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 69e1b614..bba168f6 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -37,7 +37,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># temporary main: interactive editor</span> <span class="Comment"># hit ctrl-c to exit</span> -<span class="muRecipe">def!</span> main text:address:array:character [ +<span class="muRecipe">def!</span> main text:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console @@ -317,8 +317,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console <span class="Constant">[]</span> run [ @@ -334,8 +334,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -361,8 +361,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> @@ -381,9 +381,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> @@ -402,9 +402,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> @@ -423,9 +423,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Comment"># editor occupies only left half of screen</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -452,8 +452,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -474,8 +474,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -495,8 +495,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> @@ -519,8 +519,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -541,9 +541,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -565,8 +565,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -587,9 +587,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -611,9 +611,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -635,8 +635,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[01]</span> @@ -656,8 +656,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># type a letter</span> assume-console [ @@ -694,9 +694,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert-2 [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># type more text at the start</span> assume-console [ @@ -776,8 +776,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> type <span class="Constant">[f]</span> @@ -804,7 +804,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># create an editor containing two lines</span> - contents:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> <span class="Constant">1</span>:address:editor-data/<span class="Special">raw <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ @@ -831,8 +831,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[01]</span> @@ -867,8 +867,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -973,8 +973,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -993,8 +993,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1020,10 +1020,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> @@ -1044,10 +1044,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 61a2f538..ce053fd8 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -41,9 +41,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-two-spaces-on-tab [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] @@ -74,8 +74,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-backspace-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -252,9 +252,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-clears-last-line-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">0</span> <span class="Comment"># cursor at only character in final line</span> press backspace @@ -279,9 +279,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-joins-and-wraps-lines-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> @@ -305,8 +305,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-long-lines-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor in part of the screen with a long line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># confirm that it wraps</span> screen-should-contain [ @@ -338,8 +338,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-delete-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -427,8 +427,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -524,9 +524,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> @@ -559,9 +559,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ press right-arrow @@ -584,8 +584,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -614,8 +614,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> @@ -650,8 +650,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -679,9 +679,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> @@ -710,8 +710,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -753,9 +753,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> @@ -778,10 +778,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> @@ -806,10 +806,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> @@ -835,10 +835,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> d] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> @@ -863,8 +863,8 @@ d] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -894,9 +894,9 @@ d] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line followed by a second line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -926,9 +926,9 @@ d] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a line on the verge of wrapping, followed by a second line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcd</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -961,9 +961,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -1077,9 +1077,9 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -1113,9 +1113,9 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [ + <span class="Constant">1</span>:text<span class="Special"> <- </span>new [ <span class="muRecipe">def</span>] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -1150,10 +1150,10 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-from-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> @@ -1190,9 +1190,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> @@ -1295,9 +1295,9 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> assume-console [ @@ -1333,9 +1333,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> @@ -1408,9 +1408,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> @@ -1433,9 +1433,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ @@ -1457,9 +1457,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> @@ -1484,9 +1484,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> @@ -1576,9 +1576,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> @@ -1601,9 +1601,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> @@ -1626,9 +1626,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> @@ -1653,9 +1653,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> @@ -1716,9 +1716,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line (no newline before), press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> @@ -1739,9 +1739,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line, press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> @@ -1762,9 +1762,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of final line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> @@ -1787,9 +1787,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line, press ctrl-k</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -1842,9 +1842,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line (no newline after), press ctrl-k</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> @@ -1865,9 +1865,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> @@ -1888,9 +1888,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> @@ -1911,9 +1911,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> @@ -1934,9 +1934,9 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> @@ -1961,11 +1961,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2039,11 +2039,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2071,11 +2071,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> @@ -2111,10 +2111,10 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end, type a character</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> @@ -2141,10 +2141,10 @@ d] <span class="muScenario">scenario</span> editor-scrolls-down-on-newline [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> type [ @@ -2172,10 +2172,10 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> @@ -2203,11 +2203,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> @@ -2233,9 +2233,9 @@ d] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> @@ -2300,14 +2300,14 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># scroll down one page and one line</span> assume-console [ press page-down @@ -2332,11 +2332,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2420,11 +2420,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2464,11 +2464,11 @@ d] <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2537,11 +2537,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2581,13 +2581,13 @@ d] <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] @@ -2630,12 +2630,12 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2675,11 +2675,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2723,11 +2723,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2810,9 +2810,9 @@ e] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> @@ -2840,11 +2840,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2873,9 +2873,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2903,11 +2903,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2999,7 +2999,7 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -3007,7 +3007,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3063,7 +3063,7 @@ e] <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -3074,7 +3074,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3125,9 +3125,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3168,7 +3168,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-nonempty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axx</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3177,7 +3177,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3226,7 +3226,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-empty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axy</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3235,7 +3235,7 @@ exy fxy gxy ] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index a640fa59..24b66e0d 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -42,8 +42,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox render-all <span class="Constant">0/screen</span>, env, render @@ -57,7 +57,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sandbox-in-focus?:boolean <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">def</span> new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def</span> new-programming-environment screen:address:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> width:number<span class="Special"> <- </span>screen-width screen @@ -332,9 +332,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -358,9 +358,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># type one letter in each of them</span> assume-console [ @@ -403,9 +403,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render ] <span class="Comment"># divider isn't messed up</span> @@ -421,9 +421,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> @@ -461,10 +461,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="CommentedCode">#? trace-until 100/app # trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -576,7 +576,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> -<span class="muRecipe">def</span> render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">def</span> render-code screen:address:screen, s:text, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 7c4fe9e8..47a291e5 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -45,8 +45,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox env<span class="Special"> <- </span>restore-sandboxes env @@ -66,8 +66,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> sandbox-data [ - data:address:array:character - response:address:array:character + data:text + response:text <span class="Comment"># coordinates to track clicks</span> <span class="Comment"># constraint: will be 0 for sandboxes at positions before env.render-from</span> starting-row-on-screen:number @@ -80,10 +80,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -186,7 +186,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <run-sandboxes-begin></span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:address:array:character<span class="Special"> <- </span>editor-contents current-sandbox + sandbox-contents:text<span class="Special"> <- </span>editor-contents current-sandbox <span class="muControl">break-unless</span> sandbox-contents <span class="Comment"># if contents exist, first save them</span> <span class="Comment"># run them and turn them into a new sandbox-data</span> @@ -226,7 +226,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + in:text<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -236,13 +236,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:array:character, _, fake-screen:address:screen<span class="Special"> <- </span>run-sandboxed data + data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:address:screen<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen ] -<span class="muRecipe">def</span> update-status screen:address:screen, msg:address:array:character, color:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> update-status screen:address:screen, msg:text, color:number<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> @@ -259,8 +259,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx + data:text<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> + filename:text<span class="Special"> <- </span>to-text idx save filename, data <span class="Constant"> <end-save-sandbox></span> idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> @@ -312,11 +312,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># render sandbox contents</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, left - sandbox-data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + sandbox-data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - sandbox-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + sandbox-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> <span class="Constant"> <render-sandbox-results></span> <span class="Delimiter">{</span> sandbox-screen:address:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> @@ -390,7 +390,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> <span class="Comment"># clear rest of last line, move cursor to next line</span> -<span class="muRecipe">def</span> render-text screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">def</span> render-text screen:address:screen, s:text, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s @@ -459,8 +459,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color curr:address:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> prev:address:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx - contents:address:array:character<span class="Special"> <- </span>restore filename + filename:text<span class="Special"> <- </span>to-text idx + contents:text<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># todo: handle empty sandbox</span> <span class="Comment"># create new sandbox for file</span> @@ -554,15 +554,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">z:number <- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -607,10 +607,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editor</span> assume-console [ press F4 @@ -636,7 +636,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> @@ -657,16 +657,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-provides-edited-contents [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> type <span class="Constant">[def]</span> ] run [ editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:address:array:character<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:character + <span class="Constant">3</span>:text<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:editor-data + <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:text ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> @@ -833,9 +833,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render assume-console [ <span class="Comment"># create a sandbox</span> @@ -966,11 +966,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render assume-console [ press F4 @@ -999,9 +999,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -1151,9 +1151,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create a sandbox</span> assume-console [ diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index ccf5d361..fe86e811 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -39,16 +39,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -101,16 +101,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -201,7 +201,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sandbox:address:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> clicked-on-copy-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - text:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text <span class="Comment"># reset scroll</span> @@ -258,16 +258,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index f9f26d6f..94ca6a6c 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -37,9 +37,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> deleting-sandboxes [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -185,9 +185,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -231,9 +231,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -277,9 +277,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -325,9 +325,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index e79738c5..18926f44 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -38,16 +38,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -98,16 +98,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -197,7 +197,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> clicked-on-edit-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># 'edit' button = 'copy' button + 'delete' button</span> - text:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text env<span class="Special"> <- </span>delete-sandbox env, sandbox @@ -211,10 +211,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -255,9 +255,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -303,9 +303,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index eeb61f7f..1772865b 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -39,16 +39,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -122,13 +122,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># this requires tracking a couple more things</span> <span class="muData">container</span> sandbox-data [ response-starting-row-on-screen:number - expected-response:address:array:character + expected-response:text ] <span class="Comment"># include expected response when saving or restoring a sandbox</span> <span class="muRecipe">before</span> <span class="Constant"><end-save-sandbox></span> [ <span class="Delimiter">{</span> - expected-response:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> + expected-response:text<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, <span class="Constant">[.out]</span> save filename, expected-response @@ -202,7 +202,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> toggle-expected-response sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - expected-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> <span class="muControl">break-unless</span> expected-response @@ -211,7 +211,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="Comment"># if not, set expected response to the current response</span> <span class="muControl">break-if</span> expected-response - response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">expected-response:offset</span>, response <span class="Delimiter">}</span> ] @@ -221,7 +221,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row - expected-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response <span class="Comment"># fall-through to print in grey</span> response-is-expected?:boolean<span class="Special"> <- </span>equal expected-response, sandbox-response <span class="Delimiter">{</span> diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index a5c77f15..3c4956b7 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -39,16 +39,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -115,17 +115,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> <span class="muControl">reply</span> <span class="Constant">4</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -162,14 +162,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> clicking-on-app-trace-does-nothing [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># create and expand the trace</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[stash 123456789]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[stash 123456789]</span> assume-console [ press F4 left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -204,7 +204,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> sandbox-data [ - trace:address:array:character + trace:text display-trace?:boolean ] @@ -212,8 +212,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:array:character, _, fake-screen:address:screen, trace:address:array:character<span class="Special"> <- </span>run-sandboxed data + data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:address:screen, trace:text<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace @@ -285,7 +285,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> display-trace?:boolean<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? - sandbox-trace:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> + sandbox-trace:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> <span class="muControl">break-unless</span> sandbox-trace <span class="Comment"># nothing to print; move on</span> row, screen<span class="Special"> <- </span>render-text screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index b9f46f1b..6d0117bb 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -36,7 +36,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## handling malformed programs</span> <span class="muData">container</span> programming-environment-data [ - recipe-errors:address:array:character + recipe-errors:text ] <span class="Comment"># copy code from recipe editor, persist, load into mu, save any errors</span> @@ -44,9 +44,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + in:text<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in - recipe-errors:address:array:character<span class="Special"> <- </span>reload in + recipe-errors:text<span class="Special"> <- </span>reload in *env<span class="Special"> <- </span>put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> @@ -60,7 +60,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> - recipe-errors:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> + recipe-errors:text<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 update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> @@ -69,7 +69,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant"><render-recipe-components-end></span> [ <span class="Delimiter">{</span> - recipe-errors:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> + recipe-errors:text<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> <span class="muControl">break-unless</span> recipe-errors row, screen<span class="Special"> <- </span>render-text screen, recipe-errors, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> @@ -102,21 +102,21 @@ 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? - error-index-text:address:array:character<span class="Special"> <- </span>to-text error-index - status:address:array:character<span class="Special"> <- </span>interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text + error-index-text:text<span class="Special"> <- </span>to-text error-index + status:text<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> ] <span class="muData">container</span> sandbox-data [ - errors:address:array:character + errors:text ] <span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:array:character, errors:address:array:character, fake-screen:address:screen, trace:address:array:character, completed?:boolean<span class="Special"> <- </span>run-sandboxed data + data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:text, errors:text, fake-screen:address:screen, trace:text, completed?:boolean<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen @@ -140,7 +140,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># make sure we render any trace</span> <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-trace-done></span> [ <span class="Delimiter">{</span> - sandbox-errors:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">errors:offset</span> + sandbox-errors:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">errors:offset</span> <span class="muControl">break-unless</span> sandbox-errors *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, <span class="Constant">0</span> <span class="Comment"># no response</span> row, screen<span class="Special"> <- </span>render-text screen, sandbox-errors, left, right, <span class="Constant">1/red</span>, row @@ -152,12 +152,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-shows-errors-in-get [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> get 123:number, foo:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -192,9 +192,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 1</span> @@ -216,9 +216,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox-2 [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 2</span> @@ -243,9 +243,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-hides-errors-from-past-sandboxes [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 <span class="Comment"># generate error</span> ] @@ -278,14 +278,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> + <span class="Constant">1</span>:text<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">y:address:number <- copy 0</span> <span class="Constant">z <- add x, y</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -326,12 +326,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:list:_elem -> n:number [</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:list:_elem -> n:number [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[x:address:list:number <- copy 0</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[x:address:list:number <- copy 0</span> <span class="Constant">to-text x]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run it once</span> assume-console [ press F4 @@ -385,12 +385,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-shows-missing-type-errors [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -411,12 +411,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo \\[</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -438,14 +438,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-shows-get-on-non-container-errors [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:address:point <- new point:type</span> <span class="Constant"> get x:address:point, 1:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -470,15 +470,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> run-shows-non-literal-get-argument-errors [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:number <- copy 0</span> <span class="Constant"> y:address:point <- new point:type</span> <span class="Constant"> get *y:address:point, x:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -505,13 +505,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:number <- copy y:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] @@ -551,10 +551,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -614,10 +614,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 @@ -645,14 +645,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -676,7 +676,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a error</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">a:number <- next-ingredient</span> <span class="Constant">b:number <- next-ingredient</span> @@ -684,8 +684,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color _, c:number<span class="Special"> <- </span>divide-with-remainder a, b <span class="muControl">reply</span> b ]] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run</span> assume-console [ press F4 diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 0518d0ad..ff375027 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -136,8 +136,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-typing [ <span class="Comment"># create an editor and type a character</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[0]</span> @@ -266,8 +266,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-typing-multiple [ <span class="Comment"># create an editor and type multiple characters</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[012]</span> @@ -292,8 +292,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-typing-multiple-2 [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># type some characters</span> assume-console [ @@ -338,8 +338,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-typing-enter [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># new line</span> assume-console [ @@ -401,8 +401,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-redo-typing [ <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[012]</span> @@ -465,8 +465,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-redo-typing-empty [ <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[012]</span> @@ -511,10 +511,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-work-clears-redo-stack [ <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[1]</span> @@ -553,8 +553,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-redo-typing-and-enter-and-tab [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ @@ -710,10 +710,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-touch [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor</span> assume-console [ @@ -801,10 +801,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> @@ -863,10 +863,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-left-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor</span> assume-console [ @@ -907,10 +907,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-up-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor</span> assume-console [ @@ -957,10 +957,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-down-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor</span> assume-console [ @@ -1001,13 +1001,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-ctrl-f [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># scroll the page</span> assume-console [ @@ -1036,13 +1036,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-page-down [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># scroll the page</span> assume-console [ @@ -1071,13 +1071,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-ctrl-b [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1107,13 +1107,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-page-up [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1143,10 +1143,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-ctrl-a [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ @@ -1187,10 +1187,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-home [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ @@ -1231,10 +1231,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-ctrl-e [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ @@ -1275,10 +1275,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-end [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ @@ -1319,10 +1319,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-multiple-arrows-in-the-same-direction [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># move the cursor</span> assume-console [ @@ -1373,10 +1373,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-redo-touch [ <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> @@ -1430,8 +1430,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-separates-undo-insert-from-undo-cursor-move [ <span class="Comment"># create an editor, type some text, move the cursor, type some more text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data assume-console [ type <span class="Constant">[abc]</span> @@ -1579,8 +1579,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-and-redo-backspace [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and hit backspace</span> assume-console [ @@ -1724,8 +1724,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-and-redo-delete [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ @@ -1913,9 +1913,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-k [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ @@ -2015,9 +2015,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ @@ -2116,8 +2116,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u-2 [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, <span class="Constant">2</span>:address:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ diff --git a/html/immutable-error.mu.html b/html/immutable_error.mu.html index 52c661c5..2d1fcae6 100644 --- a/html/immutable-error.mu.html +++ b/html/immutable_error.mu.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - immutable-error.mu</title> +<title>Mu - immutable_error.mu</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> diff --git a/html/lambda-to-mu.mu.html b/html/lambda_to_mu.mu.html index d93a8b00..a615b34f 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda_to_mu.mu.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - lambda-to-mu.mu</title> +<title>Mu - lambda_to_mu.mu</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> @@ -40,8 +40,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> convert-lambda [ run [ <span class="Constant">local-scope</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>lambda-to-mu <span class="Constant">[(add a (multiply b c))]</span> - <span class="Constant">2</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">1</span>:address:array:character/<span class="Special">raw</span> + <span class="Constant">1</span>:text/<span class="Special">raw <- </span>lambda-to-mu <span class="Constant">[(add a (multiply b c))]</span> + <span class="Constant">2</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">1</span>:text/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[t1 <- multiply b c</span> @@ -59,7 +59,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># 'parse' will turn lambda expressions into trees made of cells</span> <span class="muData">exclusive-container</span> cell [ - atom:address:array:character + atom:text pair:pair ] @@ -99,7 +99,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> atom-is-not-pair [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:address:cell<span class="Special"> <- </span>new-atom s <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-atom? x <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x @@ -112,7 +112,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> pair-is-not-atom [ <span class="Constant">local-scope</span> <span class="Comment"># construct (a . nil)</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:address:cell<span class="Special"> <- </span>new-atom s y:address:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-atom? y @@ -126,7 +126,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> atom-match? x:address:cell, pat:address:array:character<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - s:address:array:character, is-atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, is-atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">reply-unless</span> is-atom?, <span class="Constant">0/false</span> result<span class="Special"> <- </span>equal pat, s ] @@ -176,7 +176,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> cell-operations-on-atom [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:address:cell<span class="Special"> <- </span>new-atom s <span class="Constant">10</span>:address:cell/<span class="Special">raw <- </span>first x <span class="Constant">11</span>:address:cell/<span class="Special">raw <- </span>rest x @@ -189,7 +189,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> cell-operations-on-pair [ <span class="Constant">local-scope</span> <span class="Comment"># construct (a . nil)</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:address:cell<span class="Special"> <- </span>new-atom s y:address:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> x2:address:cell<span class="Special"> <- </span>first y @@ -236,7 +236,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color b<span class="Special"> <- </span>append b, c <span class="muControl">loop</span> <span class="Delimiter">}</span> - s:address:array:character<span class="Special"> <- </span>buffer-to-array b + s:text<span class="Special"> <- </span>buffer-to-array b out<span class="Special"> <- </span>new-atom s <span class="Delimiter">}</span> <span class="Delimiter">{</span> @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># base case: atom</span> <span class="Delimiter">{</span> - s:address:array:character, atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, atom?:boolean<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">break-unless</span> atom? buf<span class="Special"> <- </span>append buf, s <span class="muControl">reply</span> @@ -351,9 +351,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-single-letter-atom [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> x:address:cell<span class="Special"> <- </span>parse s - s2:address:array:character, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="Constant">11</span>:array:character/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> @@ -363,9 +363,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-atom [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x:address:cell<span class="Special"> <- </span>parse s - s2:address:array:character, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> <span class="Constant">11</span>:array:character/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> @@ -375,7 +375,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-list-of-two-atoms [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[(abc def)]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def)]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < abc | < <span class="muRecipe">def</span> | <span class="Constant"><></span> > > @@ -383,10 +383,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x x1:address:cell<span class="Special"> <- </span>first x x2:address:cell<span class="Special"> <- </span>rest x - s1:address:array:character, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 x3:address:cell<span class="Special"> <- </span>first x2 - s2:address:array:character, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> <span class="Constant">14</span>:address:cell/<span class="Special">raw <- </span>rest x2 <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 @@ -403,7 +403,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-list-with-extra-spaces [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ ( abc def ) ]</span> <span class="Comment"># extra spaces</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ ( abc def ) ]</span> <span class="Comment"># extra spaces</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < abc | < <span class="muRecipe">def</span> | <span class="Constant"><></span> > > @@ -411,10 +411,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x x1:address:cell<span class="Special"> <- </span>first x x2:address:cell<span class="Special"> <- </span>rest x - s1:address:array:character, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 x3:address:cell<span class="Special"> <- </span>first x2 - s2:address:array:character, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> <span class="Constant">14</span>:address:cell/<span class="Special">raw <- </span>rest x2 <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 @@ -431,7 +431,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-list-of-more-than-two-atoms [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[(abc def ghi)]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def ghi)]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < abc | < <span class="muRecipe">def</span> | < ghi | <span class="Constant"><></span> > > > @@ -439,14 +439,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x x1:address:cell<span class="Special"> <- </span>first x x2:address:cell<span class="Special"> <- </span>rest x - s1:address:array:character, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 x3:address:cell<span class="Special"> <- </span>first x2 - s2:address:array:character, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> x4:address:cell<span class="Special"> <- </span>rest x2 <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>is-pair? x4 x5:address:cell<span class="Special"> <- </span>first x4 - s3:address:array:character, <span class="Constant">15</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x5, <span class="Constant">atom:variant</span> + s3:text, <span class="Constant">15</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x5, <span class="Constant">atom:variant</span> <span class="Constant">16</span>:address:cell/<span class="Special">raw <- </span>rest x4 <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 @@ -467,7 +467,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-nested-list [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[((abc))]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[((abc))]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < < abc | <span class="Constant"><></span> > | <span class="Constant"><></span> > @@ -476,7 +476,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x1:address:cell<span class="Special"> <- </span>first x <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x x2:address:cell<span class="Special"> <- </span>first x1 - s1:address:array:character, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">13</span>:address:cell/<span class="Special">raw <- </span>rest x1 <span class="Constant">14</span>:address:cell/<span class="Special">raw <- </span>rest x <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 @@ -492,7 +492,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-nested-list-2 [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[((abc) def)]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[((abc) def)]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < < abc | <span class="Constant"><></span> > | < <span class="muRecipe">def</span> | <span class="Constant"><></span> > > @@ -501,11 +501,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x1:address:cell<span class="Special"> <- </span>first x <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>is-pair? x x2:address:cell<span class="Special"> <- </span>first x1 - s1:address:array:character, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">13</span>:address:cell/<span class="Special">raw <- </span>rest x1 x3:address:cell<span class="Special"> <- </span>rest x x4:address:cell<span class="Special"> <- </span>first x3 - s2:address:array:character, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> <span class="Constant">15</span>:address:cell/<span class="Special">raw <- </span>rest x3 <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 @@ -525,7 +525,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># assertion failures</span> <span class="CommentedCode">#? scenario parse-error [</span> <span class="CommentedCode">#? local-scope</span> -<span class="CommentedCode">#? s:address:array:character <- new [(]</span> +<span class="CommentedCode">#? s:text <- new [(]</span> <span class="CommentedCode">#? #? hide-errors</span> <span class="CommentedCode">#? x:address:cell <- parse s</span> <span class="CommentedCode">#? #? show-errors</span> @@ -536,7 +536,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="CommentedCode">#? </span> <span class="CommentedCode">#? scenario parse-error-after-element [</span> <span class="CommentedCode">#? local-scope</span> -<span class="CommentedCode">#? s:address:array:character <- new [(abc]</span> +<span class="CommentedCode">#? s:text <- new [(abc]</span> <span class="CommentedCode">#? #? hide-errors</span> <span class="CommentedCode">#? x:address:cell <- parse s</span> <span class="CommentedCode">#? #? show-errors</span> @@ -547,7 +547,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-dotted-list-of-two-atoms [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[(abc . def)]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[(abc . def)]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < abc | <span class="muRecipe">def</span> > @@ -555,8 +555,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x x1:address:cell<span class="Special"> <- </span>first x x2:address:cell<span class="Special"> <- </span>rest x - s1:address:array:character, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - s2:address:array:character, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 memory-should-contain [ @@ -571,7 +571,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-dotted-list-of-more-than-two-atoms [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[(abc def . ghi)]</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def . ghi)]</span> x:address:cell<span class="Special"> <- </span>parse s trace-should-contain [ app/parse: < abc | < <span class="muRecipe">def</span> | ghi > > @@ -579,12 +579,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>is-pair? x x1:address:cell<span class="Special"> <- </span>first x x2:address:cell<span class="Special"> <- </span>rest x - s1:address:array:character, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> + s1:text, <span class="Constant">11</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> <span class="Constant">12</span>:boolean/<span class="Special">raw <- </span>is-pair? x2 x3:address:cell<span class="Special"> <- </span>first x2 - s2:address:array:character, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> + s2:text, <span class="Constant">13</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> x4:address:cell<span class="Special"> <- </span>rest x2 - s3:address:array:character, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> + s3:text, <span class="Constant">14</span>:boolean/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *s1 <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *s2 <span class="Constant">40</span>:array:character/<span class="Special">raw <- </span>copy *s3 @@ -616,6 +616,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># null cell? no change.</span> <span class="Comment"># pair with all atoms? gensym a new variable</span> <span class="Comment"># pair containing other pairs? recurse</span> + result-name<span class="Special"> <- </span>copy <span class="Constant">0</span> ] </pre> </body> diff --git a/html/real-files.mu.html b/html/real_files.mu.html index 48cddbb8..7046a633 100644 --- a/html/real-files.mu.html +++ b/html/real_files.mu.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - real-files.mu</title> +<title>Mu - real_files.mu</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="none"> @@ -37,7 +37,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> f:number/file<span class="Special"> <- </span>$open-file-for-reading <span class="Constant">[/tmp/mu-x]</span> $print <span class="Constant">[file to read from: ]</span>, f, <span class="Constant">10/newline</span> - c:character<span class="Special"> <- </span>$read-from-file f + c:character, eof?:boolean<span class="Special"> <- </span>$read-from-file f $print <span class="Constant">[copying ]</span>, c, <span class="Constant">10/newline</span> f<span class="Special"> <- </span>$close-file f $print <span class="Constant">[file after closing: ]</span>, f, <span class="Constant">10/newline</span> diff --git a/html/server-socket.mu.html b/html/server-socket.mu.html new file mode 100644 index 00000000..32782b5a --- /dev/null +++ b/html/server-socket.mu.html @@ -0,0 +1,49 @@ +<!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 - server-socket.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; } +.muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } +.Constant { color: #00a0a0; } +.Special { color: #c00000; } +.muControl { color: #c0a020; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="muRecipe">def</span> main [ + <span class="Constant">local-scope</span> + socket:number<span class="Special"> <- </span>$socket <span class="Constant">8080/port</span> + $print <span class="Constant">[Mu socket creation returned ]</span>, socket, <span class="Constant">10/newline</span> + session:number<span class="Special"> <- </span>$accept socket + <span class="Delimiter">{</span> + client-message:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">1024</span> + c:character<span class="Special"> <- </span>$read-from-socket session + <span class="muControl">break-unless</span> c + $print c + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + $close-socket socket, session +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/index.html b/index.html index 2938f838..100cf7ad 100644 --- a/index.html +++ b/index.html @@ -209,7 +209,7 @@ convenience when debugging is the ability to add variables to the trace using the <span style='font-family:courier,fixed'>stash</span> command. By default <span style='font-family:courier,fixed'>stash</span> just prints out the locations in memory, one by one. To extend its display format specific types, -define a function called <span style='font-family:courier,fixed'>to-text</span> +define a function called <a href='html/058to_text.cc.html'><span style='font-family:courier,fixed'>to-text</span></a> with the appropriate ingredient type, returning a Mu string. <br/><a href='html/067random.cc.html'>067random.cc</a>: a random-number generator with a <a href='html/068random.mu.html'>testable</a> interface. |