diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/010vm.cc.html | 12 | ||||
-rw-r--r-- | html/014literal_string.cc.html | 6 | ||||
-rw-r--r-- | html/023boolean.cc.html | 4 | ||||
-rw-r--r-- | html/029tools.cc.html | 10 | ||||
-rw-r--r-- | html/038new_text.cc.html | 2 | ||||
-rw-r--r-- | html/052tangle.cc.html | 12 | ||||
-rw-r--r-- | html/054static_dispatch.cc.html | 16 | ||||
-rw-r--r-- | html/055shape_shifting_container.cc.html | 4 | ||||
-rw-r--r-- | html/056shape_shifting_recipe.cc.html | 52 | ||||
-rw-r--r-- | html/069rewrite_literal_string.cc.html (renamed from html/063rewrite_literal_string.cc.html) | 2 | ||||
-rw-r--r-- | html/070text.mu.html | 577 | ||||
-rw-r--r-- | html/071rewrite_stash.cc.html | 1 |
12 files changed, 356 insertions, 342 deletions
diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 636e3c3f..a2a4c926 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -91,7 +91,7 @@ recipe_ordinal Next_recipe_ordinal = <span class="Constant">1</span><span class= <span class="Normal">double</span> value<span class="Delimiter">;</span> <span class="Normal">bool</span> initialized<span class="Delimiter">;</span> <span class="Comment">// End reagent Fields</span> - reagent<span class="Delimiter">(</span>string s<span class="Delimiter">);</span> + reagent<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">);</span> reagent<span class="Delimiter">()</span> :type<span class="Delimiter">(</span><span class="Constant">NULL</span><span class="Delimiter">),</span> value<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> initialized<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">)</span> <span class="Delimiter">{}</span> ~reagent<span class="Delimiter">();</span> <span class="Normal">void</span> clear<span class="Delimiter">();</span> @@ -292,7 +292,7 @@ instruction::instruction<span class="Delimiter">()</span> :is_label<span class=" <span class="Normal">bool</span> instruction::is_empty<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> !is_label && name<span class="Delimiter">.</span>empty<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Comment">// Reagents have the form <name>:<type>:<type>:.../<property>/<property>/...</span> -reagent::reagent<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> :original_string<span class="Delimiter">(</span>s<span class="Delimiter">),</span> type<span class="Delimiter">(</span><span class="Constant">NULL</span><span class="Delimiter">),</span> value<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> initialized<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +reagent::reagent<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> :original_string<span class="Delimiter">(</span>s<span class="Delimiter">),</span> type<span class="Delimiter">(</span><span class="Constant">NULL</span><span class="Delimiter">),</span> value<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> initialized<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// Parsing reagent(string s)</span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> in >> std::noskipws<span class="Delimiter">;</span> @@ -309,14 +309,18 @@ reagent::reagent<span class="Delimiter">(</span>string s<span class="Delimiter"> <span class="Normal">if</span> <span class="Delimiter">(</span>name == <span class="Constant">"_"</span> && type == <span class="Constant">NULL</span><span class="Delimiter">)</span> type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">"literal"</span><span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"literal"</span><span class="Delimiter">));</span> <span class="Comment">// other properties</span> + slurp_properties<span class="Delimiter">(</span>in<span class="Delimiter">,</span> properties<span class="Delimiter">);</span> + <span class="Comment">// End Parsing reagent</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> slurp_properties<span class="Delimiter">(</span>istream& in<span class="Delimiter">,</span> vector<pair<string<span class="Delimiter">,</span> string_tree*> >& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">while</span> <span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> istringstream row<span class="Delimiter">(</span>slurp_until<span class="Delimiter">(</span>in<span class="Delimiter">,</span> <span class="Constant">'/'</span><span class="Delimiter">));</span> row >> std::noskipws<span class="Delimiter">;</span> string key = slurp_until<span class="Delimiter">(</span>row<span class="Delimiter">,</span> <span class="Constant">':'</span><span class="Delimiter">);</span> string_tree* value = parse_property_list<span class="Delimiter">(</span>row<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>key<span class="Delimiter">,</span> value<span class="Delimiter">));</span> + out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span>key<span class="Delimiter">,</span> value<span class="Delimiter">));</span> <span class="Delimiter">}</span> - <span class="Comment">// End Parsing reagent</span> <span class="Delimiter">}</span> string_tree* parse_property_list<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 6aa34381..cee61889 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -141,10 +141,10 @@ string slurp_quoted<span class="Delimiter">(</span>istream& in<span class="D <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> assert<span class="Delimiter">(</span>*s<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> == <span class="Constant">']'</span><span class="Delimiter">);</span> - <span class="Comment">// delete [] delimiters</span> - s<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> - strip_last<span class="Delimiter">(</span>s<span class="Delimiter">);</span> name = s<span class="Delimiter">;</span> + <span class="Comment">// delete [] delimiters</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> + strip_last<span class="Delimiter">(</span>name<span class="Delimiter">);</span> type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">"literal-string"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/023boolean.cc.html b/html/023boolean.cc.html index beae6805..9036dfa3 100644 --- a/html/023boolean.cc.html +++ b/html/023boolean.cc.html @@ -156,8 +156,8 @@ NOT<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"not"</span><span class="Delimiter">,</span> NOT<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span class="Normal">case</span> NOT: <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'not' cannot have fewer ingredients than products in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"ingredients and products should match in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">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> diff --git a/html/029tools.cc.html b/html/029tools.cc.html index fab78134..3ce59059 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -68,6 +68,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span string label = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">2</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span>depth<span class="Delimiter">,</span> label<span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> @@ -88,6 +89,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> STASH: <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>i<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"app"</span><span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> @@ -116,11 +118,13 @@ def main [ <span class="Delimiter">:(code)</span> string print_mu<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> vector<<span class="Normal">double</span>>& data<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">))</span> - <span class="Identifier">return</span> r<span class="Delimiter">.</span>name+<span class="Constant">' '</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> r<span class="Delimiter">.</span>name<span class="Delimiter">;</span> <span class="Comment">// End print Special-cases(r, data)</span> ostringstream out<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - out << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="Constant">' '</span><span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>i<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> + out << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + <span class="Delimiter">}</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> diff --git a/html/038new_text.cc.html b/html/038new_text.cc.html index e18505e9..179c33a0 100644 --- a/html/038new_text.cc.html +++ b/html/038new_text.cc.html @@ -103,7 +103,7 @@ def main [ <span class="Delimiter">:(before "End print Special-cases(r, data)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_string<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>data<span class="Delimiter">));</span> - <span class="Identifier">return</span> read_mu_string<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span>+<span class="Constant">' '</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> read_mu_string<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario unicode_string)</span> diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html index 14832b2a..3deeb260 100644 --- a/html/052tangle.cc.html +++ b/html/052tangle.cc.html @@ -104,14 +104,18 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span <span class="Delimiter">:(code)</span> <span class="Normal">void</span> insert_fragments<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + insert_fragments<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">));</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> insert_fragments<span class="Delimiter">(</span>recipe& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">bool</span> made_progress = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Normal">int</span> pass = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Normal">while</span> <span class="Delimiter">(</span>made_progress<span class="Delimiter">)</span> <span class="Delimiter">{</span> made_progress = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// create a new vector because insertions invalidate iterators</span> vector<instruction> result<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">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">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> instruction& inst = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>is_label || !is_waypoint<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> || inst<span class="Delimiter">.</span>tangle_done<span class="Delimiter">)</span> <span class="Delimiter">{</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -120,7 +124,7 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span made_progress = <span class="Constant">true</span><span class="Delimiter">;</span> Fragments_used<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">);</span> ostringstream prefix<span class="Delimiter">;</span> - prefix << <span class="Constant">'+'</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << <span class="Constant">'_'</span> << pass << <span class="Constant">'_'</span> << i<span class="Delimiter">;</span> + prefix << <span class="Constant">'+'</span> << r<span class="Delimiter">.</span>name << <span class="Constant">'_'</span> << pass << <span class="Constant">'_'</span> << i<span class="Delimiter">;</span> <span class="Comment">// ok to use contains_key even though Before_fragments uses [],</span> <span class="Comment">// because appending an empty recipe is a noop</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Before_fragments<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span> @@ -129,7 +133,7 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>After_fragments<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span> append_fragment<span class="Delimiter">(</span>result<span class="Delimiter">,</span> After_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">,</span> prefix<span class="Delimiter">.</span>str<span class="Delimiter">());</span> <span class="Delimiter">}</span> - get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>result<span class="Delimiter">);</span> + r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>result<span class="Delimiter">);</span> ++pass<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> diff --git a/html/054static_dispatch.cc.html b/html/054static_dispatch.cc.html index 3cf6bd22..614ab74c 100644 --- a/html/054static_dispatch.cc.html +++ b/html/054static_dispatch.cc.html @@ -284,7 +284,7 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_zero_agai vector<recipe_ordinal> result<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict except literal-zero-against-address) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_header_reagents_strictly_match_except_literal_zero_against_address<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -309,8 +309,6 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_zero_agai <span class="Delimiter">}</span> <span class="Normal">bool</span> types_strictly_match_except_literal_zero_against_address<span class="Delimiter">(</span><span class="Normal">const</span> reagent& to<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& from<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// to sidestep type-checking, use /unsafe in the source.</span> - <span class="Comment">// this will be highlighted in red inside vim. just for setting up some tests.</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>from<span class="Delimiter">)</span> && is_mu_address<span class="Delimiter">(</span>to<span class="Delimiter">))</span> <span class="Identifier">return</span> from<span class="Delimiter">.</span>name == <span class="Constant">"0"</span><span class="Delimiter">;</span> <span class="Identifier">return</span> types_strictly_match<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> @@ -321,7 +319,7 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_a vector<recipe_ordinal> result<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variants<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict except literals-against-booleans) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"checking variant (strict except literal-against-boolean) "</span> << i << <span class="Constant">": "</span> << header_label<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>all_header_reagents_strictly_match_except_literal_against_address_or_boolean<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))))</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -346,14 +344,10 @@ vector<recipe_ordinal> strictly_matching_variants_except_literal_against_a <span class="Delimiter">}</span> <span class="Normal">bool</span> types_strictly_match_except_literal_against_address_or_boolean<span class="Delimiter">(</span><span class="Normal">const</span> reagent& to<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& from<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// to sidestep type-checking, use /unsafe in the source.</span> - <span class="Comment">// this will be highlighted in red inside vim. just for setting up some tests.</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>from<span class="Delimiter">)</span> && to<span class="Delimiter">.</span>type && to<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"boolean"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> boolean_matches_literal<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>from<span class="Delimiter">)</span> && is_mu_address<span class="Delimiter">(</span>to<span class="Delimiter">))</span> - <span class="Identifier">return</span> from<span class="Delimiter">.</span>name == <span class="Constant">"0"</span><span class="Delimiter">;</span> - <span class="Identifier">return</span> types_strictly_match<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> + <span class="Identifier">return</span> types_strictly_match_except_literal_zero_against_address<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// phase 5</span> @@ -599,7 +593,9 @@ def foo x:number <span class="Delimiter">-></span> y:number [ <span class="Delimiter">:(code)</span> string header_label<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + <span class="Identifier">return</span> header_label<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">));</span> +<span class="Delimiter">}</span> +string header_label<span class="Delimiter">(</span><span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> out << <span class="Constant">"recipe "</span> << caller<span class="Delimiter">.</span>name<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">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> diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index 950cb714..7478d308 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -146,9 +146,9 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">)</span> && contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">)))</span> <span class="Delimiter">{</span> - <span class="Normal">const</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">));</span> + <span class="Normal">const</span> type_info& previous_info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> name<span class="Delimiter">));</span> <span class="Comment">// we've already seen this container; make sure type ingredients match</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!type_ingredients_match<span class="Delimiter">(</span>type_ingredient_names<span class="Delimiter">,</span> info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!type_ingredients_match<span class="Delimiter">(</span>type_ingredient_names<span class="Delimiter">,</span> previous_info<span class="Delimiter">.</span>type_ingredient_names<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << <span class="Constant">"headers of "</span> << command << <span class="Constant">" '"</span> << name << <span class="Constant">"' must use identical type ingredients</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> diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index 1b60581c..7e44abbd 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -99,7 +99,8 @@ candidates = strictly_matching_shape_shifting_variants<span class="Delimiter">(< trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"transforming new specialization: "</span> << variant<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// one exception: skip tangle, which would have already occurred inside new_variant above</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> == insert_fragments<span class="Delimiter">)</span> <span class="Identifier">continue</span><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="Comment">/*</span><span class="Comment">disambiguate overloading</span><span class="Comment">*/</span><span class="Normal">static_cast</span><transform_fn><span class="Delimiter">(</span>insert_fragments<span class="Delimiter">))</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">(</span>*Transform<span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">))(</span>new_recipe_ordinal<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -119,6 +120,13 @@ candidates = strictly_matching_shape_shifting_variants<span class="Delimiter">(< <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(replace{} "bool types_strictly_match_except_literal_zero_against_address(const reagent& to, const reagent& from)")</span> +<span class="Normal">bool</span> types_strictly_match_except_literal_zero_against_address<span class="Delimiter">(</span><span class="Normal">const</span> reagent& to<span class="Delimiter">,</span> <span class="Normal">const</span> reagent& from<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>from<span class="Delimiter">)</span> && is_mu_address<span class="Delimiter">(</span>to<span class="Delimiter">))</span> + <span class="Identifier">return</span> from<span class="Delimiter">.</span>name == <span class="Constant">"0"</span> && !contains_type_ingredient_name<span class="Delimiter">(</span>to<span class="Delimiter">);</span> + <span class="Identifier">return</span> types_strictly_match<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + <span class="Delimiter">:(code)</span> <span class="Comment">// phase 2 of static dispatch</span> vector<recipe_ordinal> strictly_matching_shape_shifting_variants<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> vector<recipe_ordinal>& variants<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -265,17 +273,16 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Comment">// make a copy</span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">));</span> assert<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">));</span> - put<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">));</span> - recipe& new_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">);</span> + recipe new_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">);</span> new_recipe<span class="Delimiter">.</span>name = new_name<span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"switching "</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">" to specialized "</span> << header_label<span class="Delimiter">(</span>new_recipe_ordinal<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"switching "</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">" to specialized "</span> << header_label<span class="Delimiter">(</span>new_recipe<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Comment">// Replace type ingredients with concrete types in new_recipe.</span> <span class="Comment">//</span> <span class="Comment">// preprocessing: micro-manage a couple of transforms</span> <span class="Comment">// a) perform tangle *before* replacing type ingredients, just in case</span> <span class="Comment">// inserted code involves type ingredients</span> - insert_fragments<span class="Delimiter">(</span>new_recipe_ordinal<span class="Delimiter">);</span> + insert_fragments<span class="Delimiter">(</span>new_recipe<span class="Delimiter">);</span> <span class="Comment">// b) do the work of check_types_by_name while supporting type-ingredients</span> compute_type_names<span class="Delimiter">(</span>new_recipe<span class="Delimiter">);</span> <span class="Comment">// that gives enough information to replace type-ingredients with concrete types</span> @@ -283,12 +290,14 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla map<string<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree*> mappings<span class="Delimiter">;</span> <span class="Normal">bool</span> error = <span class="Constant">false</span><span class="Delimiter">;</span> compute_type_ingredient_mappings<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> mappings<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">,</span> &error<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!error<span class="Delimiter">)</span> error = <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>mappings<span class="Delimiter">)</span> != type_ingredient_count_in_header<span class="Delimiter">(</span>exemplar<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!error<span class="Delimiter">)</span> replace_type_ingredients<span class="Delimiter">(</span>new_recipe<span class="Delimiter">,</span> mappings<span class="Delimiter">);</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree*>::iterator p = mappings<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != mappings<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> - <span class="Normal">if</span> <span class="Delimiter">(</span>error<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// todo: delete new_recipe_ordinal from Recipes and other global state</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>error<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> ensure_all_concrete_types<span class="Delimiter">(</span>new_recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">));</span> + put<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">,</span> new_recipe<span class="Delimiter">);</span> <span class="Identifier">return</span> new_recipe_ordinal<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -482,6 +491,23 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Delimiter">}</span> <span class="Delimiter">}</span> +<span class="Normal">int</span> type_ingredient_count_in_header<span class="Delimiter">(</span>recipe_ordinal variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> + set<string> type_ingredients<span class="Delimiter">;</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + accumulate_type_ingredients<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> type_ingredients<span class="Delimiter">);</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + accumulate_type_ingredients<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> type_ingredients<span class="Delimiter">);</span> + <span class="Identifier">return</span> SIZE<span class="Delimiter">(</span>type_ingredients<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Normal">void</span> accumulate_type_ingredients<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> set<string>& out<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>is_type_ingredient_name<span class="Delimiter">(</span>type<span class="Delimiter">-></span>name<span class="Delimiter">))</span> out<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>type<span class="Delimiter">-></span>name<span class="Delimiter">);</span> + accumulate_type_ingredients<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> + accumulate_type_ingredients<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span class="Delimiter">}</span> + type_tree* parse_type_tree<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> @@ -1107,7 +1133,19 @@ def main [ local-scope foo <span class="Constant">34</span> ] -$exit: <span class="Constant">0</span> +$error: <span class="Constant">0</span> + +<span class="Delimiter">:(scenario shape_shifting_recipe_coexists_with_primitive)</span> +<span class="Comment"># recipe overloading a primitive with a generic type</span> +def add a:address:foo:_elem [ + assert <span class="Constant">0</span><span class="Delimiter">,</span> [should <span class="Normal">not</span> get here] +] + +def main [ + <span class="Comment"># call primitive add with literal 0</span> + add <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">0</span> +] +$error: <span class="Constant">0</span> </pre> </body> </html> diff --git a/html/063rewrite_literal_string.cc.html b/html/069rewrite_literal_string.cc.html index c80daf06..e9ec3837 100644 --- a/html/063rewrite_literal_string.cc.html +++ b/html/069rewrite_literal_string.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 063rewrite_literal_string.cc</title> +<title>Mu - 069rewrite_literal_string.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v2"> <meta name="syntax" content="cpp"> diff --git a/html/070text.mu.html b/html/070text.mu.html index 92162003..12114ddd 100644 --- a/html/070text.mu.html +++ b/html/070text.mu.html @@ -49,13 +49,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color y<span class="Special"> <- </span>to-text *x ] -<span class="Comment"># to-text on text is just the identity function</span> -<span class="muRecipe">def</span> to-text x:address:array:character<span class="muRecipe"> -> </span>y:address:array:character [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="muControl">return</span> x -] - <span class="muRecipe">def</span> equal a:address:array:character, b:address:array:character<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -89,7 +82,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-reflexive [ run [ - <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + <span class="Constant">local-scope</span> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal x, x ] @@ -100,7 +93,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-identical [ run [ - <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + <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> <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal x, y @@ -112,7 +105,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-distinct-lengths [ run [ - <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + <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> <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal x, y @@ -130,7 +123,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-equal-with-empty [ run [ - <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + <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> <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal x, y @@ -142,7 +135,7 @@ 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">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + <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> <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal x, y @@ -303,73 +296,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> to-text n:number<span class="muRecipe"> -> </span>result:address:array:character [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - <span class="Comment"># is n zero?</span> - <span class="Delimiter">{</span> - <span class="muControl">break-if</span> n - result<span class="Special"> <- </span>new <span class="Constant">[0]</span> - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># save sign</span> - negate-result:boolean<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Delimiter">{</span> - negative?:boolean<span class="Special"> <- </span>lesser-than n, <span class="Constant">0</span> - <span class="muControl">break-unless</span> negative? - negate-result<span class="Special"> <- </span>copy <span class="Constant">1</span> - n<span class="Special"> <- </span>multiply n, <span class="Constant">-1</span> - <span class="Delimiter">}</span> - <span class="Comment"># add digits from right to left into intermediate buffer</span> - tmp:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> - digit-base:number<span class="Special"> <- </span>copy <span class="Constant">48</span> <span class="Comment"># '0'</span> - <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>equal n, <span class="Constant">0</span> - <span class="muControl">break-if</span> done? - n, digit:number<span class="Special"> <- </span>divide-with-remainder n, <span class="Constant">10</span> - c:character<span class="Special"> <- </span>add digit-base, digit - tmp:address:buffer<span class="Special"> <- </span>append tmp, c - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="Comment"># add sign</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> negate-result:boolean - minus:character<span class="Special"> <- </span>copy <span class="Constant">45/-</span> - tmp<span class="Special"> <- </span>append tmp, minus - <span class="Delimiter">}</span> - <span class="Comment"># reverse buffer into text result</span> - len:number<span class="Special"> <- </span>get *tmp, <span class="Constant">length:offset</span> - buf:address:array:character<span class="Special"> <- </span>get *tmp, <span class="Constant">data:offset</span> - result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len - i:number<span class="Special"> <- </span>subtract len, <span class="Constant">1</span> <span class="Comment"># source index, decreasing</span> - j:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># destination index, increasing</span> - <span class="Delimiter">{</span> - <span class="Comment"># while i >= 0</span> - done?:boolean<span class="Special"> <- </span>lesser-than i, <span class="Constant">0</span> - <span class="muControl">break-if</span> done? - <span class="Comment"># result[j] = tmp[i]</span> - src:character<span class="Special"> <- </span>index *buf, i - *result<span class="Special"> <- </span>put-index *result, j, src - i<span class="Special"> <- </span>subtract i, <span class="Constant">1</span> - j<span class="Special"> <- </span>add j, <span class="Constant">1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> -] - -<span class="muRecipe">def</span> to-text x:boolean<span class="muRecipe"> -> </span>result:address:array:character [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - n:number<span class="Special"> <- </span>copy x:boolean - result<span class="Special"> <- </span>to-text n -] - -<span class="muRecipe">def</span> to-text x:address:_elem<span class="muRecipe"> -> </span>result:address:array:character [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - n:number<span class="Special"> <- </span>copy x - result<span class="Special"> <- </span>to-text n -] - <span class="muRecipe">def</span> buffer-to-array in:address:buffer<span class="muRecipe"> -> </span>result:address:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -393,41 +319,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muScenario">scenario</span> integer-to-decimal-digit-zero [ - run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>to-text <span class="Constant">0</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> - ] - memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[0]</span> - ] -] - -<span class="muScenario">scenario</span> integer-to-decimal-digit-positive [ - run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>to-text <span class="Constant">234</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> - ] - memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[234]</span> - ] -] - -<span class="muScenario">scenario</span> integer-to-decimal-digit-negative [ - run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>to-text <span class="Constant">-1</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> - ] - memory-should-contain [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">45</span> <span class="Comment"># '-'</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">49</span> <span class="Comment"># '1'</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="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + <span class="Comment"># handle null addresses</span> + <span class="muControl">reply-unless</span> a, b + <span class="muControl">reply-unless</span> b, a <span class="Comment"># result = new character[a.length + b.length]</span> a-len:number<span class="Special"> <- </span>length *a b-len:number<span class="Special"> <- </span>length *b @@ -464,24 +361,52 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-append-1 [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[hello,]</span> - <span class="Constant">2</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[ world!]</span> - <span class="Constant">3</span>:address:array:character/<span class="Special">raw <- </span>append <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:array:character/<span class="Special">raw</span> - <span class="Constant">4</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">3</span>:address:array:character/<span class="Special">raw</span> + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *z + ] + memory-should-contain [ + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello, world!]</span> + ] +] + +<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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *z + ] + memory-should-contain [ + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[ world!]</span> + ] +] + +<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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ - <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello, world!]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello,]</span> ] ] <span class="muScenario">scenario</span> replace-character-in-text [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">98/b</span>, <span class="Constant">122/z</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">local-scope</span> + x:address:array:character<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">1</span>:array:character/<span class="Special">raw <- </span>copy *x ] memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[azc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[azc]</span> ] ] @@ -499,45 +424,49 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> replace-character-at-start [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">97/a</span>, <span class="Constant">122/z</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">local-scope</span> + x:address:array:character<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">1</span>:array:character/<span class="Special">raw <- </span>copy *x ] memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[zbc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[zbc]</span> ] ] <span class="muScenario">scenario</span> replace-character-at-end [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">99/c</span>, <span class="Constant">122/z</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">local-scope</span> + x:address:array:character<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">1</span>:array:character/<span class="Special">raw <- </span>copy *x ] memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[abz]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abz]</span> ] ] <span class="muScenario">scenario</span> replace-character-missing [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">100/d</span>, <span class="Constant">122/z</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">local-scope</span> + x:address:array:character<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">1</span>:array:character/<span class="Special">raw <- </span>copy *x ] memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> replace-all-characters [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[banana]</span> - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">97/a</span>, <span class="Constant">122/z</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">local-scope</span> + x:address:array:character<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">1</span>:array:character/<span class="Special">raw <- </span>copy *x ] memory-should-contain [ - <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[bznznz]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[bznznz]</span> ] ] @@ -617,35 +546,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> interpolate-works [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc _]</span> - <span class="Constant">2</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:array:character/<span class="Special">raw</span> - <span class="Constant">4</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">3</span>:address:array:character/<span class="Special">raw</span> + <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">[def]</span> + z:address:array:character<span class="Special"> <- </span>interpolate x, y + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ - <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc def]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc def]</span> ] ] <span class="muScenario">scenario</span> interpolate-at-start [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[_, hello!]</span> - <span class="Constant">2</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">3</span>:address:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:array:character/<span class="Special">raw</span> - <span class="Constant">4</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">3</span>:address:array:character/<span class="Special">raw</span> + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ - <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc, hello!]</span> - <span class="Constant">16</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># out of bounds</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc, hello!]</span> + <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># out of bounds</span> ] ] <span class="muScenario">scenario</span> interpolate-at-end [ run [ - <span class="Constant">1</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[hello, _]</span> - <span class="Constant">2</span>:address:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">3</span>:address:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:array:character/<span class="Special">raw</span> - <span class="Constant">4</span>:array:character/<span class="Special">raw <- </span>copy *<span class="Constant">3</span>:address:array:character/<span class="Special">raw</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 + <span class="Constant">4</span>:array:character/<span class="Special">raw <- </span>copy *z ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello, abc]</span> @@ -765,57 +696,62 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> trim-unmodified [ 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>trim <span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> trim-left [ 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>trim <span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> trim-right [ 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>trim <span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> trim-left-right [ 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>trim <span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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 + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> trim-newline-tab [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc</span> <span class="Constant">]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + y:address:array:character<span class="Special"> <- </span>trim x + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] @@ -837,81 +773,89 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-find-next [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> ] ] <span class="muScenario">scenario</span> text-find-next-empty [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> ] ] <span class="muScenario">scenario</span> text-find-next-initial [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># prefix match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># prefix match</span> ] ] <span class="muScenario">scenario</span> text-find-next-final [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># suffix match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># suffix match</span> ] ] <span class="muScenario">scenario</span> text-find-next-missing [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># no match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># no match</span> ] ] <span class="muScenario">scenario</span> text-find-next-invalid-index [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">4/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># no change</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># no change</span> ] ] <span class="muScenario">scenario</span> text-find-next-first [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># first '/' of multiple</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># first '/' of multiple</span> ] ] <span class="muScenario">scenario</span> text-find-next-second [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span>, <span class="Constant">3/start-index</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> + <span class="Constant">1</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 [ - <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># second '/' of multiple</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># second '/' of multiple</span> ] ] @@ -939,56 +883,61 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> find-next-text-1 [ 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">[bc]</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> ] ] <span class="muScenario">scenario</span> find-next-text-2 [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[bc]</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">1</span> + <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> + <span class="Constant">10</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">1</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> ] ] <span class="muScenario">scenario</span> find-next-no-match [ 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">[bd]</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># not found</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># not found</span> ] ] <span class="muScenario">scenario</span> find-next-suffix-match [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[cd]</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">2</span> ] ] <span class="muScenario">scenario</span> find-next-suffix-match-2 [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[cde]</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>find-next <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># not found</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># not found</span> ] ] @@ -1026,98 +975,107 @@ 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">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">[ab]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match found</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match found</span> ] ] <span class="muScenario">scenario</span> match-at-reflexive [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">1</span>:address:array:character, <span class="Constant">0</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match found</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match found</span> ] ] <span class="muScenario">scenario</span> match-at-outside-bounds [ 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">[a]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">4</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># never matches</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># never matches</span> ] ] <span class="muScenario">scenario</span> match-at-empty-pattern [ 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">[]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># always matches empty pattern given a valid index</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># always matches empty pattern given a valid index</span> ] ] <span class="muScenario">scenario</span> match-at-empty-pattern-outside-bound [ 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">[]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">4</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> ] ] <span class="muScenario">scenario</span> match-at-empty-text [ run [ - <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">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> ] ] <span class="muScenario">scenario</span> match-at-empty-against-empty [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">1</span>:address:array:character, <span class="Constant">0</span> + <span class="Constant">local-scope</span> + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># matches because pattern is also empty</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># matches because pattern is also empty</span> ] ] <span class="muScenario">scenario</span> match-at-inside-bounds [ 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">[bc]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">1</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">1</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># match</span> ] ] <span class="muScenario">scenario</span> match-at-inside-bounds-2 [ 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">[bc]</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>match-at <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character, <span class="Constant">0</span> + <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> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no match</span> ] ] @@ -1165,16 +1123,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-1 [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> - <span class="Constant">2</span>:address:array:address:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>length *<span class="Constant">2</span>:address:array:address:array:character - <span class="Constant">4</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">0</span> - <span class="Constant">5</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">1</span> - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:character - <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:array:character + <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> + <span class="Constant">1</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> + <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *a + <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *b ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># length of result</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># length of result</span> <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[a]</span> <span class="Constant">20</span>:array:character<span class="Special"> <- </span><span class="Constant">[b]</span> ] @@ -1182,18 +1141,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-2 [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> - <span class="Constant">2</span>:address:array:address:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>length *<span class="Constant">2</span>:address:array:address:array:character - <span class="Constant">4</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">0</span> - <span class="Constant">5</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">1</span> - <span class="Constant">6</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">2</span> - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:character - <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:array:character - <span class="Constant">30</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">6</span>:address:array:character + <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> + <span class="Constant">1</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> + <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *a + <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *b + <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *c ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># length of result</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># length of result</span> <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[a]</span> <span class="Constant">20</span>:array:character<span class="Special"> <- </span><span class="Constant">[b]</span> <span class="Constant">30</span>:array:character<span class="Special"> <- </span><span class="Constant">[c]</span> @@ -1202,45 +1162,48 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-missing [ 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:address:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>length *<span class="Constant">2</span>:address:array:address:array:character - <span class="Constant">4</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">0</span> - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:character + <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> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>length *y + a:address:array:character<span class="Special"> <- </span>index *y, <span class="Constant">0</span> + <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *a ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># length of result</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># length of result</span> <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> text-split-empty [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:address:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>length *<span class="Constant">2</span>:address:array:address:array:character + <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> + <span class="Constant">1</span>:number/<span class="Special">raw <- </span>length *y ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty result</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty result</span> ] ] <span class="muScenario">scenario</span> text-split-empty-piece [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> - <span class="Constant">2</span>:address:array:address:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>length *<span class="Constant">2</span>:address:array:address:array:character - <span class="Constant">4</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">0</span> - <span class="Constant">5</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">1</span> - <span class="Constant">6</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">2</span> - <span class="Constant">7</span>:address:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:array:address:array:character, <span class="Constant">3</span> - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:character - <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:array:character - <span class="Constant">30</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">6</span>:address:array:character - <span class="Constant">40</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">7</span>:address:array:character + <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> + <span class="Constant">1</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> + <span class="Constant">10</span>:array:character/<span class="Special">raw <- </span>copy *a + <span class="Constant">20</span>:array:character/<span class="Special">raw <- </span>copy *b + <span class="Constant">30</span>:array:character/<span class="Special">raw <- </span>copy *c + <span class="Constant">40</span>:array:character/<span class="Special">raw <- </span>copy *d ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># length of result</span> + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># length of result</span> <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[a]</span> <span class="Constant">20</span>:array:character<span class="Special"> <- </span><span class="Constant">[b]</span> <span class="Constant">30</span>:array:character<span class="Special"> <- </span><span class="Constant">[]</span> @@ -1268,10 +1231,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> text-split-first [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> - <span class="Constant">2</span>:address:array:character, <span class="Constant">3</span>:address:array:character<span class="Special"> <- </span>split-first <span class="Constant">1</span>:address:array:character, <span class="Constant">47/slash</span> - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character - <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:character + <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> + <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 ] memory-should-contain [ <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[a]</span> @@ -1304,34 +1268,37 @@ 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">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>copy-range <span class="Constant">1</span>:address:array:character, <span class="Constant">1</span>, <span class="Constant">3</span> - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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> + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[bc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[bc]</span> ] ] <span class="muScenario">scenario</span> text-copy-out-of-bounds [ 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>copy-range <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>, <span class="Constant">4</span> - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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> + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[c]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[c]</span> ] ] <span class="muScenario">scenario</span> text-copy-out-of-bounds-2 [ 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>copy-range <span class="Constant">1</span>:address:array:character, <span class="Constant">3</span>, <span class="Constant">3</span> - <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:character + <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> + <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *y ] memory-should-contain [ - <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[]</span> ] ] </pre> diff --git a/html/071rewrite_stash.cc.html b/html/071rewrite_stash.cc.html index 54df2510..fda0846d 100644 --- a/html/071rewrite_stash.cc.html +++ b/html/071rewrite_stash.cc.html @@ -156,6 +156,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'to-text' requires a single ingredient, but got '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + <span class="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> |