diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-26 23:47:23 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-26 23:47:23 -0800 |
commit | d009e158803956c76adbf8f58a62884c3e7affb3 (patch) | |
tree | b88198e28d15cd1fc064f5300365a190decc4c50 | |
parent | 2da43c9462c7b7c1bb78d2f2826b3b97b4874973 (diff) | |
download | mu-d009e158803956c76adbf8f58a62884c3e7affb3.tar.gz |
2605
68 files changed, 4239 insertions, 2830 deletions
diff --git a/html/003trace.cc.html b/html/003trace.cc.html index a1c0be03..c19044fb 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -287,7 +287,7 @@ int trace_count<span class="Delimiter">(</span>string label<span class="Delimite long result = <span class="Constant">0</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>label == p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>line == <span class="Constant">""</span> || line == trim<span class="Delimiter">(</span>p<span class="Delimiter">-></span>contents<span class="Delimiter">))</span> + if <span class="Delimiter">(</span>line == <span class="Constant">""</span> || trim<span class="Delimiter">(</span>line<span class="Delimiter">)</span> == trim<span class="Delimiter">(</span>p<span class="Delimiter">-></span>contents<span class="Delimiter">))</span> ++result<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -304,6 +304,16 @@ int trace_count<span class="Delimiter">(</span>string label<span class="Delimite <span class="PreProc"> </span><span class="Identifier">return</span><span class="Delimiter">;</span><span class="PreProc"> \</span> <span class="PreProc"> </span><span class="Delimiter">}</span> +<span class="PreProc">#define CHECK_TRACE_COUNT(label</span><span class="Delimiter">,</span><span class="PreProc"> count) \</span> +<span class="PreProc"> </span>if<span class="PreProc"> (trace_count(label) != (count)) </span><span class="Delimiter">{</span><span class="PreProc"> \</span> +<span class="PreProc"> ++Num_failures</span><span class="Delimiter">;</span><span class="PreProc"> \</span> +<span class="PreProc"> cerr << </span><span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span><span class="PreProc"> << __FUNCTION__ << </span><span class="Constant">"("</span><span class="PreProc"> << </span><span class="Constant">__FILE__</span><span class="PreProc"> << </span><span class="Constant">":"</span><span class="PreProc"> << </span><span class="Constant">__LINE__</span><span class="PreProc"> << </span><span class="Constant">"): trace_count of "</span><span class="PreProc"> << label << </span><span class="Constant">" should be "</span><span class="PreProc"> << count << </span><span class="cSpecial">'\n'</span><span class="Delimiter">;</span><span class="PreProc"> \</span> +<span class="PreProc"> cerr << </span><span class="Constant">" got "</span><span class="PreProc"> << trace_count(label) << </span><span class="cSpecial">'\n'</span><span class="Delimiter">;</span><span class="PreProc"> </span><span class="Comment">/*</span><span class="Comment"> multiple eval </span><span class="Comment">*/</span><span class="PreProc"> \</span> +<span class="PreProc"> DUMP(label)</span><span class="Delimiter">;</span><span class="PreProc"> \</span> +<span class="PreProc"> Passed = </span><span class="Constant">false</span><span class="Delimiter">;</span><span class="PreProc"> \</span> +<span class="PreProc"> </span><span class="Identifier">return</span><span class="Delimiter">;</span><span class="PreProc"> </span><span class="Comment">/*</span><span class="Comment"> Currently we stop at the very first failure. </span><span class="Comment">*/</span><span class="PreProc"> \</span> +<span class="PreProc"> </span><span class="Delimiter">}</span> + bool trace_doesnt_contain<span class="Delimiter">(</span>string label<span class="Delimiter">,</span> string line<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> trace_count<span class="Delimiter">(</span>label<span class="Delimiter">,</span> line<span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/003trace.test.cc.html b/html/003trace.test.cc.html index 963493e4..b5768fc6 100644 --- a/html/003trace.test.cc.html +++ b/html/003trace.test.cc.html @@ -40,6 +40,12 @@ void test_trace_check_ignores_other_layers<span class="Delimiter">()</span> <spa CHECK_TRACE_DOESNT_CONTAIN<span class="Delimiter">(</span><span class="Constant">"test layer 2: foo"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> +void test_trace_check_ignores_leading_whitespace<span class="Delimiter">()</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">"test layer 1"</span><span class="Delimiter">)</span> << <span class="Constant">" foo"</span> << end<span class="Delimiter">();</span> + CHECK<span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">"test layer 1"</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">too little whitespace</span><span class="Comment">*/</span><span class="Constant">"foo"</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">);</span> + CHECK<span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">"test layer 1"</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">too much whitespace</span><span class="Comment">*/</span><span class="Constant">" foo"</span><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> + void test_trace_check_ignores_other_lines<span class="Delimiter">()</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">"test layer 1"</span><span class="Delimiter">)</span> << <span class="Constant">"foo"</span> << end<span class="Delimiter">();</span> trace<span class="Delimiter">(</span><span class="Constant">"test layer 1"</span><span class="Delimiter">)</span> << <span class="Constant">"bar"</span> << end<span class="Delimiter">();</span> diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 69d5dec0..40ae0c5e 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -282,14 +282,14 @@ reagent::reagent<span class="Delimiter">(</span>string s<span class="Delimiter"> name = properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>first<span class="Delimiter">;</span> type = new_type_tree<span class="Delimiter">(</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>name<span class="Delimiter">)</span> && type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - type = new type_tree<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>!properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second = new string_tree<span class="Delimiter">(</span><span class="Constant">"literal"</span><span class="Delimiter">);</span> + type = new type_tree<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="Delimiter">}</span> if <span class="Delimiter">(</span>name == <span class="Constant">"_"</span> && type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - type = new type_tree<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>!properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second = new string_tree<span class="Delimiter">(</span><span class="Constant">"dummy"</span><span class="Delimiter">);</span> + type = new type_tree<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="Delimiter">}</span> <span class="Comment">// End Parsing reagent</span> <span class="Delimiter">}</span> @@ -311,7 +311,7 @@ type_tree* new_type_tree<span class="Delimiter">(</span>const string_tree* prope result<span class="Delimiter">-></span>value = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">);</span> else if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>type_name<span class="Delimiter">))</span> <span class="Comment">// sometimes types will contain non-type tags, like numbers for the size of an array</span> result<span class="Delimiter">-></span>value = <span class="Constant">0</span><span class="Delimiter">;</span> - else + else if <span class="Delimiter">(</span>properties<span class="Delimiter">-></span>value != <span class="Constant">"->"</span><span class="Delimiter">)</span> <span class="Comment">// used in recipe types</span> result<span class="Delimiter">-></span>value = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// should never happen; will trigger errors later</span> <span class="Delimiter">}</span> result<span class="Delimiter">-></span>left = new_type_tree<span class="Delimiter">(</span>properties<span class="Delimiter">-></span>left<span class="Delimiter">);</span> @@ -321,7 +321,11 @@ type_tree* new_type_tree<span class="Delimiter">(</span>const string_tree* prope <span class="Comment">//: avoid memory leaks for the type tree</span> -reagent::reagent<span class="Delimiter">(</span>const reagent& old<span class="Delimiter">)</span> :original_string<span class="Delimiter">(</span>old<span class="Delimiter">.</span>original_string<span class="Delimiter">),</span> properties<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">),</span> name<span class="Delimiter">(</span>old<span class="Delimiter">.</span>name<span class="Delimiter">),</span> value<span class="Delimiter">(</span>old<span class="Delimiter">.</span>value<span class="Delimiter">),</span> initialized<span class="Delimiter">(</span>old<span class="Delimiter">.</span>initialized<span class="Delimiter">)</span> <span class="Delimiter">{</span> +reagent::reagent<span class="Delimiter">(</span>const reagent& old<span class="Delimiter">)</span> <span class="Delimiter">{</span> + original_string = old<span class="Delimiter">.</span>original_string<span class="Delimiter">;</span> + name = old<span class="Delimiter">.</span>name<span class="Delimiter">;</span> + value = old<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + initialized = old<span class="Delimiter">.</span>initialized<span class="Delimiter">;</span> properties<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span>old<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first<span class="Delimiter">,</span> @@ -330,7 +334,8 @@ reagent::reagent<span class="Delimiter">(</span>const reagent& old<span clas type = old<span class="Delimiter">.</span>type ? new type_tree<span class="Delimiter">(</span>*old<span class="Delimiter">.</span>type<span class="Delimiter">)</span> : <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -type_tree::type_tree<span class="Delimiter">(</span>const type_tree& old<span class="Delimiter">)</span> :value<span class="Delimiter">(</span>old<span class="Delimiter">.</span>value<span class="Delimiter">)</span> <span class="Delimiter">{</span> +type_tree::type_tree<span class="Delimiter">(</span>const type_tree& old<span class="Delimiter">)</span> <span class="Delimiter">{</span> + value = old<span class="Delimiter">.</span>value<span class="Delimiter">;</span> left = old<span class="Delimiter">.</span>left ? new type_tree<span class="Delimiter">(</span>*old<span class="Delimiter">.</span>left<span class="Delimiter">)</span> : <span class="Constant">NULL</span><span class="Delimiter">;</span> right = old<span class="Delimiter">.</span>right ? new type_tree<span class="Delimiter">(</span>*old<span class="Delimiter">.</span>right<span class="Delimiter">)</span> : <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/011load.cc.html b/html/011load.cc.html index e3be7973..1bb04a8c 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -13,10 +13,9 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } @@ -94,9 +93,8 @@ long long int slurp_recipe<span class="Delimiter">(</span>istream& in<span c <span class="Delimiter">}</span> slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">,</span> result<span class="Delimiter">);</span> <span class="Comment">// End recipe Body(result)</span> - get_or_insert<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">))</span> = result<span class="Delimiter">;</span> + put<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">),</span> result<span class="Delimiter">);</span> <span class="Comment">// track added recipes because we may need to undo them in tests; see below</span> -<span class="CommentedCode">//? LOG << "recently added recipe: " << result.name << ' ' << get(Recipe_ordinal, result.name) << '\n';</span> Recently_added_recipes<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">));</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -280,7 +278,6 @@ void clear_recently_added_recipes<span class="Delimiter">()</span> <span class=" if <span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> >= Reserved_for_tests <span class="Comment">// don't renumber existing recipes, like 'interactive'</span> && contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Comment">// in case previous test had duplicate definitions</span> Recipe_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> -<span class="CommentedCode">//? LOG << "erase recipe " << Recently_added_recipes.at(i) << ' ' << get(Recipe, Recently_added_recipes.at(i)).name << '\n';</span> Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Comment">// Clear Other State For Recently_added_recipes</span> diff --git a/html/020run.cc.html b/html/020run.cc.html index d0213a69..4194981e 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -17,8 +17,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .CommentedCode { color: #6c6c6c; } .PreProc { color: #c000c0; } .Delimiter { color: #a04060; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } @@ -176,6 +176,7 @@ transform_all<span class="Delimiter">();</span> <span class="Comment">//: Step 2: load any .mu files provided at the commandline</span> <span class="Delimiter">:(before "End Commandline Parsing")</span> +<span class="Comment">// Check For .mu Files</span> if <span class="Delimiter">(</span>argc > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// skip argv[0]</span> argv++<span class="Delimiter">;</span> @@ -309,12 +310,14 @@ void write_memory<span class="Delimiter">(</span>reagent x<span class="Delimiter if <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> long long int base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>size_mismatch<span class="Delimiter">(</span>x<span class="Delimiter">,</span> data<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"size mismatch in storing to "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" ("</span> << size_of<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << SIZE<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="Constant">") at '"</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + <span class="Comment">// End write_memory(reagent x, long long int base) Special-cases</span> for <span class="Delimiter">(</span>long long int offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>base+offset == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + assert<span class="Delimiter">(</span>base+offset > <span class="Constant">0</span><span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << base+offset << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+offset<span class="Delimiter">,</span> data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -362,6 +365,7 @@ void run<span class="Delimiter">(</span>string form<span class="Delimiter">)</sp vector<recipe_ordinal> tmp = load<span class="Delimiter">(</span>form<span class="Delimiter">);</span> transform_all<span class="Delimiter">();</span> if <span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>trace_count<span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">)</span> > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> run<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>front<span class="Delimiter">());</span> <span class="Delimiter">}</span> diff --git a/html/021check_instruction.cc.html b/html/021check_instruction.cc.html index 585c2c3a..c0229312 100644 --- a/html/021check_instruction.cc.html +++ b/html/021check_instruction.cc.html @@ -170,10 +170,6 @@ bool types_strictly_match<span class="Delimiter">(</span>type_tree* lhs<span cla <span class="Identifier">return</span> types_strictly_match<span class="Delimiter">(</span>lhs<span class="Delimiter">-></span>left<span class="Delimiter">,</span> rhs<span class="Delimiter">-></span>left<span class="Delimiter">)</span> && types_strictly_match<span class="Delimiter">(</span>lhs<span class="Delimiter">-></span>right<span class="Delimiter">,</span> rhs<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Delimiter">}</span> -bool is_raw<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> has_property<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"raw"</span><span class="Delimiter">);</span> -<span class="Delimiter">}</span> - bool is_unsafe<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> has_property<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"unsafe"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -192,9 +188,11 @@ bool is_mu_address<span class="Delimiter">(</span>reagent r<span class="Delimite bool is_mu_number<span class="Delimiter">(</span>reagent r<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">))</span> + if <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Identifier">return</span> r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"literal-number"</span> || r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"literal"</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"character"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Comment">// permit arithmetic on unicode code points</span> <span class="Identifier">return</span> r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"number"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index 0a353d6d..f7e89060 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -137,6 +137,10 @@ case SUBTRACT: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(code)</span> +bool is_raw<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Identifier">return</span> has_property<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"raw"</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(scenario subtract_literal)</span> recipe main [ @@ -302,6 +306,9 @@ case DIVIDE_WITH_REMAINDER: <span class="Delimiter">{</span> long long int b = static_cast<long long int><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> if <span class="Delimiter">(</span>b == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"divide by zero in '"</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> long long int quotient = a / b<span class="Delimiter">;</span> diff --git a/html/029tools.cc.html b/html/029tools.cc.html index 5355d922..69b67fb9 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .SalientComment { color: #00ffff; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .CommentedCode { color: #6c6c6c; } .Comment { color: #9090ff; } diff --git a/html/030container.cc.html b/html/030container.cc.html index 77c582c7..00935788 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .SalientComment { color: #00ffff; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } @@ -55,7 +55,7 @@ get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<sp recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> - <span class="Constant">3</span>:point<span class="Special"> <- </span>copy <span class="Constant">1</span>:point/<span class="Special">raw</span> <span class="Comment"># unsafe</span> + <span class="Constant">3</span>:point<span class="Special"> <- </span>copy <span class="Constant">1</span>:point/unsafe ] <span class="traceContains">+mem: storing 34 in location 3</span> <span class="traceContains">+mem: storing 35 in location 4</span> @@ -85,7 +85,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> - <span class="Constant">15</span>:point-number<span class="Special"> <- </span>copy <span class="Constant">12</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> + <span class="Constant">15</span>:point-number<span class="Special"> <- </span>copy <span class="Constant">12</span>:point-number/unsafe ] <span class="traceContains">+mem: storing 36 in location 17</span> @@ -100,7 +100,7 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># second</span> <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/unsafe ] <span class="traceContains">+mem: storing 1 in location 7</span> @@ -112,7 +112,7 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># second</span> <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">37</span> <span class="Comment"># different</span> - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/unsafe ] <span class="traceContains">+mem: storing 0 in location 7</span> @@ -587,10 +587,7 @@ void check_or_set_invalid_types<span class="Delimiter">(</span>type_tree* type<s <span class="Comment">// can't assert that type_name is non-null, even at the top of a recursive call tree</span> if <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// will throw a more precise error elsewhere</span> <span class="Comment">// End Container Type Checks</span> - if <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - assert<span class="Delimiter">(</span>!type<span class="Delimiter">-></span>left && !type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> - <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>value<span class="Delimiter">))</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>type_name && contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">-></span>value<span class="Delimiter">))</span> type<span class="Delimiter">-></span>value = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">-></span>value<span class="Delimiter">);</span> diff --git a/html/031address.cc.html b/html/031address.cc.html index cabdc541..e039b331 100644 --- a/html/031address.cc.html +++ b/html/031address.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .SalientComment { color: #00ffff; } .Comment { color: #9090ff; } @@ -85,14 +85,17 @@ void canonize<span class="Delimiter">(</span>reagent& x<span class="Delimite void lookup_memory<span class="Delimiter">(</span>reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to /lookup "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" but it isn't an address</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// compute value</span> if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to /lookup 0</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << x<span class="Delimiter">.</span>value << <span class="Constant">" is "</span> << no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">));</span> - drop_address_from_type<span class="Delimiter">(</span>x<span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + <span class="Comment">// End Drop Address In lookup_memory(x)</span> drop_one_lookup<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -123,15 +126,20 @@ bool canonize_type<span class="Delimiter">(</span>reagent& r<span class="Del raise_error << <span class="Constant">"can't lookup non-address: "</span> << r<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">": "</span> << debug_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - drop_address_from_type<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + <span class="Comment">// End Drop Address In canonize_type(r)</span> drop_one_lookup<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -void drop_address_from_type<span class="Delimiter">(</span>reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +void drop_from_type<span class="Delimiter">(</span>reagent& r<span class="Delimiter">,</span> string expected_type<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << <span class="Constant">"can't drop address from "</span> << debug_string<span class="Delimiter">(</span>r<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << <span class="Constant">"can't drop "</span> << expected_type << <span class="Constant">" from "</span> << debug_string<span class="Delimiter">(</span>r<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value != expected_type<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise_error << <span class="Constant">"can't drop "</span> << expected_type << <span class="Constant">" from "</span> << debug_string<span class="Delimiter">(</span>r<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> type_tree* tmp = r<span class="Delimiter">.</span>type<span class="Delimiter">;</span> diff --git a/html/032array.cc.html b/html/032array.cc.html index d2689076..2dde32d7 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -13,9 +13,10 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .SalientComment { color: #00ffff; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } +.CommentedCode { color: #6c6c6c; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } @@ -146,7 +147,7 @@ if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type &&a raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'"</span> << r<span class="Delimiter">.</span>original_string << <span class="Constant">"' is an array of what?</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Comment">// skip the 'array' type to get at the element type</span> +<span class="CommentedCode">//? trace(9999, "mem") << "computing size of array starting at " << r.value << end();</span> <span class="Identifier">return</span> <span class="Constant">1</span> + get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> r<span class="Delimiter">.</span>value<span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>array_element<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -205,6 +206,7 @@ case INDEX: <span class="Delimiter">{</span> reagent base = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize<span class="Delimiter">(</span>base<span class="Delimiter">);</span> long long int base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"base address is "</span> << base_address << end<span class="Delimiter">();</span> if <span class="Delimiter">(</span>base_address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"tried to access location 0 in '"</span> << current_instruction<span class="Delimiter">().</span>to_string<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> @@ -253,7 +255,7 @@ recipe main [ <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span> <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span> <span class="Constant">7</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span> - <span class="Constant">8</span>:address:array:point<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">8</span>:address:array:point<span class="Special"> <- </span>copy <span class="Constant">1</span>/unsafe index *<span class="Constant">8</span>:address:array:point<span class="Delimiter">,</span> <span class="Constant">4</span> <span class="Comment"># less than size of array in locations, but larger than its length in elements</span> ] <span class="traceContains">+error: main: invalid index 4</span> @@ -373,7 +375,7 @@ recipe main [ <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span> <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span> <span class="Constant">7</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span> - <span class="Constant">8</span>:address:array:point<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Comment"># unsafe</span> + <span class="Constant">8</span>:address:array:point<span class="Special"> <- </span>copy <span class="Constant">1</span>/unsafe index-address *<span class="Constant">8</span>:address:array:point<span class="Delimiter">,</span> <span class="Constant">4</span> <span class="Comment"># less than size of array in locations, but larger than its length in elements</span> ] <span class="traceContains">+error: main: invalid index 4</span> @@ -464,10 +466,12 @@ bool is_mu_string<span class="Delimiter">(</span>const reagent& x<span class <span class="Identifier">return</span> x<span class="Delimiter">.</span>type && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right - && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">)</span> && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"character"</span><span class="Delimiter">)</span> - && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right == <span class="Constant">NULL</span><span class="Delimiter">;</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"character"</span><span class="Delimiter">)</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right == <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> </pre> </body> diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index a4fc191a..f3e258c8 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -60,7 +60,7 @@ recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Comment"># 'point' variant</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> - <span class="Constant">4</span>:number-or-point<span class="Special"> <- </span>copy <span class="Constant">1</span>:number-or-point/<span class="Special">raw</span> <span class="Comment"># unsafe</span> + <span class="Constant">4</span>:number-or-point<span class="Special"> <- </span>copy <span class="Constant">1</span>:number-or-point/unsafe ] <span class="traceContains">+mem: storing 1 in location 4</span> <span class="traceContains">+mem: storing 34 in location 5</span> @@ -94,7 +94,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:variant <span class="Comment"># unsafe</span> + <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/unsafe<span class="Delimiter">,</span> <span class="Constant">1</span>:variant ] <span class="traceContains">+mem: storing 13 in location 20</span> @@ -103,7 +103,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">0</span>:variant <span class="Comment"># unsafe</span> + <span class="Constant">20</span>:address:number<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/unsafe<span class="Delimiter">,</span> <span class="Constant">0</span>:variant ] <span class="traceContains">+mem: storing 0 in location 20</span> @@ -113,18 +113,36 @@ MAYBE_CONVERT<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"maybe-convert"</span><span class="Delimiter">,</span> MAYBE_CONVERT<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> case MAYBE_CONVERT: <span class="Delimiter">{</span> + const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << 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">"'maybe-convert' expects exactly 2 ingredients in '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'maybe-convert' expects exactly 2 ingredients in '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> reagent base = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>base<span class="Delimiter">);</span> if <span class="Delimiter">(</span>!base<span class="Delimiter">.</span>type || !base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'maybe-convert' should be an exclusive-container, but got "</span> << base<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'maybe-convert' should be an exclusive-container, but got "</span> << base<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"second ingredient of 'maybe-convert' should have type 'variant', but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"second ingredient of 'maybe-convert' should have type 'variant', but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + reagent product = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!canonize_type<span class="Delimiter">(</span>product<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + const reagent& offset = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> + long long int tag = <span class="Constant">0</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> + tag = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + tag = offset<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + reagent variant = variant_type<span class="Delimiter">(</span>base<span class="Delimiter">,</span> tag<span class="Delimiter">);</span> + variant<span class="Delimiter">.</span>type = new type_tree<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">),</span> variant<span class="Delimiter">.</span>type<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>product<span class="Delimiter">,</span> variant<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'maybe-convert "</span> << base<span class="Delimiter">.</span>original_string << <span class="Constant">", "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string << <span class="Constant">"' should write to "</span> << debug_string<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" but "</span> << product<span class="Delimiter">.</span>name << <span class="Constant">" has type "</span> << debug_string<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -151,6 +169,30 @@ case MAYBE_CONVERT: <span class="Delimiter">{</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(code)</span> +const reagent variant_type<span class="Delimiter">(</span>const reagent& canonized_base<span class="Delimiter">,</span> long long int tag<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>tag >= <span class="Constant">0</span><span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">));</span> + assert<span class="Delimiter">(</span>!get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> + const type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> canonized_base<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">);</span> + reagent element<span class="Delimiter">;</span> + element<span class="Delimiter">.</span>type = new type_tree<span class="Delimiter">(</span>*info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>tag<span class="Delimiter">));</span> + <span class="Comment">// End variant_type Special-cases</span> + <span class="Identifier">return</span> element<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(scenario maybe_convert_product_type_mismatch)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> + <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> + <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> + <span class="Constant">20</span>:address:number<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/unsafe<span class="Delimiter">,</span> <span class="Constant">1</span>:variant +] +<span class="traceContains">+error: main: 'maybe-convert 12:number-or-point/unsafe, 1:variant' should write to <address : <point : <>>> but 20 has type <address : <number : <>>></span> + + <span class="SalientComment">//:: Allow exclusive containers to be defined in mu code.</span> <span class="Delimiter">:(scenario exclusive_container)</span> diff --git a/html/034call.cc.html b/html/034call.cc.html index 10ad7632..d2664036 100644 --- a/html/034call.cc.html +++ b/html/034call.cc.html @@ -150,8 +150,12 @@ default: <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>callstack_depth < <span class="Constant">9000</span><span class="Delimiter">);</span> <span class="Comment">// 9998-101 plus cushion</span> <span class="Delimiter">}</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation<span class="Delimiter">));</span> + finish_call_housekeeping<span class="Delimiter">(</span>call_instruction<span class="Delimiter">,</span> ingredients<span class="Delimiter">);</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not done with caller; don't increment step_index of caller</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(code)</span> +void finish_call_housekeeping<span class="Delimiter">(</span>const instruction& call_instruction<span class="Delimiter">,</span> const vector<vector<double> >& ingredients<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End Call Housekeeping</span> - <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not done with caller; don't increment current_step_index()</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario calling_undefined_recipe_fails)</span> diff --git a/html/035call_ingredient.cc.html b/html/035call_ingredient.cc.html index 34c4c270..640dc430 100644 --- a/html/035call_ingredient.cc.html +++ b/html/035call_ingredient.cc.html @@ -110,9 +110,8 @@ case NEXT_INGREDIENT: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// pad the first product with sufficient zeros to match its type</span> long long int size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> - <span class="Delimiter">}</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> diff --git a/html/036call_reply.cc.html b/html/036call_reply.cc.html index dac5314a..89005838 100644 --- a/html/036call_reply.cc.html +++ b/html/036call_reply.cc.html @@ -134,8 +134,10 @@ void check_types_of_reply_instructions<span class="Delimiter">(</span>recipe_ord <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span> <span class="Delimiter">}</span> long long int ingredient_index = to_integer<span class="Delimiter">(</span>tmp<span class="Delimiter">-></span>value<span class="Delimiter">);</span> - if <span class="Delimiter">(</span>ingredient_index >= SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> - raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'same-as-ingredient' metadata overflows ingredients in: "</span> << caller_instruction<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>ingredient_index >= SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"too few ingredients in '"</span> << caller_instruction<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span> + <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!is_dummy<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> && caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name != caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>name<span class="Delimiter">)</span> raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << caller_instruction<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"' should write to "</span> << caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>original_string << <span class="Constant">" rather than "</span> << caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> diff --git a/html/037recipe.cc.html b/html/037recipe.cc.html deleted file mode 100644 index 44573495..00000000 --- a/html/037recipe.cc.html +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 037recipe.cc</title> -<meta name="Generator" content="Vim/7.4"> -<meta name="plugin-version" content="vim7.4_v1"> -<meta name="syntax" content="cpp"> -<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> -<meta name="colorscheme" content="minimal"> -<style type="text/css"> -<!-- -pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } -body { font-family: monospace; color: #eeeeee; background-color: #080808; } -* { font-size: 1.05em; } -.Comment { color: #9090ff; } -.Delimiter { color: #a04060; } -.Identifier { color: #804000; } -.Constant { color: #00a0a0; } ---> -</style> - -<script type='text/javascript'> -<!-- - ---> -</script> -</head> -<body> -<pre id='vimCodeElement'> -<span class="Comment">//: So far we've been calling a fixed recipe in each instruction, but we'd</span> -<span class="Comment">//: also like to make the recipe a variable, pass recipes to "higher-order"</span> -<span class="Comment">//: recipes, return recipes from recipes and so on.</span> - -<span class="Delimiter">:(before "End Mu Types Initialization")</span> -<span class="Comment">// 'recipe' is a literal</span> -put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> -<span class="Comment">// 'recipe-ordinal' is the literal that can store recipe literals</span> -type_ordinal recipe_ordinal = put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> -get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> recipe_ordinal<span class="Delimiter">).</span>name = <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">;</span> - -<span class="Delimiter">:(before "End Reagent-parsing Exceptions")</span> -if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second && r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"recipe"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - r<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> r<span class="Delimiter">.</span>name<span class="Delimiter">));</span> - <span class="Identifier">return</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -<span class="Delimiter">:(code)</span> -bool is_mu_recipe<span class="Delimiter">(</span>reagent r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> - <span class="Comment">// End is_mu_recipe Cases</span> - <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span class="Delimiter">}</span> -</pre> -</body> -</html> -<!-- vim: set foldmethod=manual : --> diff --git a/html/043new.cc.html b/html/038new.cc.html index 81a1c1c7..1ba4365a 100644 --- a/html/043new.cc.html +++ b/html/038new.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 043new.cc</title> +<title>Mu - 038new.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -22,6 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } +.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } --> </style> @@ -33,15 +34,59 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } </head> <body> <pre id='vimCodeElement'> -<span class="Comment">//: A simple memory allocator to create space for new variables at runtime.</span> +<span class="Comment">//: Creating space for new variables at runtime.</span> + +<span class="Comment">//: Mu has two primitives for managing allocations:</span> +<span class="Comment">//: - 'allocate' reserves a specified amount of space</span> +<span class="Comment">//: - 'abandon' returns allocated space to be reused by future calls to 'allocate'</span> +<span class="Comment">//:</span> +<span class="Comment">//: In practice it's useful to let programs copy addresses anywhere they want,</span> +<span class="Comment">//: but a prime source of (particularly security) bugs is accessing memory</span> +<span class="Comment">//: after it's been abandoned. To avoid this, mu programs use a safer</span> +<span class="Comment">//: primitive called 'new', which adds two features:</span> +<span class="Comment">//:</span> +<span class="Comment">//: - it takes a type rather than a size, to save you the trouble of</span> +<span class="Comment">//: calculating sizes of different variables.</span> +<span class="Comment">//: - it allocates an extra location where it tracks so-called 'reference</span> +<span class="Comment">//: counts' or refcounts: the number of address variables in your program that</span> +<span class="Comment">//: point to this allocation. The initial refcount of an allocation starts out</span> +<span class="Comment">//: at 1 (the product of the 'new' instruction). When other variables are</span> +<span class="Comment">//: copied from it the refcount is incremented. When a variable stops pointing</span> +<span class="Comment">//: at it the refcount is decremented. When the refcount goes to 0 the</span> +<span class="Comment">//: allocation is automatically abandoned.</span> +<span class="Comment">//:</span> +<span class="Comment">//: Mu programs guarantee you'll have no memory corruption bugs as long as you</span> +<span class="Comment">//: use 'new' and never use 'allocate' or 'abandon'. However, they don't help</span> +<span class="Comment">//: you at all to remember to abandon memory after you're done with it. To</span> +<span class="Comment">//: minimize memory use, be sure to reset allocated addresses to 0 when you're</span> +<span class="Comment">//: done with them.</span> + +<span class="Comment">//: To help you distinguish addresses that point at allocations, 'new' returns</span> +<span class="Comment">//: type address:shared:___. Think of 'shared' as a generic container that</span> +<span class="Comment">//: contains one extra field: the refcount. However, lookup operations will</span> +<span class="Comment">//: transparently drop the 'shared' and access to the refcount. Copying</span> +<span class="Comment">//: between shared and non-shared addresses is forbidden.</span> +<span class="Delimiter">:(before "End Mu Types Initialization")</span> +type_ordinal shared = put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> +get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> shared<span class="Delimiter">).</span>name = <span class="Constant">"shared"</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Drop Address In lookup_memory(x)")</span> +if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"shared"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"skipping refcount at "</span> << x<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> + x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value+<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// skip refcount</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Drop Address In canonize_type(r)")</span> +if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"shared"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + drop_from_type<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(scenarios run)</span> <span class="Delimiter">:(scenario new)</span> <span class="Comment"># call new two times with identical arguments; you should get back different results</span> recipe main [ - <span class="Constant">1</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">2</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:address:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:address:number/<span class="Special">raw</span> + <span class="Constant">1</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span> ] <span class="traceContains">+mem: storing 0 in location 3</span> @@ -70,14 +115,33 @@ NEW<span class="Delimiter">,</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"new"</span><span class="Delimiter">,</span> NEW<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> case NEW: <span class="Delimiter">{</span> + const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> || SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << 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">"'new' requires one or two ingredients, but got "</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"'new' requires one or two ingredients, but got "</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// End NEW Check Special-cases</span> reagent type = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>!is_mu_type_literal<span class="Delimiter">(</span>type<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'new' should be a type, but got "</span> << type<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'new' should be a type, but got "</span> << type<span class="Delimiter">.</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"result of 'new' should never be ignored</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + reagent product<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + canonize_type<span class="Delimiter">(</span>product<span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>product<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>product<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// array allocation</span> + drop_from_type<span class="Delimiter">(</span>product<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + reagent expected_product<span class="Delimiter">(</span><span class="Constant">"x:"</span>+type<span class="Delimiter">.</span>name<span class="Delimiter">);</span> + <span class="Comment">// End Post-processing(expected_product) When Checking 'new'</span> + if <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>product<span class="Delimiter">,</span> expected_product<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product of 'new' has incorrect type: "</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -122,6 +186,9 @@ case ALLOCATE: <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"array size is "</span> << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> size = <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span> + size*ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> + <span class="Comment">// include space for refcount</span> + size++<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"allocating size "</span> << size << end<span class="Delimiter">();</span> <span class="CommentedCode">//? Total_alloc += size;</span> <span class="CommentedCode">//? Num_alloc++;</span> <span class="Comment">// compute the region of memory to return</span> @@ -136,8 +203,10 @@ case ALLOCATE: <span class="Delimiter">{</span> for <span class="Delimiter">(</span>long long int address = result<span class="Delimiter">;</span> address < result+size<span class="Delimiter">;</span> ++address<span class="Delimiter">)</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// initialize array length</span> - if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> << <span class="Constant">" in location "</span> << result+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span> << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Delimiter">}</span> <span class="Comment">// bump</span> Current_routine<span class="Delimiter">-></span>alloc += size<span class="Delimiter">;</span> <span class="Comment">// no support for reclaiming memory</span> @@ -175,7 +244,7 @@ case NEW: <span class="Delimiter">{</span> void ensure_space<span class="Delimiter">(</span>long long int size<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>size > Initial_memory_per_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> tb_shutdown<span class="Delimiter">();</span> - cerr << <span class="Constant">"can't allocate "</span> << size << <span class="Constant">" locations, that's too much.</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + cerr << <span class="Constant">"can't allocate "</span> << size << <span class="Constant">" locations, that's too much compared to "</span> << Initial_memory_per_routine << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> exit<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>alloc + size > Current_routine<span class="Delimiter">-></span>alloc_max<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -191,73 +260,56 @@ void ensure_space<span class="Delimiter">(</span>long long int size<span class=" <span class="Special">% Memory_allocated_until = 10;</span> <span class="Special">% put(Memory, Memory_allocated_until, 1);</span> recipe main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>new number:type - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:number + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>new number:type + <span class="Constant">2</span>:number<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:number ] <span class="traceContains">+mem: storing 0 in location 2</span> <span class="Delimiter">:(scenario new_array)</span> recipe main [ - <span class="Constant">1</span>:address:array:number/<span class="Special">raw <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">5</span> - <span class="Constant">2</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:array:number/<span class="Special">raw</span> + <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">5</span> + <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw</span> ] -<span class="traceContains">+run: 1:address:array:number/raw <- new number:type, 5</span> +<span class="traceContains">+run: 1:address:shared:array:number/raw <- new number:type, 5</span> <span class="traceContains">+mem: array size is 5</span> -<span class="Comment"># don't forget the extra location for array size</span> -<span class="traceContains">+mem: storing 6 in location 3</span> +<span class="Comment"># don't forget the extra location for array size, and the second extra location for the refcount</span> +<span class="traceContains">+mem: storing 7 in location 3</span> <span class="Delimiter">:(scenario new_empty_array)</span> recipe main [ - <span class="Constant">1</span>:address:array:number/<span class="Special">raw <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">0</span> - <span class="Constant">2</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:array:number/<span class="Special">raw</span> + <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">0</span> + <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">3</span>:number/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:number/<span class="Special">raw</span> ] -<span class="traceContains">+run: 1:address:array:number/raw <- new number:type, 0</span> +<span class="traceContains">+run: 1:address:shared:array:number/raw <- new number:type, 0</span> <span class="traceContains">+mem: array size is 0</span> -<span class="traceContains">+mem: storing 1 in location 3</span> - -<span class="Comment">//: Make sure that each routine gets a different alloc to start.</span> -<span class="Delimiter">:(scenario new_concurrent)</span> -recipe f1 [ - start-running f2:recipe - <span class="Constant">1</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Comment"># wait for f2 to complete</span> - <span class="Delimiter">{</span> - loop-unless <span class="Constant">4</span>:number/<span class="Special">raw</span> - <span class="Delimiter">}</span> -] -recipe f2 [ - <span class="Constant">2</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Comment"># hack: assumes scheduler implementation</span> - <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:address:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:address:number/<span class="Special">raw</span> - <span class="Comment"># signal f2 complete</span> - <span class="Constant">4</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">1</span> -] -<span class="traceContains">+mem: storing 0 in location 3</span> +<span class="Comment"># one location for array size, and one for the refcount</span> +<span class="traceContains">+mem: storing 2 in location 3</span> <span class="Comment">//: If a routine runs out of its initial allocation, it should allocate more.</span> <span class="Delimiter">:(scenario new_overflow)</span> -<span class="Special">% Initial_memory_per_routine = 2;</span> +<span class="Special">% Initial_memory_per_routine = 3; // barely enough room for point allocation below</span> recipe main [ - <span class="Constant">1</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">2</span>:address:point/<span class="Special">raw <- </span>new point:type <span class="Comment"># not enough room in initial page</span> + <span class="Constant">1</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">2</span>:address:shared:point/<span class="Special">raw <- </span>new point:type <span class="Comment"># not enough room in initial page</span> ] -<span class="traceContains">+new: routine allocated memory from 1000 to 1002</span> -<span class="traceContains">+new: routine allocated memory from 1002 to 1004</span> +<span class="traceContains">+new: routine allocated memory from 1000 to 1003</span> +<span class="traceContains">+new: routine allocated memory from 1003 to 1006</span> -<span class="Comment">//: We also provide a way to return memory, and to reuse reclaimed memory.</span> +<span class="SalientComment">//:: A way to return memory, and to reuse reclaimed memory.</span> <span class="Comment">//: todo: custodians, etc. Following malloc/free is a temporary hack.</span> <span class="Delimiter">:(scenario new_reclaim)</span> recipe main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>new number:type - abandon <span class="Constant">1</span>:address:number - <span class="Constant">2</span>:address:number<span class="Special"> <- </span>new number:type <span class="Comment"># must be same size as abandoned memory to reuse</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:number<span class="Delimiter">,</span> <span class="Constant">2</span>:address:number + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>new number:type + <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:number <span class="Comment"># because 1 will get reset during abandon below</span> + abandon <span class="Constant">1</span>:address:shared:number <span class="Comment"># unsafe</span> + <span class="Constant">3</span>:address:shared:number<span class="Special"> <- </span>new number:type <span class="Comment"># must be same size as abandoned memory to reuse</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:shared:number<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:number ] <span class="Comment"># both allocations should have returned the same address</span> -<span class="traceContains">+mem: storing 1 in location 3</span> +<span class="traceContains">+mem: storing 1 in location 4</span> <span class="Delimiter">:(before "End Globals")</span> map<long long int<span class="Delimiter">,</span> long long int> Free_list<span class="Delimiter">;</span> @@ -276,8 +328,8 @@ case ABANDON: <span class="Delimiter">{</span> <span class="Delimiter">}</span> reagent types = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> canonize_type<span class="Delimiter">(</span>types<span class="Delimiter">);</span> - if <span class="Delimiter">(</span>!types<span class="Delimiter">.</span>type || types<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'abandon' should be an address, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>!types<span class="Delimiter">.</span>type || types<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> || types<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'abandon' should be an address:shared:___, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -285,18 +337,27 @@ case ABANDON: <span class="Delimiter">{</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case ABANDON: <span class="Delimiter">{</span> long long int address = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"address to abandon is "</span> << address << end<span class="Delimiter">();</span> reagent types = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"value of ingredient is "</span> << types<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> canonize<span class="Delimiter">(</span>types<span class="Delimiter">);</span> <span class="Comment">// lookup_memory without drop_one_lookup {</span> - types<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> types<span class="Delimiter">.</span>value<span class="Delimiter">));</span> - drop_address_from_type<span class="Delimiter">(</span>types<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"value of ingredient after canonization is "</span> << types<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> + long long int address_location = types<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + types<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> types<span class="Delimiter">.</span>value<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>types<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>types<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> <span class="Comment">// }</span> - abandon<span class="Delimiter">(</span>address<span class="Delimiter">,</span> size_of<span class="Delimiter">(</span>types<span class="Delimiter">));</span> + abandon<span class="Delimiter">(</span>address<span class="Delimiter">,</span> size_of<span class="Delimiter">(</span>types<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Comment">// clear the address</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"resetting location "</span> << address_location << end<span class="Delimiter">();</span> + Memory[address_location] = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> void abandon<span class="Delimiter">(</span>long long int address<span class="Delimiter">,</span> long long int size<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"saving in free-list of size "</span> << size << end<span class="Delimiter">();</span> <span class="CommentedCode">//? Total_free += size;</span> <span class="CommentedCode">//? Num_free++;</span> <span class="CommentedCode">//? cerr << "abandon: " << size << '\n';</span> @@ -310,6 +371,7 @@ void abandon<span class="Delimiter">(</span>long long int address<span class="De <span class="Delimiter">:(before "ensure_space(size)" following "case ALLOCATE")</span> if <span class="Delimiter">(</span>Free_list[size]<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"abandon"</span><span class="Delimiter">)</span> << <span class="Constant">"picking up space from free-list of size "</span> << size << end<span class="Delimiter">();</span> long long int result = Free_list[size]<span class="Delimiter">;</span> Free_list[size] = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">);</span> for <span class="Delimiter">(</span>long long int curr = result+<span class="Constant">1</span><span class="Delimiter">;</span> curr < result+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -319,7 +381,7 @@ if <span class="Delimiter">(</span>Free_list[size]<span class="Delimiter">)</spa <span class="Delimiter">}</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> else put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> result<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -329,39 +391,113 @@ if <span class="Delimiter">(</span>Free_list[size]<span class="Delimiter">)</spa <span class="Delimiter">:(scenario new_differing_size_no_reclaim)</span> recipe main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>new number:type - abandon <span class="Constant">1</span>:address:number - <span class="Constant">2</span>:address:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># different size</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:number<span class="Delimiter">,</span> <span class="Constant">2</span>:address:number + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>new number:type + <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:number + abandon <span class="Constant">1</span>:address:shared:number + <span class="Constant">3</span>:address:shared:array:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># different size</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:shared:number<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:array:number ] <span class="Comment"># no reuse</span> -<span class="traceContains">+mem: storing 0 in location 3</span> +<span class="traceContains">+mem: storing 0 in location 4</span> <span class="Delimiter">:(scenario new_reclaim_array)</span> recipe main [ - <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> - abandon <span class="Constant">1</span>:address:array:number - <span class="Constant">2</span>:address:array:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:array:number<span class="Delimiter">,</span> <span class="Constant">2</span>:address:array:number + <span class="Constant">1</span>:address:shared:array:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> + <span class="Constant">2</span>:address:shared:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:array:number + abandon <span class="Constant">1</span>:address:shared:array:number <span class="Comment"># unsafe</span> + <span class="Constant">3</span>:address:shared:array:number<span class="Special"> <- </span>new number:type<span class="Delimiter">,</span> <span class="Constant">2</span> + <span class="Constant">4</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:shared:array:number<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:array:number ] <span class="Comment"># reuse</span> -<span class="traceContains">+mem: storing 1 in location 3</span> +<span class="traceContains">+mem: storing 1 in location 4</span> -<span class="SalientComment">//:: Next, extend 'new' to handle a unicode string literal argument.</span> +<span class="Delimiter">:(scenario reset_on_abandon)</span> +recipe main [ + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>new number:type + abandon <span class="Constant">1</span>:address:shared:number +] +<span class="Comment"># reuse</span> +<span class="traceContains">+run: abandon 1:address:shared:number</span> +<span class="traceContains">+mem: resetting location 1</span> + +<span class="SalientComment">//:: Manage refcounts when copying addresses.</span> + +<span class="Delimiter">:(scenario refcounts)</span> +recipe main [ + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:number + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:address:shared:number<span class="Special"> <- </span>copy <span class="Constant">0</span> +] +<span class="traceContains">+run: 1:address:shared:number <- copy 1000/unsafe</span> +<span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> +<span class="traceContains">+run: 2:address:shared:number <- copy 1:address:shared:number</span> +<span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> +<span class="traceContains">+run: 1:address:shared:number <- copy 0</span> +<span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> +<span class="traceContains">+run: 2:address:shared:number <- copy 0</span> +<span class="traceContains">+mem: decrementing refcount of 1000: 1 -> 0</span> +<span class="Comment"># the /unsafe corrupts memory but fortunately we won't be running any more 'new' in this scenario</span> +<span class="traceContains">+mem: automatically abandoning 1000</span> + +<span class="Delimiter">:(before "End write_memory(reagent x, long long int base) Special-cases")</span> +if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Comment">// compute old address of x, as well as new address we want to write in</span> + long long int old_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>data<span class="Delimiter">));</span> + long long int new_address = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Comment">// decrement refcount of old address</span> + if <span class="Delimiter">(</span>old_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int old_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">);</span> +<span class="CommentedCode">//? cerr << old_refcount << '\n';</span> +<span class="CommentedCode">//? assert(old_refcount > 0);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"decrementing refcount of "</span> << old_address << <span class="Constant">": "</span> << old_refcount << <span class="Constant">" -> "</span> << <span class="Delimiter">(</span>old_refcount-<span class="Constant">1</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">,</span> old_refcount-<span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Comment">// perform the write</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << base << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> + <span class="Comment">// increment refcount of new address</span> + if <span class="Delimiter">(</span>new_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int new_refcount = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> new_address<span class="Delimiter">);</span> +<span class="CommentedCode">//? assert(new_refcount >= 0); // == 0 only when new_address == old_address</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"incrementing refcount of "</span> << new_address << <span class="Constant">": "</span> << new_refcount << <span class="Constant">" -> "</span> << <span class="Delimiter">(</span>new_refcount+<span class="Constant">1</span><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> new_address<span class="Delimiter">,</span> new_refcount+<span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Comment">// abandon old address if necessary</span> + <span class="Comment">// do this after all refcount updates are done just in case old and new are identical</span> + <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">: doesn't work yet</span> + assert<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">)</span> >= <span class="Constant">0</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>old_address && get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> old_address<span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// lookup_memory without drop_one_lookup {</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"automatically abandoning "</span> << old_address << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"computing size to abandon at "</span> << x<span class="Delimiter">.</span>value << end<span class="Delimiter">();</span> + x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + drop_from_type<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> + <span class="Comment">// }</span> + abandon<span class="Delimiter">(</span>old_address<span class="Delimiter">,</span> size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="SalientComment">//:: Extend 'new' to handle a unicode string literal argument.</span> <span class="Delimiter">:(scenario new_string)</span> recipe main [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [abc def] - <span class="Constant">2</span>:character<span class="Special"> <- </span>index *<span class="Constant">1</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">5</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [abc def] + <span class="Constant">2</span>:character<span class="Special"> <- </span>index *<span class="Constant">1</span>:address:shared:array:character<span class="Delimiter">,</span> <span class="Constant">5</span> ] <span class="Comment"># number code for 'e'</span> <span class="traceContains">+mem: storing 101 in location 2</span> <span class="Delimiter">:(scenario new_string_handles_unicode)</span> recipe main [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [a«c] - <span class="Constant">2</span>:number<span class="Special"> <- </span>length *<span class="Constant">1</span>:address:array:character - <span class="Constant">3</span>:character<span class="Special"> <- </span>index *<span class="Constant">1</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">1</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [a«c] + <span class="Constant">2</span>:number<span class="Special"> <- </span>length *<span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:character<span class="Special"> <- </span>index *<span class="Constant">1</span>:address:shared:array:character<span class="Delimiter">,</span> <span class="Constant">1</span> ] <span class="traceContains">+mem: storing 3 in location 2</span> <span class="Comment"># unicode for '«'</span> @@ -387,6 +523,9 @@ long long int new_mu_string<span class="Delimiter">(</span>const string& con ensure_space<span class="Delimiter">(</span>string_length+<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// don't forget the extra location for array size</span> <span class="Comment">// initialize string</span> long long int result = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Comment">// initialize refcount</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc++<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Comment">// store length</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc++<span class="Delimiter">,</span> string_length<span class="Delimiter">);</span> long long int curr = <span class="Constant">0</span><span class="Delimiter">;</span> const char* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> @@ -402,45 +541,41 @@ long long int new_mu_string<span class="Delimiter">(</span>const string& con <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Comment">//: pass in commandline args as ingredients to main</span> -<span class="Comment">//: todo: test this</span> - -<span class="Delimiter">:(after "Update main_routine")</span> -Current_routine = main_routine<span class="Delimiter">;</span> -for <span class="Delimiter">(</span>long long int i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - vector<double> arg<span class="Delimiter">;</span> - arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> - current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>arg<span class="Delimiter">);</span> -<span class="Delimiter">}</span> - <span class="Comment">//: stash recognizes strings</span> <span class="Delimiter">:(scenario stash_string)</span> recipe main [ - x:address:array:character<span class="Special"> <- </span>new [abc] - stash [foo:]<span class="Delimiter">,</span> x:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [abc] + stash [foo:]<span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:character ] <span class="traceContains">+app: foo: abc</span> <span class="Delimiter">:(before "End print Special-cases(reagent r, data)")</span> if <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="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="Delimiter">}</span> <span class="Delimiter">:(scenario unicode_string)</span> recipe main [ - x:address:array:character<span class="Special"> <- </span>new [♠] - stash [foo:]<span class="Delimiter">,</span> x:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [♠] + stash [foo:]<span class="Delimiter">,</span> <span class="Constant">1</span>:address:shared:array:character ] <span class="traceContains">+app: foo: ♠</span> +<span class="Delimiter">:(scenario stash_space_after_string)</span> +recipe main [ + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [abc] + stash <span class="Constant">1</span>:address:shared:array:character<span class="Delimiter">,</span> [foo] +] +<span class="traceContains">+app: abc foo</span> + <span class="Comment">//: Allocate more to routine when initializing a literal string</span> <span class="Delimiter">:(scenario new_string_overflow)</span> <span class="Special">% Initial_memory_per_routine = 2;</span> recipe main [ - <span class="Constant">1</span>:address:number/<span class="Special">raw <- </span>new number:type - <span class="Constant">2</span>:address:array:character/<span class="Special">raw <- </span>new [a] <span class="Comment"># not enough room in initial page, if you take the array size into account</span> + <span class="Constant">1</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Constant">2</span>:address:shared:array:character/<span class="Special">raw <- </span>new [a] <span class="Comment"># not enough room in initial page, if you take the array size into account</span> ] <span class="traceContains">+new: routine allocated memory from 1000 to 1002</span> <span class="traceContains">+new: routine allocated memory from 1002 to 1004</span> @@ -460,6 +595,8 @@ long long int unicode_length<span class="Delimiter">(</span>const string& s< <span class="Delimiter">}</span> string read_mu_string<span class="Delimiter">(</span>long long int address<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>address == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> + address++<span class="Delimiter">;</span> <span class="Comment">// skip refcount</span> long long int size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> address<span class="Delimiter">);</span> if <span class="Delimiter">(</span>size == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> ostringstream tmp<span class="Delimiter">;</span> diff --git a/html/042name.cc.html b/html/042name.cc.html index 08b875ef..e6f0b296 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .Identifier { color: #804000; } .cSpecial { color: #008000; } .Constant { color: #00a0a0; } @@ -54,7 +54,7 @@ recipe main [ <span class="traceContains">+error: main: use before set: y</span> <span class="Comment"># todo: detect conditional defines</span> -<span class="Delimiter">:(before "End Instruction Modifying Transforms")</span> +<span class="Delimiter">:(after "End Type Modifying Transforms")</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>transform_names<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(before "End Globals")</span> @@ -80,18 +80,20 @@ void transform_names<span class="Delimiter">(</span>const recipe_ordinal r<span <span class="Comment">// End transform_names(inst) Special-cases</span> <span class="Comment">// map names to addresses</span> for <span class="Delimiter">(</span>long long int in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>!already_transformed<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> names<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"use before set: "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">));</span> <span class="Delimiter">}</span> for <span class="Delimiter">(</span>long long int out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> inst<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>names<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == names<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"name"</span><span class="Delimiter">)</span> << <span class="Constant">"assign "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>name << <span class="Constant">" "</span> << curr_idx << end<span class="Delimiter">();</span> names[inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">).</span>name] = curr_idx<span class="Delimiter">;</span> @@ -106,12 +108,12 @@ void transform_names<span class="Delimiter">(</span>const recipe_ordinal r<span bool disqualified<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">mutable</span><span class="Comment">*/</span> reagent& x<span class="Delimiter">,</span> const instruction& inst<span class="Delimiter">,</span> const string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// End transform_names Exceptions</span> raise_error << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"missing type for "</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">" in '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Comment">// End Disqualified Reagents</span> if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>initialized<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> @@ -126,8 +128,10 @@ long long int lookup_name<span class="Delimiter">(</span>const reagent& r<sp <span class="Delimiter">}</span> type_ordinal skip_addresses<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">,</span> const string& recipe_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> + type_ordinal address = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">);</span> + type_ordinal shared = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> for <span class="Delimiter">(;</span> type<span class="Delimiter">;</span> type = type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">))</span> + if <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value != address && type<span class="Delimiter">-></span>value != shared<span class="Delimiter">)</span> <span class="Identifier">return</span> type<span class="Delimiter">-></span>value<span class="Delimiter">;</span> <span class="Delimiter">}</span> raise_error << maybe<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> << <span class="Constant">"expected a container"</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> @@ -222,7 +226,7 @@ get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<sp get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>element_names<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"y"</span><span class="Delimiter">);</span> <span class="Delimiter">:(scenario transform_names_transforms_container_elements)</span> recipe main [ - p:address:point<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># unsafe</span> + p:address:point<span class="Special"> <- </span>copy <span class="Constant">0</span> a:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> y:offset b:number<span class="Special"> <- </span>get *p:address:point<span class="Delimiter">,</span> x:offset ] @@ -266,7 +270,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span> - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> p:variant <span class="Comment"># unsafe</span> + <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/unsafe<span class="Delimiter">,</span> p:variant ] <span class="traceContains">+name: variant p of type number-or-point has tag 1</span> <span class="traceContains">+mem: storing 13 in location 20</span> diff --git a/html/044space.cc.html b/html/043space.cc.html index 10e456cb..7f14f589 100644 --- a/html/044space.cc.html +++ b/html/043space.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 044space.cc</title> +<title>Mu - 043space.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .SalientComment { color: #00ffff; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } @@ -38,23 +38,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment">//: (unless they have the /raw property)</span> <span class="Delimiter">:(scenario set_default_space)</span> -<span class="Comment"># if default-space is 10, and if an array of 5 locals lies from location 11 to 15 (inclusive),</span> -<span class="Comment"># then location 0 is really location 11, location 1 is really location 12, and so on.</span> +<span class="Comment"># if default-space is 10, and if an array of 5 locals lies from location 12 to 16 (inclusive),</span> +<span class="Comment"># then local 0 is really location 12, local 1 is really location 13, and so on.</span> recipe main [ - <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># pretend array; in practice we'll use new</span> - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> ] -<span class="traceContains">+mem: storing 23 in location 12</span> +<span class="traceContains">+mem: storing 23 in location 13</span> <span class="Delimiter">:(scenario lookup_sidesteps_default_space)</span> recipe main [ <span class="Comment"># pretend pointer from outside</span> <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Comment"># pretend array</span> - <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">1001</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">3</span>/unsafe <span class="Constant">8</span>:number/<span class="Special">raw <- </span>copy *<span class="Constant">1</span>:address:number ] @@ -95,6 +98,56 @@ void absolutize<span class="Delimiter">(</span>reagent& x<span class="Delimi assert<span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">));</span> <span class="Delimiter">}</span> +long long int space_base<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// temporary stub; will be replaced in a later layer</span> + <span class="Identifier">return</span> current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +long long int address<span class="Delimiter">(</span>long long int offset<span class="Delimiter">,</span> long long int base<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> offset<span class="Delimiter">;</span> <span class="Comment">// raw</span> + long long int size = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>offset >= size<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// todo: test</span> + raise_error << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << size << <span class="Constant">" at "</span> << base << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> base + <span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span> + offset<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="SalientComment">//:: reads and writes to the 'default-space' variable have special behavior</span> + +<span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> + || !x<span class="Delimiter">.</span>type + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> + || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">)</span> + || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'default-space' should be of type address:shared:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + current_call<span class="Delimiter">().</span>default_space = data<span class="Delimiter">.</span>at<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> + +<span class="Delimiter">:(scenario get_default_space)</span> +recipe main [ + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Constant">1</span>:address:shared:array:location/<span class="Special">raw <- </span>copy default-space:address:shared:array:location +] +<span class="traceContains">+mem: storing 10 in location 1</span> + +<span class="Delimiter">:(after "vector<double> read_memory(reagent x)")</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + vector<double> result<span class="Delimiter">;</span> + result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="SalientComment">//:: fix 'get'</span> <span class="Delimiter">:(scenario lookup_sidesteps_default_space_in_get)</span> @@ -102,10 +155,11 @@ recipe main [ <span class="Comment"># pretend pointer to container from outside</span> <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> - <span class="Comment"># pretend array</span> - <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">1001</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe <span class="Constant">1</span>:address:point<span class="Special"> <- </span>copy <span class="Constant">12</span>/unsafe <span class="Constant">9</span>:number/<span class="Special">raw <- </span>get *<span class="Constant">1</span>:address:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset ] @@ -122,10 +176,11 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">2</span> <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> - <span class="Comment"># pretend array</span> - <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">1000</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">1001</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">12</span>/unsafe <span class="Constant">9</span>:number/<span class="Special">raw <- </span>index *<span class="Constant">1</span>:address:array:number<span class="Delimiter">,</span> <span class="Constant">1</span> ] @@ -154,7 +209,7 @@ if <span class="Delimiter">(</span>s == <span class="Constant">"number-of-l <span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> <span class="Comment">// rewrite `new-default-space` to</span> -<span class="Comment">// `default-space:address:array:location <- new location:type, number-of-locals:literal`</span> +<span class="Comment">// `default-space:address:shared:array:location <- new location:type, number-of-locals:literal`</span> <span class="Comment">// where N is Name[recipe][""]</span> if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"new-default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> rewrite_default_space_instruction<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> @@ -185,7 +240,7 @@ recipe main [ recipe foo [ local-scope x:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - reply default-space:address:array:location + reply default-space:address:shared:array:location ] <span class="Comment"># both calls to foo should have received the same default-space</span> <span class="traceContains">+mem: storing 1 in location 3</span> @@ -210,7 +265,7 @@ void try_reclaim_locals<span class="Delimiter">()</span> <span class="Delimiter" const instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>old_name != <span class="Constant">"local-scope"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> abandon<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">,</span> - <span class="Comment">/*</span><span class="Comment">array length</span><span class="Comment">*/</span><span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">number-of-locals</span><span class="Comment">*/</span>Name[r][<span class="Constant">""</span>]<span class="Delimiter">);</span> + <span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">array length</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">number-of-locals</span><span class="Comment">*/</span>Name[r][<span class="Constant">""</span>]<span class="Delimiter">);</span> <span class="Delimiter">}</span> void rewrite_default_space_instruction<span class="Delimiter">(</span>instruction& curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -221,55 +276,8 @@ void rewrite_default_space_instruction<span class="Delimiter">(</span>instructio curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"number-of-locals:literal"</span><span class="Delimiter">));</span> if <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> raise_error << <span class="Constant">"new-default-space can't take any results</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"default-space:address:array:location"</span><span class="Delimiter">));</span> + curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"default-space:address:shared:array:location"</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> - -<span class="SalientComment">//:: helpers</span> - -<span class="Delimiter">:(code)</span> -long long int space_base<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// temporary stub; will be replaced in a later layer</span> - <span class="Identifier">return</span> current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -long long int address<span class="Delimiter">(</span>long long int offset<span class="Delimiter">,</span> long long int base<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> offset<span class="Delimiter">;</span> <span class="Comment">// raw</span> - if <span class="Delimiter">(</span>offset >= static_cast<long long int><span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">)))</span> <span class="Delimiter">{</span> - <span class="Comment">// todo: test</span> - raise_error << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base<span class="Delimiter">))</span> << <span class="Constant">" at "</span> << base << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> - <span class="Delimiter">}</span> - <span class="Identifier">return</span> base+<span class="Constant">1</span> + offset<span class="Delimiter">;</span> -<span class="Delimiter">}</span> - -<span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> - if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> - || !x<span class="Delimiter">.</span>type - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> - || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> - || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'default-space' should be of type address:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> - <span class="Delimiter">}</span> - current_call<span class="Delimiter">().</span>default_space = data<span class="Delimiter">.</span>at<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> - -<span class="Delimiter">:(scenario get_default_space)</span> -recipe main [ - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe - <span class="Constant">1</span>:address:array:location/<span class="Special">raw <- </span>copy default-space:address:array:location -] -<span class="traceContains">+mem: storing 10 in location 1</span> - -<span class="Delimiter">:(after "vector<double> read_memory(reagent x)")</span> - if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - vector<double> result<span class="Delimiter">;</span> - result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> - <span class="Identifier">return</span> result<span class="Delimiter">;</span> - <span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/045space_surround.cc.html b/html/044space_surround.cc.html index 29d58818..47e01b94 100644 --- a/html/045space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 045space_surround.cc</title> +<title>Mu - 044space_surround.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -15,6 +15,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } .traceContains { color: #008000; } .cSpecial { color: #008000; } +.CommentedCode { color: #6c6c6c; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } @@ -40,21 +41,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario surrounding_space)</span> <span class="Comment"># location 1 in space 1 refers to the space surrounding the default space, here 20.</span> recipe main [ - <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># pretend array</span> - <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># pretend array</span> - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe - <span class="Constant">0</span>:address:array:location/names:dummy<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe <span class="Comment"># later layers will explain the /names: property</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">21</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> + <span class="Comment"># actual start of this recipe</span> + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Constant">0</span>:address:shared:array:location/names:dummy<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe <span class="Comment"># later layers will explain the /names: property</span> <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">32</span> <span class="Constant">1</span>:number/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">33</span> ] -recipe dummy [ +recipe dummy [ <span class="Comment"># just for the /names: property above</span> ] -<span class="Comment"># chain space</span> -<span class="traceContains">+mem: storing 20 in location 11</span> -<span class="Comment"># store to default-space</span> -<span class="traceContains">+mem: storing 32 in location 12</span> -<span class="Comment"># store to chained space</span> -<span class="traceContains">+mem: storing 33 in location 22</span> +<span class="Comment"># chain space: 10 + /*skip refcount*/1 + /*skip length*/1</span> +<span class="traceContains">+mem: storing 20 in location 12</span> +<span class="Comment"># store to default space: 10 + /*skip refcount*/1 + /*skip length*/1 + /*index*/1</span> +<span class="traceContains">+mem: storing 32 in location 13</span> +<span class="Comment"># store to chained space: /*contents of location 12*/20 + /*skip refcount*/1 + /*skip length*/1 + /*index*/1</span> +<span class="traceContains">+mem: storing 33 in location 23</span> <span class="Comment">//: If you think of a space as a collection of variables with a common</span> <span class="Comment">//: lifetime, surrounding allows managing shorter lifetimes inside a longer</span> @@ -62,14 +68,17 @@ recipe dummy [ <span class="Delimiter">:(replace{} "long long int space_base(const reagent& x)")</span> long long int space_base<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index<span class="Delimiter">(</span>x<span class="Delimiter">),</span> current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> + long long int base = current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index<span class="Delimiter">(</span>x<span class="Delimiter">),</span> base<span class="Delimiter">);</span> <span class="Delimiter">}</span> long long int space_base<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">,</span> long long int space_index<span class="Delimiter">,</span> long long int base<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? trace(9999, "space") << "space-base: " << space_index << " " << base << end();</span> if <span class="Delimiter">(</span>space_index == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> base<span class="Delimiter">;</span> <span class="Delimiter">}</span> - long long int result = space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index-<span class="Constant">1</span><span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+<span class="Constant">1</span><span class="Delimiter">));</span> + long long int result = space_base<span class="Delimiter">(</span>x<span class="Delimiter">,</span> space_index-<span class="Constant">1</span><span class="Delimiter">,</span> get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">))</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> +<span class="CommentedCode">//? trace(9999, "space") << "space-base: " << space_index << " " << base << " => " << result << end();</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/046closure_name.cc.html b/html/045closure_name.cc.html index 13c7ddd2..ae93ad02 100644 --- a/html/046closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 046closure_name.cc</title> +<title>Mu - 045closure_name.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -39,22 +39,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario closure)</span> recipe main [ - default-space:address:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> - <span class="Constant">1</span>:address:array:location/names:new-counter<span class="Special"> <- </span>new-counter - <span class="Constant">2</span>:number/<span class="Special">raw <- </span>increment-counter <span class="Constant">1</span>:address:array:location/names:new-counter - <span class="Constant">3</span>:number/<span class="Special">raw <- </span>increment-counter <span class="Constant">1</span>:address:array:location/names:new-counter + default-space:address:shared:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> + <span class="Constant">1</span>:address:shared:array:location/names:new-counter<span class="Special"> <- </span>new-counter + <span class="Constant">2</span>:number/<span class="Special">raw <- </span>increment-counter <span class="Constant">1</span>:address:shared:array:location/names:new-counter + <span class="Constant">3</span>:number/<span class="Special">raw <- </span>increment-counter <span class="Constant">1</span>:address:shared:array:location/names:new-counter ] recipe new-counter [ - default-space:address:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> + default-space:address:shared:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> x:number<span class="Special"> <- </span>copy <span class="Constant">23</span> y:number<span class="Special"> <- </span>copy <span class="Constant">3</span> <span class="Comment"># variable that will be incremented</span> - reply default-space:address:array:location + reply default-space:address:shared:array:location ] recipe increment-counter [ - default-space:address:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> - <span class="Constant">0</span>:address:array:location/names:new-counter<span class="Special"> <- </span>next-ingredient <span class="Comment"># outer space must be created by 'new-counter' above</span> + default-space:address:shared:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">30</span> + <span class="Constant">0</span>:address:shared:array:location/names:new-counter<span class="Special"> <- </span>next-ingredient <span class="Comment"># outer space must be created by 'new-counter' above</span> y:number/space:<span class="Constant">1</span><span class="Special"> <- </span>add y:number/space:<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span> <span class="Comment"># increment</span> y:number<span class="Special"> <- </span>copy <span class="Constant">234</span> <span class="Comment"># dummy</span> reply y:number/space:<span class="Constant">1</span> @@ -86,11 +86,13 @@ void collect_surrounding_spaces<span class="Delimiter">(</span>const recipe_ordi if <span class="Delimiter">(</span>!type || type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> || !type<span class="Delimiter">-></span>right - || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">)</span> || !type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> - || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << <span class="Constant">"slot 0 should always have type address:array:location, but is "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + || !type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right + || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> + || type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise_error << <span class="Constant">"slot 0 should always have type address:shared:array:location, but is "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> string_tree* s = property<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">),</span> <span class="Constant">"names"</span><span class="Delimiter">);</span> diff --git a/html/047global.cc.html b/html/046global.cc.html index b2017a82..d5a1331c 100644 --- a/html/047global.cc.html +++ b/html/046global.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 047global.cc</title> +<title>Mu - 046global.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -38,17 +38,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario global_space)</span> recipe main [ - <span class="Comment"># pretend arrays; in practice we'll use new</span> - <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> - <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> + <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> + <span class="Constant">20</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> + <span class="Constant">21</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> - global-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe - default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + global-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe + default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">1</span>:number/space:global<span class="Special"> <- </span>copy <span class="Constant">24</span> ] -<span class="traceContains">+mem: storing 23 in location 12</span> -<span class="traceContains">+mem: storing 24 in location 22</span> +<span class="Comment"># store to default space: 10 + /*skip refcount*/1 + /*skip length*/1 + /*index*/1</span> +<span class="traceContains">+mem: storing 23 in location 13</span> +<span class="Comment"># store to chained space: /*contents of location 12*/20 + /*skip refcount*/1 + /*skip length*/1 + /*index*/1</span> +<span class="traceContains">+mem: storing 24 in location 23</span> <span class="Comment">//: to support it, create another special variable called global space</span> <span class="Delimiter">:(before "End Disqualified Reagents")</span> @@ -68,11 +73,13 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> || !x<span class="Delimiter">.</span>type || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'global-space' should be of type address:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> + || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'global-space' should be of type address:shared:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> raise_error << <span class="Constant">"routine already has a global-space; you can't over-write your globals"</span> << end<span class="Delimiter">();</span> @@ -85,7 +92,7 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> raise_error << <span class="Constant">"routine has no global space</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">;</span> + <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>global_space + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">//: for now let's not bother giving global variables names.</span> @@ -94,7 +101,7 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(scenario global_space_with_names)</span> <span class="Special">% Hide_errors = true;</span> recipe main [ - global-space:address:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">10</span> + global-space:address:shared:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">10</span> x:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">1</span>:number/space:global<span class="Special"> <- </span>copy <span class="Constant">24</span> ] diff --git a/html/048check_type_by_name.cc.html b/html/047check_type_by_name.cc.html index 13703a0e..0bc520b9 100644 --- a/html/048check_type_by_name.cc.html +++ b/html/047check_type_by_name.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 048check_type_by_name.cc</title> +<title>Mu - 047check_type_by_name.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -81,16 +81,14 @@ void deduce_missing_type<span class="Delimiter">(</span>map<string<span class void check_type<span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> type_tree*>& type<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> string_tree*>& type_name<span class="Delimiter">,</span> const reagent& x<span class="Delimiter">,</span> const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - <span class="Comment">// if you use raw locations you're probably doing something unsafe</span> - if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// will throw a more precise error elsewhere</span> + if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// if you use raw locations you're probably doing something unsafe</span> + if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// might get filled in by other logic later</span> if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" => "</span> << debug_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> type[x<span class="Delimiter">.</span>name] = x<span class="Delimiter">.</span>type<span class="Delimiter">;</span> <span class="Delimiter">}</span> - if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>type_name<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>type_name<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> type_name[x<span class="Delimiter">.</span>name] = x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">;</span> - <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>type[x<span class="Delimiter">.</span>name]<span class="Delimiter">,</span> x<span class="Delimiter">.</span>type<span class="Delimiter">))</span> raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << x<span class="Delimiter">.</span>name << <span class="Constant">" used with multiple types</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -125,10 +123,10 @@ recipe main [ <span class="Delimiter">:(scenario typo_in_address_type_fails)</span> <span class="Special">% Hide_errors = true;</span> recipe main [ - y:address:charcter<span class="Special"> <- </span>new character:type + y:address:shared:charcter<span class="Special"> <- </span>new character:type *y<span class="Special"> <- </span>copy <span class="Constant">67</span> ] -<span class="traceContains">+error: main: unknown type charcter in 'y:address:charcter <- new character:type'</span> +<span class="traceContains">+error: main: unknown type charcter in 'y:address:shared:charcter <- new character:type'</span> </pre> </body> </html> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 523ea59f..a44b76d0 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -13,16 +13,16 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.traceAbsent { color: #c00000; } .traceContains { color: #008000; } -.CommentedCode { color: #6c6c6c; } .SalientComment { color: #00ffff; } .cSpecial { color: #008000; } -.traceAbsent { color: #c00000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -135,18 +135,26 @@ scenario foo [ <span class="Delimiter">:(scenario read_scenario_with_bracket_in_comment_in_nested_string)</span> scenario foo [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [<span class="Comment"># not a comment]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [<span class="Comment"># not a comment]</span> ] -<span class="traceContains">+run: 1:address:array:character <- new [# not a comment]</span> +<span class="traceContains">+run: 1:address:shared:array:character <- new [# not a comment]</span> <span class="SalientComment">//:: Run scenarios when we run 'mu test'.</span> <span class="Comment">//: Treat the text of the scenario as a regular series of instructions.</span> +<span class="Delimiter">:(before "End Globals")</span> +long long int Num_core_mu_tests = <span class="Constant">0</span><span class="Delimiter">;</span> +<span class="Delimiter">:(after "Check For .mu Files")</span> +Num_core_mu_tests = SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Tests")</span> time_t mu_time<span class="Delimiter">;</span> time<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> cerr << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">Mu tests: "</span> << ctime<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << i << ": " << Scenarios.at(i).name << '\n';</span> + if <span class="Delimiter">(</span>i == Num_core_mu_tests<span class="Delimiter">)</span> <span class="Delimiter">{</span> + time<span class="Delimiter">(</span>&t<span class="Delimiter">);</span> + cerr << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">App tests: "</span> << ctime<span class="Delimiter">(</span>&t<span class="Delimiter">);</span> + <span class="Delimiter">}</span> run_mu_scenario<span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> if <span class="Delimiter">(</span>Passed<span class="Delimiter">)</span> cerr << <span class="Constant">"."</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -173,7 +181,6 @@ void run_mu_scenario<span class="Delimiter">(</span>const scenario& s<span c Trace_stream = new trace_stream<span class="Delimiter">;</span> setup<span class="Delimiter">();</span> <span class="Delimiter">}</span> - assert<span class="Delimiter">(</span>Routines<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> vector<recipe_ordinal> tmp = load<span class="Delimiter">(</span><span class="Constant">"recipe scenario-"</span>+s<span class="Delimiter">.</span>name+<span class="Constant">" [ "</span>+s<span class="Delimiter">.</span>to_run+<span class="Constant">" ]"</span><span class="Delimiter">);</span> bind_special_scenario_names<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> transform_all<span class="Delimiter">();</span> diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html index 131de37a..42f5b7ca 100644 --- a/html/052tangle.cc.html +++ b/html/052tangle.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } @@ -216,12 +216,6 @@ before +label1 [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+error: can't tangle before label +label1</span> -<span class="traceContains">+mem: storing 0 in location 1</span> -<span class="traceContains">+mem: storing 0 in location 4</span> -<span class="Comment"># label1</span> -<span class="traceAbsent">-mem: storing 0 in location 2</span> -<span class="Comment"># nothing else</span> -$mem: <span class="Constant">2</span> <span class="Delimiter">:(scenario tangle_keeps_labels_separate)</span> recipe main [ diff --git a/html/053rewrite_stash.cc.html b/html/053rewrite_stash.cc.html index ba867faf..6bef7eed 100644 --- a/html/053rewrite_stash.cc.html +++ b/html/053rewrite_stash.cc.html @@ -68,7 +68,7 @@ void rewrite_stashes_to_text_named<span class="Delimiter">(</span>recipe& ca def<span class="Delimiter">.</span>name = <span class="Constant">"to-text-line"</span><span class="Delimiter">;</span> def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> ostringstream ingredient_name<span class="Delimiter">;</span> - ingredient_name << <span class="Constant">"stash_"</span> << stash_instruction_idx << <span class="Constant">'_'</span> << j << <span class="Constant">":address:array:character"</span><span class="Delimiter">;</span> + ingredient_name << <span class="Constant">"stash_"</span> << stash_instruction_idx << <span class="Constant">'_'</span> << j << <span class="Constant">":address:shared:array:character"</span><span class="Delimiter">;</span> def<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">()));</span> new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>def<span class="Delimiter">);</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>clear<span class="Delimiter">();</span> <span class="Comment">// reclaim old memory</span> diff --git a/html/054dilated_reagent.cc.html b/html/054dilated_reagent.cc.html index 1d908069..55526228 100644 --- a/html/054dilated_reagent.cc.html +++ b/html/054dilated_reagent.cc.html @@ -51,6 +51,22 @@ recipe main [ ] <span class="Comment"># successfully parsed</span> +<span class="Delimiter">:(scenarios run)</span> +<span class="Delimiter">:(scenario dilated_reagent_with_comment)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: bar<span class="Delimiter">}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># test comment</span> +] +<span class="traceContains">+parse: product: {"1": "number", "foo": "bar"}</span> +$error: <span class="Constant">0</span> + +<span class="Delimiter">:(scenario dilated_reagent_with_comment_immediately_following)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Delimiter">{</span><span class="Constant">34</span>: literal<span class="Delimiter">}</span> <span class="Comment"># test comment</span> +] +$error: <span class="Constant">0</span> + <span class="Comment">//: First augment next_word to group balanced brackets together.</span> <span class="Delimiter">:(before "End next_word Special-cases")</span> @@ -106,6 +122,7 @@ string slurp_balanced_bracket<span class="Delimiter">(</span>istream& in<spa result << c<span class="Delimiter">;</span> if <span class="Delimiter">(</span>open_brackets<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + skip_whitespace_and_comments_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -130,7 +147,7 @@ if <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span clas <span class="Comment">// this type can't be an integer literal</span> put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> <span class="Delimiter">}</span> - type = new type_tree<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type_name<span class="Delimiter">));</span> + type = new_type_tree<span class="Delimiter">(</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/055parse_tree.cc.html b/html/055parse_tree.cc.html index 1d97dee4..ec8d3f77 100644 --- a/html/055parse_tree.cc.html +++ b/html/055parse_tree.cc.html @@ -103,11 +103,14 @@ container bar [ <span class="Delimiter">:(scenario dilated_reagent_with_new)</span> recipe main [ - x:address:number<span class="Special"> <- </span>new <span class="Delimiter">{(</span>foo bar<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> + x:address:shared:address:number<span class="Special"> <- </span>new <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> ] -<span class="Comment"># type isn't defined so size is meaningless, but at least we parse the type correctly</span> -<span class="traceContains">+new: size of <"foo" : <"bar" : <>>> is 1</span> +<span class="traceContains">+new: size of <"address" : <"number" : <>>> is 1</span> +<span class="Delimiter">:(before "End Post-processing(expected_product) When Checking 'new'")</span> +expected_product<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second = parse_string_tree<span class="Delimiter">(</span>expected_product<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> +delete expected_product<span class="Delimiter">.</span>type<span class="Delimiter">;</span> +expected_product<span class="Delimiter">.</span>type = new_type_tree<span class="Delimiter">(</span>expected_product<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Post-processing(type_name) When Converting 'new'")</span> type_name = parse_string_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">);</span> </pre> diff --git a/html/056recipe_header.cc.html b/html/056recipe_header.cc.html index 08cc8fdd..48da455e 100644 --- a/html/056recipe_header.cc.html +++ b/html/056recipe_header.cc.html @@ -175,15 +175,133 @@ if <span class="Delimiter">(</span>result<span class="Delimiter">.</span>has_hea <span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"load-ingredients"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> curr<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + recipe_ordinal op = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"next-ingredient-without-typechecking"</span><span class="Delimiter">);</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>result<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - curr<span class="Delimiter">.</span>operation = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"next-ingredient"</span><span class="Delimiter">);</span> - curr<span class="Delimiter">.</span>name = <span class="Constant">"next-ingredient"</span><span class="Delimiter">;</span> + curr<span class="Delimiter">.</span>operation = op<span class="Delimiter">;</span> + curr<span class="Delimiter">.</span>name = <span class="Constant">"next-ingredient-without-typechecking"</span><span class="Delimiter">;</span> curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> result<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> curr<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> +<span class="Comment">//: internal version of next-ingredient; don't call this directly</span> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +NEXT_INGREDIENT_WITHOUT_TYPECHECKING<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"next-ingredient-without-typechecking"</span><span class="Delimiter">,</span> NEXT_INGREDIENT_WITHOUT_TYPECHECKING<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> + if <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>next_ingredient_to_process < SIZE<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">))</span> <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span> + current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>at<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>next_ingredient_to_process<span class="Delimiter">));</span> + assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>products<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// push a new vector</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> + ++current_call<span class="Delimiter">().</span>next_ingredient_to_process<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> + <span class="Comment">// pad the first product with sufficient zeros to match its type</span> + long long int size = size_of<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="SalientComment">//:: Check all calls against headers.</span> + +<span class="Delimiter">:(scenario show_clear_error_on_bad_call)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>foo <span class="Constant">34</span> +] +recipe foo x:boolean <span class="Delimiter">-></span> y:number [ + local-scope + load-ingredients + reply <span class="Constant">35</span> +] +<span class="traceContains">+error: main: ingredient 0 has the wrong type at '1:number <- foo 34'</span> + +<span class="Delimiter">:(scenario show_clear_error_on_bad_call_2)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">1</span>:boolean<span class="Special"> <- </span>foo <span class="Constant">34</span> +] +recipe foo x:number <span class="Delimiter">-></span> y:number [ + local-scope + load-ingredients + reply x +] +<span class="traceContains">+error: main: product 0 has the wrong type at '1:boolean <- foo 34'</span> + +<span class="Delimiter">:(after "Transform.push_back(check_instruction)")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_calls_against_header<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> +<span class="Delimiter">:(code)</span> +void check_calls_against_header<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check calls inside recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> + const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + const instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation < MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + const recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!callee<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i << <span class="Constant">" has the wrong type at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>is_unique_address<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"try to avoid passing non-shared addresses into calls, like ingredient "</span> << i << <span class="Constant">" at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(</span>long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>is_unique_address<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"try to avoid getting non-shared addresses out of calls, like product "</span> << i << <span class="Constant">" at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> + +bool is_unique_address<span class="Delimiter">(</span>reagent x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!canonize_type<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">);</span> +<span class="Delimiter">}</span> + +<span class="Comment">//: additionally, warn on calls receiving non-shared addresses</span> + +<span class="Delimiter">:(scenario warn_on_calls_with_addresses)</span> +<span class="Special">% Hide_warnings= true;</span> +recipe main [ + <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">3</span>/unsafe + foo <span class="Constant">1</span>:address:number +] +recipe foo x:address:number [ + local-scope + load-ingredients +] +<span class="traceContains">+warn: main: try to avoid passing non-shared addresses into calls, like ingredient 0 at 'foo 1:address:number'</span> + +<span class="Delimiter">:(scenario warn_on_calls_with_addresses_2)</span> +<span class="Special">% Hide_warnings= true;</span> +recipe main [ + <span class="Constant">1</span>:address:number<span class="Special"> <- </span>foo +] +recipe foo <span class="Delimiter">-></span> x:address:number [ + local-scope + load-ingredients + x<span class="Special"> <- </span>copy <span class="Constant">0</span> +] +<span class="traceContains">+warn: main: try to avoid getting non-shared addresses out of calls, like product 0 at '1:address:number <- foo '</span> + <span class="SalientComment">//:: Check types going in and out of all recipes with headers.</span> <span class="Delimiter">:(scenarios transform)</span> @@ -235,6 +353,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa void check_header_ingredients<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe& caller_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> if <span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- checking reply instructions against header for "</span> << caller_recipe<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">))</span> @@ -284,10 +403,8 @@ void deduce_types_from_header<span class="Delimiter">(</span>const recipe_ordina trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction: "</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> for <span class="Delimiter">(</span>long long int 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> if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"unknown variable "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" in '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type = new type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>header_type<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">));</span> if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">)</span> @@ -297,10 +414,8 @@ void deduce_types_from_header<span class="Delimiter">(</span>const recipe_ordina for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">" product: "</span> << debug_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"unknown variable "</span> << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name << <span class="Constant">" in '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>header_type<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> == header_type<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type = new type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>header_type<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">));</span> if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">)</span> @@ -415,6 +530,10 @@ recipe add2 x:number<span class="Delimiter">,</span> y:number <span class="Delim load-ingredients ] <span class="traceContains">+error: main: '3:number <- add2 1:number, 2:number' should write to 1:number rather than 3:number</span> + +<span class="Delimiter">:(before "End Includes")</span> +using std::min<span class="Delimiter">;</span> +using std::max<span class="Delimiter">;</span> </pre> </body> </html> diff --git a/html/057static_dispatch.cc.html b/html/057static_dispatch.cc.html index 04d02ab2..319c72e9 100644 --- a/html/057static_dispatch.cc.html +++ b/html/057static_dispatch.cc.html @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .Identifier { color: #804000; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } @@ -65,16 +65,14 @@ for <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Load Recipe Header(result)")</span> -if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> +if <span class="Delimiter">(</span>result<span class="Delimiter">.</span>name != <span class="Constant">"main"</span> && contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> const recipe_ordinal r = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">);</span> -<span class="CommentedCode">//? LOG << "checking " << r << " " << result.name << '\n';</span> <span class="CommentedCode">//? cerr << result.name << ": " << contains_key(Recipe, r) << (contains_key(Recipe, r) ? get(Recipe, r).has_header : 0) << matching_variant_name(result) << '\n';</span> if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>has_header<span class="Delimiter">)</span> <span class="Delimiter">{</span> string new_name = matching_variant_name<span class="Delimiter">(</span>result<span class="Delimiter">);</span> if <span class="Delimiter">(</span>new_name<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span class="Comment">// variant doesn't already exist</span> new_name = next_unused_recipe_name<span class="Delimiter">(</span>result<span class="Delimiter">.</span>name<span class="Delimiter">);</span> -<span class="CommentedCode">//? LOG << "adding a variant of " << result.name << ": " << new_name << " is now " << Next_recipe_ordinal << '\n';</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> new_name<span class="Delimiter">,</span> Next_recipe_ordinal++<span class="Delimiter">);</span> get_or_insert<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> new_name<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -84,7 +82,6 @@ if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>R <span class="Delimiter">}</span> else <span class="Delimiter">{</span> <span class="Comment">// save first variant</span> -<span class="CommentedCode">//? LOG << "saving first variant of " << result.name << ": " << Next_recipe_ordinal << '\n';</span> put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">,</span> Next_recipe_ordinal++<span class="Delimiter">);</span> get_or_insert<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> result<span class="Delimiter">.</span>name<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -93,14 +90,11 @@ else <span class="Delimiter">{</span> string matching_variant_name<span class="Delimiter">(</span>const recipe& rr<span class="Delimiter">)</span> <span class="Delimiter">{</span> const vector<recipe_ordinal>& variants = get_or_insert<span class="Delimiter">(</span>Recipe_variants<span class="Delimiter">,</span> rr<span class="Delimiter">.</span>name<span class="Delimiter">);</span> for <span class="Delimiter">(</span>long long int 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="CommentedCode">//? LOG << "checking variant " << variants.at(i) << " of " << rr.name << '\n';</span> if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> const recipe& candidate = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> if <span class="Delimiter">(</span>!all_reagents_match<span class="Delimiter">(</span>rr<span class="Delimiter">,</span> candidate<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span class="CommentedCode">//? LOG << " exists\n";</span> <span class="Identifier">return</span> candidate<span class="Delimiter">.</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="CommentedCode">//? LOG << " does not exist\n";</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -178,7 +172,7 @@ for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</ <span class="Delimiter">}</span> <span class="Comment">//: after filling in all missing types (because we'll be introducing 'blank' types in this transform in a later layer, for shape-shifting recipes)</span> -<span class="Delimiter">:(after "End Type Modifying Transforms")</span> +<span class="Delimiter">:(after "Transform.push_back(transform_names)")</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>resolve_ambiguous_calls<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(code)</span> @@ -224,13 +218,8 @@ long long int variant_score<span class="Delimiter">(</span>const instruction& <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> const vector<reagent>& header_ingredients = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>ingredients<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>header_ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"too few ingredients"</span> << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << "too few ingredients\n";</span> - <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> <span class="CommentedCode">//? cerr << "=== checking ingredients\n";</span> - for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>header_ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>header_ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>header_ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"mismatch: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="CommentedCode">//? cerr << "mismatch: ingredient " << i << '\n';</span> @@ -253,13 +242,8 @@ long long int variant_score<span class="Delimiter">(</span>const instruction& <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="CommentedCode">//? cerr << "=== done checking ingredients\n";</span> - if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">)</span> > SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"too few products"</span> << end<span class="Delimiter">();</span> -<span class="CommentedCode">//? cerr << "too few products\n";</span> - <span class="Identifier">return</span> -<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> const vector<reagent>& header_products = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>products<span class="Delimiter">;</span> - for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>header_products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>header_products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"mismatch: product "</span> << i << end<span class="Delimiter">();</span> @@ -283,8 +267,8 @@ long long int variant_score<span class="Delimiter">(</span>const instruction& <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Comment">// the greater the number of unused ingredients/products, the lower the score</span> - <span class="Identifier">return</span> result - <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> - - <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>ingredients<span class="Delimiter">));</span> <span class="Comment">// ok to go negative</span> + <span class="Identifier">return</span> result - abs<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>products<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> + - abs<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>-SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variant<span class="Delimiter">).</span>ingredients<span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario static_dispatch_disabled_on_headerless_definition)</span> @@ -348,13 +332,13 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_first_use)</span> <span class="Special">% Hide_errors = true;</span> recipe main [ - x:address:foo<span class="Special"> <- </span>new foo:type + x:address:shared:foo<span class="Special"> <- </span>new foo:type test x ] container foo [ x:number ] -recipe test a:address:foo <span class="Delimiter">-></span> z:number [ +recipe test a:address:shared:foo <span class="Delimiter">-></span> z:number [ local-scope load-ingredients z:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset @@ -364,10 +348,10 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_second_use)</span> <span class="Special">% Hide_errors = true;</span> recipe main [ - x:address:foo<span class="Special"> <- </span>new foo:type + x:address:shared:foo<span class="Special"> <- </span>new foo:type test x ] -recipe test a:address:foo <span class="Delimiter">-></span> z:number [ +recipe test a:address:shared:foo <span class="Delimiter">-></span> z:number [ local-scope load-ingredients z:number<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> x:offset @@ -400,7 +384,7 @@ recipe foo x:number <span class="Delimiter">-></span> y:number [ load-ingredients reply <span class="Constant">34</span> ] -<span class="traceContains">+error: foo: wrong type for ingredient x:number</span> +<span class="traceContains">+error: main: ingredient 0 has the wrong type at '1:number/raw <- foo x'</span> <span class="traceAbsent">-mem: storing 34 in location 1</span> <span class="Delimiter">:(scenario static_dispatch_dispatches_literal_to_boolean_before_character)</span> @@ -454,43 +438,6 @@ recipe foo x:number <span class="Delimiter">-></span> y:number [ <span class="Comment"># number variant is preferred</span> <span class="traceContains">+mem: storing 35 in location 1</span> -<span class="Comment">//: after we make all attempts to dispatch, any unhandled cases will end up at</span> -<span class="Comment">//: some wrong variant and trigger an error while trying to load-ingredients</span> - -<span class="Delimiter">:(scenario static_dispatch_shows_clear_error_on_missing_variant)</span> -<span class="Special">% Hide_errors = true;</span> -recipe main [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>foo <span class="Constant">34</span> -] -recipe foo x:boolean <span class="Delimiter">-></span> y:number [ - local-scope - load-ingredients - reply <span class="Constant">35</span> -] -<span class="traceContains">+error: foo: wrong type for ingredient x:boolean</span> -<span class="traceContains">+error: (we're inside recipe foo x:boolean -> y:number)</span> -<span class="traceContains">+error: (we're trying to call '1:number <- foo 34' inside recipe main)</span> - -<span class="Delimiter">:(before "End next-ingredient Type Mismatch Error")</span> -raise_error << <span class="Constant">" (we're inside "</span> << header_label<span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>running_recipe<span class="Delimiter">)</span> << <span class="Constant">")</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> -raise_error << <span class="Constant">" (we're trying to call '"</span> << to_instruction<span class="Delimiter">(</span>*++Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>begin<span class="Delimiter">()).</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"' inside "</span> << header_label<span class="Delimiter">((</span>++Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>begin<span class="Delimiter">())-></span>running_recipe<span class="Delimiter">)</span> << <span class="Constant">")</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - -<span class="Delimiter">:(scenario static_dispatch_shows_clear_error_on_missing_variant_2)</span> -<span class="Special">% Hide_errors = true;</span> -recipe main [ - <span class="Constant">1</span>:boolean<span class="Special"> <- </span>foo <span class="Constant">34</span> -] -recipe foo x:number <span class="Delimiter">-></span> y:number [ - local-scope - load-ingredients - reply x -] -<span class="traceContains">+error: foo: reply ingredient x can't be saved in 1:boolean</span> -<span class="traceContains">+error: (we just returned from recipe foo x:number -> y:number)</span> - -<span class="Delimiter">:(before "End reply Type Mismatch Error")</span> -raise_error << <span class="Constant">" (we just returned from "</span> << header_label<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>operation<span class="Delimiter">)</span> << <span class="Constant">")</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Delimiter">:(code)</span> string header_label<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> @@ -527,6 +474,27 @@ recipe! foo x:address:number <span class="Delimiter">-></span> y:number [ <span class="traceContains">+mem: storing 34 in location 2</span> $error: <span class="Constant">0</span> $warn: <span class="Constant">0</span> + +<span class="Delimiter">:(scenario dispatch_errors_come_after_unknown_name_errors)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + y:number<span class="Special"> <- </span>foo x +] +recipe foo a:number <span class="Delimiter">-></span> b:number [ + local-scope + load-ingredients + reply <span class="Constant">34</span> +] +recipe foo a:boolean <span class="Delimiter">-></span> b:number [ + local-scope + load-ingredients + reply <span class="Constant">35</span> +] +<span class="traceContains">+error: main: missing type for x in 'y:number <- foo x'</span> +<span class="traceContains">+error: main: failed to find a matching call for 'y:number <- foo x'</span> + +<span class="Delimiter">:(before "End Includes")</span> +using std::abs<span class="Delimiter">;</span> </pre> </body> </html> diff --git a/html/059shape_shifting_recipe.cc.html b/html/059shape_shifting_recipe.cc.html index 4b895042..dcbcd680 100644 --- a/html/059shape_shifting_recipe.cc.html +++ b/html/059shape_shifting_recipe.cc.html @@ -109,32 +109,28 @@ if <span class="Delimiter">(</span>best_score == -<span class="Constant">1</span if <span class="Delimiter">(</span>exemplar<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << "specializing " << inst.name << '\n';</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">"found variant to specialize: "</span> << exemplar << <span class="Constant">' '</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> - LOG << <span class="Constant">"found variant to specialize: "</span> << exemplar << <span class="Constant">' '</span> << header<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> recipe_ordinal new_recipe_ordinal = new_variant<span class="Delimiter">(</span>exemplar<span class="Delimiter">,</span> inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>new_recipe_ordinal == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">goto</span> done_constructing_variant<span class="Delimiter">;</span> variants<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_recipe_ordinal<span class="Delimiter">);</span> <span class="Comment">// perform all transforms on the new specialization</span> const string& new_name = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>back<span class="Delimiter">()).</span>name<span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"transforming new specialization: "</span> << new_name << end<span class="Delimiter">();</span> - LOG << <span class="Constant">"transforming new specialization: "</span> << header<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>back<span class="Delimiter">()))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int t = <span class="Constant">0</span><span class="Delimiter">;</span> t < SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Delimiter">(</span>*Transform<span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">))(</span>new_recipe_ordinal<span class="Delimiter">);</span> <span class="Delimiter">}</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">).</span>transformed_until = SIZE<span class="Delimiter">(</span>Transform<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">;</span> - LOG << <span class="Constant">"replacing "</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">" with "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>back<span class="Delimiter">()).</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> inst<span class="Delimiter">.</span>name = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> variants<span class="Delimiter">.</span>back<span class="Delimiter">()).</span>name<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">"new specialization: "</span> << inst<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - LOG << <span class="Constant">"new specialization: "</span> << inst<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + done_constructing_variant:<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">//: make sure we have no unspecialized shape-shifting recipes being called</span> <span class="Comment">//: before running mu programs</span> <span class="Delimiter">:(before "End Instruction Operation Checks")</span> -<span class="CommentedCode">//? LOG << inst.operation << " " << contains_key(Recipe, inst.operation) << '\n';</span> if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">)</span> && inst<span class="Delimiter">.</span>operation >= MAX_PRIMITIVE_RECIPES && any_type_ingredient_in_header<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span class="CommentedCode">//? LOG << header(caller) << "instruction " << inst.name << " has no valid specialization\n";</span> raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"instruction "</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">" has no valid specialization</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -319,7 +315,7 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla if <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> for <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> const string_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> delete p<span class="Delimiter">-></span>second<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>error<span class="Delimiter">)</span> <span class="Identifier">return</span> exemplar<span class="Delimiter">;</span> + if <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="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> <span class="Identifier">return</span> new_recipe_ordinal<span class="Delimiter">;</span> @@ -574,14 +570,14 @@ container foo:_t [ <span class="Delimiter">:(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient)</span> recipe main [ - <span class="Constant">1</span>:address:foo:point<span class="Special"> <- </span>bar <span class="Constant">3</span> - <span class="Constant">11</span>:foo:point<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:foo:point + <span class="Constant">1</span>:address:shared:foo:point<span class="Special"> <- </span>bar <span class="Constant">3</span> + <span class="Constant">11</span>:foo:point<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:foo:point ] container foo:_t [ x:_t y:number ] -recipe bar x:number <span class="Delimiter">-></span> result:address:foo:_t [ +recipe bar x:number <span class="Delimiter">-></span> result:address:shared:foo:_t [ local-scope load-ingredients <span class="Comment"># new refers to _t in its ingredient *value*</span> @@ -593,10 +589,10 @@ recipe bar x:number <span class="Delimiter">-></span> result:address:foo:_t [ <span class="Delimiter">:(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient_2)</span> recipe main [ - <span class="Constant">1</span>:address:foo:point<span class="Special"> <- </span>bar <span class="Constant">3</span> - <span class="Constant">11</span>:foo:point<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:foo:point + <span class="Constant">1</span>:address:shared:foo:point<span class="Special"> <- </span>bar <span class="Constant">3</span> + <span class="Constant">11</span>:foo:point<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:foo:point ] -recipe bar x:number <span class="Delimiter">-></span> result:address:foo:_t [ +recipe bar x:number <span class="Delimiter">-></span> result:address:shared:foo:_t [ local-scope load-ingredients <span class="Comment"># new refers to _t in its ingredient *value*</span> @@ -613,11 +609,11 @@ container foo:_t [ <span class="Delimiter">:(scenario shape_shifting_recipe_supports_compound_types)</span> recipe main [ - <span class="Constant">1</span>:address:point<span class="Special"> <- </span>new point:type - <span class="Constant">2</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">1</span>:address:point<span class="Delimiter">,</span> y:offset + <span class="Constant">1</span>:address:shared:point<span class="Special"> <- </span>new point:type + <span class="Constant">2</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">1</span>:address:shared:point<span class="Delimiter">,</span> y:offset *<span class="Constant">2</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Constant">3</span>:address:point<span class="Special"> <- </span>bar <span class="Constant">1</span>:address:point <span class="Comment"># specialize _t to address:point</span> - <span class="Constant">4</span>:point<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:point + <span class="Constant">3</span>:address:shared:point<span class="Special"> <- </span>bar <span class="Constant">1</span>:address:shared:point <span class="Comment"># specialize _t to address:shared:point</span> + <span class="Constant">4</span>:point<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:point ] recipe bar a:_t <span class="Delimiter">-></span> result:_t [ local-scope @@ -630,13 +626,13 @@ recipe bar a:_t <span class="Delimiter">-></span> result:_t [ <span class="Special">% Hide_errors = true;</span> recipe main [ a:number<span class="Special"> <- </span>copy <span class="Constant">3</span> - b:address:number<span class="Special"> <- </span>foo a + b:address:shared:number<span class="Special"> <- </span>foo a ] recipe foo a:_t <span class="Delimiter">-></span> b:_t [ load-ingredients b<span class="Special"> <- </span>copy a ] -<span class="traceContains">+error: main: no call found for 'b:address:number <- foo a'</span> +<span class="traceContains">+error: main: no call found for 'b:address:shared:number <- foo a'</span> <span class="Delimiter">:(scenario specialize_inside_recipe_without_header)</span> recipe main [ @@ -685,7 +681,7 @@ recipe foo x:_elem <span class="Delimiter">-></span> y:_elem [ recipe main [ local-scope <span class="Comment"># permit '0' to map to address to shape-shifting type-ingredient</span> - <span class="Constant">1</span>:address:character/<span class="Special">raw <- </span>foo <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:character/<span class="Special">raw <- </span>foo <span class="Constant">0</span> ] recipe foo x:address:_elem <span class="Delimiter">-></span> y:address:_elem [ local-scope @@ -755,7 +751,7 @@ container d2:_elem [ <span class="Comment"># static dispatch between shape-shifting variants, _including pointer lookups_</span> recipe main [ e1:d1:number<span class="Special"> <- </span>merge <span class="Constant">3</span> - e2:address:d2:number<span class="Special"> <- </span>new <span class="Delimiter">{(</span>d2 number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> + e2:address:shared:d2:number<span class="Special"> <- </span>new <span class="Delimiter">{(</span>d2 number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> <span class="Constant">1</span>:number/<span class="Special">raw <- </span>foo e1 <span class="Constant">2</span>:number/<span class="Special">raw <- </span>foo *e2 <span class="Comment"># different from previous scenario</span> ] @@ -838,15 +834,15 @@ recipe foo x:_elem <span class="Delimiter">-></span> y:number [ <span class="Delimiter">:(scenarios run)</span> <span class="Delimiter">:(scenario specialize_most_similar_variant)</span> recipe main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>new number:type - <span class="Constant">2</span>:number<span class="Special"> <- </span>foo <span class="Constant">1</span>:address:number + <span class="Constant">1</span>:address:shared:number<span class="Special"> <- </span>new number:type + <span class="Constant">2</span>:number<span class="Special"> <- </span>foo <span class="Constant">1</span>:address:shared:number ] recipe foo x:_elem <span class="Delimiter">-></span> y:number [ local-scope load-ingredients reply <span class="Constant">34</span> ] -recipe foo x:address:_elem <span class="Delimiter">-></span> y:number [ +recipe foo x:address:shared:_elem <span class="Delimiter">-></span> y:number [ local-scope load-ingredients reply <span class="Constant">35</span> diff --git a/html/060immutable.cc.html b/html/060immutable.cc.html index 8d8c7633..777149a7 100644 --- a/html/060immutable.cc.html +++ b/html/060immutable.cc.html @@ -39,7 +39,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:point<span class="Special"> <- </span>new point:type + p:address:shared:point<span class="Special"> <- </span>new point:type foo *p ] recipe foo p:point [ @@ -54,10 +54,10 @@ $warn: <span class="Constant">0</span> <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:point<span class="Special"> <- </span>new point:type + p:address:shared:point<span class="Special"> <- </span>new point:type p<span class="Special"> <- </span>foo p ] -recipe foo p:address:point <span class="Delimiter">-></span> p:address:point [ +recipe foo p:address:shared:point <span class="Delimiter">-></span> p:address:shared:point [ local-scope load-ingredients x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset @@ -69,13 +69,13 @@ $warn: <span class="Constant">0</span> <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:d1<span class="Special"> <- </span>new d1:type + p:address:shared:d1<span class="Special"> <- </span>new d1:type q:number<span class="Special"> <- </span>foo p ] -recipe foo p:address:d1 <span class="Delimiter">-></span> q:number [ +recipe foo p:address:shared:d1 <span class="Delimiter">-></span> q:number [ local-scope load-ingredients - x:address:d1<span class="Special"> <- </span>new d1:type + x:address:shared:d1<span class="Special"> <- </span>new d1:type y:address:number<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> p:offset <span class="Comment"># ignore this 'p'</span> q<span class="Special"> <- </span>copy <span class="Constant">34</span> ] @@ -89,10 +89,10 @@ $warn: <span class="Constant">0</span> <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:point<span class="Special"> <- </span>new point:type + p:address:shared:point<span class="Special"> <- </span>new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset @@ -104,15 +104,15 @@ recipe foo p:address:point [ <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:point<span class="Special"> <- </span>new point:type + p:address:shared:point<span class="Special"> <- </span>new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients bar p ] -recipe bar p:address:point <span class="Delimiter">-></span> p:address:point [ +recipe bar p:address:shared:point <span class="Delimiter">-></span> p:address:shared:point [ local-scope load-ingredients x:address:number<span class="Special"> <- </span>get-address *p<span class="Delimiter">,</span> x:offset @@ -124,13 +124,13 @@ recipe bar p:address:point <span class="Delimiter">-></span> p:address:point <span class="Special">% Hide_warnings = true;</span> recipe main [ local-scope - p:address:point<span class="Special"> <- </span>new point:type + p:address:shared:point<span class="Special"> <- </span>new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients - q:address:point<span class="Special"> <- </span>copy p + q:address:shared:point<span class="Special"> <- </span>copy p x:address:number<span class="Special"> <- </span>get-address *q<span class="Delimiter">,</span> x:offset ] <span class="traceContains">+warn: foo: cannot modify q after instruction 'x:address:number <- get-address *q, x:offset' because that would modify ingredient p which is not also a product of foo</span> @@ -138,19 +138,19 @@ recipe foo p:address:point [ <span class="Delimiter">:(scenario can_traverse_immutable_ingredients)</span> <span class="Special">% Hide_warnings = true;</span> container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list<span class="Special"> <- </span>new test-list:type + p:address:shared:test-list<span class="Special"> <- </span>new test-list:type foo p ] -recipe foo p:address:test-list [ +recipe foo p:address:shared:test-list [ local-scope load-ingredients - p2:address:test-list<span class="Special"> <- </span>bar p + p2:address:shared:test-list<span class="Special"> <- </span>bar p ] -recipe bar x:address:test-list <span class="Delimiter">-></span> y:address:test-list [ +recipe bar x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list [ local-scope load-ingredients y<span class="Special"> <- </span>get *x<span class="Delimiter">,</span> next:offset @@ -160,11 +160,11 @@ $warn: <span class="Constant">0</span> <span class="Delimiter">:(scenario handle_optional_ingredients_in_immutability_checks)</span> <span class="Special">% Hide_warnings = true;</span> recipe main [ - k:address:number<span class="Special"> <- </span>new number:type + k:address:shared:number<span class="Special"> <- </span>new number:type test k ] <span class="Comment"># recipe taking an immutable address ingredient</span> -recipe test k:address:number [ +recipe test k:address:shared:number [ local-scope load-ingredients foo k @@ -173,7 +173,7 @@ recipe test k:address:number [ recipe foo <span class="Delimiter">-></span> [ local-scope load-ingredients - k:address:number<span class="Delimiter">,</span> found?:boolean<span class="Special"> <- </span>next-ingredient + k:address:shared:number<span class="Delimiter">,</span> found?:boolean<span class="Special"> <- </span>next-ingredient ] $warn: <span class="Constant">0</span> @@ -246,25 +246,25 @@ set<long long int> scan_contained_in_product_indices<span class="Delimiter <span class="Delimiter">:(scenario immutability_infects_contained_in_variables)</span> <span class="Special">% Hide_warnings = true;</span> container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list<span class="Special"> <- </span>new test-list:type + p:address:shared:test-list<span class="Special"> <- </span>new test-list:type foo p ] -recipe foo p:address:test-list [ <span class="Comment"># p is immutable</span> +recipe foo p:address:shared:test-list [ <span class="Comment"># p is immutable</span> local-scope load-ingredients - p2:address:test-list<span class="Special"> <- </span>test-next p <span class="Comment"># p2 is immutable</span> - p3:address:address:test-list<span class="Special"> <- </span>get-address *p2<span class="Delimiter">,</span> next:offset <span class="Comment"># signal modification of p2</span> + p2:address:shared:test-list<span class="Special"> <- </span>test-next p <span class="Comment"># p2 is immutable</span> + p3:address:address:shared:test-list<span class="Special"> <- </span>get-address *p2<span class="Delimiter">,</span> next:offset <span class="Comment"># signal modification of p2</span> ] -recipe test-next x:address:test-list <span class="Delimiter">-></span> y:address:test-list/contained-in:x [ +recipe test-next x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list/contained-in:x [ local-scope load-ingredients y<span class="Special"> <- </span>get *x<span class="Delimiter">,</span> next:offset ] -<span class="traceContains">+warn: foo: cannot modify p2 after instruction 'p3:address:address:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo</span> +<span class="traceContains">+warn: foo: cannot modify p2 after instruction 'p3:address:address:shared:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo</span> <span class="Delimiter">:(code)</span> void check_immutable_ingredient_in_instruction<span class="Delimiter">(</span>const instruction& inst<span class="Delimiter">,</span> const set<string>& current_ingredient_and_aliases<span class="Delimiter">,</span> const string& original_ingredient_name<span class="Delimiter">,</span> const recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -349,28 +349,28 @@ set<long long int> ingredient_indices<span class="Delimiter">(</span>const <span class="Delimiter">:(scenario can_modify_contained_in_addresses)</span> <span class="Special">% Hide_warnings = true;</span> container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list<span class="Special"> <- </span>new test-list:type + p:address:shared:test-list<span class="Special"> <- </span>new test-list:type foo p ] -recipe foo p:address:test-list <span class="Delimiter">-></span> p:address:test-list [ +recipe foo p:address:shared:test-list <span class="Delimiter">-></span> p:address:shared:test-list [ local-scope load-ingredients - p2:address:test-list<span class="Special"> <- </span>test-next p + p2:address:shared:test-list<span class="Special"> <- </span>test-next p p<span class="Special"> <- </span>test-remove p2<span class="Delimiter">,</span> p ] -recipe test-next x:address:test-list <span class="Delimiter">-></span> y:address:test-list [ +recipe test-next x:address:shared:test-list <span class="Delimiter">-></span> y:address:shared:test-list [ local-scope load-ingredients y<span class="Special"> <- </span>get *x<span class="Delimiter">,</span> next:offset ] -recipe test-remove x:address:test-list/contained-in:from<span class="Delimiter">,</span> from:address:test-list <span class="Delimiter">-></span> from:address:test-list [ +recipe test-remove x:address:shared:test-list/contained-in:from<span class="Delimiter">,</span> from:address:shared:test-list <span class="Delimiter">-></span> from:address:shared:test-list [ local-scope load-ingredients - x2:address:address:test-list<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> next:offset <span class="Comment"># pretend modification</span> + x2:address:address:shared:test-list<span class="Special"> <- </span>get-address *x<span class="Delimiter">,</span> next:offset <span class="Comment"># pretend modification</span> ] $warn: <span class="Constant">0</span> diff --git a/html/061abandon_checks.cc.html b/html/061abandon_checks.cc.html deleted file mode 100644 index 9f91f90e..00000000 --- a/html/061abandon_checks.cc.html +++ /dev/null @@ -1,159 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 061abandon_checks.cc</title> -<meta name="Generator" content="Vim/7.4"> -<meta name="plugin-version" content="vim7.4_v1"> -<meta name="syntax" content="cpp"> -<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> -<meta name="colorscheme" content="minimal"> -<style type="text/css"> -<!-- -pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } -body { font-family: monospace; color: #eeeeee; background-color: #080808; } -* { font-size: 1.05em; } -.Comment { color: #9090ff; } -.Delimiter { color: #a04060; } -.Special { color: #ff6060; } ---> -</style> - -<script type='text/javascript'> -<!-- - ---> -</script> -</head> -<body> -<pre id='vimCodeElement'> -<span class="Delimiter">:(scenarios transform)</span> <span class="Comment">// many of the tests below are *extremely* unsafe</span> -<span class="Delimiter">:(scenario abandon_in_same_recipe_as_new)</span> -recipe test [ - x:address:number<span class="Special"> <- </span>new number:type - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_in_separate_recipe_from_new)</span> -recipe test [ - x:address:number<span class="Special"> <- </span>test-new - test-abandon x -] -recipe test-new <span class="Delimiter">-></span> result:address:number [ - result<span class="Special"> <- </span>new number:type -] -recipe test-abandon x:address:number [ - load-ingredients - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario define_after_abandon_in_same_recipe_as_new)</span> -recipe test [ - x:address:number<span class="Special"> <- </span>new number:type - abandon x - x<span class="Special"> <- </span>new number:type - reply x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario define_after_abandon_in_separate_recipe_from_new)</span> -recipe test [ - x:address:number<span class="Special"> <- </span>test-new - test-abandon x - x<span class="Special"> <- </span>test-new - reply x -] -recipe test-new <span class="Delimiter">-></span> result:address:number [ - result<span class="Special"> <- </span>new number:type -] -recipe test-abandon x:address:number [ - load-ingredients - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable)</span> -recipe test [ - <span class="Delimiter">{</span> - x:address:number<span class="Special"> <- </span>new number:type - abandon x - loop - <span class="Delimiter">}</span> -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_2)</span> -recipe test [ - <span class="Delimiter">{</span> - x:address:number<span class="Special"> <- </span>test-new - test-abandon x - loop - <span class="Delimiter">}</span> -] -recipe test-new <span class="Delimiter">-></span> result:address:number [ - result<span class="Special"> <- </span>new number:type -] -recipe test-abandon x:address:number [ - load-ingredients - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_3)</span> -recipe test [ - <span class="Delimiter">{</span> - x:address:number<span class="Special"> <- </span>test-new - test-abandon x - x:address:number<span class="Special"> <- </span>test-new <span class="Comment"># modify x to a new value</span> - y:address:number<span class="Special"> <- </span>copy x <span class="Comment"># use x after reinitialization</span> - loop - <span class="Delimiter">}</span> -] -recipe test-new <span class="Delimiter">-></span> result:address:number [ - result<span class="Special"> <- </span>new number:type -] -recipe test-abandon x:address:number [ - load-ingredients - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_inside_loop_initializing_variable_4)</span> -container test-list [ - value:number - next:address:test-list -] -recipe test-cleanup x:address:test-list [ - load-ingredients - <span class="Delimiter">{</span> - next:address:test-list<span class="Special"> <- </span>test-next x - test-abandon x - x<span class="Special"> <- </span>copy next - loop - <span class="Delimiter">}</span> -] -recipe test-next x:address:test-list <span class="Delimiter">-></span> result:address:test-list/contained-in:x [ - load-ingredients - result<span class="Special"> <- </span>get *x<span class="Delimiter">,</span> next:offset -] -recipe test-abandon x:address:test-list [ - load-ingredients - abandon x -] -<span class="Comment"># no warnings</span> - -<span class="Delimiter">:(scenario abandon_non_unique_address_after_define)</span> -recipe test [ - x:address:number<span class="Special"> <- </span>new number:type - y:address:number<span class="Special"> <- </span>copy x - abandon x - y:address:number<span class="Special"> <- </span>new number:type <span class="Comment"># overwrite alias</span> - z:address:number<span class="Special"> <- </span>copy y -] -<span class="Comment"># no warnings</span> -</pre> -</body> -</html> -<!-- vim: set foldmethod=manual : --> diff --git a/html/061recipe.cc.html b/html/061recipe.cc.html new file mode 100644 index 00000000..163347ff --- /dev/null +++ b/html/061recipe.cc.html @@ -0,0 +1,235 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 061recipe.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 1.05em; } +.SalientComment { color: #00ffff; } +.traceContains { color: #008000; } +.cSpecial { color: #008000; } +.Comment { color: #9090ff; } +.Delimiter { color: #a04060; } +.Special { color: #ff6060; } +.Identifier { color: #804000; } +.Constant { color: #00a0a0; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: So far we've been calling a fixed recipe in each instruction, but we'd</span> +<span class="Comment">//: also like to make the recipe a variable, pass recipes to "higher-order"</span> +<span class="Comment">//: recipes, return recipes from recipes and so on.</span> + +<span class="Delimiter">:(scenario call_literal_recipe)</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>call f<span class="Delimiter">,</span> <span class="Constant">34</span> +] +recipe f x:number <span class="Delimiter">-></span> y:number [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+mem: storing 34 in location 1</span> + +<span class="Delimiter">:(scenario call_variable)</span> +recipe main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe number <span class="Delimiter">-></span> number<span class="Delimiter">)}</span><span class="Special"> <- </span>copy f + <span class="Constant">2</span>:number<span class="Special"> <- </span>call <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe number <span class="Delimiter">-></span> number<span class="Delimiter">)},</span> <span class="Constant">34</span> +] +recipe f x:number <span class="Delimiter">-></span> y:number [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+mem: storing 34 in location 2</span> + +<span class="Delimiter">:(before "End Mu Types Initialization")</span> +put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-literal"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> +<span class="Comment">// 'recipe' variables can store recipe-literal</span> +type_ordinal recipe = put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> +get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> recipe<span class="Delimiter">).</span>name = <span class="Constant">"recipe"</span><span class="Delimiter">;</span> + +<span class="Delimiter">:(before "End transform_names Exceptions")</span> +if <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second && contains_key<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> + x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second = new string_tree<span class="Delimiter">(</span><span class="Constant">"recipe-literal"</span><span class="Delimiter">);</span> + x<span class="Delimiter">.</span>type = new type_tree<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-literal"</span><span class="Delimiter">));</span> + x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">));</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +CALL<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"call"</span><span class="Delimiter">,</span> CALL<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +case CALL: <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + raise_error << 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">"'call' requires at least one ingredient (the recipe to call)</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> + if <span class="Delimiter">(</span>!is_mu_recipe<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> + raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'call' should be a recipe, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case CALL: <span class="Delimiter">{</span> + <span class="Comment">// Begin Call</span> + if <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span> + ++Trace_stream<span class="Delimiter">-></span>callstack_depth<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span><span class="Constant">"trace"</span><span class="Delimiter">)</span> << <span class="Constant">"indirect 'call': incrementing callstack depth to "</span> << Trace_stream<span class="Delimiter">-></span>callstack_depth << end<span class="Delimiter">();</span> + assert<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>callstack_depth < <span class="Constant">9000</span><span class="Delimiter">);</span> <span class="Comment">// 9998-101 plus cushion</span> + <span class="Delimiter">}</span> + const instruction& caller_instruction = current_instruction<span class="Delimiter">();</span> + Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span> + ingredients<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>begin<span class="Delimiter">());</span> <span class="Comment">// drop the callee</span> + finish_call_housekeeping<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">,</span> ingredients<span class="Delimiter">);</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="SalientComment">//:: check types for 'call' instructions</span> + +<span class="Delimiter">:(scenario call_check_literal_recipe)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>call f<span class="Delimiter">,</span> <span class="Constant">34</span> +] +recipe f x:boolean <span class="Delimiter">-></span> y:boolean [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+error: main: ingredient 0 has the wrong type at '1:number <- call f, 34'</span> +<span class="traceContains">+error: main: product 0 has the wrong type at '1:number <- call f, 34'</span> + +<span class="Delimiter">:(scenario call_check_variable_recipe)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe boolean <span class="Delimiter">-></span> boolean<span class="Delimiter">)}</span><span class="Special"> <- </span>copy f + <span class="Constant">2</span>:number<span class="Special"> <- </span>call <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe boolean <span class="Delimiter">-></span> boolean<span class="Delimiter">)},</span> <span class="Constant">34</span> +] +recipe f x:boolean <span class="Delimiter">-></span> y:boolean [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+error: main: ingredient 0 has the wrong type at '2:number <- call {1: (recipe boolean -> boolean)}, 34'</span> +<span class="traceContains">+error: main: product 0 has the wrong type at '2:number <- call {1: (recipe boolean -> boolean)}, 34'</span> + +<span class="Delimiter">:(after "Transform.push_back(check_instruction)")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_indirect_calls_against_header<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> +<span class="Delimiter">:(code)</span> +void check_indirect_calls_against_header<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check 'call' instructions inside recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> + const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + const instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation != CALL<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// error raised above</span> + const reagent& callee = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!is_mu_recipe<span class="Delimiter">(</span>callee<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// error raised above</span> + const recipe callee_header = is_literal<span class="Delimiter">(</span>callee<span class="Delimiter">)</span> ? get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> callee<span class="Delimiter">.</span>value<span class="Delimiter">)</span> : from_reagent<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + if <span class="Delimiter">(</span>!callee_header<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long int i = <span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i-<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i-<span class="Comment">/*</span><span class="Comment">skip callee</span><span class="Comment">*/</span><span class="Constant">1</span> << <span class="Constant">" has the wrong type at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(</span>long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>callee_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + raise_error << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" has the wrong type at '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> + +recipe from_reagent<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"recipe"</span><span class="Delimiter">);</span> + recipe result_header<span class="Delimiter">;</span> <span class="Comment">// will contain only ingredients and products, nothing else</span> + result_header<span class="Delimiter">.</span>has_header = <span class="Constant">true</span><span class="Delimiter">;</span> + const string_tree* curr = r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>right<span class="Delimiter">;</span> + for <span class="Delimiter">(;</span> curr<span class="Delimiter">;</span> curr=curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>value == <span class="Constant">"->"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Comment">// skip delimiter</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + result_header<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"recipe:"</span>+curr<span class="Delimiter">-></span>value<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(;</span> curr<span class="Delimiter">;</span> curr=curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + result_header<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"recipe:"</span>+curr<span class="Delimiter">-></span>value<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> result_header<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +bool is_mu_recipe<span class="Delimiter">(</span>reagent r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"recipe"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"recipe-literal"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Comment">// End is_mu_recipe Cases</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(scenario copy_typecheck_recipe_variable)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># abc def</span> + <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe number <span class="Delimiter">-></span> number<span class="Delimiter">)}</span><span class="Special"> <- </span>copy f <span class="Comment"># store literal in a matching variable</span> + <span class="Delimiter">{</span><span class="Constant">2</span>: <span class="Delimiter">(</span>recipe boolean <span class="Delimiter">-></span> boolean<span class="Delimiter">)}</span><span class="Special"> <- </span>copy <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe number <span class="Delimiter">-></span> number<span class="Delimiter">)}</span> <span class="Comment"># mismatch between recipe variables</span> +] +recipe f x:number <span class="Delimiter">-></span> y:number [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+error: main: can't copy {1: (recipe number -> number)} to {2: (recipe boolean -> boolean)}; types don't match</span> + +<span class="Delimiter">:(scenario copy_typecheck_recipe_variable_2)</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>recipe number <span class="Delimiter">-></span> number<span class="Delimiter">)}</span><span class="Special"> <- </span>copy f <span class="Comment"># mismatch with a recipe literal</span> +] +recipe f x:boolean <span class="Delimiter">-></span> y:boolean [ + local-scope + load-ingredients + y<span class="Special"> <- </span>copy x +] +<span class="traceContains">+error: main: can't copy f to {1: (recipe number -> number)}; types don't match</span> + +<span class="Delimiter">:(before "End Matching Types For Literal(lhs)")</span> +if <span class="Delimiter">(</span>is_mu_recipe<span class="Delimiter">(</span>lhs<span class="Delimiter">))</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> rhs<span class="Delimiter">.</span>value<span class="Delimiter">))</span> <span class="Delimiter">{</span> + raise_error << <span class="Constant">"trying to store recipe "</span> << rhs<span class="Delimiter">.</span>name << <span class="Constant">" into "</span> << debug_string<span class="Delimiter">(</span>lhs<span class="Delimiter">)</span> << <span class="Constant">" but there's no such recipe</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> + const recipe& rrhs = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> rhs<span class="Delimiter">.</span>value<span class="Delimiter">);</span> + const recipe& rlhs = from_reagent<span class="Delimiter">(</span>lhs<span class="Delimiter">);</span> + for <span class="Delimiter">(</span>long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>rlhs<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>rrhs<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>rlhs<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> rrhs<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(</span>long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>rlhs<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>rrhs<span class="Delimiter">.</span>products<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!types_match<span class="Delimiter">(</span>rlhs<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> rrhs<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/038scheduler.cc.html b/html/062scheduler.cc.html index 56396b68..d772144e 100644 --- a/html/038scheduler.cc.html +++ b/html/062scheduler.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 038scheduler.cc</title> +<title>Mu - 062scheduler.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -13,8 +13,8 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .SalientComment { color: #00ffff; } .cSpecial { color: #008000; } .Comment { color: #9090ff; } @@ -38,7 +38,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario scheduler)</span> recipe f1 [ - start-running f2:recipe + start-running f2 <span class="Comment"># wait for f2 to run</span> <span class="Delimiter">{</span> jump-unless <span class="Constant">1</span>:number<span class="Delimiter">,</span> -<span class="Constant">1</span> @@ -147,11 +147,17 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Delimiter">:(replace{} "void run_main(int argc, char* argv[])")</span> void run_main<span class="Delimiter">(</span>int argc<span class="Delimiter">,</span> char* argv[]<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe_ordinal r = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">);</span> - if <span class="Delimiter">(</span>r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - routine* main_routine = new routine<span class="Delimiter">(</span>r<span class="Delimiter">);</span> - <span class="Comment">// Update main_routine</span> - run<span class="Delimiter">(</span>main_routine<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + routine* main_routine = new routine<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + <span class="Comment">// pass in commandline args as ingredients to main</span> + <span class="Comment">// todo: test this</span> + Current_routine = main_routine<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + vector<double> arg<span class="Delimiter">;</span> + arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_string<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> + current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>arg<span class="Delimiter">);</span> <span class="Delimiter">}</span> + run<span class="Delimiter">(</span>main_routine<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="SalientComment">//:: To schedule new routines to run, call 'start-running'.</span> @@ -186,7 +192,7 @@ case START_RUNNING: <span class="Delimiter">{</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!is_mu_recipe<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'start-running' should be a recipe, but got "</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'start-running' should be a recipe, but got "</span> << debug_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -222,7 +228,7 @@ recipe f1 [ <span class="Delimiter">:(scenario scheduler_interleaves_routines)</span> <span class="Special">% Scheduling_interval = 1;</span> recipe f1 [ - start-running f2:recipe + start-running f2 <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] @@ -231,7 +237,7 @@ recipe f2 [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+schedule: f1</span> -<span class="traceContains">+run: start-running f2:recipe</span> +<span class="traceContains">+run: start-running f2</span> <span class="traceContains">+schedule: f2</span> <span class="traceContains">+run: 3:number <- copy 0</span> <span class="traceContains">+schedule: f1</span> @@ -243,7 +249,7 @@ recipe f2 [ <span class="Delimiter">:(scenario start_running_takes_ingredients)</span> recipe f1 [ - start-running f2:recipe<span class="Delimiter">,</span> <span class="Constant">3</span> + start-running f2<span class="Delimiter">,</span> <span class="Constant">3</span> <span class="Comment"># wait for f2 to run</span> <span class="Delimiter">{</span> jump-unless <span class="Constant">1</span>:number<span class="Delimiter">,</span> -<span class="Constant">1</span> @@ -257,7 +263,7 @@ recipe f2 [ <span class="Delimiter">:(scenario start_running_returns_routine_id)</span> recipe f1 [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>start-running f2:recipe + <span class="Constant">1</span>:number<span class="Special"> <- </span>start-running f2 ] recipe f2 [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">44</span> @@ -300,7 +306,7 @@ recipe f1 [ <span class="Special">% Hide_errors = true;</span> <span class="Special">% Scheduling_interval = 2;</span> recipe f1 [ - start-running f2:recipe + start-running f2 <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] @@ -322,7 +328,7 @@ recipe f2 [ <span class="Delimiter">:(scenario scheduler_kills_orphans)</span> recipe main [ - start-running f1:recipe + start-running f1 <span class="Comment"># f1 never actually runs because its parent completes without waiting for it</span> ] recipe f1 [ @@ -353,7 +359,7 @@ bool has_completed_parent<span class="Delimiter">(</span>long long int routine_i <span class="Delimiter">:(scenario routine_state_test)</span> <span class="Special">% Scheduling_interval = 2;</span> recipe f1 [ - <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2:recipe + <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2 <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># race condition since we don't care about location 12</span> <span class="Comment"># thanks to Scheduling_interval, f2's one instruction runs in between here and completes</span> <span class="Constant">2</span>:number/state<span class="Special"> <- </span>routine-state <span class="Constant">1</span>:number/child-id @@ -475,7 +481,7 @@ case _DUMP_ROUTINES: <span class="Delimiter">{</span> <span class="Delimiter">:(scenario routine_discontinues_past_limit)</span> <span class="Special">% Scheduling_interval = 2;</span> recipe f1 [ - <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2:recipe + <span class="Constant">1</span>:number/child-id<span class="Special"> <- </span>start-running f2 limit-time <span class="Constant">1</span>:number/child-id<span class="Delimiter">,</span> <span class="Constant">10</span> <span class="Comment"># padding loop just to make sure f2 has time to completed</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">20</span> @@ -539,6 +545,26 @@ case LIMIT_TIME: <span class="Delimiter">{</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + +<span class="SalientComment">//:: make sure that each routine gets a different alloc to start</span> + +<span class="Delimiter">:(scenario new_concurrent)</span> +recipe f1 [ + start-running f2 + <span class="Constant">1</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Comment"># wait for f2 to complete</span> + <span class="Delimiter">{</span> + loop-unless <span class="Constant">4</span>:number/<span class="Special">raw</span> + <span class="Delimiter">}</span> +] +recipe f2 [ + <span class="Constant">2</span>:address:shared:number/<span class="Special">raw <- </span>new number:type + <span class="Comment"># hack: assumes scheduler implementation</span> + <span class="Constant">3</span>:boolean/<span class="Special">raw <- </span>equal <span class="Constant">1</span>:address:shared:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:address:shared:number/<span class="Special">raw</span> + <span class="Comment"># signal f2 complete</span> + <span class="Constant">4</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">1</span> +] +<span class="traceContains">+mem: storing 0 in location 3</span> </pre> </body> </html> diff --git a/html/039wait.cc.html b/html/063wait.cc.html index 057c54b6..08d4b049 100644 --- a/html/039wait.cc.html +++ b/html/063wait.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 039wait.cc</title> +<title>Mu - 063wait.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -39,7 +39,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario wait_for_location)</span> recipe f1 [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - start-running f2:recipe + start-running f2 wait-for-location <span class="Constant">1</span>:number <span class="Comment"># now wait for f2 to run and modify location 1 before using its value</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number @@ -100,7 +100,7 @@ for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</ <span class="Delimiter">:(scenario wait_for_routine)</span> recipe f1 [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">12</span>:number/routine<span class="Special"> <- </span>start-running f2:recipe + <span class="Constant">12</span>:number/routine<span class="Special"> <- </span>start-running f2 wait-for-routine <span class="Constant">12</span>:number/routine <span class="Comment"># now wait for f2 to run and modify location 1 before using its value</span> <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number diff --git a/html/070text.mu.html b/html/070text.mu.html index 38851b6c..fc695ef5 100644 --- a/html/070text.mu.html +++ b/html/070text.mu.html @@ -37,21 +37,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># to-text-line gets called implicitly in various places</span> <span class="Comment"># define it to be identical to 'to-text' by default</span> -<span class="muRecipe">recipe</span> to-text-line x:_elem<span class="muRecipe"> -> </span>y:address:array:character [ +<span class="muRecipe">recipe</span> to-text-line x:_elem<span class="muRecipe"> -> </span>y:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> y<span class="Special"> <- </span>to-text x ] <span class="Comment"># to-text on text is just the identity function</span> -<span class="muRecipe">recipe</span> to-text x:address:array:character<span class="muRecipe"> -> </span>y:address:array:character [ +<span class="muRecipe">recipe</span> to-text x:address:shared:array:character<span class="muRecipe"> -> </span>y:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $print [to-text text], 10/newline</span> <span class="muControl">reply</span> x ] -<span class="muRecipe">recipe</span> equal a:address:array:character, b:address:array:character<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> equal a:address:shared:array:character, b:address:shared:array:character<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> a-len:number<span class="Special"> <- </span>length *a @@ -84,8 +84,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">default-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + x:address:shared: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 ] memory-should-contain [ @@ -95,9 +95,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - 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">default-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + x:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:address:shared: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 ] memory-should-contain [ @@ -107,9 +107,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - 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">default-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + x:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:address:shared: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 ] memory-should-contain [ @@ -125,9 +125,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - 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">default-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + x:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:address:shared: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 ] memory-should-contain [ @@ -137,9 +137,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - 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">default-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + x:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:address:shared: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 ] memory-should-contain [ @@ -150,28 +150,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># A new type to help incrementally construct texts.</span> <span class="muData">container</span> buffer [ length:number - data:address:array:character + data:address:shared:array:character ] -<span class="muRecipe">recipe</span> new-buffer capacity:number<span class="muRecipe"> -> </span>result:address:buffer [ +<span class="muRecipe">recipe</span> new-buffer capacity:number<span class="muRecipe"> -> </span>result:address:shared:buffer [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>new <span class="Constant">buffer:type</span> len:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">length:offset</span> *len:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - s:address:address:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + s:address:address:shared:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *s<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity <span class="muControl">reply</span> result ] -<span class="muRecipe">recipe</span> grow-buffer in:address:buffer<span class="muRecipe"> -> </span>in:address:buffer [ +<span class="muRecipe">recipe</span> grow-buffer in:address:shared:buffer<span class="muRecipe"> -> </span>in:address:shared:buffer [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># double buffer size</span> - x:address:address:array:character<span class="Special"> <- </span>get-address *in, <span class="Constant">data:offset</span> + x:address:address:shared:array:character<span class="Special"> <- </span>get-address *in, <span class="Constant">data:offset</span> oldlen:number<span class="Special"> <- </span>length **x newlen:number<span class="Special"> <- </span>multiply oldlen, <span class="Constant">2</span> - olddata:address:array:character<span class="Special"> <- </span>copy *x + olddata:address:shared:array:character<span class="Special"> <- </span>copy *x *x<span class="Special"> <- </span>new <span class="Constant">character:type</span>, newlen <span class="Comment"># copy old contents</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -186,21 +186,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> buffer-full? in:address:buffer<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> buffer-full? in:address:shared:buffer<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>get *in, <span class="Constant">length:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:shared:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> capacity:number<span class="Special"> <- </span>length *s result<span class="Special"> <- </span>greater-or-equal len, capacity ] <span class="Comment"># most broadly applicable definition of append to a buffer: just call to-text</span> -<span class="muRecipe">recipe</span> append buf:address:buffer, x:_elem<span class="muRecipe"> -> </span>buf:address:buffer [ +<span class="muRecipe">recipe</span> append buf:address:shared:buffer, x:_elem<span class="muRecipe"> -> </span>buf:address:shared:buffer [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [append _elem to buffer], 10/newline</span> <span class="Constant">load-ingredients</span> - text:address:array:character<span class="Special"> <- </span>to-text x + text:address:shared:array:character<span class="Special"> <- </span>to-text x len:number<span class="Special"> <- </span>length *text i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -213,7 +213,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> append in:address:buffer, c:character<span class="muRecipe"> -> </span>in:address:buffer [ +<span class="muRecipe">recipe</span> append in:address:shared:buffer, c:character<span class="muRecipe"> -> </span>in:address:shared:buffer [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [append character to buffer], 10/newline</span> <span class="Constant">load-ingredients</span> @@ -233,7 +233,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> full? in<span class="Special"> <- </span>grow-buffer in <span class="Delimiter">}</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:shared:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> dest:address:character<span class="Special"> <- </span>index-address *s, *len *dest<span class="Special"> <- </span>copy c *len<span class="Special"> <- </span>add *len, <span class="Constant">1</span> @@ -242,20 +242,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> buffer-append-works [ run [ <span class="Constant">local-scope</span> - x:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> - s1:address:array:character<span class="Special"> <- </span>get *x:address:buffer, <span class="Constant">data:offset</span> - x:address:buffer<span class="Special"> <- </span>append x:address:buffer, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - x:address:buffer<span class="Special"> <- </span>append x:address:buffer, <span class="Constant">98</span> <span class="Comment"># 'b'</span> - x:address:buffer<span class="Special"> <- </span>append x:address:buffer, <span class="Constant">99</span> <span class="Comment"># 'c'</span> - s2:address:array:character<span class="Special"> <- </span>get *x:address:buffer, <span class="Constant">data:offset</span> - <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>equal s1:address:array:character, s2:address:array:character - <span class="Constant">2</span>:array:character/<span class="Special">raw <- </span>copy *s2:address:array:character + x:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> + s1:address:shared:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + x<span class="Special"> <- </span>append x, <span class="Constant">97</span> <span class="Comment"># 'a'</span> + x<span class="Special"> <- </span>append x, <span class="Constant">98</span> <span class="Comment"># 'b'</span> + x<span class="Special"> <- </span>append x, <span class="Constant">99</span> <span class="Comment"># 'c'</span> + s2:address:shared:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="Constant">1</span>:boolean/<span class="Special">raw <- </span>equal s1, s2 + <span class="Constant">2</span>:array:character/<span class="Special">raw <- </span>copy *s2 <span class="Constant"> +buffer-filled</span> - x:address:buffer<span class="Special"> <- </span>append x:address:buffer, <span class="Constant">100</span> <span class="Comment"># 'd'</span> - s3:address:array:character<span class="Special"> <- </span>get *x:address:buffer, <span class="Constant">data:offset</span> - <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal s1:address:array:character, s3:address:array:character - <span class="Constant">11</span>:number/<span class="Special">raw <- </span>get *x:address:buffer, <span class="Constant">length:offset</span> - <span class="Constant">12</span>:array:character/<span class="Special">raw <- </span>copy *s3:address:array:character + x<span class="Special"> <- </span>append x, <span class="Constant">100</span> <span class="Comment"># 'd'</span> + s3:address:shared:array:character<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="Constant">10</span>:boolean/<span class="Special">raw <- </span>equal s1, s3 + <span class="Constant">11</span>:number/<span class="Special">raw <- </span>get *x, <span class="Constant">length:offset</span> + <span class="Constant">12</span>:array:character/<span class="Special">raw <- </span>copy *s3 ] memory-should-contain [ <span class="Comment"># before +buffer-filled</span> @@ -280,11 +280,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> buffer-append-handles-backspace [ run [ <span class="Constant">local-scope</span> - x:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> + x:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> x<span class="Special"> <- </span>append x, <span class="Constant">97</span> <span class="Comment"># 'a'</span> x<span class="Special"> <- </span>append x, <span class="Constant">98</span> <span class="Comment"># 'b'</span> x<span class="Special"> <- </span>append x, <span class="Constant">8/backspace</span> - s:address:array:character<span class="Special"> <- </span>buffer-to-array x + s:address:shared:array:character<span class="Special"> <- </span>buffer-to-array x <span class="Constant">1</span>:array:character/<span class="Special">raw <- </span>copy *s ] memory-should-contain [ @@ -294,7 +294,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> to-text n:number<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> to-text n:number<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># is n zero?</span> @@ -312,14 +312,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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> + tmp:address:shared: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 + tmp:address:shared:buffer<span class="Special"> <- </span>append tmp, c <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># add sign</span> @@ -329,7 +329,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + buf:address:shared: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> @@ -347,7 +347,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> buffer-to-array in:address:buffer<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> buffer-to-array in:address:shared:buffer<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -356,7 +356,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> <span class="Constant">0</span> <span class="Delimiter">}</span> len:number<span class="Special"> <- </span>get *in, <span class="Constant">length:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:shared:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> <span class="Comment"># we can't just return s because it is usually the wrong length</span> result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -373,8 +373,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + <span class="Constant">1</span>:address:shared: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:shared: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> @@ -383,8 +383,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + <span class="Constant">1</span>:address:shared: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:shared: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> @@ -393,8 +393,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -403,7 +403,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> append a:address:array:character, b:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> append a:address:shared:array:character, b:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [append text to text], 10/newline</span> <span class="Constant">load-ingredients</span> @@ -445,10 +445,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[hello,]</span> + <span class="Constant">2</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[ world!]</span> + <span class="Constant">3</span>:address:shared:array:character/<span class="Special">raw <- </span>append <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello, world!]</span> @@ -457,19 +457,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[azc]</span> ] ] -<span class="muRecipe">recipe</span> replace s:address:array:character, oldc:character, newc:character<span class="muRecipe"> -> </span>s:address:array:character [ +<span class="muRecipe">recipe</span> replace s:address:shared:array:character, oldc:character, newc:character, from:number/optional<span class="muRecipe"> -> </span>s:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - from:number, _<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># default to 0</span> len:number<span class="Special"> <- </span>length *s i:number<span class="Special"> <- </span>find-next s, oldc, from done?:boolean<span class="Special"> <- </span>greater-or-equal i, len @@ -482,9 +481,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[zbc]</span> @@ -493,9 +492,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[abz]</span> @@ -504,9 +503,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> @@ -515,9 +514,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[banana]</span> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>replace <span class="Constant">1</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">2</span>:array:character<span class="Special"> <- </span><span class="Constant">[bznznz]</span> @@ -525,7 +524,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># replace underscores in first with remaining args</span> -<span class="muRecipe">recipe</span> interpolate template:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> interpolate template:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># consume just the template</span> <span class="Comment"># compute result-len, space to allocate for result</span> @@ -533,7 +532,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result-len:number<span class="Special"> <- </span>copy tem-len <span class="Delimiter">{</span> <span class="Comment"># while ingredients remain</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + a:address:shared:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="muControl">break-unless</span> arg-received? <span class="Comment"># result-len = result-len + arg.length - 1 (for the 'underscore' being replaced)</span> a-len:number<span class="Special"> <- </span>length *a @@ -543,13 +542,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> rewind-ingredients _<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># skip template</span> - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, result-len + result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, result-len <span class="Comment"># repeatedly copy sections of template and 'holes' into result</span> result-idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="Comment"># while arg received</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + a:address:shared:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="muControl">break-unless</span> arg-received? <span class="Comment"># copy template into result until '_'</span> <span class="Delimiter">{</span> @@ -603,10 +602,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc _]</span> + <span class="Constant">2</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc def]</span> @@ -615,10 +614,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[_, hello!]</span> + <span class="Constant">2</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">3</span>:address:shared:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc, hello!]</span> @@ -628,10 +627,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[hello, _]</span> + <span class="Constant">2</span>:address:shared:array:character/<span class="Special">raw <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">3</span>:address:shared:array:character/<span class="Special">raw <- </span>interpolate <span class="Constant">1</span>:address:shared:array:character/<span class="Special">raw</span>, <span class="Constant">2</span>:address:shared: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:shared:array:character/<span class="Special">raw</span> ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[hello, abc]</span> @@ -700,7 +699,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result<span class="Special"> <- </span>equal c, <span class="Constant">12288/ideographic-space</span> ] -<span class="muRecipe">recipe</span> trim s:address:array:character<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> trim s:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>length *s @@ -732,7 +731,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Comment"># result = new character[end+1 - start]</span> new-len:number<span class="Special"> <- </span>subtract end, start, <span class="Constant">-1</span> - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, new-len + result:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, new-len <span class="Comment"># copy the untrimmed parts between start and end</span> i:number<span class="Special"> <- </span>copy start j:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -752,9 +751,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> @@ -763,9 +762,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> @@ -774,9 +773,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc ]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> @@ -785,9 +784,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc ]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> @@ -796,21 +795,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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 + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>trim <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[abc]</span> ] ] -<span class="muRecipe">recipe</span> find-next text:address:array:character, pattern:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ +<span class="muRecipe">recipe</span> find-next text:address:shared:array:character, pattern:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ <span class="Constant">local-scope</span> - text:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - pattern:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - idx:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> len:number<span class="Special"> <- </span>length *text <span class="Delimiter">{</span> eof?:boolean<span class="Special"> <- </span>greater-or-equal idx, len @@ -826,8 +823,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -836,8 +833,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -846,8 +843,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -856,8 +853,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -866,8 +863,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -876,8 +873,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -886,8 +883,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -896,8 +893,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <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> @@ -906,7 +903,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># search for a pattern of multiple characters</span> <span class="Comment"># fairly dumb algorithm</span> -<span class="muRecipe">recipe</span> find-next text:address:array:character, pattern:address:array:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ +<span class="muRecipe">recipe</span> find-next text:address:shared:array:character, pattern:address:shared:array:character, idx:number<span class="muRecipe"> -> </span>next-index:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> first:character<span class="Special"> <- </span>index *pattern, <span class="Constant">0</span> @@ -928,9 +925,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <span class="Constant">0</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -939,9 +936,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <span class="Constant">1</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -950,9 +947,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -961,9 +958,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <span class="Constant">0</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -972,9 +969,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -982,7 +979,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># checks if pattern matches at index 'idx'</span> -<span class="muRecipe">recipe</span> match-at text:address:array:character, pattern:address:array:character, idx:number<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> match-at text:address:shared:array:character, pattern:address:shared:array:character, idx:number<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> pattern-len:number<span class="Special"> <- </span>length *pattern @@ -1015,9 +1012,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1026,8 +1023,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <span class="Constant">1</span>:address:shared:array:character, <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> @@ -1036,9 +1033,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1047,9 +1044,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1058,9 +1055,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1069,9 +1066,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1080,8 +1077,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared: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:shared:array:character, <span class="Constant">1</span>:address:shared:array:character, <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> @@ -1090,9 +1087,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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> @@ -1101,16 +1098,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared: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:shared:array:character, <span class="Constant">2</span>:address:shared:array:character, <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="muRecipe">recipe</span> split s:address:array:character, delim:character<span class="muRecipe"> -> </span>result:address:array:address:array:character [ +<span class="muRecipe">recipe</span> split s:address:shared:array:character, delim:character<span class="muRecipe"> -> </span>result:address:shared:array:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># empty text? return empty array</span> @@ -1118,7 +1115,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> empty?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">0</span> <span class="muControl">break-unless</span> empty? - result<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">0</span> + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address shared array character): type<span class="Delimiter">}</span>, <span class="Constant">0</span> <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># count #pieces we need room for</span> @@ -1133,7 +1130,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># allocate space</span> - result<span class="Special"> <- </span>new <span class="Constant">location:type</span>, count + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address shared array character): type<span class="Delimiter">}</span>, count <span class="Comment"># repeatedly copy slices start..end until delimiter into result[curr-result]</span> curr-result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> start:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -1143,8 +1140,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-if</span> done? end:number<span class="Special"> <- </span>find-next s, delim, start <span class="Comment"># copy start..end into result[curr-result]</span> - dest:address:address:array:character<span class="Special"> <- </span>index-address *result, curr-result - *dest<span class="Special"> <- </span>copy s, start, end + dest:address:address:shared:array:character<span class="Special"> <- </span>index-address *result, curr-result + *dest<span class="Special"> <- </span>copy-range s, start, end <span class="Comment"># slide over to next slice</span> start<span class="Special"> <- </span>add end, <span class="Constant">1</span> curr-result<span class="Special"> <- </span>add curr-result, <span class="Constant">1</span> @@ -1154,13 +1151,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:shared: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:shared:array:address:shared:array:character + <span class="Constant">4</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">0</span> + <span class="Constant">5</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared: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:shared:array:character + <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># length of result</span> @@ -1171,15 +1168,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:shared: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:shared:array:address:shared:array:character + <span class="Constant">4</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">0</span> + <span class="Constant">5</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">1</span> + <span class="Constant">6</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared: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:shared:array:character + <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:shared:array:character + <span class="Constant">30</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">6</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># length of result</span> @@ -1191,11 +1188,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:shared: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:shared:array:address:shared:array:character + <span class="Constant">4</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared: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:shared:array:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># length of result</span> @@ -1205,9 +1202,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:shared: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:shared:array:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty result</span> @@ -1216,17 +1213,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character<span class="Special"> <- </span>split <span class="Constant">1</span>:address:shared: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:shared:array:address:shared:array:character + <span class="Constant">4</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">0</span> + <span class="Constant">5</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">1</span> + <span class="Constant">6</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared:array:character, <span class="Constant">2</span> + <span class="Constant">7</span>:address:shared:array:character<span class="Special"> <- </span>index *<span class="Constant">2</span>:address:shared:array:address:shared: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:shared:array:character + <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">5</span>:address:shared:array:character + <span class="Constant">30</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">6</span>:address:shared:array:character + <span class="Constant">40</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">7</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># length of result</span> @@ -1237,7 +1234,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> split-first text:address:array:character, delim:character<span class="muRecipe"> -> </span>x:address:array:character, y:address:array:character [ +<span class="muRecipe">recipe</span> split-first text:address:shared:array:character, delim:character<span class="muRecipe"> -> </span>x:address:shared:array:character, y:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># empty text? return empty texts</span> @@ -1245,22 +1242,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> empty?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">0</span> <span class="muControl">break-unless</span> empty? - x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + x:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="muControl">reply</span> <span class="Delimiter">}</span> idx:number<span class="Special"> <- </span>find-next text, delim, <span class="Constant">0</span> - x:address:array:character<span class="Special"> <- </span>copy text, <span class="Constant">0</span>, idx + x:address:shared:array:character<span class="Special"> <- </span>copy-range text, <span class="Constant">0</span>, idx idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - y:address:array:character<span class="Special"> <- </span>copy text, idx, len + y:address:shared:array:character<span class="Special"> <- </span>copy-range text, idx, len ] <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> + <span class="Constant">2</span>:address:shared:array:character, <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>split-first <span class="Constant">1</span>:address:shared: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:shared:array:character + <span class="Constant">20</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">10</span>:array:character<span class="Special"> <- </span><span class="Constant">[a]</span> @@ -1268,7 +1265,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> copy buf:address:array:character, start:number, end:number<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> copy-range buf:address:shared:array:character, start:number, end:number<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if end is out of bounds, trim it</span> @@ -1276,7 +1273,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } end:number<span class="Special"> <- </span>min len, end <span class="Comment"># allocate space for result</span> len<span class="Special"> <- </span>subtract end, start - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len + result:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, len <span class="Comment"># copy start..end into result[curr-result]</span> src-idx:number<span class="Special"> <- </span>copy start dest-idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -1294,9 +1291,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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 <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>copy-range <span class="Constant">1</span>:address:shared: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:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[bc]</span> @@ -1305,9 +1302,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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 <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>copy-range <span class="Constant">1</span>:address:shared: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:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[c]</span> @@ -1316,9 +1313,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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 <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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>copy-range <span class="Constant">1</span>:address:shared: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:shared:array:character ] memory-should-contain [ <span class="Constant">3</span>:array:character<span class="Special"> <- </span><span class="Constant">[]</span> diff --git a/html/071channel.mu.html b/html/071channel.mu.html index ec4fc68d..e1e14aaf 100644 --- a/html/071channel.mu.html +++ b/html/071channel.mu.html @@ -45,9 +45,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:character, <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + <span class="Constant">2</span>:character, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">34</span> @@ -63,11 +63,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># A circular buffer contains values from index first-full up to (but not</span> <span class="Comment"># including) index first-empty. The reader always modifies it at first-full,</span> <span class="Comment"># while the writer always modifies it at first-empty.</span> - data:address:array:character + data:address:shared:array:character ] -<span class="Comment"># result:address:channel <- new-channel capacity:number</span> -<span class="muRecipe">recipe</span> new-channel capacity:number<span class="muRecipe"> -> </span>result:address:channel [ +<span class="muRecipe">recipe</span> new-channel capacity:number<span class="muRecipe"> -> </span>result:address:shared:channel [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>new <span class="Constant">channel:type</span> @@ -79,11 +78,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *free<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># result.data = new location[ingredient+1]</span> capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="Comment"># unused slot for 'full?' below</span> - dest:address:address:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + dest:address:address:shared:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *dest<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity ] -<span class="muRecipe">recipe</span> write chan:address:channel, val:character<span class="muRecipe"> -> </span>chan:address:channel [ +<span class="muRecipe">recipe</span> write chan:address:shared:channel, val:character<span class="muRecipe"> -> </span>chan:address:shared:channel [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -94,7 +93,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } wait-for-location *full-address <span class="Delimiter">}</span> <span class="Comment"># store val</span> - circular-buffer:address:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + circular-buffer:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> free:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-free:offset</span> dest:address:character<span class="Special"> <- </span>index-address *circular-buffer, *free *dest<span class="Special"> <- </span>copy val @@ -109,7 +108,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> read chan:address:channel<span class="muRecipe"> -> </span>result:character, chan:address:channel [ +<span class="muRecipe">recipe</span> read chan:address:shared:channel<span class="muRecipe"> -> </span>result:character, chan:address:shared:channel [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -121,7 +120,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Comment"># read result</span> full:address:number<span class="Special"> <- </span>get-address *chan, <span class="Constant">first-full:offset</span> - circular-buffer:address:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + circular-buffer:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> result<span class="Special"> <- </span>index *circular-buffer, *full <span class="Comment"># mark its slot as empty</span> *full<span class="Special"> <- </span>add *full, <span class="Constant">1</span> @@ -134,7 +133,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> clear-channel chan:address:channel<span class="muRecipe"> -> </span>chan:address:channel [ +<span class="muRecipe">recipe</span> clear-channel chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -146,9 +145,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-initialization [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> @@ -158,10 +157,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-write-increments-free [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first-full</span> @@ -171,11 +170,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-read-increments-full [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:channel - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-full:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-full</span> @@ -186,19 +185,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-wrap [ run [ <span class="Comment"># channel with just 1 slot</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> <span class="Comment"># write and read a value</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel <span class="Comment"># first-free will now be 1</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> <span class="Comment"># write second value, verify that first-free wraps</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-free:offset</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-free:offset</span> <span class="Comment"># read second value, verify that first-full wraps</span> - _, <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:channel - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:channel, <span class="Constant">first-full:offset</span> + _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:channel, <span class="Constant">first-full:offset</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first-free after first write</span> @@ -211,7 +210,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## helpers</span> <span class="Comment"># An empty channel has first-empty and first-full both at the same value.</span> -<span class="muRecipe">recipe</span> channel-empty? chan:address:channel<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> channel-empty? chan:address:shared:channel<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># return chan.first-full == chan.first-free</span> @@ -222,7 +221,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># A full channel has first-empty just before first-full, wasting one slot.</span> <span class="Comment"># (Other alternatives: <a href="https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)">https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)</a></span> -<span class="muRecipe">recipe</span> channel-full? chan:address:channel<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> channel-full? chan:address:shared:channel<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># tmp = chan.first-free + 1</span> @@ -240,19 +239,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result<span class="Special"> <- </span>equal full, tmp ] -<span class="Comment"># result:number <- channel-capacity chan:address:channel</span> -<span class="muRecipe">recipe</span> channel-capacity chan:address:channel<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">recipe</span> channel-capacity chan:address:shared:channel<span class="muRecipe"> -> </span>result:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - q:address:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> + q:address:shared:array:character<span class="Special"> <- </span>get *chan, <span class="Constant">data:offset</span> result<span class="Special"> <- </span>length *q ] <span class="muScenario">scenario</span> channel-new-empty-not-full [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> @@ -262,10 +260,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-write-not-empty [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> @@ -275,10 +273,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-write-full [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty?</span> @@ -288,11 +286,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> channel-read-not-full [ run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">34</span> - _, <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:channel - <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:channel - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:channel + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">34</span> + _, <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>read <span class="Constant">1</span>:address:shared:channel + <span class="Constant">2</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">1</span>:address:shared:channel + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-full? <span class="Constant">1</span>:address:shared:channel ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># empty?</span> @@ -301,12 +299,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># helper for channels of characters in particular</span> -<span class="muRecipe">recipe</span> buffer-lines in:address:channel, out:address:channel<span class="muRecipe"> -> </span>out:address:channel, in:address:channel [ +<span class="muRecipe">recipe</span> buffer-lines in:address:shared:channel, out:address:shared:channel<span class="muRecipe"> -> </span>out:address:shared:channel, in:address:shared:channel [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># repeat forever</span> <span class="Delimiter">{</span> - line:address:buffer<span class="Special"> <- </span>new-buffer, <span class="Constant">30</span> + line:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> <span class="Comment"># read characters from 'in' until newline, copy into line</span> <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> @@ -337,7 +335,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Comment"># copy line into 'out'</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - line-contents:address:array:character<span class="Special"> <- </span>get *line, <span class="Constant">data:offset</span> + line-contents:address:shared:array:character<span class="Special"> <- </span>get *line, <span class="Constant">data:offset</span> max:number<span class="Special"> <- </span>get *line, <span class="Constant">length:offset</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i, max @@ -353,36 +351,36 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> buffer-lines-blocks-until-newline [ run [ - <span class="Constant">1</span>:address:channel/stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - <span class="Constant">2</span>:address:channel/buffered-stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">1</span>:address:shared:channel/stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + <span class="Constant">2</span>:address:shared:channel/buffered-stdin<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin assert <span class="Constant">3</span>:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> init] <span class="Comment"># buffer stdin into buffered-stdin, try to read from buffered-stdin</span> - <span class="Constant">4</span>:number/buffer-routine<span class="Special"> <- </span>start-running <span class="Constant">buffer-lines:recipe</span>, <span class="Constant">1</span>:address:channel/stdin, <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">4</span>:number/buffer-routine<span class="Special"> <- </span>start-running buffer-lines, <span class="Constant">1</span>:address:shared:channel/stdin, <span class="Constant">2</span>:address:shared:channel/buffered-stdin wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">5</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin assert <span class="Constant">5</span>:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> buffer-lines bring-up] <span class="Comment"># write 'a'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> restart <span class="Constant">4</span>:number/buffer-routine wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">6</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">6</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin assert <span class="Constant">6</span>:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'a'] <span class="Comment"># write 'b'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">98/b</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">98/b</span> restart <span class="Constant">4</span>:number/buffer-routine wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin assert <span class="Constant">7</span>:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'b'] <span class="Comment"># write newline</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">10/newline</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10/newline</span> restart <span class="Constant">4</span>:number/buffer-routine wait-for-routine <span class="Constant">4</span>:number/buffer-routine - <span class="Constant">8</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:channel/buffered-stdin + <span class="Constant">8</span>:boolean<span class="Special"> <- </span>channel-empty? <span class="Constant">2</span>:address:shared:channel/buffered-stdin <span class="Constant">9</span>:boolean/completed?<span class="Special"> <- </span>not <span class="Constant">8</span>:boolean assert <span class="Constant">9</span>:boolean/completed?, [ F buffer-lines-blocks-until-newline: channel should contain data <span class="muRecipe">after</span> writing newline] diff --git a/html/072array.mu.html b/html/072array.mu.html index e4ab32a8..61b5e14e 100644 --- a/html/072array.mu.html +++ b/html/072array.mu.html @@ -33,8 +33,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <pre id='vimCodeElement'> <span class="muScenario">scenario</span> array-from-args [ run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new-array <span class="Constant">0</span>, <span class="Constant">1</span>, <span class="Constant">2</span> - <span class="Constant">2</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new-array <span class="Constant">0</span>, <span class="Constant">1</span>, <span class="Constant">2</span> + <span class="Constant">2</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># array length</span> @@ -45,7 +45,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># create an array out of a list of scalar args</span> -<span class="muRecipe">recipe</span> new-array [ +<span class="muRecipe">recipe</span> new-array<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> capacity:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -55,7 +55,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - result:address:array:character<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity + result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, capacity rewind-ingredients i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> diff --git a/html/073list.mu.html b/html/073list.mu.html index 2097a4e6..c184e73f 100644 --- a/html/073list.mu.html +++ b/html/073list.mu.html @@ -40,27 +40,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> list:_elem [ value:_elem - next:address:list:_elem + next:address:shared:list:_elem ] -<span class="muRecipe">recipe</span> push x:_elem, in:address:list:_elem<span class="muRecipe"> -> </span>in:address:list:_elem [ +<span class="muRecipe">recipe</span> push x:_elem, in:address:shared:list:_elem<span class="muRecipe"> -> </span>in:address:shared:list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:address:list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span> + result:address:shared:list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span> val:address:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">value:offset</span> *val<span class="Special"> <- </span>copy x - next:address:address:list:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">next:offset</span> + next:address:address:shared:list:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">next:offset</span> *next<span class="Special"> <- </span>copy in <span class="muControl">reply</span> result <span class="Comment"># needed explicitly because we need to replace 'in' with 'result'</span> ] -<span class="muRecipe">recipe</span> first in:address:list:_elem<span class="muRecipe"> -> </span>result:_elem [ +<span class="muRecipe">recipe</span> first in:address:shared:list:_elem<span class="muRecipe"> -> </span>result:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>get *in, <span class="Constant">value:offset</span> ] -<span class="muRecipe">recipe</span> rest in:address:list:_elem<span class="muRecipe"> -> </span>result:address:list:_elem/contained-in:in [ +<span class="muRecipe">recipe</span> rest in:address:shared:list:_elem<span class="muRecipe"> -> </span>result:address:shared:list:_elem/contained-in:in [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> @@ -68,15 +68,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> list-handling [ run [ - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:list:number - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:list:number - <span class="Constant">2</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:list:number - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:list:number - <span class="Constant">3</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:list:number - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:list:number - <span class="Constant">4</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:list:number - <span class="Constant">1</span>:address:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:list:number + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">2</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">3</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">4</span>:number<span class="Special"> <- </span>first <span class="Constant">1</span>:address:shared:list:number + <span class="Constant">1</span>:address:shared:list:number<span class="Special"> <- </span>rest <span class="Constant">1</span>:address:shared:list:number ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># empty to empty, dust to dust..</span> @@ -86,26 +86,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> to-text in:address:list:_elem<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> to-text in:address:shared:list:_elem<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [to text: list], 10/newline</span> <span class="Constant">load-ingredients</span> - buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> + buf:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> buf<span class="Special"> <- </span>to-buffer in, buf result<span class="Special"> <- </span>buffer-to-array buf ] <span class="Comment"># variant of 'to-text' which stops printing after a few elements (and so is robust to cycles)</span> -<span class="muRecipe">recipe</span> to-text-line in:address:list:_elem<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> to-text-line in:address:shared:list:_elem<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [to text line: list], 10/newline</span> <span class="Constant">load-ingredients</span> - buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> + buf:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> buf<span class="Special"> <- </span>to-buffer in, buf, <span class="Constant">6</span> <span class="Comment"># max elements to display</span> result<span class="Special"> <- </span>buffer-to-array buf ] -<span class="muRecipe">recipe</span> to-buffer in:address:list:_elem, buf:address:buffer<span class="muRecipe"> -> </span>buf:address:buffer [ +<span class="muRecipe">recipe</span> to-buffer in:address:shared:list:_elem, buf:address:shared:buffer<span class="muRecipe"> -> </span>buf:address:shared:buffer [ <span class="Constant">local-scope</span> <span class="CommentedCode">#? $print [to buffer: list], 10/newline</span> <span class="Constant">load-ingredients</span> @@ -118,13 +118,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } val:_elem<span class="Special"> <- </span>get *in, <span class="Constant">value:offset</span> buf<span class="Special"> <- </span>append buf, val <span class="Comment"># now prepare next</span> - next:address:list:_elem<span class="Special"> <- </span>rest in + next:address:shared:list:_elem<span class="Special"> <- </span>rest in nextn:number<span class="Special"> <- </span>copy next <span class="CommentedCode">#? buf <- append buf, nextn</span> <span class="muControl">reply-unless</span> next space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> buf<span class="Special"> <- </span>append buf, space:character - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[-> ]</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[-> ]</span> n:number<span class="Special"> <- </span>length *s buf<span class="Special"> <- </span>append buf, s <span class="Comment"># and recurse</span> @@ -143,13 +143,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># past recursion depth; insert ellipses and stop</span> - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[...]</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[...]</span> append buf, s ] <span class="muScenario">scenario</span> stash-on-list-converts-to-text [ run [ - x:address:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> + x:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> x<span class="Special"> <- </span>push <span class="Constant">5</span>, x x<span class="Special"> <- </span>push <span class="Constant">6</span>, x stash <span class="Constant">[foo foo]</span>, x @@ -161,8 +161,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> stash-handles-list-with-cycle [ run [ - x:address:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> - y:address:address:list:number<span class="Special"> <- </span>get-address *x, <span class="Constant">next:offset</span> + x:address:shared:list:number<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">0</span> + y:address:address:shared:list:number<span class="Special"> <- </span>get-address *x, <span class="Constant">next:offset</span> *y<span class="Special"> <- </span>copy x stash <span class="Constant">[foo foo]</span>, x ] diff --git a/html/075duplex_list.mu.html b/html/075duplex_list.mu.html index 4a0abcbb..d30afff6 100644 --- a/html/075duplex_list.mu.html +++ b/html/075duplex_list.mu.html @@ -36,42 +36,42 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> duplex-list:_elem [ value:_elem - next:address:duplex-list:_elem - prev:address:duplex-list:_elem + next:address:shared:duplex-list:_elem + prev:address:shared:duplex-list:_elem ] <span class="Comment"># should I say in/contained-in:result, allow ingredients to refer to products?</span> -<span class="muRecipe">recipe</span> push x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> push x:_elem, in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:address:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + result:address:shared:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> val:address:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">value:offset</span> *val<span class="Special"> <- </span>copy x - next:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">next:offset</span> + next:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *result, <span class="Constant">next:offset</span> *next<span class="Special"> <- </span>copy in <span class="Delimiter">{</span> <span class="muControl">break-unless</span> in - prev:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *in, <span class="Constant">prev:offset</span> + prev:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *in, <span class="Constant">prev:offset</span> *prev<span class="Special"> <- </span>copy result <span class="Delimiter">}</span> <span class="muControl">reply</span> result <span class="Comment"># needed explicitly because we need to replace 'in' with 'result'</span> ] -<span class="muRecipe">recipe</span> first in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:_elem [ +<span class="muRecipe">recipe</span> first in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>result:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> in, <span class="Constant">0</span> result<span class="Special"> <- </span>get *in, <span class="Constant">value:offset</span> ] -<span class="muRecipe">recipe</span> next in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem/contained-in:in [ +<span class="muRecipe">recipe</span> next in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:shared:duplex-list:_elem/contained-in:in [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> in, <span class="Constant">0</span> result<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> ] -<span class="muRecipe">recipe</span> prev in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem/contained-in:in [ +<span class="muRecipe">recipe</span> prev in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:shared:duplex-list:_elem/contained-in:in [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> in, <span class="Constant">0</span> @@ -84,24 +84,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># reserve locations 0, 1 and 2 to check for missing null check</span> <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">3</span>:address:duplex-list:character - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">3</span>:address:duplex-list:character - <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">8</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">8</span>:address:duplex-list:character - <span class="Constant">10</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">8</span>:address:duplex-list:character - <span class="Constant">11</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">8</span>:address:duplex-list:character - <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">12</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">4</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">13</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:duplex-list:character - <span class="Constant">14</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">3</span>:address:duplex-list:character, <span class="Constant">4</span>:address:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">3</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">3</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">8</span>:address:shared:duplex-list:character + <span class="Constant">10</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">8</span>:address:shared:duplex-list:character + <span class="Constant">11</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">8</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">12</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">13</span>:character<span class="Special"> <- </span>first <span class="Constant">4</span>:address:shared:duplex-list:character + <span class="Constant">14</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">3</span>:address:shared:duplex-list:character, <span class="Constant">4</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">0</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># no modifications to null pointers</span> @@ -121,15 +121,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># insert 'x' after 'in'</span> -<span class="muRecipe">recipe</span> insert x:_elem, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> insert x:_elem, in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - new-node:address:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + new-node:address:shared:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> val:address:_elem<span class="Special"> <- </span>get-address *new-node, <span class="Constant">value:offset</span> *val<span class="Special"> <- </span>copy x - next-node:address:duplex-list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> + next-node:address:shared:duplex-list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> <span class="Comment"># in.next = new-node</span> - y:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *in, <span class="Constant">next:offset</span> + y:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *in, <span class="Constant">next:offset</span> *y<span class="Special"> <- </span>copy new-node <span class="Comment"># new-node.prev = in</span> y<span class="Special"> <- </span>get-address *new-node, <span class="Constant">prev:offset</span> @@ -146,27 +146,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> inserting-into-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character <span class="Comment"># 2 points inside list</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># 2 points inside list</span> + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">2</span>:address:shared:duplex-list:character <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -182,28 +182,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> inserting-at-end-of-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character <span class="Comment"># 2 points inside list</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character <span class="Comment"># now at end of list</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># 2 points inside list</span> + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character <span class="Comment"># now at end of list</span> + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">2</span>:address:shared:duplex-list:character <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -219,26 +219,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> inserting-after-start-of-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>insert <span class="Constant">6</span>, <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">9</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">10</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">5</span> <span class="Comment"># scanning next</span> @@ -256,15 +256,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment">#</span> <span class="Comment"># Returns null if and only if list is empty. Beware: in that case any other</span> <span class="Comment"># pointers to the head are now invalid.</span> -<span class="muRecipe">recipe</span> remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> remove x:address:shared:duplex-list:_elem/contained-in:in, in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>in:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if 'x' is null, return</span> <span class="muControl">reply-unless</span> x - next-node:address:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">next:offset</span> - prev-node:address:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">prev:offset</span> + next-node:address:shared:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">next:offset</span> + prev-node:address:shared:duplex-list:_elem<span class="Special"> <- </span>get *x, <span class="Constant">prev:offset</span> <span class="Comment"># null x's pointers</span> - tmp:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *x, <span class="Constant">next:offset</span> + tmp:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *x, <span class="Constant">next:offset</span> *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> tmp<span class="Special"> <- </span>get-address *x, <span class="Constant">prev:offset</span> *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -288,21 +288,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> removing-from-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character <span class="Comment"># 2 points at second element</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># 2 points at second element</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">0</span> <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">8</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># remove returned non-null</span> @@ -316,19 +316,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> removing-from-start-of-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># scanning next, skipping deleted element</span> @@ -341,23 +341,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> removing-from-end-of-duplex-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">4</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">5</span>, <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># delete last element</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">0</span> + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">0</span> <span class="Comment"># check structure like before</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">6</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">8</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">5</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>prev <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">7</span>:character<span class="Special"> <- </span>first <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># remove returned non-null</span> @@ -371,8 +371,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> removing-from-singleton-list [ run [ - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>remove <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">1</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># back to an empty list</span> @@ -381,16 +381,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># remove values between 'start' and 'end' (both exclusive)</span> <span class="Comment"># also clear pointers back out from start/end for hygiene</span> -<span class="muRecipe">recipe</span> remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem/contained-in:start<span class="muRecipe"> -> </span>start:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> remove-between start:address:shared:duplex-list:_elem, end:address:shared:duplex-list:_elem/contained-in:start<span class="muRecipe"> -> </span>start:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> start <span class="Comment"># start->next->prev = 0</span> <span class="Comment"># start->next = end</span> - next:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *start, <span class="Constant">next:offset</span> + next:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *start, <span class="Constant">next:offset</span> nothing-to-delete?:boolean<span class="Special"> <- </span>equal *next, end <span class="muControl">reply-if</span> nothing-to-delete? - prev:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address **next, <span class="Constant">prev:offset</span> + prev:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address **next, <span class="Constant">prev:offset</span> *prev<span class="Special"> <- </span>copy <span class="Constant">0</span> *next<span class="Special"> <- </span>copy end <span class="muControl">reply-unless</span> end @@ -404,25 +404,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> remove-range [ <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">17</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">16</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">17</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">16</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:shared:duplex-list:character run [ <span class="Comment"># delete 16 onwards</span> <span class="Comment"># first pointer: to the third element</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>remove-between <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">0</span> + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>remove-between <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">0</span> <span class="Comment"># now check the list</span> - <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">5</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">7</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:duplex-list:character - <span class="Constant">8</span>:character<span class="Special"> <- </span>get *<span class="Constant">7</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">9</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">7</span>:address:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">5</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">7</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:character<span class="Special"> <- </span>get *<span class="Constant">7</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">9</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">7</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -434,29 +434,29 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> remove-range-to-end [ <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">17</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">16</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">18</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">17</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">16</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:shared:duplex-list:character run [ <span class="Comment"># delete 15, 16 and 17</span> <span class="Comment"># first pointer: to the third element</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character <span class="Comment"># second pointer: to the fifth element</span> - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:duplex-list:character - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:duplex-list:character - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:duplex-list:character - <span class="Constant">3</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:duplex-list:character - remove-between <span class="Constant">2</span>:address:duplex-list:character, <span class="Constant">3</span>:address:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">2</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:shared:duplex-list:character + <span class="Constant">3</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">3</span>:address:shared:duplex-list:character + remove-between <span class="Constant">2</span>:address:shared:duplex-list:character, <span class="Constant">3</span>:address:shared:duplex-list:character <span class="Comment"># now check the list</span> - <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">5</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">7</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:duplex-list:character - <span class="Constant">8</span>:character<span class="Special"> <- </span>get *<span class="Constant">7</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">9</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">7</span>:address:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">5</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">7</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:shared:duplex-list:character + <span class="Constant">8</span>:character<span class="Special"> <- </span>get *<span class="Constant">7</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">9</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">7</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -468,18 +468,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> remove-range-empty [ <span class="Comment"># construct a duplex list with six elements [13, 14, 15, 16, 17, 18]</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">0</span> - <span class="Constant">1</span>:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:duplex-list:character + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">14</span>, <span class="Constant">0</span> + <span class="Constant">1</span>:address:shared:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">13</span>, <span class="Constant">1</span>:address:shared:duplex-list:character run [ <span class="Comment"># delete 16 onwards</span> <span class="Comment"># first pointer: to the third element</span> - <span class="Constant">2</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - remove-between <span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">2</span>:address:duplex-list:character + <span class="Constant">2</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + remove-between <span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">2</span>:address:shared:duplex-list:character <span class="Comment"># now check the list</span> - <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">5</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:duplex-list:character - <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:duplex-list:character, <span class="Constant">value:offset</span> - <span class="Constant">7</span>:address:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:duplex-list:character + <span class="Constant">4</span>:character<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">5</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">1</span>:address:shared:duplex-list:character + <span class="Constant">6</span>:character<span class="Special"> <- </span>get *<span class="Constant">5</span>:address:shared:duplex-list:character, <span class="Constant">value:offset</span> + <span class="Constant">7</span>:address:shared:duplex-list:character<span class="Special"> <- </span>next <span class="Constant">5</span>:address:shared:duplex-list:character ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">13</span> @@ -489,20 +489,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># insert list beginning at 'new' after 'in'</span> -<span class="muRecipe">recipe</span> insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> insert-range in:address:shared:duplex-list:_elem, start:address:shared:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> in <span class="muControl">reply-unless</span> start - end:address:duplex-list:_elem<span class="Special"> <- </span>copy start + end:address:shared:duplex-list:_elem<span class="Special"> <- </span>copy start <span class="Delimiter">{</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next end/insert-range + next:address:shared:duplex-list:_elem<span class="Special"> <- </span>next end/insert-range <span class="muControl">break-unless</span> next end<span class="Special"> <- </span>copy next <span class="muControl">loop</span> <span class="Delimiter">}</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next in - dest:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *end, <span class="Constant">next:offset</span> + next:address:shared:duplex-list:_elem<span class="Special"> <- </span>next in + dest:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *end, <span class="Constant">next:offset</span> *dest<span class="Special"> <- </span>copy next <span class="Delimiter">{</span> <span class="muControl">break-unless</span> next @@ -515,23 +515,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *dest<span class="Special"> <- </span>copy in ] -<span class="muRecipe">recipe</span> append in:address:duplex-list:_elem, new:address:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> append in:address:shared:duplex-list:_elem, new:address:shared:duplex-list:_elem/contained-in:in<span class="muRecipe"> -> </span>in:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - last:address:duplex-list:_elem<span class="Special"> <- </span>last in - dest:address:address:duplex-list:_elem<span class="Special"> <- </span>get-address *last, <span class="Constant">next:offset</span> + last:address:shared:duplex-list:_elem<span class="Special"> <- </span>last in + dest:address:address:shared:duplex-list:_elem<span class="Special"> <- </span>get-address *last, <span class="Constant">next:offset</span> *dest<span class="Special"> <- </span>copy new <span class="muControl">reply-unless</span> new dest<span class="Special"> <- </span>get-address *new, <span class="Constant">prev:offset</span> *dest<span class="Special"> <- </span>copy last ] -<span class="muRecipe">recipe</span> last in:address:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> last in:address:shared:duplex-list:_elem<span class="muRecipe"> -> </span>result:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>copy in <span class="Delimiter">{</span> - next:address:duplex-list:_elem<span class="Special"> <- </span>next result + next:address:shared:duplex-list:_elem<span class="Special"> <- </span>next result <span class="muControl">break-unless</span> next result<span class="Special"> <- </span>copy next <span class="muControl">loop</span> @@ -539,7 +539,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># helper for debugging</span> -<span class="muRecipe">recipe</span> dump-from x:address:duplex-list:_elem [ +<span class="muRecipe">recipe</span> dump-from x:address:shared:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> $print x, <span class="Constant">[: ]</span> diff --git a/html/076stream.mu.html b/html/076stream.mu.html index 91861d7d..ec37fd4b 100644 --- a/html/076stream.mu.html +++ b/html/076stream.mu.html @@ -32,41 +32,41 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># new type to help incrementally read texts (arrays of characters)</span> <span class="muData">container</span> stream [ index:number - data:address:array:character + data:address:shared:array:character ] -<span class="muRecipe">recipe</span> new-stream s:address:array:character<span class="muRecipe"> -> </span>result:address:stream [ +<span class="muRecipe">recipe</span> new-stream s:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:stream [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>new <span class="Constant">stream:type</span> i:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">index:offset</span> *i<span class="Special"> <- </span>copy <span class="Constant">0</span> - d:address:address:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + d:address:address:shared:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *d<span class="Special"> <- </span>copy s ] -<span class="muRecipe">recipe</span> rewind-stream in:address:stream<span class="muRecipe"> -> </span>in:address:stream [ +<span class="muRecipe">recipe</span> rewind-stream in:address:shared:stream<span class="muRecipe"> -> </span>in:address:shared:stream [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> x:address:number<span class="Special"> <- </span>get-address *in, <span class="Constant">index:offset</span> *x<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> read-line in:address:stream<span class="muRecipe"> -> </span>result:address:array:character, in:address:stream [ +<span class="muRecipe">recipe</span> read-line in:address:shared:stream<span class="muRecipe"> -> </span>result:address:shared:array:character, in:address:shared:stream [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> idx:address:number<span class="Special"> <- </span>get-address *in, <span class="Constant">index:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:shared:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> next-idx:number<span class="Special"> <- </span>find-next s, <span class="Constant">10/newline</span>, *idx - result<span class="Special"> <- </span>copy s, *idx, next-idx + result<span class="Special"> <- </span>copy-range s, *idx, next-idx *idx<span class="Special"> <- </span>add next-idx, <span class="Constant">1</span> <span class="Comment"># skip newline</span> ] -<span class="muRecipe">recipe</span> end-of-stream? in:address:stream<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> end-of-stream? in:address:shared:stream<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> idx:number<span class="Special"> <- </span>get *in, <span class="Constant">index:offset</span> - s:address:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> + s:address:shared:array:character<span class="Special"> <- </span>get *in, <span class="Constant">data:offset</span> len:number<span class="Special"> <- </span>length *s result<span class="Special"> <- </span>greater-or-equal idx, len ] diff --git a/html/080display.cc.html b/html/080display.cc.html index 88a10a41..6e605255 100644 --- a/html/080display.cc.html +++ b/html/080display.cc.html @@ -14,7 +14,6 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #00a0a0; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } @@ -447,7 +446,6 @@ case CHECK_FOR_INTERACTION: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">text event</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>event<span class="Delimiter">.</span>key == TB_KEY_CTRL_C<span class="Delimiter">)</span> <span class="Delimiter">{</span> tb_shutdown<span class="Delimiter">();</span> -<span class="CommentedCode">//? LOG << "exit\n";</span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>event<span class="Delimiter">.</span>key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> event<span class="Delimiter">.</span>key = TB_KEY_BACKSPACE<span class="Delimiter">;</span> diff --git a/html/081print.mu.html b/html/081print.mu.html index 7bfdc7dc..4a25e071 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -20,6 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #ff6060; } +.CommentedCode { color: #6c6c6c; } .Delimiter { color: #a04060; } --> </style> @@ -40,7 +41,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } num-columns:number cursor-row:number cursor-column:number - data:address:array:screen-cell + data:address:shared:array:screen-cell ] <span class="muData">container</span> screen-cell [ @@ -48,7 +49,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } color:number ] -<span class="muRecipe">recipe</span> new-fake-screen w:number, h:number<span class="muRecipe"> -> </span>result:address:screen [ +<span class="muRecipe">recipe</span> new-fake-screen w:number, h:number<span class="muRecipe"> -> </span>result:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result<span class="Special"> <- </span>new <span class="Constant">screen:type</span> @@ -61,19 +62,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">cursor-column:offset</span> *column<span class="Special"> <- </span>copy <span class="Constant">0</span> bufsize:number<span class="Special"> <- </span>multiply *width, *height - buf:address:address:array:screen-cell<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + buf:address:address:shared:array:screen-cell<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *buf<span class="Special"> <- </span>new <span class="Constant">screen-cell:type</span>, bufsize result<span class="Special"> <- </span>clear-screen result ] -<span class="muRecipe">recipe</span> clear-screen screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-screen screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> screen <span class="Comment"># clear fake screen</span> - buf:address:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> + buf:address:shared:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> max:number<span class="Special"> <- </span>length *buf i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -98,9 +99,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } clear-display ] -<span class="muRecipe">recipe</span> sync-screen screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> sync-screen screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> - screen:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> screen sync-display @@ -108,11 +109,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># do nothing for fake screens</span> ] -<span class="muRecipe">recipe</span> fake-screen-is-empty? screen:address:screen<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> fake-screen-is-empty? screen:address:shared:screen<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> screen, <span class="Constant">1/true</span> - buf:address:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> + buf:address:shared:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> len:number<span class="Special"> <- </span>length *buf <span class="Delimiter">{</span> @@ -128,7 +129,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> <span class="Constant">1/true</span> ] -<span class="muRecipe">recipe</span> print screen:address:screen, c:character<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> print screen:address:shared:screen, c:character<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> @@ -161,6 +162,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-unless</span> legal? legal?<span class="Special"> <- </span>lesser-than *column, width <span class="muControl">reply-unless</span> legal? +<span class="CommentedCode">#? $print [print-character (], *row, [, ], *column, [): ], c, 10/newline</span> <span class="Comment"># special-case: newline</span> <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> @@ -179,7 +181,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># save character in fake screen</span> index:number<span class="Special"> <- </span>multiply *row, width index<span class="Special"> <- </span>add index, *column - buf:address:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> + buf:address:shared:array:screen-cell<span class="Special"> <- </span>get *screen, <span class="Constant">data:offset</span> len:number<span class="Special"> <- </span>length *buf <span class="Comment"># special-case: backspace</span> <span class="Delimiter">{</span> @@ -220,10 +222,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-character-at-top-left [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">2</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">3</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">2</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">3</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># width*height</span> @@ -235,10 +238,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-character-in-color [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97/a</span>, <span class="Constant">1/red</span> - <span class="Constant">2</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">3</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a, <span class="Constant">1/red</span> + <span class="Constant">2</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">3</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># width*height</span> @@ -250,12 +254,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-backspace-character [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">8</span> <span class="Comment"># backspace</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> - <span class="Constant">3</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">12</span>:character<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">12</span>:character/backspace + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> @@ -268,13 +274,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-extra-backspace-character [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">8</span> <span class="Comment"># backspace</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">8</span> <span class="Comment"># backspace</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> - <span class="Constant">3</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">12</span>:character<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">12</span>:character/backspace + <span class="Constant">12</span>:character<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">12</span>:character/backspace + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> @@ -287,13 +296,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-character-at-right-margin [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">98</span> <span class="Comment"># 'b'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">99</span> <span class="Comment"># 'c'</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> - <span class="Constant">3</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">12</span>:character<span class="Special"> <- </span>copy <span class="Constant">98/b</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">12</span>:character/b + <span class="Constant">13</span>:character<span class="Special"> <- </span>copy <span class="Constant">99/b</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">13</span>:character/c + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor column</span> @@ -308,13 +320,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-newline-character [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-row:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> - <span class="Constant">4</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">5</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-row:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">4</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">5</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -328,12 +342,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-newline-at-bottom-line [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-row:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-row:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -343,37 +358,43 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-character-at-bottom-right [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">98</span> <span class="Comment"># 'b'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">99</span> <span class="Comment"># 'c'</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">100</span> <span class="Comment"># 'd'</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-row:offset</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">cursor-column:offset</span> - <span class="Constant">4</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">5</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">11</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">11</span>:character/a + <span class="Constant">12</span>:character<span class="Special"> <- </span>copy <span class="Constant">98/b</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">12</span>:character/b + <span class="Constant">13</span>:character<span class="Special"> <- </span>copy <span class="Constant">99/c</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">13</span>:character/c + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/newline + <span class="Constant">14</span>:character<span class="Special"> <- </span>copy <span class="Constant">100/d</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">14</span>:character/d + <span class="Constant">2</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-row:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">cursor-column:offset</span> + <span class="Constant">4</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">20</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">4</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">2</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor column</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># width*height</span> - <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># unused</span> - <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> - <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># unused</span> - <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">100</span> <span class="Comment"># 'd' over 'b' and 'c' and newline</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># width*height</span> + <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># unused</span> + <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> + <span class="Constant">23</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># unused</span> + <span class="Constant">24</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> + <span class="Constant">25</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span> + <span class="Constant">26</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> + <span class="Constant">27</span><span class="Special"> <- </span><span class="Constant">100</span> <span class="Comment"># 'd' over 'b' and 'c' and newline</span> + <span class="Constant">28</span><span class="Special"> <- </span><span class="Constant">7</span> <span class="Comment"># white</span> + <span class="Constant">29</span><span class="Special"> <- </span><span class="Constant">0</span> ] ] -<span class="muRecipe">recipe</span> clear-line screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-line screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">0/nul</span> <span class="Comment"># if x exists, clear line in fake screen</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> screen @@ -385,7 +406,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } right:number<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> done?:boolean<span class="Special"> <- </span>greater-or-equal *column, right <span class="muControl">break-if</span> done? - print screen, <span class="Constant">[ ]</span> <span class="Comment"># implicitly updates 'column'</span> + print screen, space <span class="Comment"># implicitly updates 'column'</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># now back to where the cursor was</span> @@ -396,7 +417,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } clear-line-on-display ] -<span class="muRecipe">recipe</span> cursor-position screen:address:screen<span class="muRecipe"> -> </span>row:number, column:number [ +<span class="muRecipe">recipe</span> cursor-position screen:address:shared:screen<span class="muRecipe"> -> </span>row:number, column:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, lookup cursor in fake screen</span> @@ -409,7 +430,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } row, column<span class="Special"> <- </span>cursor-position-on-display ] -<span class="muRecipe">recipe</span> move-cursor screen:address:screen, new-row:number, new-column:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> move-cursor screen:address:shared:screen, new-row:number, new-column:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -427,35 +448,36 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> clear-line-erases-printed-characters [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> <span class="Comment"># print a character</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">97</span> <span class="Comment"># 'a'</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">10</span>:character/a <span class="Comment"># move cursor to start of line</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>move-cursor <span class="Constant">1</span>:address:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>move-cursor <span class="Constant">1</span>:address:shared:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> <span class="Comment"># clear line</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>clear-line <span class="Constant">1</span>:address:screen - <span class="Constant">2</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">3</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>clear-line <span class="Constant">1</span>:address:shared:screen + <span class="Constant">2</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">20</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:screen-cell ] <span class="Comment"># screen should be blank</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># width*height</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">7</span> - <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">7</span> - <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">7</span> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">7</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">7</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">15</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># width*height</span> + <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">22</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">23</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">24</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">25</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">26</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">27</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">28</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">29</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant">31</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant">32</span><span class="Special"> <- </span><span class="Constant">7</span> ] ] -<span class="muRecipe">recipe</span> cursor-down screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-down screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -476,7 +498,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-cursor-down-on-display ] -<span class="muRecipe">recipe</span> cursor-up screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-up screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -495,7 +517,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-cursor-up-on-display ] -<span class="muRecipe">recipe</span> cursor-right screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-right screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -516,7 +538,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-cursor-right-on-display ] -<span class="muRecipe">recipe</span> cursor-left screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-left screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -535,7 +557,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-cursor-left-on-display ] -<span class="muRecipe">recipe</span> cursor-to-start-of-line screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-to-start-of-line screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> row:number<span class="Special"> <- </span>cursor-position screen @@ -543,14 +565,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>move-cursor screen, row, column ] -<span class="muRecipe">recipe</span> cursor-to-next-line screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> cursor-to-next-line screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> screen<span class="Special"> <- </span>cursor-down screen screen<span class="Special"> <- </span>cursor-to-start-of-line screen ] -<span class="muRecipe">recipe</span> screen-width screen:address:screen<span class="muRecipe"> -> </span>width:number [ +<span class="muRecipe">recipe</span> screen-width screen:address:shared:screen<span class="muRecipe"> -> </span>width:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -563,7 +585,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } width<span class="Special"> <- </span>display-width ] -<span class="muRecipe">recipe</span> screen-height screen:address:screen<span class="muRecipe"> -> </span>height:number [ +<span class="muRecipe">recipe</span> screen-height screen:address:shared:screen<span class="muRecipe"> -> </span>height:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists, move cursor in fake screen</span> @@ -576,7 +598,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } height<span class="Special"> <- </span>display-height ] -<span class="muRecipe">recipe</span> hide-cursor screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> hide-cursor screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists (not real display), do nothing</span> @@ -588,7 +610,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } hide-cursor-on-display ] -<span class="muRecipe">recipe</span> show-cursor screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> show-cursor screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists (not real display), do nothing</span> @@ -600,7 +622,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } show-cursor-on-display ] -<span class="muRecipe">recipe</span> hide-screen screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> hide-screen screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists (not real display), do nothing</span> @@ -613,7 +635,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } hide-display ] -<span class="muRecipe">recipe</span> show-screen screen:address:screen<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> show-screen screen:address:shared:screen<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if x exists (not real display), do nothing</span> @@ -626,7 +648,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } show-display ] -<span class="muRecipe">recipe</span> print screen:address:screen, s:address:array:character<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> print screen:address:shared:screen, s:address:shared:array:character<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> @@ -655,11 +677,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-text-stops-at-right-margin [ run [ - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - <span class="Constant">1</span>:address:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:screen, <span class="Constant">2</span>:address:array:character - <span class="Constant">3</span>:address:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:screen, <span class="Constant">data:offset</span> - <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:screen-cell + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + <span class="Constant">1</span>:address:shared:screen<span class="Special"> <- </span>print <span class="Constant">1</span>:address:shared:screen, <span class="Constant">2</span>:address:shared:array:character + <span class="Constant">3</span>:address:shared:array:screen-cell<span class="Special"> <- </span>get *<span class="Constant">1</span>:address:shared:screen, <span class="Constant">data:offset</span> + <span class="Constant">4</span>:array:screen-cell<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:screen-cell ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># width*height</span> @@ -673,10 +695,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> print-integer screen:address:screen, n:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> print-integer screen:address:shared:screen, n:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> - screen:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> @@ -690,9 +711,48 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> <span class="Comment"># todo: other bases besides decimal</span> - s:address:array:character<span class="Special"> <- </span>to-text n + s:address:shared:array:character<span class="Special"> <- </span>to-text n screen<span class="Special"> <- </span>print screen, s, color, bg-color ] + +<span class="Comment"># for now, we can only print integers</span> +<span class="muRecipe">recipe</span> print screen:address:shared:screen, n:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default color to white</span> + <span class="muControl">break-if</span> color-found? + color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + <span class="Delimiter">}</span> + bg-color:number, bg-color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default bg-color to black</span> + <span class="muControl">break-if</span> bg-color-found? + bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> + <span class="Delimiter">}</span> + screen<span class="Special"> <- </span>print-integer screen, n, color, bg-color +] + +<span class="Comment"># addresses</span> +<span class="muRecipe">recipe</span> print screen:address:shared:screen, n:address:_elem<span class="muRecipe"> -> </span>screen:address:shared:screen [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default color to white</span> + <span class="muControl">break-if</span> color-found? + color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + <span class="Delimiter">}</span> + bg-color:number, bg-color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default bg-color to black</span> + <span class="muControl">break-if</span> bg-color-found? + bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> + <span class="Delimiter">}</span> + n2:number<span class="Special"> <- </span>copy n + screen<span class="Special"> <- </span>print-integer screen, n2, color, bg-color +] </pre> </body> </html> diff --git a/html/082scenario_screen.cc.html b/html/082scenario_screen.cc.html index 85ef4880..71522122 100644 --- a/html/082scenario_screen.cc.html +++ b/html/082scenario_screen.cc.html @@ -44,7 +44,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } scenario screen-in-scenario [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">97</span> <span class="Comment"># 'a'</span> + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -58,8 +59,10 @@ scenario screen-in-scenario [ scenario screen-in-scenario-unicode-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">955</span>/greek-small-lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">97</span>/a + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Constant">2</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -74,8 +77,10 @@ scenario screen-in-scenario-unicode-color [ scenario screen-in-scenario-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">955</span>/greek-small-lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">97</span>/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Constant">2</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white ] <span class="Comment"># screen-should-contain shows everything</span> screen-should-contain [ @@ -107,7 +112,8 @@ scenario screen-in-scenario-color [ scenario screen-in-scenario-error [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">97</span> <span class="Comment"># 'a'</span> + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -125,7 +131,8 @@ scenario screen-in-scenario-error [ scenario screen-in-scenario-color [ assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">97</span>/a<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97</span>/a + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a<span class="Delimiter">,</span> <span class="Constant">1</span>/red ] screen-should-contain-in-color <span class="Constant">2</span>/green<span class="Delimiter">,</span> [ <span class="Comment"># 01234</span> @@ -174,11 +181,11 @@ Name[r][<span class="Constant">"screen"</span>] = SCREEN<span class="D <span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> <span class="Comment">// rewrite `assume-screen width, height` to</span> -<span class="Comment">// `screen:address:screen <- new-fake-screen width, height`</span> +<span class="Comment">// `screen:address:shared:screen <- new-fake-screen width, height`</span> if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"assume-screen"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> curr<span class="Delimiter">.</span>name = <span class="Constant">"new-fake-screen"</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> - curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"screen:address:screen"</span><span class="Delimiter">));</span> + curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"screen:address:shared:screen"</span><span class="Delimiter">));</span> curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>SCREEN<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -235,18 +242,18 @@ struct raw_string_stream <span class="Delimiter">{</span> <span class="Delimiter">:(code)</span> void check_screen<span class="Delimiter">(</span>const string& expected_contents<span class="Delimiter">,</span> const int color<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> <span class="Comment">// not supported</span> - long long int screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">);</span> + long long int screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> int data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"data"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>data_offset >= <span class="Constant">0</span><span class="Delimiter">);</span> - long long int screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:array:character</span> - long long int screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">);</span> <span class="Comment">// type: array:character</span> + long long int screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> + long long int screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> int width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-columns"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> long long int screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> int height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-rows"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> long long int screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> raw_string_stream cursor<span class="Delimiter">(</span>expected_contents<span class="Delimiter">);</span> <span class="Comment">// todo: too-long expected_contents should fail</span> - long long int addr = screen_data_start+<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// skip length</span> + long long int addr = screen_data_start+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> cursor<span class="Delimiter">.</span>skip_whitespace_and_comments<span class="Delimiter">();</span> if <span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>at_end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -370,15 +377,15 @@ case _DUMP_SCREEN: <span class="Delimiter">{</span> <span class="Delimiter">:(code)</span> void dump_screen<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> <span class="Comment">// not supported</span> - long long int screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">);</span> + long long int screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> int width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-columns"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> long long int screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span> int height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"num-rows"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> long long int screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span> int data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"screen"</span><span class="Delimiter">),</span> <span class="Constant">"data"</span><span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>data_offset >= <span class="Constant">0</span><span class="Delimiter">);</span> - long long int screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:array:character</span> - long long int screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">);</span> <span class="Comment">// type: array:character</span> + long long int screen_data_location = screen_location+data_offset<span class="Delimiter">;</span> <span class="Comment">// type: address:shared:array:character</span> + long long int screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// type: array:character</span> assert<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_start<span class="Delimiter">)</span> == screen_width*screen_height<span class="Delimiter">);</span> long long int curr = screen_data_start+<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// skip length</span> for <span class="Delimiter">(</span>long long int row = <span class="Constant">0</span><span class="Delimiter">;</span> row < screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span> diff --git a/html/083scenario_screen_test.mu.html b/html/083scenario_screen_test.mu.html index 2fdd57bc..195d8a79 100644 --- a/html/083scenario_screen_test.mu.html +++ b/html/083scenario_screen_test.mu.html @@ -33,7 +33,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> print-character-at-top-left-2 [ assume-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> run [ - screen:address:screen<span class="Special"> <- </span>print screen:address:screen, <span class="Constant">97/a</span> + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen, <span class="Constant">1</span>:character/a ] screen-should-contain [ <span class="Constant"> .a .</span> @@ -45,11 +46,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ <span class="Comment"># print a character</span> - screen:address:screen<span class="Special"> <- </span>print screen:address:screen, <span class="Constant">97/a</span> + <span class="Constant">1</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + screen:address:shared:screen<span class="Special"> <- </span>print screen:address:shared:screen, <span class="Constant">1</span>:character/a <span class="Comment"># move cursor to start of line</span> - screen:address:screen<span class="Special"> <- </span>move-cursor screen:address:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> + screen:address:shared:screen<span class="Special"> <- </span>move-cursor screen:address:shared:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> <span class="Comment"># clear line</span> - screen:address:screen<span class="Special"> <- </span>clear-line screen:address:screen + screen:address:shared:screen<span class="Special"> <- </span>clear-line screen:address:shared:screen ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/084console.mu.html b/html/084console.mu.html index 4065e18b..f608bafe 100644 --- a/html/084console.mu.html +++ b/html/084console.mu.html @@ -55,31 +55,31 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> console [ current-event-index:number - events:address:array:event + events:address:shared:array:event ] -<span class="muRecipe">recipe</span> new-fake-console events:address:array:event<span class="muRecipe"> -> </span>result:address:console [ +<span class="muRecipe">recipe</span> new-fake-console events:address:shared:array:event<span class="muRecipe"> -> </span>result:address:shared:console [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:address:console<span class="Special"> <- </span>new <span class="Constant">console:type</span> - buf:address:address:array:event<span class="Special"> <- </span>get-address *result, <span class="Constant">events:offset</span> + result:address:shared:console<span class="Special"> <- </span>new <span class="Constant">console:type</span> + buf:address:address:shared:array:event<span class="Special"> <- </span>get-address *result, <span class="Constant">events:offset</span> *buf<span class="Special"> <- </span>copy events idx:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">current-event-index:offset</span> *idx<span class="Special"> <- </span>copy <span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> read-event console:address:console<span class="muRecipe"> -> </span>result:event, console:address:console, found?:boolean, quit?:boolean [ +<span class="muRecipe">recipe</span> read-event console:address:shared:console<span class="muRecipe"> -> </span>result:event, console:address:shared:console, found?:boolean, quit?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> console current-event-index:address:number<span class="Special"> <- </span>get-address *console, <span class="Constant">current-event-index:offset</span> - buf:address:array:event<span class="Special"> <- </span>get *console, <span class="Constant">events:offset</span> + buf:address:shared:array:event<span class="Special"> <- </span>get *console, <span class="Constant">events:offset</span> <span class="Delimiter">{</span> max:number<span class="Special"> <- </span>length *buf done?:boolean<span class="Special"> <- </span>greater-or-equal *current-event-index, max <span class="muControl">break-unless</span> done? - dummy:address:event<span class="Special"> <- </span>new <span class="Constant">event:type</span> + dummy:address:shared:event<span class="Special"> <- </span>new <span class="Constant">event:type</span> <span class="muControl">reply</span> *dummy, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">1/quit</span> <span class="Delimiter">}</span> result<span class="Special"> <- </span>index *buf, *current-event-index @@ -94,7 +94,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># variant of read-event for just keyboard events. Discards everything that</span> <span class="Comment"># isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get</span> <span class="Comment"># newlines, tabs, ctrl-d..</span> -<span class="muRecipe">recipe</span> read-key console:address:console<span class="muRecipe"> -> </span>result:character, console:address:console, found?:boolean, quit?:boolean [ +<span class="muRecipe">recipe</span> read-key console:address:shared:console<span class="muRecipe"> -> </span>result:character, console:address:shared:console, found?:boolean, quit?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> x:event, console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console @@ -105,7 +105,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> *c, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span> ] -<span class="muRecipe">recipe</span> send-keys-to-channel console:address:console, chan:address:channel, screen:address:screen<span class="muRecipe"> -> </span>console:address:console, chan:address:channel, screen:address:screen [ +<span class="muRecipe">recipe</span> send-keys-to-channel console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -119,7 +119,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> wait-for-event console:address:console<span class="muRecipe"> -> </span>console:address:console [ +<span class="muRecipe">recipe</span> wait-for-event console:address:shared:console<span class="muRecipe"> -> </span>console:address:shared:console [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -129,7 +129,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># use this helper to skip rendering if there's lots of other events queued up</span> -<span class="muRecipe">recipe</span> has-more-events? console:address:console<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> has-more-events? console:address:shared:console<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> diff --git a/html/085scenario_console.cc.html b/html/085scenario_console.cc.html index 061712fa..24311448 100644 --- a/html/085scenario_console.cc.html +++ b/html/085scenario_console.cc.html @@ -43,10 +43,10 @@ scenario keyboard-in-scenario [ type [abc] ] run [ - <span class="Constant">1</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">2</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">3</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">4</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">5</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">6</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">7</span>:character<span class="Delimiter">,</span> console:address:console<span class="Delimiter">,</span> <span class="Constant">8</span>:boolean<span class="Delimiter">,</span> <span class="Constant">9</span>:boolean<span class="Special"> <- </span>read-key console:address:console + <span class="Constant">1</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">2</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">3</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">4</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">5</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">6</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">7</span>:character<span class="Delimiter">,</span> console:address:shared:console<span class="Delimiter">,</span> <span class="Constant">8</span>:boolean<span class="Delimiter">,</span> <span class="Constant">9</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span> @@ -86,14 +86,16 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span> slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">,</span> r<span class="Delimiter">);</span> long long int num_events = count_events<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// initialize the events like in new-fake-console</span> - long long int size = num_events*size_of_event<span class="Delimiter">()</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> + long long int size = <span class="Comment">/*</span><span class="Comment">space for refcount</span><span class="Comment">*/</span><span class="Constant">1</span> + <span class="Comment">/*</span><span class="Comment">space for length</span><span class="Comment">*/</span><span class="Constant">1</span> + num_events*size_of_event<span class="Delimiter">();</span> ensure_space<span class="Delimiter">(</span>size<span class="Delimiter">);</span> long long int event_data_address = Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> event_data_address<span class="Delimiter">,</span> num_events<span class="Delimiter">);</span> - ++Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> + <span class="Comment">// store length</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> num_events<span class="Delimiter">);</span> + Current_routine<span class="Delimiter">-></span>alloc += <span class="Comment">/*</span><span class="Comment">skip refcount and length</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int 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> const instruction& curr = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"left-click"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'left-click' event starting at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'touch-event' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">);</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'type' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">,</span> TB_KEY_MOUSE_LEFT<span class="Delimiter">);</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'row' in 'mouse-event'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> to_integer<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">));</span> @@ -101,6 +103,7 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span> Current_routine<span class="Delimiter">-></span>alloc += size_of_event<span class="Delimiter">();</span> <span class="Delimiter">}</span> else if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"press"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'press' event starting at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> string key = curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>key<span class="Delimiter">))</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span><span class="Delimiter">,</span> to_integer<span class="Delimiter">(</span>key<span class="Delimiter">));</span> @@ -121,15 +124,18 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span> else <span class="Delimiter">{</span> <span class="Comment">// keyboard input</span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"type"</span><span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'type' event starting at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> const string& contents = curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> const char* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> long long int num_keyboard_events = unicode_length<span class="Delimiter">(</span>contents<span class="Delimiter">);</span> long long int curr = <span class="Constant">0</span><span class="Delimiter">;</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num_keyboard_events<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 'text' tag at "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">tag for 'text' variant of 'event' exclusive-container</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> uint32_t curr_character<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>curr < SIZE<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> tb_utf8_char_to_unicode<span class="Delimiter">(</span>&curr_character<span class="Delimiter">,</span> &raw_contents[curr]<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing character "</span> << curr_character << <span class="Constant">" at "</span> << Current_routine<span class="Delimiter">-></span>alloc+<span class="Constant">1</span> << end<span class="Delimiter">();</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc+<span class="Comment">/*</span><span class="Comment">skip exclusive container tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> curr_character<span class="Delimiter">);</span> curr += tb_utf8_char_length<span class="Delimiter">(</span>raw_contents[curr]<span class="Delimiter">);</span> Current_routine<span class="Delimiter">-></span>alloc += size_of_event<span class="Delimiter">();</span> @@ -140,9 +146,11 @@ case ASSUME_CONSOLE: <span class="Delimiter">{</span> <span class="Comment">// wrap the array of events in a console object</span> ensure_space<span class="Delimiter">(</span>size_of_console<span class="Delimiter">());</span> put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing console in "</span> << Current_routine<span class="Delimiter">-></span>alloc << end<span class="Delimiter">();</span> Current_routine<span class="Delimiter">-></span>alloc += size_of_console<span class="Delimiter">();</span> long long int console_address = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> CONSOLE<span class="Delimiter">);</span> - put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> event_data_address<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing console data in "</span> << console_address+<span class="Constant">2</span> << end<span class="Delimiter">();</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> console_address+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span>+<span class="Comment">/*</span><span class="Comment">offset of 'data' in container 'events'</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> event_data_address<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -216,15 +224,15 @@ scenario events-in-scenario [ ] run [ <span class="Comment"># 3 keyboard events; each event occupies 4 locations</span> - <span class="Constant">1</span>:event<span class="Special"> <- </span>read-event console:address:console - <span class="Constant">5</span>:event<span class="Special"> <- </span>read-event console:address:console - <span class="Constant">9</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">1</span>:event<span class="Special"> <- </span>read-event console:address:shared:console + <span class="Constant">5</span>:event<span class="Special"> <- </span>read-event console:address:shared:console + <span class="Constant">9</span>:event<span class="Special"> <- </span>read-event console:address:shared:console <span class="Comment"># mouse click</span> - <span class="Constant">13</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">13</span>:event<span class="Special"> <- </span>read-event console:address:shared:console <span class="Comment"># non-character keycode</span> - <span class="Constant">17</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">17</span>:event<span class="Special"> <- </span>read-event console:address:shared:console <span class="Comment"># final keyboard event</span> - <span class="Constant">21</span>:event<span class="Special"> <- </span>read-event console:address:console + <span class="Constant">21</span>:event<span class="Special"> <- </span>read-event console:address:shared:console ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># 'text'</span> @@ -313,7 +321,7 @@ long long int size_of_console<span class="Delimiter">()</span> <span class="Deli if <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"console"</span><span class="Delimiter">));</span> type_tree* type = new type_tree<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"console"</span><span class="Delimiter">));</span> - result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">);</span> + result = size_of<span class="Delimiter">(</span>type<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> delete type<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/086scenario_console_test.mu.html b/html/086scenario_console_test.mu.html index 8f0c8685..f36290b3 100644 --- a/html/086scenario_console_test.mu.html +++ b/html/086scenario_console_test.mu.html @@ -37,10 +37,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[abc]</span> ] run [ - <span class="Constant">1</span>:character, console:address:console, <span class="Constant">2</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">3</span>:character, console:address:console, <span class="Constant">4</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">5</span>:character, console:address:console, <span class="Constant">6</span>:boolean<span class="Special"> <- </span>read-key console:address:console - <span class="Constant">7</span>:character, console:address:console, <span class="Constant">8</span>:boolean<span class="Special"> <- </span>read-key console:address:console + <span class="Constant">1</span>:character, console:address:shared:console, <span class="Constant">2</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">3</span>:character, console:address:shared:console, <span class="Constant">4</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">5</span>:character, console:address:shared:console, <span class="Constant">6</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console + <span class="Constant">7</span>:character, console:address:shared:console, <span class="Constant">8</span>:boolean<span class="Special"> <- </span>read-key console:address:shared:console ] memory-should-contain [ <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span> diff --git a/html/091run_interactive.cc.html b/html/091run_interactive.cc.html index 703fd5c1..661ff83c 100644 --- a/html/091run_interactive.cc.html +++ b/html/091run_interactive.cc.html @@ -38,16 +38,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">:(scenario run_interactive_code)</span> recipe main [ <span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new [<span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">34</span>] - run-interactive <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new [<span class="Constant">1</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">34</span>] + run-interactive <span class="Constant">2</span>:address:shared:array:character <span class="Constant">3</span>:number/<span class="Special">raw <- </span>copy <span class="Constant">1</span>:number/<span class="Special">raw</span> ] <span class="traceContains">+mem: storing 34 in location 3</span> <span class="Delimiter">:(scenario run_interactive_empty)</span> recipe main [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>copy <span class="Constant">0</span>/unsafe + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character ] <span class="Comment"># result is null</span> <span class="traceContains">+mem: storing 0 in location 2</span> @@ -122,7 +122,7 @@ bool run_interactive<span class="Delimiter">(</span>long long int address<span c <span class="Comment">// call run(string) but without the scheduling</span> load<span class="Delimiter">(</span>string<span class="Delimiter">(</span><span class="Constant">"recipe! interactive [</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">)</span> + <span class="Constant">"local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"screen:address:screen <- next-ingredient</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"screen:address:shared:screen <- next-ingredient</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"$start-tracking-products</span><span class="cSpecial">\n</span><span class="Constant">"</span> + command + <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"$stop-tracking-products</span><span class="cSpecial">\n</span><span class="Constant">"</span> + @@ -187,15 +187,15 @@ load<span class="Delimiter">(</span>string<span class="Delimiter">(</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"recipe sandbox [</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"screen:address:screen/shared <- new-fake-screen 30, 5</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"r:number/routine_id <- start-running interactive:recipe, screen</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"screen:address:shared:screen <- new-fake-screen 30, 5</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"r:number/routine_id <- start-running interactive, screen</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"limit-time r, 100000/instructions</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"wait-for-routine r</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"sandbox-state:number <- routine-state r/routine_id</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"completed?:boolean <- equal sandbox-state, 1/completed</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"output:address:array:character <- $most-recent-products</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"warnings:address:array:character <- save-errors-warnings</span><span class="cSpecial">\n</span><span class="Constant">"</span> + - <span class="Constant">"stashes:address:array:character <- save-app-trace</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"output:address:shared:array:character <- $most-recent-products</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"warnings:address:shared:array:character <- save-errors-warnings</span><span class="cSpecial">\n</span><span class="Constant">"</span> + + <span class="Constant">"stashes:address:shared:array:character <- save-app-trace</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"$cleanup-run-interactive</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"reply output, warnings, screen, stashes, completed?</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> @@ -208,10 +208,10 @@ Recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimite <span class="Delimiter">:(scenario run_interactive_comments)</span> recipe main [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [<span class="Comment"># ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [<span class="Comment"># ab</span> add <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">2</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>run-interactive <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">2</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">3</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">2</span>:address:shared:array:character ] <span class="traceContains">+mem: storing 52 in location 4</span> @@ -305,9 +305,9 @@ case _CLEANUP_RUN_INTERACTIVE: <span class="Delimiter">{</span> <span class="Delimiter">:(scenario "run_interactive_converts_result_to_text")</span> recipe main [ <span class="Comment"># try to interactively add 2 and 2</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [add <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">2</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:array:character - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">2</span>:address:array:character/lookup + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [add <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">2</span>] + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">2</span>:address:shared:array:character/lookup ] <span class="Comment"># first letter in the output should be '4' in unicode</span> <span class="traceContains">+mem: storing 52 in location 11</span> @@ -315,13 +315,13 @@ recipe main [ <span class="Delimiter">:(scenario "run_interactive_returns_text")</span> recipe main [ <span class="Comment"># try to interactively add 2 and 2</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [ - x:address:array:character<span class="Special"> <- </span>new [a] - y:address:array:character<span class="Special"> <- </span>new [b] - z:address:array:character<span class="Special"> <- </span>append x:address:array:character<span class="Delimiter">,</span> y:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [ + x:address:shared:array:character<span class="Special"> <- </span>new [a] + y:address:shared:array:character<span class="Special"> <- </span>new [b] + z:address:shared:array:character<span class="Special"> <- </span>append x:address:shared:array:character<span class="Delimiter">,</span> y:address:shared:array:character ] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:array:character - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">2</span>:address:array:character/lookup + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">2</span>:address:shared:array:character/lookup ] <span class="Comment"># output contains "ab"</span> <span class="traceContains">+mem: storing 97 in location 11</span> @@ -330,10 +330,10 @@ recipe main [ <span class="Delimiter">:(scenario "run_interactive_returns_errors")</span> recipe main [ <span class="Comment"># run a command that generates an error</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [x:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [x:number<span class="Special"> <- </span>copy <span class="Constant">34</span> get x:number<span class="Delimiter">,</span> foo:offset] - <span class="Constant">2</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:array:character - <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:array:character/lookup + <span class="Constant">2</span>:address:shared:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character + <span class="Constant">10</span>:array:character<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:shared:array:character/lookup ] <span class="Comment"># error should be "unknown element foo in container number"</span> <span class="traceContains">+mem: storing 117 in location 11</span> @@ -345,10 +345,10 @@ get x:number<span class="Delimiter">,</span> foo:offset] <span class="Delimiter">:(scenario run_interactive_with_comment)</span> recipe main [ <span class="Comment"># 2 instructions, with a comment after the first</span> - <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>new [a:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abc</span> + <span class="Constant">1</span>:address:shared:array:number<span class="Special"> <- </span>new [a:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abc</span> b:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] - <span class="Constant">2</span>:address:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Delimiter">,</span> <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>run-interactive <span class="Constant">1</span>:address:shared:array:character ] <span class="Comment"># no errors</span> <span class="traceContains">+mem: storing 0 in location 3</span> @@ -365,8 +365,8 @@ void test_run_interactive_cleans_up_any_created_specializations<span class="Deli <span class="Comment">// run-interactive a call that specializes this recipe</span> run<span class="Delimiter">(</span><span class="Constant">"recipe main [</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">" 1:number/raw <- copy 0</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" 2:address:array:character <- new [foo 1:number/raw]</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" run-interactive 2:address:array:character</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" 2:address:shared:array:character <- new [foo 1:number/raw]</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" run-interactive 2:address:shared:array:character</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Recently_added_recipes<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// foo, main</span> <span class="Comment">// check that number of variants doesn't change</span> @@ -512,7 +512,6 @@ case RELOAD: <span class="Delimiter">{</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Recently_added_shape_shifting_recipes<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span class="CommentedCode">//? LOG << "erasing " << get(Recipe, Recently_added_shape_shifting_recipes.at(i)).name << '\n';</span> Recipe_ordinal<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)).</span>name<span class="Delimiter">);</span> Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recently_added_shape_shifting_recipes<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -539,7 +538,7 @@ case RELOAD: <span class="Delimiter">{</span> <span class="Delimiter">:(scenario reload_continues_past_error)</span> recipe main [ local-scope - x:address:array:character<span class="Special"> <- </span>new [recipe foo [ + x:address:shared:array:character<span class="Special"> <- </span>new [recipe foo [ get <span class="Constant">1234</span>:number<span class="Delimiter">,</span> foo:offset ]] reload x @@ -555,7 +554,7 @@ void test_reload_cleans_up_any_created_specializations<span class="Delimiter">() <span class="Comment">// a call that specializes this recipe</span> run<span class="Delimiter">(</span><span class="Constant">"recipe main [</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">" local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> - <span class="Constant">" x:address:array:character <- new [recipe foo x:_elem -> n:number [</span><span class="cSpecial">\n</span><span class="Constant">"</span> + <span class="Constant">" x:address:shared:array:character <- new [recipe foo x:_elem -> n:number [</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"load-ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"reply 34</span><span class="cSpecial">\n</span><span class="Constant">"</span> diff --git a/html/channel.mu.html b/html/channel.mu.html index 15a75d1f..98bd4066 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -32,7 +32,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <pre id='vimCodeElement'> <span class="Comment"># example program: communicating between routines using channels</span> -<span class="muRecipe">recipe</span> producer chan:address:channel<span class="muRecipe"> -> </span>chan:address:channel [ +<span class="muRecipe">recipe</span> producer chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ <span class="Comment"># produce characters 1 to 5 on a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> @@ -44,19 +44,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[produce: ]</span>, n, <span class="Constant">[ </span> <span class="Constant">]</span> - chan:address:channel<span class="Special"> <- </span>write chan, n + chan:address:shared:channel<span class="Special"> <- </span>write chan, n n<span class="Special"> <- </span>add n, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> consumer chan:address:channel<span class="muRecipe"> -> </span>chan:address:channel [ +<span class="muRecipe">recipe</span> consumer chan:address:shared:channel<span class="muRecipe"> -> </span>chan:address:shared:channel [ <span class="Comment"># consume and print integers from a channel</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> - n:character, chan:address:channel<span class="Special"> <- </span>read chan + n:character, chan:address:shared:channel<span class="Special"> <- </span>read chan <span class="Comment"># other threads might get between these prints</span> $print <span class="Constant">[consume: ]</span>, n:character, <span class="Constant">[ </span> <span class="Constant">]</span> @@ -66,10 +66,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> main [ <span class="Constant">local-scope</span> - chan:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">3</span> + chan:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">3</span> <span class="Comment"># create two background 'routines' that communicate by a channel</span> - routine1:character<span class="Special"> <- </span>start-running <span class="Constant">producer:recipe</span>, chan - routine2:character<span class="Special"> <- </span>start-running <span class="Constant">consumer:recipe</span>, chan + routine1:number<span class="Special"> <- </span>start-running producer, chan + routine2:number<span class="Special"> <- </span>start-running consumer, chan wait-for-routine routine1 wait-for-routine routine2 ] diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 16230411..2211f854 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -70,7 +70,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">]</span> ] run [ - screen:address:screen, console:address:console<span class="Special"> <- </span>chessboard screen:address:screen, console:address:console + screen:address:shared:screen, console:address:shared:console<span class="Special"> <- </span>chessboard screen:address:shared:screen, console:address:shared:console <span class="Comment"># icon for the cursor</span> screen<span class="Special"> <- </span>print screen, <span class="Constant">9251/␣</span> ] @@ -102,18 +102,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## Here's how 'chessboard' is implemented.</span> -<span class="muRecipe">recipe</span> chessboard screen:address:screen, console:address:console<span class="muRecipe"> -> </span>screen:address:screen, console:address:console [ +<span class="muRecipe">recipe</span> chessboard screen:address:shared:screen, console:address:shared:console<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - board:address:array:address:array:character<span class="Special"> <- </span>initial-position + board:address:shared:array:address:shared:array:character<span class="Special"> <- </span>initial-position <span class="Comment"># hook up stdin</span> - stdin:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - start-running <span class="Constant">send-keys-to-channel:recipe</span>, console, stdin, screen + stdin:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + start-running send-keys-to-channel, console, stdin, screen <span class="Comment"># buffer lines in stdin</span> - buffered-stdin:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> - start-running <span class="Constant">buffer-lines:recipe</span>, stdin, buffered-stdin + buffered-stdin:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + start-running buffer-lines, stdin, buffered-stdin <span class="Delimiter">{</span> - msg:address:array:character<span class="Special"> <- </span>new <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> + msg:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> <span class="Constant">]</span> print screen, msg cursor-to-next-line screen @@ -130,7 +130,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-to-next-line screen msg<span class="Special"> <- </span>new <span class="Constant">[move: ]</span> screen<span class="Special"> <- </span>print screen, msg - m:address:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin, screen + m:address:shared:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin, screen <span class="muControl">break-if</span> quit, <span class="Constant">+quit:label</span> buffered-stdin<span class="Special"> <- </span>clear-channel buffered-stdin <span class="Comment"># cleanup after error. todo: test this?</span> <span class="muControl">loop-if</span> error @@ -139,12 +139,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>clear-screen screen <span class="muControl">loop</span> <span class="Delimiter">}</span> + msg<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant"> +quit</span> ] <span class="SalientComment">## a board is an array of files, a file is an array of characters (squares)</span> -<span class="muRecipe">recipe</span> new-board initial-position:address:array:character<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">recipe</span> new-board initial-position:address:shared:array:character<span class="muRecipe"> -> </span>board:address:shared:array:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert(length(initial-position) == 64)</span> @@ -152,19 +153,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } correct-length?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">64</span> assert correct-length?, <span class="Constant">[chessboard had incorrect size]</span> <span class="Comment"># board is an array of pointers to files; file is an array of characters</span> - board<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">8</span> + board<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address shared array character): type<span class="Delimiter">}</span>, <span class="Constant">8</span> col:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col, <span class="Constant">8</span> <span class="muControl">break-if</span> done? - file:address:address:array:character<span class="Special"> <- </span>index-address *board, col + file:address:address:shared:array:character<span class="Special"> <- </span>index-address *board, col *file<span class="Special"> <- </span>new-file initial-position, col col<span class="Special"> <- </span>add col, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> new-file position:address:array:character, index:number<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> new-file position:address:shared:array:character, index:number<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> index<span class="Special"> <- </span>multiply index, <span class="Constant">8</span> @@ -181,10 +182,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> print-board screen:address:screen, board:address:array:address:array:character<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> print-board screen:address:shared:screen, board:address:shared:array:address:shared:array:character<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> row:number<span class="Special"> <- </span>copy <span class="Constant">7</span> <span class="Comment"># start printing from the top of the board</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> <span class="Comment"># print each row</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>lesser-than row, <span class="Constant">0</span> @@ -192,17 +194,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># print rank number as a legend</span> rank:number<span class="Special"> <- </span>add row, <span class="Constant">1</span> print-integer screen, rank - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ | ]</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ | ]</span> print screen, s <span class="Comment"># print each square in the row</span> col:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col:number, <span class="Constant">8</span> <span class="muControl">break-if</span> done?:boolean - f:address:array:character<span class="Special"> <- </span>index *board, col + f:address:shared:array:character<span class="Special"> <- </span>index *board, col c:character<span class="Special"> <- </span>index *f, row print screen, c - print screen, <span class="Constant">32/space</span> + print screen, space col<span class="Special"> <- </span>add col, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -219,7 +221,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>cursor-to-next-line screen ] -<span class="muRecipe">recipe</span> initial-position<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">recipe</span> initial-position<span class="muRecipe"> -> </span>board:address:shared:array:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Comment"># layout in memory (in raster order):</span> <span class="Comment"># R P _ _ _ _ p r</span> @@ -230,7 +232,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># B P _ _ _ _ p B</span> <span class="Comment"># N P _ _ _ _ p n</span> <span class="Comment"># R P _ _ _ _ p r</span> - initial-position:address:array:character<span class="Special"> <- </span>new-array <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">81/Q</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">113/q</span>, <span class="Constant">75/K</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">107/k</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span> + initial-position:address:shared:array:character<span class="Special"> <- </span>new-array <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">81/Q</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">113/q</span>, <span class="Constant">75/K</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">107/k</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span> <span class="CommentedCode">#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r,</span> <span class="CommentedCode">#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,</span> <span class="CommentedCode">#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, </span> @@ -245,8 +247,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> printing-the-board [ assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> run [ - <span class="Constant">1</span>:address:array:address:array:character/board<span class="Special"> <- </span>initial-position - screen:address:screen<span class="Special"> <- </span>print-board screen:address:screen, <span class="Constant">1</span>:address:array:address:array:character/board + <span class="Constant">1</span>:address:shared:array:address:shared:array:character/board<span class="Special"> <- </span>initial-position + screen:address:shared:screen<span class="Special"> <- </span>print-board screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:address:shared:array:character/board ] screen-should-contain [ <span class="Comment"># 012345678901234567890123456789</span> @@ -276,14 +278,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># prints only error messages to screen</span> -<span class="muRecipe">recipe</span> read-move stdin:address:channel, screen:address:screen<span class="muRecipe"> -> </span>result:address:move, quit?:boolean, error?:boolean, stdin:address:channel, screen:address:screen [ +<span class="muRecipe">recipe</span> read-move stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>result:address:shared:move, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> from-file:number, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin, screen <span class="muControl">reply-if</span> quit?, <span class="Constant">0/dummy</span>, quit?, error? <span class="muControl">reply-if</span> error?, <span class="Constant">0/dummy</span>, quit?, error? <span class="Comment"># construct the move object</span> - result:address:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> + result:address:shared:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> x:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">from-file:offset</span> *x<span class="Special"> <- </span>copy from-file x<span class="Special"> <- </span>get-address *result, <span class="Constant">from-rank:offset</span> @@ -306,7 +308,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># valid values for file: 0-7</span> -<span class="muRecipe">recipe</span> read-file stdin:address:channel, screen:address:screen<span class="muRecipe"> -> </span>file:number, quit:boolean, error:boolean, stdin:address:channel, screen:address:screen [ +<span class="muRecipe">recipe</span> read-file stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>file:number, quit:boolean, error:boolean, stdin:address:shared:channel, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin @@ -328,7 +330,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? - error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> + error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> print screen, error-message <span class="muControl">reply</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> @@ -337,7 +339,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal file, <span class="Constant">0</span> <span class="muControl">break-if</span> above-min - error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[file too low: ]</span> + error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[file too low: ]</span> print screen, error-message print screen, c cursor-to-next-line screen @@ -355,7 +357,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># valid values: 0-7, -1 (quit), -2 (error)</span> -<span class="muRecipe">recipe</span> read-rank stdin:address:channel, screen:address:screen<span class="muRecipe"> -> </span>rank:number, quit?:boolean, error?:boolean, stdin:address:channel, screen:address:screen [ +<span class="muRecipe">recipe</span> read-rank stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -> </span>rank:number, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin @@ -372,7 +374,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10</span> <span class="Comment"># newline</span> <span class="muControl">break-unless</span> newline? - error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> + error-message:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> print screen, error-message <span class="muControl">reply</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> @@ -399,14 +401,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span class="Comment"># return true on error</span> -<span class="muRecipe">recipe</span> expect-from-channel stdin:address:channel, expected:character, screen:address:screen<span class="muRecipe"> -> </span>result:boolean, stdin:address:channel, screen:address:screen [ +<span class="muRecipe">recipe</span> expect-from-channel stdin:address:shared:channel, expected:character, screen:address:shared:screen<span class="muRecipe"> -> </span>result:boolean, stdin:address:shared:channel, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character, stdin<span class="Special"> <- </span>read stdin <span class="Delimiter">{</span> match?:boolean<span class="Special"> <- </span>equal c, expected <span class="muControl">break-if</span> match? - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[expected character not found]</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[expected character not found]</span> print screen, s <span class="Delimiter">}</span> result<span class="Special"> <- </span>not match? @@ -415,8 +417,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> read-move-blocking [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running <span class="Constant">read-move:recipe</span>, <span class="Constant">1</span>:address:channel, screen:address:screen + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine <span class="Constant">2</span>:number <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id @@ -424,7 +426,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] <span class="Comment"># press 'a'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine <span class="Constant">2</span>:number @@ -433,7 +435,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a'] <span class="Comment"># press '2'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">50/'2'</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine <span class="Constant">2</span>:number @@ -442,7 +444,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2'] <span class="Comment"># press '-'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">45/'-'</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">45/'-'</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine <span class="Constant">2</span>:number @@ -451,7 +453,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span assert <span class="Constant">4</span>:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> hyphen 'a2-'] <span class="Comment"># press 'a'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine <span class="Constant">2</span>:number @@ -460,7 +462,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span assert <span class="Constant">4</span>:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a2-a'] <span class="Comment"># press '4'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">52/'4'</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">52/'4'</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' still waiting for input</span> wait-for-routine <span class="Constant">2</span>:number @@ -469,7 +471,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2-a4'] <span class="Comment"># press 'newline'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">10</span> <span class="Comment"># newline</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10</span> <span class="Comment"># newline</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' now completes</span> wait-for-routine <span class="Constant">2</span>:number @@ -487,8 +489,8 @@ F read-move-blocking: routine failed to terminate on newline] <span class="muScenario">scenario</span> read-move-quit [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running <span class="Constant">read-move:recipe</span>, <span class="Constant">1</span>:address:channel, screen:address:screen + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine <span class="Constant">2</span>:number <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id @@ -496,7 +498,7 @@ F read-move-blocking: routine failed to terminate on newline] assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-quit: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] <span class="Comment"># press 'q'</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">113/q</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">113/q</span> restart <span class="Constant">2</span>:number/routine <span class="Comment"># 'read-move' completes</span> wait-for-routine <span class="Constant">2</span>:number @@ -514,15 +516,15 @@ F read-move-quit: routine failed to terminate on 'q'] <span class="muScenario">scenario</span> read-move-illegal-file [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running <span class="Constant">read-move:recipe</span>, <span class="Constant">1</span>:address:channel, screen:address:screen + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine <span class="Constant">2</span>:number <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">50/'2'</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span> restart <span class="Constant">2</span>:number/routine wait-for-routine <span class="Constant">2</span>:number ] @@ -535,16 +537,16 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co <span class="muScenario">scenario</span> read-move-illegal-rank [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running <span class="Constant">read-move:recipe</span>, <span class="Constant">1</span>:address:channel, screen:address:screen + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine <span class="Constant">2</span>:number <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> restart <span class="Constant">2</span>:number/routine wait-for-routine <span class="Constant">2</span>:number ] @@ -557,16 +559,16 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co <span class="muScenario">scenario</span> read-move-empty [ assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> - <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running <span class="Constant">read-move:recipe</span>, <span class="Constant">1</span>:address:channel, screen:address:screen + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>new-channel <span class="Constant">2</span> + <span class="Constant">2</span>:number/routine<span class="Special"> <- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine <span class="Constant">2</span>:number <span class="Constant">3</span>:number<span class="Special"> <- </span>routine-state <span class="Constant">2</span>:number/id <span class="Constant">4</span>:boolean/waiting?<span class="Special"> <- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span> assert <span class="Constant">4</span>:boolean/waiting?, [ F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">10/newline</span> - <span class="Constant">1</span>:address:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:channel, <span class="Constant">97/a</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10/newline</span> + <span class="Constant">1</span>:address:shared:channel<span class="Special"> <- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span> restart <span class="Constant">2</span>:number/routine wait-for-routine <span class="Constant">2</span>:number ] @@ -576,14 +578,14 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co ] ] -<span class="muRecipe">recipe</span> make-move board:address:array:address:array:character, m:address:move<span class="muRecipe"> -> </span>board:address:array:address:array:character [ +<span class="muRecipe">recipe</span> make-move board:address:shared:array:address:shared:array:character, m:address:shared:move<span class="muRecipe"> -> </span>board:address:shared:array:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> from-file:number<span class="Special"> <- </span>get *m, <span class="Constant">from-file:offset</span> from-rank:number<span class="Special"> <- </span>get *m, <span class="Constant">from-rank:offset</span> to-file:number<span class="Special"> <- </span>get *m, <span class="Constant">to-file:offset</span> to-rank:number<span class="Special"> <- </span>get *m, <span class="Constant">to-rank:offset</span> - f:address:array:character<span class="Special"> <- </span>index *board, from-file + f:address:shared:array:character<span class="Special"> <- </span>index *board, from-file src:address:character/square<span class="Special"> <- </span>index-address *f, from-rank f<span class="Special"> <- </span>index *board, to-file dest:address:character/square<span class="Special"> <- </span>index-address *f, to-rank @@ -594,18 +596,18 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co <span class="muScenario">scenario</span> making-a-move [ assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> run [ - <span class="Constant">2</span>:address:array:address:array:character/board<span class="Special"> <- </span>initial-position - <span class="Constant">3</span>:address:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> - <span class="Constant">4</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:move, <span class="Constant">from-file:offset</span> + <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board<span class="Special"> <- </span>initial-position + <span class="Constant">3</span>:address:shared:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> + <span class="Constant">4</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">from-file:offset</span> *<span class="Constant">4</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">6/g</span> - <span class="Constant">5</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:move, <span class="Constant">from-rank:offset</span> + <span class="Constant">5</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">from-rank:offset</span> *<span class="Constant">5</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">1/'2'</span> - <span class="Constant">6</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:move, <span class="Constant">to-file:offset</span> + <span class="Constant">6</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">to-file:offset</span> *<span class="Constant">6</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">6/g</span> - <span class="Constant">7</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:move, <span class="Constant">to-rank:offset</span> + <span class="Constant">7</span>:address:number<span class="Special"> <- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">to-rank:offset</span> *<span class="Constant">7</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">3/'4'</span> - <span class="Constant">2</span>:address:array:address:array:character/board<span class="Special"> <- </span>make-move <span class="Constant">2</span>:address:array:address:array:character/board, <span class="Constant">3</span>:address:move - screen:address:screen<span class="Special"> <- </span>print-board screen:address:screen, <span class="Constant">2</span>:address:array:address:array:character/board + <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board<span class="Special"> <- </span>make-move <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board, <span class="Constant">3</span>:address:shared:move + screen:address:shared:screen<span class="Special"> <- </span>print-board screen:address:shared:screen, <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board ] screen-should-contain [ <span class="Comment"># 012345678901234567890123456789</span> diff --git a/html/counters.mu.html b/html/counters.mu.html index 495def81..e73a5581 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -31,24 +31,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># example program: maintain multiple counters with isolated lexical scopes</span> <span class="Comment"># (spaces)</span> -<span class="muRecipe">recipe</span> new-counter n:number<span class="muRecipe"> -> </span><span class="Constant">default-space</span>:address:array:location [ +<span class="muRecipe">recipe</span> new-counter n:number<span class="muRecipe"> -> </span><span class="Constant">default-space</span>:address:shared:array:location [ <span class="Constant">default-space</span><span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> <span class="Constant">load-ingredients</span> ] -<span class="muRecipe">recipe</span> increment-counter outer:address:array:location/names:new-counter, x:number<span class="muRecipe"> -> </span>n:number/space:<span class="Constant">1</span> [ +<span class="muRecipe">recipe</span> increment-counter outer:address:shared:array:location/names:new-counter, x:number<span class="muRecipe"> -> </span>n:number/space:<span class="Constant">1</span> [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Constant">0</span>:address:array:location/names:new-counter<span class="Special"> <- </span>copy outer <span class="Comment"># setup outer space; it *must* come from 'new-counter'</span> + <span class="Constant">0</span>:address:shared:array:location/names:new-counter<span class="Special"> <- </span>copy outer <span class="Comment"># setup outer space; it *must* come from 'new-counter'</span> n/space:<span class="Constant">1</span><span class="Special"> <- </span>add n/space:<span class="Constant">1</span>, x ] <span class="muRecipe">recipe</span> main [ <span class="Constant">local-scope</span> <span class="Comment"># counter A</span> - a:address:array:location<span class="Special"> <- </span>new-counter <span class="Constant">34</span> + a:address:shared:array:location<span class="Special"> <- </span>new-counter <span class="Constant">34</span> <span class="Comment"># counter B</span> - b:address:array:location<span class="Special"> <- </span>new-counter <span class="Constant">23</span> + b:address:shared:array:location<span class="Special"> <- </span>new-counter <span class="Constant">23</span> <span class="Comment"># increment both by 2 but in different ways</span> increment-counter a, <span class="Constant">1</span> b-value:number<span class="Special"> <- </span>increment-counter b, <span class="Constant">2</span> diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 11d1cb9d..ec683ce7 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -37,7 +37,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># temporary main for this layer: just render the given text at the given</span> <span class="Comment"># screen dimensions, then stop</span> -<span class="muRecipe">recipe!</span> main text:address:array:character [ +<span class="muRecipe">recipe!</span> main text:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console @@ -51,8 +51,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-text-to-screen [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> ] screen-should-contain [ <span class="Comment"># top line of screen reserved for menu</span> @@ -64,16 +64,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> editor-data [ <span class="Comment"># editable text: doubly linked list of characters (head contains a special sentinel)</span> - data:address:duplex-list:character - top-of-screen:address:duplex-list:character - bottom-of-screen:address:duplex-list:character + data:address:shared:duplex-list:character + top-of-screen:address:shared:duplex-list:character + bottom-of-screen:address:shared:duplex-list:character <span class="Comment"># location before cursor inside data</span> - before-cursor:address:duplex-list:character + before-cursor:address:shared:duplex-list:character <span class="Comment"># raw bounds of display area on screen</span> <span class="Comment"># always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen</span> left:number right:number + bottom:number <span class="Comment"># raw screen coordinates of cursor</span> cursor-row:number cursor-column:number @@ -82,7 +83,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span> <span class="Comment"># top/left/right constrain the screen area available to the new editor</span> <span class="Comment"># right is exclusive</span> -<span class="muRecipe">recipe</span> new-editor s:address:array:character, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data, screen:address:screen [ +<span class="muRecipe">recipe</span> new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:shared:editor-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> @@ -98,11 +99,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *x<span class="Special"> <- </span>copy <span class="Constant">1/top</span> x<span class="Special"> <- </span>get-address *result, <span class="Constant">cursor-column:offset</span> *x<span class="Special"> <- </span>copy left - init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + init:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *init - y:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">before-cursor:offset</span> + y:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">before-cursor:offset</span> *y<span class="Special"> <- </span>copy *init result<span class="Special"> <- </span>insert-text result, s <span class="Comment"># initialize cursor to top of screen</span> @@ -113,7 +114,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> <editor-initialization></span> ] -<span class="muRecipe">recipe</span> insert-text editor:address:editor-data, text:address:array:character<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> insert-text editor:address:shared:editor-data, text:address:shared:array:character<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> @@ -122,7 +123,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># now we can start appending the rest, character by character</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal idx, len <span class="muControl">break-if</span> done? @@ -139,8 +140,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initializes-without-data [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - <span class="Constant">1</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> - <span class="Constant">2</span>:editor-data<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:editor-data + <span class="Constant">1</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:address:shared:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:editor-data<span class="Special"> <- </span>copy *<span class="Constant">1</span>:address:shared:editor-data ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> @@ -149,8 +150,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># 5 (before cursor) <- the § sentinel</span> <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># left</span> <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># right (inclusive)</span> - <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column</span> + <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># bottom</span> + <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -162,7 +164,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Assumes cursor should be at coordinates (cursor-row, cursor-column) and</span> <span class="Comment"># updates before-cursor to match. Might also move coordinates if they're</span> <span class="Comment"># outside text.</span> -<span class="muRecipe">recipe</span> render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">recipe</span> render screen:address:shared:screen, editor:address:shared:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> @@ -170,8 +172,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen-height:number<span class="Special"> <- </span>screen-height screen right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> <span class="Comment"># traversing editor</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:address:shared:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> curr<span class="Special"> <- </span>next curr <span class="Comment"># traversing screen</span> <span class="Constant"> +render-loop-initialization</span> @@ -180,7 +182,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column:number<span class="Special"> <- </span>copy left cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> screen<span class="Special"> <- </span>move-cursor screen, row, column <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> @@ -228,7 +230,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + print screen, wrap-icon, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -242,7 +245,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - bottom-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span> *bottom-of-screen<span class="Special"> <- </span>copy curr <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> @@ -256,22 +259,31 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-column<span class="Special"> <- </span>copy column *before-cursor<span class="Special"> <- </span>copy prev <span class="Delimiter">}</span> + bottom:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom:offset</span> + *bottom<span class="Special"> <- </span>copy row <span class="muControl">reply</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> ] -<span class="muRecipe">recipe</span> clear-line-delimited screen:address:screen, column:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-line-delimited screen:address:shared:screen, column:number, right:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + bg-color:number, bg-color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default bg-color to black</span> + <span class="muControl">break-if</span> bg-color-found? + bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> + <span class="Delimiter">}</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + screen<span class="Special"> <- </span>print screen, space, <span class="Constant">7/white</span>, bg-color <span class="Comment"># foreground color is mostly unused except if the cursor shows up at this cell</span> column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if it's the real screen, use the optimized primitive</span> @@ -287,7 +299,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:screen, row:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -306,9 +318,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -321,8 +333,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-handles-offsets [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -334,9 +346,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines-at-offset [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -349,8 +361,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-wraps-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -369,8 +381,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-wraps-barely-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span> <span class="Comment"># end of the line</span> @@ -391,10 +403,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initializes-empty-text [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -412,10 +424,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> render-colors-comments [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -493,10 +505,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> render-colors-assignment [ assume-screen <span class="Constant">8/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 2585450c..e36c71db 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -37,16 +37,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># temporary main: interactive editor</span> <span class="Comment"># hit ctrl-c to exit</span> -<span class="muRecipe">recipe!</span> main text:address:array:character [ +<span class="muRecipe">recipe!</span> main text:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console - editor:address:editor-data<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> + editor:address:shared:editor-data<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> editor-event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, editor close-console ] -<span class="muRecipe">recipe</span> editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console, editor:address:editor-data [ +<span class="muRecipe">recipe</span> editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -55,7 +55,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - e:event, console:address:console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console + e:event, console:address:shared:console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? <span class="Comment"># only in tests</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> @@ -80,7 +80,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># process click, return if it was on current editor</span> -<span class="muRecipe">recipe</span> move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event<span class="muRecipe"> -> </span>in-focus?:boolean, editor:address:editor-data [ +<span class="muRecipe">recipe</span> move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event<span class="muRecipe"> -> </span>in-focus?:boolean, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">0/false</span> @@ -105,7 +105,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Variant of 'render' that only moves the cursor (coordinates and</span> <span class="Comment"># before-cursor). If it's past the end of a line, it 'slides' it left. If it's</span> <span class="Comment"># past the last line it positions at end of last line.</span> -<span class="muRecipe">recipe</span> snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor @@ -113,8 +113,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> screen-height:number<span class="Special"> <- </span>screen-height screen <span class="Comment"># count newlines until screen row</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:address:shared:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> curr<span class="Special"> <- </span>next curr row:number<span class="Special"> <- </span>copy <span class="Constant">1/top</span> column:number<span class="Special"> <- </span>copy left @@ -122,7 +122,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-row<span class="Special"> <- </span>copy target-row cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy target-column - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr @@ -190,7 +190,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Process an event 'e' and try to minimally update the screen.</span> <span class="Comment"># Set 'go-render?' to true to indicate the caller must perform a non-minimal update.</span> -<span class="muRecipe">recipe</span> handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event<span class="muRecipe"> -> </span>screen:address:screen, editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event<span class="muRecipe"> -> </span>screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -199,7 +199,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen-height:number<span class="Special"> <- </span>screen-height screen left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> save-row:number<span class="Special"> <- </span>copy *cursor-row @@ -230,10 +230,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> ] -<span class="muRecipe">recipe</span> insert-at-cursor editor:address:editor-data, c:character, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean [ +<span class="muRecipe">recipe</span> insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> insert c, *before-cursor *before-cursor<span class="Special"> <- </span>next *before-cursor cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> @@ -248,7 +248,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> <insert-character-special-case></span> <span class="Comment"># but mostly we'll just move the cursor right</span> *cursor-column<span class="Special"> <- </span>add *cursor-column, <span class="Constant">1</span> - next:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + next:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Delimiter">{</span> <span class="Comment"># at end of all text? no need to scroll? just print the character and leave</span> at-end?:boolean<span class="Special"> <- </span>equal next, <span class="Constant">0/null</span> @@ -268,7 +268,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> next at-right?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-column, screen-width <span class="muControl">break-if</span> at-right? - curr:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor move-cursor screen, save-row, save-column curr-column:number<span class="Special"> <- </span>copy save-column <span class="Delimiter">{</span> @@ -294,7 +294,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># helper for tests</span> -<span class="muRecipe">recipe</span> editor-render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">recipe</span> editor-render screen:address:shared:screen, editor:address:shared:editor-data<span class="muRecipe"> -> </span>screen:address:shared:screen, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> @@ -309,12 +309,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console <span class="Constant">[]</span> run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -326,17 +326,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> <span class="Comment"># on the 'b'</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -353,16 +353,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -373,17 +373,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -394,17 +394,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> @@ -415,19 +415,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Comment"># editor occupies only left half of screen</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on right half of screen</span> left-click <span class="Constant">3</span>, <span class="Constant">8</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -444,18 +444,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on first, 'menu' row</span> left-click <span class="Constant">0</span>, <span class="Constant">3</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ @@ -466,15 +466,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -487,9 +487,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ @@ -498,7 +498,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -511,16 +511,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of last line</span> type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -533,17 +533,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of non-last line</span> type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -557,16 +557,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -579,17 +579,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -603,17 +603,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> type <span class="Constant">[ef]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -627,14 +627,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -648,15 +648,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># type a letter</span> assume-console [ type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># no wrap yet</span> screen-should-contain [ @@ -671,7 +671,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># now wrap</span> screen-should-contain [ @@ -686,19 +686,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-line-on-insert-2 [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># type more text at the start</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ @@ -738,16 +738,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">4</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -764,16 +764,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -790,16 +790,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -827,14 +827,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -857,12 +857,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> insert-new-line-and-indent editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean [ +<span class="muRecipe">recipe</span> insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> screen-height:number<span class="Special"> <- </span>screen-height screen @@ -882,8 +882,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># indent if necessary</span> indent?:boolean<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">reply-unless</span> indent? - d:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:address:duplex-list:character<span class="Special"> <- </span>prev *before-cursor + d:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:address:shared:duplex-list:character<span class="Special"> <- </span>prev *before-cursor indent:number<span class="Special"> <- </span>line-indent end-of-previous-line, d i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> @@ -897,7 +897,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># takes a pointer 'curr' into the doubly-linked list and its sentinel, counts</span> <span class="Comment"># the number of spaces at the start of the line containing 'curr'.</span> -<span class="muRecipe">recipe</span> line-indent curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">recipe</span> line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character<span class="muRecipe"> -> </span>result:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -929,14 +929,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -949,8 +949,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -962,7 +962,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># line should be fully cleared</span> screen-should-contain [ @@ -976,10 +976,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> @@ -987,9 +987,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1000,10 +1000,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> @@ -1012,9 +1012,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press <span class="Constant">65506</span> <span class="Comment"># end paste</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1047,7 +1047,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-horizontal screen:address:screen, row:number, x:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> draw-horizontal screen:address:shared:screen, row:number, x:number, right:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 0f7a60da..243635b0 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -41,14 +41,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-two-spaces-on-tab [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -74,18 +74,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-backspace-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -105,7 +105,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } delete-previous-character?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">8/backspace</span> <span class="muControl">break-unless</span> delete-previous-character? <span class="Constant"> <backspace-character-begin></span> - editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character<span class="Special"> <- </span>delete-before-cursor editor, screen <span class="Constant"> <backspace-character-end></span> <span class="muControl">reply</span> <span class="Delimiter">}</span> @@ -114,19 +114,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># return values:</span> <span class="Comment"># go-render? - whether caller needs to update the screen</span> <span class="Comment"># backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc.</span> -<span class="muRecipe">recipe</span> delete-before-cursor editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ +<span class="muRecipe">recipe</span> delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - data:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + data:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Comment"># if at start of text (before-cursor at § sentinel), return</span> - prev:address:duplex-list:character<span class="Special"> <- </span>prev *before-cursor + prev:address:shared:duplex-list:character<span class="Special"> <- </span>prev *before-cursor go-render?, backspaced-cell<span class="Special"> <- </span>copy <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> <span class="muControl">reply-unless</span> prev trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[delete-before-cursor]</span> original-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> editor, scroll?:boolean<span class="Special"> <- </span>move-cursor-coordinates-left editor - backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + backspaced-cell:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor data<span class="Special"> <- </span>remove *before-cursor, data <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/*before-cursor</span> *before-cursor<span class="Special"> <- </span>copy prev go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -140,7 +140,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-unless</span> same-row? left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - curr:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column curr-column:number<span class="Special"> <- </span>copy cursor-column <span class="Delimiter">{</span> @@ -159,14 +159,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + screen<span class="Special"> <- </span>print screen, space go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] -<span class="muRecipe">recipe</span> move-cursor-coordinates-left editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-cursor-coordinates-left editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> @@ -198,7 +199,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> previous-character-is-newline? <span class="Comment"># compute length of previous line</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[switching to previous line]</span> - d:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + d:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> end-of-line:number<span class="Special"> <- </span>previous-line-length before-cursor, d *cursor-column<span class="Special"> <- </span>add left, end-of-line <span class="muControl">reply</span> @@ -211,7 +212,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># takes a pointer 'curr' into the doubly-linked list and its sentinel, counts</span> <span class="Comment"># the length of the previous line before the 'curr' pointer.</span> -<span class="muRecipe">recipe</span> previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">recipe</span> previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character<span class="muRecipe"> -> </span>result:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -234,17 +235,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-clears-last-line-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">0</span> <span class="Comment"># cursor at only character in final line</span> press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -261,10 +262,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-joins-and-wraps-lines-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> assume-console [ @@ -272,7 +273,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># resulting single line should wrap correctly</span> screen-should-contain [ @@ -287,9 +288,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-long-lines-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor in part of the screen with a long line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># confirm that it wraps</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -304,7 +305,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># resulting single line should wrap correctly and not overflow its bounds</span> screen-should-contain [ @@ -320,15 +321,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-delete-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -342,7 +343,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -358,18 +359,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } delete-next-character?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65522/delete</span> <span class="muControl">break-unless</span> delete-next-character? <span class="Constant"> <delete-character-begin></span> - editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character<span class="Special"> <- </span>delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character<span class="Special"> <- </span>delete-at-cursor editor, screen <span class="Constant"> <delete-character-end></span> <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-at-cursor editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ +<span class="muRecipe">recipe</span> delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - data:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - deleted-cell:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + data:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + deleted-cell:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-unless</span> deleted-cell currc:character<span class="Special"> <- </span>get *deleted-cell, <span class="Constant">value:offset</span> @@ -378,7 +379,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply-if</span> deleted-newline? <span class="Comment"># wasn't a newline? render rest of line</span> - curr:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Comment"># refresh after remove above</span> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Comment"># refresh after remove above</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, *cursor-row, *cursor-column @@ -400,7 +401,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + screen<span class="Special"> <- </span>print screen, space go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] @@ -408,16 +410,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ press right-arrow type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -433,7 +435,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-to-next-character?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65514/right-arrow</span> <span class="muControl">break-unless</span> move-to-next-character? <span class="Comment"># if not at end of text</span> - next-cursor:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + next-cursor:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="muControl">break-unless</span> next-cursor <span class="Comment"># scan to next character</span> <span class="Constant"> <move-cursor-begin></span> @@ -446,10 +448,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-cursor-coordinates-right editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> + before-cursor:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> @@ -476,7 +478,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-wrap?:boolean<span class="Special"> <- </span>equal *cursor-column, wrap-column <span class="muControl">break-unless</span> at-wrap? <span class="Comment"># and if next character isn't newline</span> - next:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + next:address:shared:duplex-list:character<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> next next-character:character<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> newline?:boolean<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> @@ -497,10 +499,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> assume-console [ @@ -510,7 +512,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow <span class="Comment"># next line</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># type something and ensure it goes where it should</span> @@ -518,7 +520,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -532,10 +534,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ press right-arrow press right-arrow @@ -544,7 +546,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -557,18 +559,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -587,9 +589,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> assume-console [ @@ -597,9 +599,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -610,9 +612,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -623,18 +625,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">4</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -652,10 +654,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> assume-console [ @@ -664,7 +666,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># new character should be in next line</span> screen-should-contain [ @@ -683,9 +685,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> @@ -693,7 +695,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -710,7 +712,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> move-to-previous-character? trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[left arrow]</span> <span class="Comment"># if not at start of text (before-cursor at § sentinel)</span> - prev:address:duplex-list:character<span class="Special"> <- </span>prev *before-cursor + prev:address:shared:duplex-list:character<span class="Special"> <- </span>prev *before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-unless</span> prev <span class="Constant"> <move-cursor-begin></span> @@ -725,10 +727,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> assume-console [ @@ -736,9 +738,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -750,11 +752,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> <span class="Comment"># the cursor)</span> @@ -764,7 +766,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -778,11 +780,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> assume-console [ @@ -791,7 +793,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># left-arrow should have had no effect</span> screen-should-contain [ @@ -807,11 +809,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> d] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ @@ -820,7 +822,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -835,9 +837,9 @@ d] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -852,9 +854,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> @@ -869,19 +871,19 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -892,7 +894,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -915,12 +917,12 @@ d] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-previous-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-to-previous-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> already-at-top?:boolean<span class="Special"> <- </span>lesser-or-equal *cursor-row, <span class="Constant">1/top</span> @@ -930,13 +932,13 @@ d] <span class="Comment"># if not at newline, move to start of line (previous newline)</span> <span class="Comment"># then scan back another line</span> <span class="Comment"># if either step fails, give up without modifying cursor or coordinates</span> - curr:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor <span class="Delimiter">{</span> - old:address:duplex-list:character<span class="Special"> <- </span>copy curr + old:address:shared:duplex-list:character<span class="Special"> <- </span>copy curr c2:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> at-newline?:boolean<span class="Special"> <- </span>equal c2, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr:address:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor no-motion?:boolean<span class="Special"> <- </span>equal curr, old go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-if</span> no-motion? @@ -956,7 +958,7 @@ d] <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-column, target-column <span class="muControl">break-if</span> done? - curr:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="muControl">break-unless</span> curr currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> @@ -980,19 +982,19 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1003,7 +1005,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1016,19 +1018,19 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [ + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [ def] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1039,7 +1041,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1053,11 +1055,11 @@ def] <span class="muScenario">scenario</span> editor-moves-to-previous-line-from-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> assume-console [ @@ -1065,9 +1067,9 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1078,7 +1080,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1093,19 +1095,19 @@ def] <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> assume-console [ press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ @@ -1117,7 +1119,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1140,12 +1142,12 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-next-line editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-to-next-line editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> last-line:number<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> @@ -1155,7 +1157,7 @@ def] <span class="muControl">break-if</span> already-at-bottom? <span class="Comment"># scan to start of next line, then to right column or until end of line</span> max:number<span class="Special"> <- </span>subtract right, left - next-line:address:duplex-list:character<span class="Special"> <- </span>before-start-of-next-line *before-cursor, max + next-line:address:shared:duplex-list:character<span class="Special"> <- </span>before-start-of-next-line *before-cursor, max <span class="Delimiter">{</span> <span class="Comment"># already at end of buffer? try to scroll up (so we can see more</span> <span class="Comment"># warnings or sandboxes below)</span> @@ -1173,7 +1175,7 @@ def] <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-column, target-column <span class="muControl">break-if</span> done? - curr:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="muControl">break-unless</span> curr currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> @@ -1193,19 +1195,19 @@ def] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1216,7 +1218,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1231,10 +1233,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ @@ -1242,9 +1244,9 @@ def] press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1280,7 +1282,7 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> move-to-start-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> @@ -1288,8 +1290,8 @@ def] cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy left <span class="Comment"># update before-cursor</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - init:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + init:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> at-start-of-text?:boolean<span class="Special"> <- </span>equal *before-cursor, init @@ -1305,10 +1307,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ @@ -1316,9 +1318,9 @@ def] press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1330,9 +1332,9 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ @@ -1340,9 +1342,9 @@ def] press home ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1354,10 +1356,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ @@ -1365,9 +1367,9 @@ def] press home ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1381,10 +1383,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ @@ -1392,9 +1394,9 @@ def] press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1407,9 +1409,9 @@ def] type <span class="Constant">[z]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1451,14 +1453,14 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> move-to-end-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> - next:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + next:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="muControl">break-unless</span> next <span class="Comment"># end of text</span> nextc:character<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> at-end-of-line?:boolean<span class="Special"> <- </span>equal nextc, <span class="Constant">10/newline</span> @@ -1471,10 +1473,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ @@ -1482,9 +1484,9 @@ def] press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1496,10 +1498,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ @@ -1507,9 +1509,9 @@ def] press end ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1521,10 +1523,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ @@ -1532,9 +1534,9 @@ def] press end ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1548,16 +1550,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1574,21 +1576,21 @@ def] delete-to-start-of-line?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">21/ctrl-u</span> <span class="muControl">break-unless</span> delete-to-start-of-line? <span class="Constant"> <delete-to-start-of-line-begin></span> - deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-start-of-line editor + deleted-cells:address:shared:duplex-list:character<span class="Special"> <- </span>delete-to-start-of-line editor <span class="Constant"> <delete-to-start-of-line-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character, editor:address:editor-data [ +<span class="muRecipe">recipe</span> delete-to-start-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:duplex-list:character, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - init:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - start:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor - end:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + init:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + start:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + end:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Delimiter">{</span> at-start-of-text?:boolean<span class="Special"> <- </span>equal start, init <span class="muControl">break-if</span> at-start-of-text? @@ -1600,7 +1602,7 @@ def] <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result:address:duplex-list:character<span class="Special"> <- </span>next start + result:address:shared:duplex-list:character<span class="Special"> <- </span>next start remove-between start, end <span class="Comment"># adjust cursor</span> *before-cursor<span class="Special"> <- </span>copy start @@ -1611,16 +1613,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line (no newline before), press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1634,16 +1636,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line, press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1657,16 +1659,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of final line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1682,16 +1684,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line, press ctrl-k</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1708,19 +1710,19 @@ def] delete-to-end-of-line?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">11/ctrl-k</span> <span class="muControl">break-unless</span> delete-to-end-of-line? <span class="Constant"> <delete-to-end-of-line-begin></span> - deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-end-of-line editor + deleted-cells:address:shared:duplex-list:character<span class="Special"> <- </span>delete-to-end-of-line editor <span class="Constant"> <delete-to-end-of-line-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character, editor:address:editor-data [ +<span class="muRecipe">recipe</span> delete-to-end-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:duplex-list:character, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - start:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>next start + start:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + end:address:shared:duplex-list:character<span class="Special"> <- </span>next start <span class="Delimiter">{</span> at-end-of-text?:boolean<span class="Special"> <- </span>equal end, <span class="Constant">0/null</span> <span class="muControl">break-if</span> at-end-of-text? @@ -1737,16 +1739,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line (no newline after), press ctrl-k</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1760,16 +1762,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes just last character</span> screen-should-contain [ @@ -1783,16 +1785,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1806,16 +1808,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes just the final character</span> screen-should-contain [ @@ -1829,16 +1831,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1856,11 +1858,11 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1873,7 +1875,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -1886,11 +1888,11 @@ def] <span class="muRecipe">after</span> <span class="Constant"><scroll-down></span> [ trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> max:number<span class="Special"> <- </span>subtract right, left - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen *top-of-screen<span class="Special"> <- </span>before-start-of-next-line *top-of-screen, max no-movement?:boolean<span class="Special"> <- </span>equal old-top, *top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -1900,11 +1902,11 @@ def] <span class="Comment"># takes a pointer into the doubly-linked list, scans ahead at most 'max'</span> <span class="Comment"># positions until the next newline</span> <span class="Comment"># beware: never return null pointer.</span> -<span class="muRecipe">recipe</span> before-start-of-next-line original:address:duplex-list:character, max:number<span class="muRecipe"> -> </span>curr:address:duplex-list:character [ +<span class="muRecipe">recipe</span> before-start-of-next-line original:address:shared:duplex-list:character, max:number<span class="muRecipe"> -> </span>curr:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:duplex-list:character<span class="Special"> <- </span>copy original + curr:address:shared:duplex-list:character<span class="Special"> <- </span>copy original <span class="Comment"># skip the initial newline if it exists</span> <span class="Delimiter">{</span> c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -1933,11 +1935,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -1950,7 +1952,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -1965,18 +1967,18 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line containing a wrap icon</span> screen-should-contain [ @@ -1990,7 +1992,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2005,19 +2007,19 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end, type a character</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> type <span class="Constant">[g]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2035,19 +2037,19 @@ def] <span class="muScenario">scenario</span> editor-scrolls-down-on-newline [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> type [ ] ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2066,19 +2068,19 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2097,20 +2099,20 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2127,10 +2129,10 @@ def] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ @@ -2138,9 +2140,9 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should scroll, moving cursor to end of text</span> memory-should-contain [ @@ -2151,7 +2153,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2166,9 +2168,9 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen stops scrolling because cursor is already at top</span> memory-should-contain [ @@ -2180,7 +2182,7 @@ def] type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2194,14 +2196,14 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># scroll down one page and one line</span> assume-console [ press page-down @@ -2209,7 +2211,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen scrolls down 3 lines</span> screen-should-contain [ @@ -2226,11 +2228,11 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2243,7 +2245,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2256,8 +2258,8 @@ def] <span class="muRecipe">after</span> <span class="Constant"><scroll-up></span> [ trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen *top-of-screen<span class="Special"> <- </span>before-previous-line *top-of-screen, editor no-movement?:boolean<span class="Special"> <- </span>equal old-top, *top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -2267,7 +2269,7 @@ def] <span class="Comment"># takes a pointer into the doubly-linked list, scans back to before start of</span> <span class="Comment"># previous *wrapped* line</span> <span class="Comment"># beware: never return null pointer</span> -<span class="muRecipe">recipe</span> before-previous-line curr:address:duplex-list:character, editor:address:editor-data<span class="muRecipe"> -> </span>curr:address:duplex-list:character [ +<span class="muRecipe">recipe</span> before-previous-line curr:address:shared:duplex-list:character, editor:address:shared:editor-data<span class="muRecipe"> -> </span>curr:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -2277,12 +2279,12 @@ def] left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> max-line-length:number<span class="Special"> <- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> - sentinel:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + sentinel:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> len:number<span class="Special"> <- </span>previous-line-length curr, sentinel <span class="Delimiter">{</span> <span class="muControl">break-if</span> len <span class="Comment"># empty line; just skip this newline</span> - prev:address:duplex-list:character<span class="Special"> <- </span>prev curr + prev:address:shared:duplex-list:character<span class="Special"> <- </span>prev curr <span class="muControl">reply-unless</span> prev, curr <span class="muControl">reply</span> prev <span class="Delimiter">}</span> @@ -2298,7 +2300,7 @@ def] <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:address:duplex-list:character<span class="Special"> <- </span>prev curr + prev:address:shared:duplex-list:character<span class="Special"> <- </span>prev curr <span class="muControl">break-unless</span> prev curr<span class="Special"> <- </span>copy prev count<span class="Special"> <- </span>add count, <span class="Constant">1</span> @@ -2312,11 +2314,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2328,7 +2330,7 @@ def] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2341,7 +2343,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2356,17 +2358,17 @@ def] <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2380,7 +2382,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2395,7 +2397,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2410,7 +2412,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2429,11 +2431,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2445,7 +2447,7 @@ def] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2458,7 +2460,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2473,18 +2475,18 @@ def] <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2496,7 +2498,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2508,7 +2510,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2522,18 +2524,18 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2546,9 +2548,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2567,11 +2569,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2586,7 +2588,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2600,7 +2602,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen remains unchanged</span> screen-should-contain [ @@ -2615,11 +2617,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2631,7 +2633,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2646,8 +2648,8 @@ e] <span class="Delimiter">{</span> page-down?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <span class="Constant"> <move-cursor-begin></span> page-down editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> @@ -2662,8 +2664,8 @@ e] <span class="Delimiter">{</span> page-down?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <span class="Constant"> <move-cursor-begin></span> page-down editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> @@ -2676,14 +2678,14 @@ e] <span class="Comment"># page-down skips entire wrapped lines, so it can't scroll past lines</span> <span class="Comment"># taking up the entire screen</span> -<span class="muRecipe">recipe</span> page-down editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> page-down editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if editor contents don't overflow screen, do nothing</span> - bottom-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> <span class="muControl">reply-unless</span> bottom-of-screen <span class="Comment"># if not, position cursor at final character</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> *before-cursor<span class="Special"> <- </span>prev bottom-of-screen <span class="Comment"># keep one line in common with previous page</span> <span class="Delimiter">{</span> @@ -2694,16 +2696,16 @@ e] <span class="Delimiter">}</span> <span class="Comment"># move cursor and top-of-screen to start of that line</span> move-to-start-of-line editor - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *before-cursor ] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2715,7 +2717,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen remains unmodified</span> screen-should-contain [ @@ -2730,11 +2732,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2747,7 +2749,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2763,9 +2765,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2778,7 +2780,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2793,11 +2795,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2809,7 +2811,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2823,7 +2825,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2838,8 +2840,8 @@ e] <span class="Delimiter">{</span> page-up?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">2/ctrl-b</span> <span class="muControl">break-unless</span> page-up? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <span class="Constant"> <move-cursor-begin></span> editor<span class="Special"> <- </span>page-up editor, screen-height undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> @@ -2854,8 +2856,8 @@ e] <span class="Delimiter">{</span> page-up?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <span class="Constant"> <move-cursor-begin></span> editor<span class="Special"> <- </span>page-up editor, screen-height undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> @@ -2867,16 +2869,16 @@ e] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> page-up editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> page-up editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> max:number<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:address:duplex-list:character<span class="Special"> <- </span>before-previous-line *top-of-screen, editor + prev:address:shared:duplex-list:character<span class="Special"> <- </span>before-previous-line *top-of-screen, editor <span class="muControl">break-unless</span> prev *top-of-screen<span class="Special"> <- </span>copy prev count<span class="Special"> <- </span>add count, <span class="Constant">1</span> @@ -2888,7 +2890,7 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -2896,7 +2898,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2909,7 +2911,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows third page</span> screen-should-contain [ @@ -2923,7 +2925,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows second page</span> screen-should-contain [ @@ -2937,7 +2939,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2952,7 +2954,7 @@ e] <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -2963,7 +2965,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2980,7 +2982,7 @@ e] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2996,7 +2998,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3014,9 +3016,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3029,7 +3031,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3043,7 +3045,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3057,7 +3059,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-nonempty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axx</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3066,7 +3068,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3077,7 +3079,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3089,7 +3091,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3102,7 +3104,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3115,7 +3117,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-empty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axy</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3124,7 +3126,7 @@ exy fxy gxy ] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> @@ -3135,7 +3137,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3147,7 +3149,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3160,7 +3162,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 7b632086..adcb7c8c 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -20,6 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } .Delimiter { color: #a04060; } .muScenario { color: #00af00; } --> @@ -41,22 +42,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:address:shared:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox render-all <span class="Constant">0/screen</span>, env event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> ] <span class="muData">container</span> programming-environment-data [ - recipes:address:editor-data - current-sandbox:address:editor-data + recipes:address:shared:editor-data + current-sandbox:address:shared:editor-data sandbox-in-focus?:boolean <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">recipe</span> new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe</span> new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> width:number<span class="Special"> <- </span>screen-width screen @@ -68,25 +69,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start - run-button:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> + run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> print screen, run-button, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment"># recipe editor on the left</span> - recipes:address:address:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">recipes:offset</span> + recipes:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">recipes:offset</span> *recipes<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> new-left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - current-sandbox:address:address:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">current-sandbox:offset</span> *current-sandbox<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, new-left, width/right +<span class="Constant"> <programming-environment-initialization></span> ] -<span class="muRecipe">recipe</span> event-loop screen:address:screen, console:address:console, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console, env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Comment"># if we fall behind we'll stop updating the screen, but then we have to</span> <span class="Comment"># render the entire screen when we catch up.</span> @@ -125,7 +127,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># send to both editors</span> _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, *t *sandbox-in-focus?<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, *t - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> <span class="Comment"># 'resize' event - redraw editor</span> @@ -207,21 +209,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Constant"> +finish-event</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> resize screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe</span> resize screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>env:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> clear-screen screen <span class="Comment"># update screen dimensions</span> width:number<span class="Special"> <- </span>screen-width screen divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> <span class="Comment"># update recipe editor</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> right:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">right:offset</span> *right<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> @@ -230,7 +232,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-column:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># update sandbox editor</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> left:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">left:offset</span> right:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">right:offset</span> *left<span class="Special"> <- </span>add divider, <span class="Constant">1</span> @@ -246,9 +248,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -256,11 +258,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -272,10 +274,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data <span class="Comment"># type one letter in each of them</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -284,11 +286,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> @@ -302,7 +304,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># show the cursor at the right window</span> run [ - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + <span class="Constant">8</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">8</span>:character/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -316,10 +319,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># divider isn't messed up</span> screen-should-contain [ @@ -334,15 +337,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -356,8 +360,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[z]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -372,11 +377,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊abc .</span> @@ -390,8 +395,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ @@ -402,7 +408,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> render-all screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-all screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> @@ -410,12 +416,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># top menu</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render top menu]</span> width:number<span class="Special"> <- </span>screen-width screen +<span class="CommentedCode">#? $print [draw menu], 10/newline</span> draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> +<span class="CommentedCode">#? $print [draw menu end], 10/newline</span> button-start:number<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start - run-button:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> + run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> print screen, run-button, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> @@ -427,19 +435,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>render-sandbox-side screen, env <span class="Constant"> <render-components-end></span> <span class="Comment">#</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment">#</span> show-screen screen ] -<span class="muRecipe">recipe</span> render-recipes screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> <span class="Comment"># render recipes</span> left:number<span class="Special"> <- </span>get *recipes, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *recipes, <span class="Constant">right:offset</span> @@ -454,10 +462,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> row:number, column:number, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox @@ -469,9 +477,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } clear-screen-from screen, row, left, left, right ] -<span class="muRecipe">recipe</span> update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> +<span class="Constant"> <update-cursor-special-cases></span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? cursor-row:number<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-row:offset</span> @@ -487,7 +496,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> <span class="Comment"># clear rest of last line, move cursor to next line</span> -<span class="muRecipe">recipe</span> render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">recipe</span> render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> s @@ -508,7 +517,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + print screen, wrap-icon, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -523,7 +533,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - print screen, <span class="Constant">32/space</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -546,7 +557,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> -<span class="muRecipe">recipe</span> render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">recipe</span> render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> s @@ -569,7 +580,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + print screen, wrap-icon, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -584,7 +596,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - print screen, <span class="Constant">32/space</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -612,7 +625,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> redraw-screen?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">12/ctrl-l</span> <span class="muControl">break-unless</span> redraw-screen? - screen<span class="Special"> <- </span>render-all screen, env:address:programming-environment-data + screen<span class="Special"> <- </span>render-all screen, env:address:shared:programming-environment-data sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> @@ -626,14 +639,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } switch-side?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? *sandbox-in-focus?<span class="Special"> <- </span>not *sandbox-in-focus? - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-vertical screen:address:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 0b3e3926..c079109e 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -43,10 +43,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:address:shared:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox env<span class="Special"> <- </span>restore-sandboxes env render-all <span class="Constant">0/screen</span>, env event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env @@ -54,42 +54,50 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muData">container</span> programming-environment-data [ - sandbox:address:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> + sandbox:address:shared:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> + render-from:number + number-of-sandboxes:number +] + +<span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ + render-from:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">render-from:offset</span> + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> ] <span class="muData">container</span> sandbox-data [ - data:address:array:character - response:address:array:character - expected-response:address:array:character + data:address:shared:array:character + response:address:shared:array:character + expected-response:address:shared:array:character <span class="Comment"># coordinates to track clicks</span> + <span class="Comment"># constraint: will be 0 for sandboxes at positions before env.render-from</span> starting-row-on-screen:number code-ending-row-on-screen:number <span class="Comment"># past end of code</span> response-starting-row-on-screen:number - screen:address:screen <span class="Comment"># prints in the sandbox go here</span> - next-sandbox:address:sandbox-data + screen:address:shared:screen <span class="Comment"># prints in the sandbox go here</span> + next-sandbox:address:shared:sandbox-data ] <span class="muScenario">scenario</span> run-and-show-results [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -118,6 +126,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] + <span class="Comment"># sandbox title in reverse video</span> + screen-should-contain-in-color <span class="Constant">240/dark-grey</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + <span class="Constant"> . 0 .</span> + ] <span class="Comment"># run another command</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -125,18 +140,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊1 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -151,105 +166,113 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } do-run?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? <span class="CommentedCode">#? $log [F4 pressed]</span> - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[running... ]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[running... ]</span> screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> error?:boolean, env, screen<span class="Special"> <- </span>run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> +<span class="CommentedCode">#? $print [render-all begin], 10/newline</span> screen<span class="Special"> <- </span>render-all screen, env +<span class="CommentedCode">#? $print [render-all end], 10/newline</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ ]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ ]</span> screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> run-sandboxes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe</span> run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> errors-found?:boolean, env, screen<span class="Special"> <- </span>update-recipes env, screen <span class="muControl">reply-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> +<span class="Constant"> <run-sandboxes-begin></span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:address:array:character<span class="Special"> <- </span>editor-contents current-sandbox + sandbox-contents:address:shared:array:character<span class="Special"> <- </span>editor-contents current-sandbox <span class="muControl">break-unless</span> sandbox-contents <span class="Comment"># if contents exist, first save them</span> <span class="Comment"># run them and turn them into a new sandbox-data</span> - new-sandbox:address:sandbox-data<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> - data:address:address:array:character<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">data:offset</span> + new-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> + data:address:address:shared:array:character<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">data:offset</span> *data<span class="Special"> <- </span>copy sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> - next:address:address:sandbox-data<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span> + dest:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + next:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span> *next<span class="Special"> <- </span>copy *dest *dest<span class="Special"> <- </span>copy new-sandbox + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>add *sandbox-count, <span class="Constant">1</span> <span class="Comment"># clear sandbox editor</span> - init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> + init:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *init <span class="Delimiter">}</span> <span class="Comment"># save all sandboxes before running, just in case we die when running</span> save-sandboxes env <span class="Comment"># run all sandboxes</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - curr<span class="Special"> <- </span>update-sandbox curr + curr<span class="Special"> <- </span>update-sandbox curr, env, idx curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> +<span class="Constant"> <run-sandboxes-end></span> ] <span class="Comment"># copy code from recipe editor, persist, load into mu</span> <span class="Comment"># replaced in a later layer (whereupon errors-found? will actually be set)</span> -<span class="muRecipe">recipe</span> update-recipes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe</span> update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + in:address:shared:array:character<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> *response, _, *fake-screen<span class="Special"> <- </span>run-interactive data ] -<span class="muRecipe">recipe</span> update-status screen:address:screen, msg:address:array:character, color:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> update-status screen:address:shared:screen, msg:address:shared:array:character, color:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> screen<span class="Special"> <- </span>print screen, msg, color, <span class="Constant">238/grey/background</span> ] -<span class="muRecipe">recipe</span> save-sandboxes env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> save-sandboxes env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> <span class="Comment"># first clear previous versions, in case we deleted some sandbox</span> $system <span class="Constant">[rm lesson/[0-9]</span>* >/dev/null <span class="Constant">2</span>>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - suffix:address:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx + data:address:shared:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> + filename:address:shared:array:character<span class="Special"> <- </span>to-text idx save filename, data <span class="Delimiter">{</span> - expected-response:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> + expected-response:address:shared:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response filename<span class="Special"> <- </span>append filename, suffix save filename, expected-response @@ -260,24 +283,32 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [render sandbox side]</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + row:number, column:number<span class="Special"> <- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> - row:number, column:number, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox - clear-screen-from screen, row, column, left, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + <span class="Comment"># render sandbox editor</span> + render-from:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + <span class="Delimiter">{</span> + render-current-sandbox?:boolean<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + <span class="muControl">break-unless</span> render-current-sandbox? + row, column, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox + clear-screen-from screen, row, column, left, right + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + <span class="Delimiter">}</span> + <span class="Comment"># render sandboxes</span> draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row - clear-rest-of-screen screen, row, left, left, right + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row, render-from + clear-rest-of-screen screen, row, left, right ] -<span class="muRecipe">recipe</span> render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen, sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [render sandbox]</span> @@ -285,69 +316,86 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen-height:number<span class="Special"> <- </span>screen-height screen at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">reply-if</span> at-bottom?:boolean - <span class="Comment"># render sandbox menu</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - clear-line-delimited screen, left, right - print screen, <span class="Constant">120/x</span>, <span class="Constant">245/grey</span> - <span class="Comment"># save menu row so we can detect clicks to it later</span> - starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - *starting-row<span class="Special"> <- </span>copy row - <span class="Comment"># render sandbox contents</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - sandbox-data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row - code-ending-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> - *code-ending-row<span class="Special"> <- </span>copy row - <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - response-starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> - sandbox-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> -<span class="Constant"> <render-sandbox-results></span> + hidden?:boolean<span class="Special"> <- </span>lesser-than idx, render-from <span class="Delimiter">{</span> - sandbox-screen:address:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> - empty-screen?:boolean<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen - <span class="muControl">break-if</span> empty-screen? - row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row + <span class="muControl">break-if</span> hidden? + <span class="Comment"># render sandbox menu</span> + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + screen<span class="Special"> <- </span>move-cursor screen, row, left + print screen, idx, <span class="Constant">240/dark-grey</span> + clear-line-delimited screen, left, right + delete-icon:character<span class="Special"> <- </span>copy <span class="Constant">120/x</span> + print screen, delete-icon, <span class="Constant">245/grey</span> + <span class="Comment"># save menu row so we can detect clicks to it later</span> + starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + *starting-row<span class="Special"> <- </span>copy row + <span class="Comment"># render sandbox contents</span> + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + screen<span class="Special"> <- </span>move-cursor screen, row, left + sandbox-data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row + code-ending-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + *code-ending-row<span class="Special"> <- </span>copy row + <span class="Comment"># render sandbox warnings, screen or response, in that order</span> + response-starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + sandbox-response:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> +<span class="Constant"> <render-sandbox-results></span> + <span class="Delimiter">{</span> + sandbox-screen:address:shared:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> + empty-screen?:boolean<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen + <span class="muControl">break-if</span> empty-screen? + row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row + <span class="Delimiter">}</span> + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> empty-screen? + *response-starting-row<span class="Special"> <- </span>copy row +<span class="Constant"> <render-sandbox-response></span> + row, screen<span class="Special"> <- </span>render screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + <span class="Delimiter">}</span> +<span class="Constant"> +render-sandbox-end</span> + at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + <span class="muControl">reply-if</span> at-bottom? + <span class="Comment"># draw solid line after sandbox</span> + draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span> <span class="Delimiter">}</span> + <span class="Comment"># if hidden, reset row attributes</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> empty-screen? - *response-starting-row<span class="Special"> <- </span>copy row -<span class="Constant"> <render-sandbox-response></span> - row, screen<span class="Special"> <- </span>render screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + <span class="muControl">break-unless</span> hidden? + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">}</span> -<span class="Constant"> +render-sandbox-end</span> - at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height - <span class="muControl">reply-if</span> at-bottom? - <span class="Comment"># draw solid line after sandbox</span> - draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span> <span class="Comment"># draw next sandbox</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row + next-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-idx:number<span class="Special"> <- </span>add idx, <span class="Constant">1</span> + row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span> -<span class="muRecipe">recipe</span> restore-sandboxes env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> restore-sandboxes env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> - suffix:address:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> + suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + curr:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx - contents:address:array:character<span class="Special"> <- </span>restore filename + filename:address:shared:array:character<span class="Special"> <- </span>to-text idx + contents:address:shared:array:character<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># create new sandbox for file</span> *curr<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> - data:address:address:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">data:offset</span> + data:address:address:shared:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">data:offset</span> *data<span class="Special"> <- </span>copy contents <span class="Comment"># restore expected output for sandbox if it exists</span> <span class="Delimiter">{</span> filename<span class="Special"> <- </span>append filename, suffix contents<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents - expected-response:address:address:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">expected-response:offset</span> + expected-response:address:address:shared:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">expected-response:offset</span> *expected-response<span class="Special"> <- </span>copy contents <span class="Delimiter">}</span> <span class="Constant"> +continue</span> @@ -355,23 +403,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } curr<span class="Special"> <- </span>get-address **curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> + <span class="Comment"># update sandbox count</span> + number-of-sandboxes:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *number-of-sandboxes<span class="Special"> <- </span>copy idx ] <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span> <span class="Comment"># leave cursor at start of next line</span> -<span class="muRecipe">recipe</span> render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">recipe</span> render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - header:address:array:character<span class="Special"> <- </span>new <span class="Constant">[screen:]</span> + header:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[screen:]</span> row<span class="Special"> <- </span>render screen, header, left, right, <span class="Constant">245/grey</span>, row screen<span class="Special"> <- </span>move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> column:number<span class="Special"> <- </span>copy left s-width:number<span class="Special"> <- </span>screen-width sandbox-screen s-height:number<span class="Special"> <- </span>screen-height sandbox-screen - buf:address:array:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> + buf:address:shared:array:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> stop-printing:number<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> max-column:number<span class="Special"> <- </span>min stop-printing, right i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -385,9 +436,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column <span class="Comment"># initial leader for each row: two spaces and a '.'</span> - print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span> - print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span> - print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + print screen, space, <span class="Constant">245/grey</span> + print screen, space, <span class="Constant">245/grey</span> + full-stop:character<span class="Special"> <- </span>copy <span class="Constant">46/period</span> + print screen, full-stop, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>add left, <span class="Constant">3</span> <span class="Delimiter">{</span> <span class="Comment"># print row</span> @@ -408,13 +461,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print final '.'</span> - print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span> + print screen, full-stop, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="Delimiter">{</span> <span class="Comment"># clear rest of current line</span> line-done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> line-done? - print screen, <span class="Constant">32/space</span> + print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -427,24 +480,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">z:number <- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .z:number <- add 2, 2 ┊ x.</span> + <span class="Constant"> .z:number <- add 2, 2 ┊0 x.</span> <span class="Constant"> .reply z ┊foo .</span> <span class="Constant"> .] ┊4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -458,14 +511,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .z:number <- add 2, 3 ┊ x.</span> + <span class="Constant"> .z:number <- add 2, 3 ┊0 x.</span> <span class="Constant"> .reply z ┊foo .</span> <span class="Constant"> .] ┊5 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -477,23 +530,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the code in the editor</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> @@ -506,11 +559,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> editor-contents editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + buf:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Comment"># skip § sentinel</span> assert curr, <span class="Constant">[editor without data is illegal; must have at least a sentinel]</span> curr<span class="Special"> <- </span>next curr @@ -527,21 +580,447 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-provides-edited-contents [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> type <span class="Constant">[def]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:address:array:character<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:array:character + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> ] ] + +<span class="Comment"># scrolling through sandboxes</span> + +<span class="muScenario">scenario</span> scrolling-down-past-bottom-of-sandbox-editor [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize sandbox side</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + assume-console [ + <span class="Comment"># create a sandbox</span> + press F4 + <span class="Comment"># switch to sandbox editor and type in 2 lines</span> + press ctrl-n + type <span class="Constant">[abc</span> +<span class="Constant">]</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + screen-should-contain [ + <span class="Constant"> . . # minor: F4 clears menu tooltip in very narrow screens</span> + <span class="Constant"> . ┊abc .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + ] + <span class="Comment"># hit 'down' at bottom of sandbox editor</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up'</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor displays again</span> + screen-should-contain [ + <span class="Constant"> . . # minor: F4 clears menu tooltip in very narrow screens</span> + <span class="Constant"> . ┊abc .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + ] +] + +<span class="Comment"># down on sandbox side updates render-from when sandbox editor has cursor at bottom</span> +<span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *sandbox-in-focus? + down?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65516/down-arrow</span> + <span class="muControl">break-unless</span> down? + sandbox-bottom:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">bottom:offset</span> + sandbox-cursor:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> + sandbox-cursor-on-last-line?:boolean<span class="Special"> <- </span>equal sandbox-bottom, sandbox-cursor + <span class="muControl">break-unless</span> sandbox-cursor-on-last-line? + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + <span class="muControl">break-unless</span> sandbox + <span class="Comment"># slide down if possible</span> + <span class="Delimiter">{</span> + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + number-of-sandboxes:number<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> + max:number<span class="Special"> <- </span>subtract number-of-sandboxes, <span class="Constant">1</span> + at-end?:boolean<span class="Special"> <- </span>greater-or-equal *render-from, max + <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event:label</span> <span class="Comment"># render nothing</span> + *render-from<span class="Special"> <- </span>add *render-from, <span class="Constant">1</span> + <span class="Delimiter">}</span> + hide-screen screen + screen<span class="Special"> <- </span>render-sandbox-side screen, env + show-screen screen + <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span> + <span class="Delimiter">}</span> +] + +<span class="Comment"># update-cursor takes render-from into account</span> +<span class="muRecipe">after</span> <span class="Constant"><update-cursor-special-cases></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> sandbox-in-focus? + render-from:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + scrolling?:boolean<span class="Special"> <- </span>greater-or-equal render-from, <span class="Constant">0</span> + <span class="muControl">break-unless</span> scrolling? + cursor-column:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> + <span class="muControl">reply</span> + <span class="Delimiter">}</span> +] + +<span class="Comment"># 'up' on sandbox side is like 'down': updates render-from when necessary</span> +<span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *sandbox-in-focus? + up?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65517/up-arrow</span> + <span class="muControl">break-unless</span> up? + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + at-beginning?:boolean<span class="Special"> <- </span>equal *render-from, <span class="Constant">-1</span> + <span class="muControl">break-if</span> at-beginning? + *render-from<span class="Special"> <- </span>subtract *render-from, <span class="Constant">1</span> + hide-screen screen + screen<span class="Special"> <- </span>render-sandbox-side screen, env + show-screen screen + <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span> + <span class="Delimiter">}</span> +] + +<span class="Comment"># sandbox belonging to 'env' whose next-sandbox is 'in'</span> +<span class="Comment"># return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox</span> +<span class="muRecipe">recipe</span> previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data<span class="muRecipe"> -> </span>out:address:shared:sandbox-data [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + <span class="muControl">reply-unless</span> curr, <span class="Constant">0/nil</span> + next:address:shared:sandbox-data<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + <span class="Delimiter">{</span> + <span class="muControl">reply-unless</span> next, <span class="Constant">0/nil</span> + found?:boolean<span class="Special"> <- </span>equal next, in + <span class="muControl">break-if</span> found? + curr<span class="Special"> <- </span>copy next + next<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="muControl">reply</span> curr +] + +<span class="muScenario">scenario</span> scrolling-down-on-recipe-side [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize sandbox side and create a sandbox</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> +<span class="Constant">]</span> + <span class="Comment"># create a sandbox</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + assume-console [ + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># hit 'down' in recipe editor</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> .␣ ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> scrolling-through-multiple-sandboxes [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># hit 'down'</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + ] + <span class="Comment"># hit 'down' again</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># just second sandbox displayed</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down' again</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up'</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># back to displaying both sandboxes without editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># back to displaying both sandboxes as well as editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] +] + +<span class="muScenario">scenario</span> scrolling-manages-sandbox-index-correctly [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create a sandbox</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down' and 'up' a couple of times. sandbox index should be stable</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># back to displaying both sandboxes as well as editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down'</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x. # no change</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/006-sandbox-edit.mu.html b/html/edit/006-sandbox-edit.mu.html index d902c4b7..a4830985 100644 --- a/html/edit/006-sandbox-edit.mu.html +++ b/html/edit/006-sandbox-edit.mu.html @@ -38,22 +38,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -64,7 +64,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">30</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -82,7 +82,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -103,7 +103,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox first-sandbox-begins:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> click-row:number<span class="Special"> <- </span>get *t, <span class="Constant">row:offset</span> @@ -112,35 +112,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } empty-sandbox-editor?:boolean<span class="Special"> <- </span>empty-editor? current-sandbox <span class="muControl">break-unless</span> empty-sandbox-editor? <span class="Comment"># don't clobber existing contents</span> <span class="Comment"># identify the sandbox to edit and remove it from the sandbox list</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>extract-sandbox env, click-row - text:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>extract-sandbox env, click-row + <span class="muControl">break-unless</span> sandbox + text:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> empty-editor? editor:address:editor-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> empty-editor? editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - head:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - first:address:duplex-list:character<span class="Special"> <- </span>next head + head:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + first:address:shared:duplex-list:character<span class="Special"> <- </span>next head result<span class="Special"> <- </span>not first ] -<span class="muRecipe">recipe</span> extract-sandbox env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:sandbox-data, env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> extract-sandbox env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> - sandbox:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + sandbox:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> start:number<span class="Special"> <- </span>get **sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:boolean<span class="Special"> <- </span>greater-or-equal click-row, start - assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> + in-editor?:boolean<span class="Special"> <- </span>lesser-than click-row, start + <span class="muControl">reply-if</span> in-editor?, <span class="Constant">0</span> <span class="Delimiter">{</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get **sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get **sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox <span class="Comment"># if click-row < sandbox.next-sandbox.starting-row-on-screen, break</span> next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> @@ -152,6 +154,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># snip sandbox out of its list</span> result<span class="Special"> <- </span>copy *sandbox *sandbox<span class="Special"> <- </span>copy next-sandbox + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>subtract *sandbox-count, <span class="Constant">1</span> <span class="Comment"># position cursor in sandbox editor</span> sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox-in-focus?:offset</span> *sandbox-in-focus?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -161,20 +166,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> @@ -190,7 +195,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">70</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -200,6 +205,125 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ .</span> ] ] + +<span class="muScenario">scenario</span> editing-sandbox-after-scrolling-resets-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># edit the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">20</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊add 2, 2 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> editing-sandbox-updates-sandbox-count [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># edit the second sandbox, then resave</span> + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">20</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change in contents</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># now try to scroll past end</span> + assume-console [ + press down-arrow + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># screen should show just final sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 6d289afa..b88de17f 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -37,9 +37,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> deleting-sandboxes [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -48,16 +48,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[add 2, 2]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊1 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -69,13 +69,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">7</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -87,7 +87,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -105,23 +105,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> was-delete? hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-sandbox t:touch-event, env:address:programming-environment-data<span class="muRecipe"> -> </span>was-delete?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> delete-sandbox t:touch-event, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>was-delete?:boolean, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> at-right?:boolean<span class="Special"> <- </span>equal click-column, right <span class="muControl">reply-unless</span> at-right?, <span class="Constant">0/false</span> click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - prev:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + prev:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr <span class="Comment"># more sandboxes to check</span> @@ -129,9 +129,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } target-row:number<span class="Special"> <- </span>get *curr, <span class="Constant">starting-row-on-screen:offset</span> delete-curr?:boolean<span class="Special"> <- </span>equal target-row, click-row <span class="muControl">break-unless</span> delete-curr? - <span class="Comment"># delete this sandbox, rerender and stop</span> + <span class="Comment"># delete this sandbox</span> *prev<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> - <span class="muControl">reply</span> <span class="Constant">1/true</span> + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>subtract *sandbox-count, <span class="Constant">1</span> + <span class="Comment"># if it's the last sandbox and if it was the only sandbox rendered, reset scroll</span> + <span class="Delimiter">{</span> + <span class="muControl">break-if</span> *prev + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + reset-scroll?:boolean<span class="Special"> <- </span>equal *render-from, *sandbox-count + <span class="muControl">break-unless</span> reset-scroll? + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> + <span class="Delimiter">}</span> + <span class="muControl">reply</span> <span class="Constant">1/true</span> <span class="Comment"># force rerender</span> <span class="Delimiter">}</span> prev<span class="Special"> <- </span>get-address *curr, <span class="Constant">next-sandbox:offset</span> curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> @@ -139,6 +150,204 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="muControl">reply</span> <span class="Constant">0/false</span> ] + +<span class="muScenario">scenario</span> deleting-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">6</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-top-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-final-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># implicitly scroll up to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-updates-sandbox-count [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># delete the second sandbox, then try to scroll down twice</span> + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">29</span> + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># shouldn't go past last sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/008-sandbox-test.mu.html b/html/edit/008-sandbox-test.mu.html index bdf918e8..d5dbcfcb 100644 --- a/html/edit/008-sandbox-test.mu.html +++ b/html/edit/008-sandbox-test.mu.html @@ -38,22 +38,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -64,7 +64,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">5</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -79,13 +79,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># cursor should remain unmoved</span> run [ - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -100,7 +101,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -123,38 +124,38 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox first-sandbox-begins:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> click-row:number<span class="Special"> <- </span>get *t, <span class="Constant">row:offset</span> below-sandbox-editor?:boolean<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose output is being clicked on</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-output env, click-row + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-output env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its expected-response, and save session</span> sandbox<span class="Special"> <- </span>toggle-expected-response sandbox save-sandboxes env hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env, <span class="Constant">1/clear</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> find-click-in-sandbox-output env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> start:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> clicked-on-sandboxes?:boolean<span class="Special"> <- </span>greater-or-equal click-row, start assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> found?:boolean<span class="Special"> <- </span>lesser-than click-row, next-start @@ -170,10 +171,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> sandbox ] -<span class="muRecipe">recipe</span> toggle-expected-response sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> toggle-expected-response sandbox:address:shared:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - expected-response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">expected-response:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> <span class="muControl">break-unless</span> *expected-response @@ -181,7 +182,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> sandbox/same-as-ingredient:<span class="Constant">0</span> <span class="Delimiter">}</span> <span class="Comment"># if not, current response is the expected response</span> - response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + response:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> *expected-response<span class="Special"> <- </span>copy response ] @@ -189,7 +190,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-response></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-response - expected-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response <span class="Comment"># fall-through to print in grey</span> response-is-expected?:boolean<span class="Special"> <- </span>equal expected-response, sandbox-response <span class="Delimiter">{</span> diff --git a/html/edit/009-sandbox-trace.mu.html b/html/edit/009-sandbox-trace.mu.html index 6d5603bd..868d68fc 100644 --- a/html/edit/009-sandbox-trace.mu.html +++ b/html/edit/009-sandbox-trace.mu.html @@ -39,22 +39,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> @@ -64,15 +64,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor-icon<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor-icon ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -93,15 +94,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">25</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor-icon ] <span class="Comment"># trace hidden again</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> @@ -112,23 +113,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> <span class="muControl">reply</span> <span class="Constant">4</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> @@ -139,14 +140,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># trace now printed above result</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊abc .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> @@ -156,18 +157,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muData">container</span> sandbox-data [ - trace:address:array:character + trace:address:shared:array:character display-trace?:boolean ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - trace:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + trace:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> *response, _, *fake-screen, *trace<span class="Special"> <- </span>run-interactive data ] @@ -179,28 +180,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox first-sandbox-begins:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> click-row:number<span class="Special"> <- </span>get *t, <span class="Constant">row:offset</span> below-sandbox-editor?:boolean<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose code is being clicked on</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-code env, click-row + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-code env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its display-trace? property</span> x:address:boolean<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">display-trace?:offset</span> *x<span class="Special"> <- </span>not *x hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env, <span class="Constant">1/clear</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> find-click-in-sandbox-code env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> @@ -210,7 +211,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> found?:boolean<span class="Special"> <- </span>lesser-than click-row, next-start @@ -236,7 +237,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> display-trace?:boolean<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? - sandbox-trace:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> + sandbox-trace:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> <span class="muControl">break-unless</span> sandbox-trace <span class="Comment"># nothing to print; move on</span> row, screen<span class="Special"> <- </span>render screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> diff --git a/html/edit/010-warnings.mu.html b/html/edit/010-warnings.mu.html index c675b386..a9b81c9e 100644 --- a/html/edit/010-warnings.mu.html +++ b/html/edit/010-warnings.mu.html @@ -37,23 +37,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## handling malformed programs</span> <span class="muData">container</span> programming-environment-data [ - recipe-warnings:address:array:character + recipe-warnings:address:shared:array:character ] <span class="Comment"># copy code from recipe editor, persist, load into mu, save any warnings</span> -<span class="muRecipe">recipe!</span> update-recipes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe!</span> update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [update recipes]</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + in:address:shared:array:character<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in - recipe-warnings:address:address:array:character<span class="Special"> <- </span>get-address *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:address:shared:array:character<span class="Special"> <- </span>get-address *env, <span class="Constant">recipe-warnings:offset</span> *recipe-warnings<span class="Special"> <- </span>reload in <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> *recipe-warnings - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> update-status screen, status, <span class="Constant">1/red</span> errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply</span> @@ -63,35 +63,72 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> - recipe-warnings:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:shared:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-warnings - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> update-status screen, status, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><render-recipe-components-end></span> [ <span class="Delimiter">{</span> - recipe-warnings:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:shared:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> <span class="muControl">break-unless</span> recipe-warnings row, screen<span class="Special"> <- </span>render screen, recipe-warnings, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> ] +<span class="muData">container</span> programming-environment-data [ + warning-index:number <span class="Comment"># index of first sandbox with an error (or -1 if none)</span> +] + +<span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ + warning-index:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">warning-index:offset</span> + *warning-index<span class="Special"> <- </span>copy <span class="Constant">-1</span> +] + +<span class="muRecipe">after</span> <span class="Constant"><run-sandboxes-begin></span> [ + warning-index:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">warning-index:offset</span> + *warning-index<span class="Special"> <- </span>copy <span class="Constant">-1</span> +] + +<span class="muRecipe">before</span> <span class="Constant"><run-sandboxes-end></span> [ + <span class="Delimiter">{</span> + sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal *warning-index, <span class="Constant">-1</span> + <span class="muControl">break-if</span> sandboxes-completed-successfully? + errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="Delimiter">}</span> +] + +<span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-if</span> recipe-warnings + warning-index:number<span class="Special"> <- </span>get *env, <span class="Constant">warning-index:offset</span> + sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal warning-index, <span class="Constant">-1</span> + <span class="muControl">break-if</span> sandboxes-completed-successfully? + status-template:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found (_) ]</span> + warning-index-text:address:shared:array:character<span class="Special"> <- </span>to-text warning-index + status:address:shared:array:character<span class="Special"> <- </span>interpolate status-template, warning-index-text +<span class="CommentedCode">#? $print [update-status: sandbox warning], 10/newline</span> + update-status screen, status, <span class="Constant">1/red</span> +<span class="CommentedCode">#? $print [run sandboxes end], 10/newline</span> + <span class="Delimiter">}</span> +] + <span class="muData">container</span> sandbox-data [ - warnings:address:array:character + warnings:address:shared:array:character ] -<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [update sandbox]</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - warnings:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">warnings:offset</span> - trace:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + warnings:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">warnings:offset</span> + trace:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> <span class="CommentedCode">#? $print [run-interactive], 10/newline</span> *response, *warnings, *fake-screen, *trace, completed?:boolean<span class="Special"> <- </span>run-interactive data <span class="Delimiter">{</span> @@ -100,13 +137,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *warnings<span class="Special"> <- </span>new <span class="Constant">[took too long!</span> <span class="Constant">]</span> <span class="Delimiter">}</span> + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *warnings +<span class="CommentedCode">#? $print [setting warning-index to ], idx, 10/newline</span> + warning-index:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">warning-index:offset</span> + warning-not-set?:boolean<span class="Special"> <- </span>equal *warning-index, <span class="Constant">-1</span> + <span class="muControl">break-unless</span> warning-not-set? + *warning-index<span class="Special"> <- </span>copy idx + <span class="Delimiter">}</span> <span class="CommentedCode">#? $print [done with run-interactive], 10/newline</span> ] <span class="Comment"># make sure we render any trace</span> <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-trace-done></span> [ <span class="Delimiter">{</span> - sandbox-warnings:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">warnings:offset</span> + sandbox-warnings:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">warnings:offset</span> <span class="muControl">break-unless</span> sandbox-warnings *response-starting-row<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># no response</span> row, screen<span class="Special"> <- </span>render screen, sandbox-warnings, left, right, <span class="Constant">1/red</span>, row @@ -118,17 +163,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-warnings-in-get [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> get 123:number, foo:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -155,32 +200,84 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] +<span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">80</span> + <span class="Comment"># create invalid sandbox 1</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create invalid sandbox 0</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># status shows first sandbox with error</span> + screen-should-contain [ + <span class="Constant"> . errors found (0) run (F4) .</span> + ] +] + +<span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox-2 [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">80</span> + <span class="Comment"># create invalid sandbox 2</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create invalid sandbox 1</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create valid sandbox 0</span> + type <span class="Constant">[add 2, 2]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># status shows first sandbox with error</span> + screen-should-contain [ + <span class="Constant"> . errors found (1) run (F4) .</span> + ] +] + <span class="muScenario">scenario</span> run-hides-warnings-from-past-sandboxes [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 <span class="Comment"># generate error</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> press ctrl-k type <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> - press F4 <span class="Comment"># error should disappear</span> + press F4 <span class="Comment"># update sandbox</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] + <span class="Comment"># error should disappear</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -192,24 +289,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant">z <- add x, [a]</span> ]] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .load-ingredients ┊ x.</span> + <span class="Constant"> .load-ingredients ┊0 x.</span> <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> @@ -221,14 +318,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># error should remain unchanged</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .load-ingredients ┊ x.</span> + <span class="Constant"> .load-ingredients ┊0 x.</span> <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> @@ -241,24 +338,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:list:_elem -> n:number [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:shared:list:_elem -> n:number [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[x:address:list:number <- copy 0</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[x:address:shared:list:number <- copy 0</span> <span class="Constant">to-text x]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run it once</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data <span class="Comment"># no errors anywhere on screen (can't check anything else, since to-text will return an address)</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> . <- .</span> + <span class="Constant"> . <- .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -275,7 +372,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># still no errors</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -283,7 +380,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> . <- .</span> + <span class="Constant"> . <- .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -300,17 +397,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-missing-type-warnings [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -326,18 +423,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo «</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> - replace <span class="Constant">1</span>:address:array:character, <span class="Constant">171/«</span>, <span class="Constant">91</span> <span class="Comment"># '['</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + replace <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">171/«</span>, <span class="Constant">91</span> <span class="Comment"># '['</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -354,28 +451,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-get-on-non-container-warnings [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> -<span class="Constant"> x:address:point <- new point:type</span> -<span class="Constant"> get x:address:point, 1:offset</span> +<span class="Constant"> x:address:shared:point <- new point:type</span> +<span class="Constant"> get x:address:shared:point, 1:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . x:address:point <- new point:type ┊ .</span> - <span class="Constant"> . get x:address:point, 1:offset ┊ .</span> + <span class="Constant"> . x:address:shared:point <- new point:type ┊ .</span> + <span class="Constant"> . get x:address:shared:point, 1:offset ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩┊ .</span> - <span class="Constant"> .ner, but got x:address:point ┊ .</span> + <span class="Constant"> .ner, but got x:address:shared:point ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -384,27 +481,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-non-literal-get-argument-warnings [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x:number <- copy 0</span> -<span class="Constant"> y:address:point <- new point:type</span> -<span class="Constant"> get *y:address:point, x:number</span> +<span class="Constant"> y:address:shared:point <- new point:type</span> +<span class="Constant"> get *y:address:shared:point, x:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . x:number <- copy 0 ┊ .</span> - <span class="Constant"> . y:address:point <- new point:type ┊ .</span> - <span class="Constant"> . get *y:address:point, x:number ┊ .</span> + <span class="Constant"> . y:address:shared:point <- new point:type ┊ .</span> + <span class="Constant"> . get *y:address:shared:point, x:number ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: expected ingredient 1 of 'get' to have type ↩┊ .</span> <span class="Constant"> .'offset'; got x:number ┊ .</span> @@ -419,17 +516,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x:number <- copy y:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -446,7 +543,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -464,23 +561,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊get 1234:number, foo:offset .</span> <span class="Constant"> . ┊unknown element foo in container number .</span> <span class="Constant"> . ┊first ingredient of 'get' should be a container,↩.</span> @@ -499,7 +596,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> ] screen-should-contain-in-color <span class="Constant">1/red</span>, [ - <span class="Constant"> . .</span> + <span class="Constant"> . errors found (0) .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -527,24 +624,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊get 1234:number, foo:offset .</span> <span class="Constant"> . ┊unknown element foo in container number .</span> <span class="Constant"> . ┊first ingredient of 'get' should be a container,↩.</span> @@ -558,26 +655,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> . { ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . loop ┊ x.</span> + <span class="Constant"> . loop ┊0 x.</span> <span class="Constant"> . } ┊foo .</span> <span class="Constant"> .] ┊took too long! .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -589,7 +686,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a warning</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">a:number <- next-ingredient</span> <span class="Constant">b:number <- next-ingredient</span> @@ -597,40 +694,43 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } _, c:number<span class="Special"> <- </span>divide-with-remainder a, b <span class="muControl">reply</span> b ]] - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data <span class="Comment"># screen prints error message</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .recipe foo \\\[ ┊ .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> + <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .a:number <- next-ingredient ┊ x.</span> + <span class="Constant"> .a:number <- next-ingredient ┊0 x.</span> <span class="Constant"> .b:number <- next-ingredient ┊foo 4, 0 .</span> <span class="Constant"> .stash [dividing by], b ┊foo: divide by zero in '_, c:number <- divide-wi↩.</span> <span class="Constant"> ._, c:number <- divide-with-remainder a, b ┊th-remainder a, b' .</span> + <span class="Constant"> .reply b ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .] ┊ .</span> ] <span class="Comment"># click on the call in the sandbox</span> assume-console [ left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># screen should expand trace</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .recipe foo \\\[ ┊ .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> + <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .a:number <- next-ingredient ┊ x.</span> + <span class="Constant"> .a:number <- next-ingredient ┊0 x.</span> <span class="Constant"> .b:number <- next-ingredient ┊foo 4, 0 .</span> <span class="Constant"> .stash [dividing by], b ┊dividing by 0 .</span> <span class="Constant"> ._, c:number <- divide-with-remainder a, b ┊foo: divide by zero in '_, c:number <- divide-wi↩.</span> <span class="Constant"> .reply b ┊th-remainder a, b' .</span> + <span class="Constant"> .] ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> ] ] </pre> diff --git a/html/edit/011-editor-undo.mu.html b/html/edit/011-editor-undo.mu.html index 801ca648..d5d66d09 100644 --- a/html/edit/011-editor-undo.mu.html +++ b/html/edit/011-editor-undo.mu.html @@ -46,13 +46,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> insert-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character <span class="Comment"># inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate</span> - insert-from:address:duplex-list:character - insert-until:address:duplex-list:character + insert-from:address:shared:duplex-list:character + insert-until:address:shared:duplex-list:character tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (enter+indent)</span> <span class="Comment"># 1: regular alphanumeric characters</span> @@ -61,10 +61,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> move-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (touch events, etc)</span> <span class="Comment"># 1: left arrow</span> @@ -76,13 +76,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> delete-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character - deleted-text:address:duplex-list:character - delete-from:address:duplex-list:character - delete-until:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character + deleted-text:address:shared:duplex-list:character + delete-from:address:shared:duplex-list:character + delete-until:address:shared:duplex-list:character tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (ctrl-k, ctrl-u)</span> <span class="Comment"># 1: backspace</span> @@ -91,8 +91,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># every editor accumulates a list of operations to undo/redo</span> <span class="muData">container</span> editor-data [ - undo:address:list:address:operation - redo:address:list:address:operation + undo:address:shared:list:address:shared:operation + redo:address:shared:list:address:shared:operation ] <span class="Comment"># ctrl-z - undo operation</span> @@ -100,11 +100,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> undo?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">26/ctrl-z</span> <span class="muControl">break-unless</span> undo? - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo *undo<span class="Special"> <- </span>rest *undo - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> *redo<span class="Special"> <- </span>push op, *redo <span class="Constant"> <handle-undo></span> <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> @@ -116,11 +116,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> redo?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">25/ctrl-y</span> <span class="muControl">break-unless</span> redo? - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> <span class="muControl">break-unless</span> *redo - op:address:operation<span class="Special"> <- </span>first *redo + op:address:shared:operation<span class="Special"> <- </span>first *redo *redo<span class="Special"> <- </span>rest *redo - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> *undo<span class="Special"> <- </span>push op, *undo <span class="Constant"> <handle-redo></span> <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> @@ -132,19 +132,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing [ <span class="Comment"># create an editor and type a character</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># character should be gone</span> screen-should-contain [ @@ -158,7 +158,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -170,34 +170,34 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant"><insert-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor ] <span class="muRecipe">before</span> <span class="Constant"><insert-character-end></span> [ - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing previous-coalesce-tag:number<span class="Special"> <- </span>get *typing, <span class="Constant">tag:offset</span> <span class="muControl">break-unless</span> previous-coalesce-tag - insert-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> + insert-until:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> *insert-until<span class="Special"> <- </span>next *before-cursor after-row:address:number<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="muControl">break</span> <span class="Constant">+done-adding-insert-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - insert-from:address:duplex-list:character<span class="Special"> <- </span>next cursor-before - insert-to:address:duplex-list:character<span class="Special"> <- </span>next insert-from - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + insert-from:address:shared:duplex-list:character<span class="Special"> <- </span>next cursor-before + insert-to:address:shared:duplex-list:character<span class="Special"> <- </span>next insert-from + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-insert-operation</span> @@ -207,15 +207,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">after</span> <span class="Constant"><insert-enter-begin></span> [ cursor-row-before:number<span class="Special"> <- </span>copy *cursor-row cursor-column-before:number<span class="Special"> <- </span>copy *cursor-column - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor ] <span class="muRecipe">before</span> <span class="Constant"><insert-enter-end></span> [ - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Comment"># never coalesce</span> - insert-from:address:duplex-list:character<span class="Special"> <- </span>next cursor-before - insert-to:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + insert-from:address:shared:duplex-list:character<span class="Special"> <- </span>next cursor-before + insert-to:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op ] @@ -224,12 +224,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># redo stack, because it's now obsolete.</span> <span class="Comment"># Beware: since we're counting cursor moves as operations, this means just</span> <span class="Comment"># moving the cursor can lose work on the undo stack.</span> -<span class="muRecipe">recipe</span> add-operation editor:address:editor-data, op:address:operation<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> add-operation editor:address:shared:editor-data, op:address:shared:operation<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> *undo<span class="Special"> <- </span>push op *undo - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> *redo<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span> ] @@ -238,14 +238,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing - start:address:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-until:offset</span> + start:address:shared:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> + end:address:shared:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-until:offset</span> <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *before-cursor<span class="Special"> <- </span>prev start remove-between *before-cursor, end *cursor-row<span class="Special"> <- </span>get *typing, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *typing, <span class="Constant">before-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *typing, <span class="Constant">before-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -253,19 +253,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-multiple [ <span class="Comment"># create an editor and type multiple characters</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be gone</span> screen-should-contain [ @@ -279,14 +279,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-multiple-2 [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># type some characters</span> assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .012a .</span> @@ -298,7 +298,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -312,7 +312,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -325,15 +325,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-enter [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># new line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">8</span> press enter ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . abc .</span> @@ -342,8 +342,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> ] <span class="Comment"># line is indented</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -353,10 +353,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">5</span> @@ -373,7 +373,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -388,14 +388,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-typing [ <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -407,7 +407,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -421,7 +421,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -435,13 +435,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing - insert-from:address:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> + insert-from:address:shared:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> <span class="Comment"># assert insert-to matches next(*before-cursor)</span> insert-range *before-cursor, insert-from <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *cursor-row<span class="Special"> <- </span>get *typing, <span class="Constant">after-row:offset</span> *cursor-column<span class="Special"> <- </span>get *typing, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *typing, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -449,14 +449,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-typing-empty [ <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -468,7 +468,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -482,7 +482,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -495,21 +495,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-work-clears-redo-stack [ <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[1]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># do some more work</span> assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .0abc .</span> @@ -522,7 +522,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># nothing should happen</span> screen-should-contain [ @@ -537,9 +537,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-redo-typing-and-enter-and-tab [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ press tab @@ -550,7 +550,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press tab type <span class="Constant">[efg]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . ab cd .</span> @@ -558,8 +558,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -569,11 +569,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># typing in second line deleted, but not indent</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -590,11 +590,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -610,11 +610,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># empty screen</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -630,11 +630,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -650,11 +650,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># newline and indent inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -671,11 +671,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -694,24 +694,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-touch [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># click undone</span> memory-should-contain [ @@ -723,7 +723,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -737,19 +737,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">after</span> <span class="Constant"><move-cursor-begin></span> [ before-cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> before-cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + before-top-of-screen:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><move-cursor-end></span> [ after-cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> after-cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - after-top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + after-top-of-screen:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> undo-coalesce-tag <span class="Comment"># if previous operation was also a move, and also had the same coalesce</span> <span class="Comment"># tag, coalesce with it</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo move:address:move-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> move previous-coalesce-tag:number<span class="Special"> <- </span>get *move, <span class="Constant">tag:offset</span> @@ -759,11 +759,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *after-row<span class="Special"> <- </span>copy after-cursor-row after-column:address:number<span class="Special"> <- </span>get-address *move, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy after-cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *move, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *move, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="muControl">break</span> <span class="Constant">+done-adding-move-operation:label</span> <span class="Delimiter">}</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">1/move-operation</span>, before-cursor-row, before-cursor-column, before-top-of-screen, after-cursor-row, after-cursor-column, after-top-of-screen, undo-coalesce-tag editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-move-operation</span> @@ -774,7 +774,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move:address:move-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> move <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *cursor-row<span class="Special"> <- </span>get *move, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *move, <span class="Constant">before-column:offset</span> *top<span class="Special"> <- </span>get *move, <span class="Constant">before-top-of-screen:offset</span> @@ -785,18 +785,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -813,9 +813,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moved back</span> memory-should-contain [ @@ -834,7 +834,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -847,25 +847,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-left-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press left-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -877,7 +877,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -891,19 +891,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-up-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -913,9 +913,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -927,7 +927,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -941,25 +941,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-down-arrow [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press down-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -971,7 +971,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -985,27 +985,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-f [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># scroll the page</span> assume-console [ press ctrl-f ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1020,27 +1020,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-page-down [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># scroll the page</span> assume-console [ press page-down ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1055,28 +1055,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-b [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1091,28 +1091,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-page-up [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press page-up ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1127,25 +1127,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-a [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-a ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1157,7 +1157,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1171,25 +1171,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-home [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press home ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1201,7 +1201,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1215,25 +1215,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-e [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-e ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1245,7 +1245,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1259,25 +1259,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-end [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press end ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1289,7 +1289,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1303,17 +1303,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-separates-undo-insert-from-undo-cursor-move [ <span class="Comment"># create an editor, type some text, move the cursor, type some more text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ type <span class="Constant">[abc]</span> left-click <span class="Constant">1</span>, <span class="Constant">1</span> type <span class="Constant">[d]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1329,9 +1329,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1349,9 +1349,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1369,9 +1369,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1389,9 +1389,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1409,9 +1409,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1429,9 +1429,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1449,11 +1449,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-multiple-arrows-in-the-same-direction [ <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> @@ -1461,9 +1461,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1473,9 +1473,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># up-arrow is undone</span> memory-should-contain [ @@ -1487,9 +1487,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># both right-arrows are undone</span> memory-should-contain [ @@ -1503,24 +1503,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-touch [ <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># redo</span> assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to left-click</span> memory-should-contain [ @@ -1532,7 +1532,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1550,7 +1550,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *cursor-row<span class="Special"> <- </span>get *move, <span class="Constant">after-row:offset</span> *cursor-column<span class="Special"> <- </span>get *move, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *move, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1560,24 +1560,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-backspace [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and hit backspace</span> assume-console [ type <span class="Constant">[abc]</span> press backspace press backspace ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1587,10 +1587,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1606,10 +1606,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1624,38 +1624,38 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant"><backspace-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><backspace-character-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> backspaced-cell <span class="Comment"># backspace failed; don't add an undo operation</span> - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion previous-coalesce-tag:number<span class="Special"> <- </span>get *deletion, <span class="Constant">tag:offset</span> coalesce?:boolean<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> <span class="muControl">break-unless</span> coalesce? - delete-from:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-from:offset</span> + delete-from:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-from:offset</span> *delete-from<span class="Special"> <- </span>copy *before-cursor - backspaced-so-far:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + backspaced-so-far:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> insert-range backspaced-cell, *backspaced-so-far *backspaced-so-far<span class="Special"> <- </span>copy backspaced-cell after-row:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="muControl">break</span> <span class="Constant">+done-adding-backspace-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, backspaced-cell/deleted, *before-cursor/delete-from, deleted-until, <span class="Constant">1/coalesce-backspace</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-backspace-operation</span> @@ -1666,17 +1666,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion - start2:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">data:offset</span> - anchor:address:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> + start2:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">data:offset</span> + anchor:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> <span class="muControl">break-unless</span> anchor - deleted:address:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">deleted-text:offset</span> - old-cursor:address:duplex-list:character<span class="Special"> <- </span>last deleted + deleted:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">deleted-text:offset</span> + old-cursor:address:shared:duplex-list:character<span class="Special"> <- </span>last deleted insert-range anchor, deleted <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *before-cursor<span class="Special"> <- </span>copy old-cursor *cursor-row<span class="Special"> <- </span>get *deletion, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *deletion, <span class="Constant">before-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *deletion, <span class="Constant">before-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1685,13 +1685,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion - start:address:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-until:offset</span> + start:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> + end:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-until:offset</span> remove-between start, end <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *cursor-row<span class="Special"> <- </span>get *deletion, <span class="Constant">after-row:offset</span> *cursor-column<span class="Special"> <- </span>get *deletion, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *deletion, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1701,9 +1701,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-delete [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abcdef]</span> @@ -1713,15 +1713,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .af .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1731,10 +1731,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1750,10 +1750,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1769,10 +1769,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1788,11 +1788,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1808,11 +1808,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1828,11 +1828,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1846,37 +1846,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muRecipe">after</span> <span class="Constant"><delete-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-character-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cell <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion previous-coalesce-tag:number<span class="Special"> <- </span>get *deletion, <span class="Constant">tag:offset</span> coalesce?:boolean<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> <span class="muControl">break-unless</span> coalesce? - delete-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> + delete-until:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> *delete-until<span class="Special"> <- </span>next *before-cursor - deleted-so-far:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + deleted-so-far:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> *deleted-so-far<span class="Special"> <- </span>append *deleted-so-far, deleted-cell after-row:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="muControl">break</span> <span class="Constant">+done-adding-delete-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cell/deleted, *before-cursor/delete-from, deleted-until, <span class="Constant">2/coalesce-delete</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -1888,16 +1888,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-k [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press ctrl-k ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1905,8 +1905,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1916,7 +1916,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1925,8 +1925,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1936,7 +1936,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -1946,8 +1946,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1957,7 +1957,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1969,15 +1969,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-end-of-line-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-end-of-line-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -1989,16 +1989,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-u ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .c .</span> @@ -2006,8 +2006,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -2017,7 +2017,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2026,8 +2026,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -2037,7 +2037,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -2047,8 +2047,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -2058,7 +2058,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2070,15 +2070,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-start-of-line-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-start-of-line-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, *cursor-row/<span class="muRecipe">after</span>, *cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -2088,16 +2088,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u-2 [ <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abc]</span> press ctrl-u press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> diff --git a/html/fork.mu.html b/html/fork.mu.html index 69dc4e30..1a378255 100644 --- a/html/fork.mu.html +++ b/html/fork.mu.html @@ -16,8 +16,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .muControl { color: #c0a020; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } -.Constant { color: #00a0a0; } .Delimiter { color: #a04060; } +.Constant { color: #00a0a0; } --> </style> @@ -32,7 +32,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># example program: running multiple routines</span> <span class="muRecipe">recipe</span> main [ - start-running <span class="Constant">thread2:recipe</span> + start-running thread2 <span class="Delimiter">{</span> $print <span class="Constant">34</span> <span class="muControl">loop</span> diff --git a/html/global.mu.html b/html/global.mu.html index 6e2c0491..a95ef552 100644 --- a/html/global.mu.html +++ b/html/global.mu.html @@ -32,7 +32,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> main [ <span class="Comment"># allocate 5 locations for globals</span> - <span class="Constant">global-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">5</span> + <span class="Constant">global-space</span>:address:shared:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">5</span> <span class="Comment"># read to globals by using /space:global</span> <span class="Special">1:number/space:global</span><span class="Special"> <- </span>copy <span class="Constant">3</span> foo @@ -40,7 +40,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> foo [ <span class="Comment"># ditto for writing to globals</span> - $print <span class="Special">1:number/space:global</span> + $print <span class="Special">1:number/space:global</span>, <span class="Constant">10/newline</span> ] </pre> </body> diff --git a/html/screen.mu.html b/html/screen.mu.html index ea2b0232..000304a5 100644 --- a/html/screen.mu.html +++ b/html/screen.mu.html @@ -35,12 +35,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> main [ open-console - print <span class="Constant">0/screen</span>, <span class="Constant">97/a</span>, <span class="Constant">2/red</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + print <span class="Constant">0/screen</span>, <span class="Constant">10</span>:character/a, <span class="Constant">2/red</span> <span class="Constant">1</span>:number/<span class="Special">raw</span>, <span class="Constant">2</span>:number/<span class="Special">raw <- </span>cursor-position <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> clear-screen <span class="Constant">0/screen</span> move-cursor <span class="Constant">0/screen</span>, <span class="Constant">0/row</span>, <span class="Constant">4/column</span> - print <span class="Constant">0/screen</span>, <span class="Constant">98/b</span> + <span class="Constant">10</span>:character<span class="Special"> <- </span>copy <span class="Constant">98/b</span> + print <span class="Constant">0/screen</span>, <span class="Constant">10</span>:character wait-for-event <span class="Constant">0/console</span> move-cursor <span class="Constant">0/screen</span>, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> clear-line <span class="Constant">0/screen</span> diff --git a/index.html b/index.html index aed791b6..e88da515 100644 --- a/index.html +++ b/index.html @@ -106,12 +106,14 @@ recipes pass arguments or 'ingredients' without introducing any syntax and breaking the metaphor of recipes as lists of instructions. <br/><a href='html/036call_reply.cc.html'>036call_reply.cc</a>: recipes can return arbitrary numbers of values to their callers. -<br/><a href='html/037recipe.cc.html'>037recipe.cc</a>: passing recipes around +<br/><a href='html/038new.cc.html'>038new.cc</a>: rudimentary memory +allocator that is aware of all global types in any Mu program. +<br/><a href='html/061recipe.cc.html'>061recipe.cc</a>: passing recipes around as first-class values in higher-order functions. -<br/><a href='html/038scheduler.cc.html'>038scheduler.cc</a>: running multiple +<br/><a href='html/062scheduler.cc.html'>062scheduler.cc</a>: running multiple recipes concurrently using <em>routines</em> that might execute in interleaved fashion. -<br/><a href='html/039wait.cc.html'>039wait.cc</a>: primitives for +<br/><a href='html/063wait.cc.html'>063wait.cc</a>: primitives for synchronization between routines. <p><b>Part III</b>: transforms to provide 80% of the benefits of high-level @@ -122,20 +124,18 @@ structured goto-less programming without introducing the syntax of conditionals and loops other languages require. <br/><a href='html/042name.cc.html'>042name.cc</a>: how Mu transforms variable names to raw memory addresses. -<br/><a href='html/043new.cc.html'>043new.cc</a>: rudimentary memory -allocator that is aware of all global types in any Mu program. -<br/><a href='html/044space.cc.html'>044space.cc</a>: how variables in +<br/><a href='html/043space.cc.html'>043space.cc</a>: how variables in different routines are isolated from each other using <em>spaces</em>. Mu ‘local variables’ are allocated on the heap. -<br/><a href='html/045space_surround.cc.html'>045space_surround.cc</a>: +<br/><a href='html/044space_surround.cc.html'>044space_surround.cc</a>: Chaining spaces together to accomodate variables with varying lifetimes and ownership properties. -<br/><a href='html/046closure_name.cc.html'>046closure_name.cc</a>: how spaces +<br/><a href='html/045closure_name.cc.html'>045closure_name.cc</a>: how spaces can implement lexical scope. -<br/><a href='html/047global.cc.html'>047global.cc</a>: support for 'global' +<br/><a href='html/046global.cc.html'>046global.cc</a>: support for 'global' variables that are always available inside a single routine. Mu has no variables that are available transparently across routines. -<br/><a href='html/048check_type_by_name.cc.html'>048check_type_by_name.cc</a>: +<br/><a href='html/047check_type_by_name.cc.html'>047check_type_by_name.cc</a>: a simple transform to deduce missing types in instructions on the basis of previous instructions in the same recipe. <br/><a href='html/050scenario.cc.html'>050scenario.cc</a>: Mu's first syntax |