diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-03-20 16:53:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-03-20 16:53:36 -0700 |
commit | 317c0a34e82c9a64050f106761ee837310c3fd0c (patch) | |
tree | 525925001e3c1c4026544ec04627dee93e326fbe | |
parent | 09125ea2169f2820c2174696ccf7cef00452c60e (diff) | |
download | mu-317c0a34e82c9a64050f106761ee837310c3fd0c.tar.gz |
3803
-rw-r--r-- | 026call.cc | 2 | ||||
-rw-r--r-- | 072scheduler.cc | 2 | ||||
-rw-r--r-- | 101run_sandboxed.cc | 1 | ||||
-rw-r--r-- | html/026call.cc.html | 2 | ||||
-rw-r--r-- | html/072scheduler.cc.html | 2 | ||||
-rw-r--r-- | html/101run_sandboxed.cc.html | 441 |
6 files changed, 224 insertions, 226 deletions
diff --git a/026call.cc b/026call.cc index 113e71bb..7ad4dd33 100644 --- a/026call.cc +++ b/026call.cc @@ -155,7 +155,7 @@ const vector<instruction>& routine::steps() const { return get(Recipe, calls.front().running_recipe).steps; } -:(before "Running One Instruction") +:(after "Running One Instruction") // when we reach the end of one call, we may reach the end of the one below // it, and the one below that, and so on while (current_step_index() >= SIZE(Current_routine->steps())) { diff --git a/072scheduler.cc b/072scheduler.cc index 68f2e463..ad79bace 100644 --- a/072scheduler.cc +++ b/072scheduler.cc @@ -22,7 +22,7 @@ int Scheduling_interval = 500; int instructions_run_this_scheduling_slice; :(before "End routine Constructor") instructions_run_this_scheduling_slice = 0; -:(before "Running One Instruction") +:(after "Running One Instruction") ++Current_routine->instructions_run_this_scheduling_slice; :(replace{} "bool should_continue_running(const routine* current_routine)") bool should_continue_running(const routine* current_routine) { diff --git a/101run_sandboxed.cc b/101run_sandboxed.cc index d47cdb86..b048b321 100644 --- a/101run_sandboxed.cc +++ b/101run_sandboxed.cc @@ -337,7 +337,6 @@ def main [ :(scenario "run_interactive_ignores_products_in_nested_functions") def main [ 1:text <- new [foo] - stash [aaa] 2:text <- run-sandboxed 1:text 10:@:char <- copy *2:text ] diff --git a/html/026call.cc.html b/html/026call.cc.html index bb0dcfcd..40a396b5 100644 --- a/html/026call.cc.html +++ b/html/026call.cc.html @@ -219,7 +219,7 @@ if ('onhashchange' in window) { <span id="L155" class="LineNr">155 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> <span id="L156" class="LineNr">156 </span><span class="Delimiter">}</span> <span id="L157" class="LineNr">157 </span> -<span id="L158" class="LineNr">158 </span><span class="Delimiter">:(before "Running One Instruction")</span> +<span id="L158" class="LineNr">158 </span><span class="Delimiter">:(after "Running One Instruction")</span> <span id="L159" class="LineNr">159 </span><span class="Comment">// when we reach the end of one call, we may reach the end of the one below</span> <span id="L160" class="LineNr">160 </span><span class="Comment">// it, and the one below that, and so on</span> <span id="L161" class="LineNr">161 </span><span class="Normal">while</span> <span class="Delimiter">(</span>current_step_index<span class="Delimiter">()</span> >= <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>steps<span class="Delimiter">()))</span> <span class="Delimiter">{</span> diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index f63cfae0..bdb3cd76 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -87,7 +87,7 @@ if ('onhashchange' in window) { <span id="L22" class="LineNr"> 22 </span><span class="Normal">int</span> instructions_run_this_scheduling_slice<span class="Delimiter">;</span> <span id="L23" class="LineNr"> 23 </span><span class="Delimiter">:(before "End routine Constructor")</span> <span id="L24" class="LineNr"> 24 </span>instructions_run_this_scheduling_slice = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(before "Running One Instruction")</span> +<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(after "Running One Instruction")</span> <span id="L26" class="LineNr"> 26 </span> ++Current_routine<span class="Delimiter">-></span>instructions_run_this_scheduling_slice<span class="Delimiter">;</span> <span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(replace{} "bool should_continue_running(const routine* current_routine)")</span> <span id="L28" class="LineNr"> 28 </span><span class="Normal">bool</span> <a href='072scheduler.cc.html#L28'>should_continue_running</a><span class="Delimiter">(</span><span class="Normal">const</span> routine* current_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index 0eaeea27..8c3b1f54 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -120,9 +120,9 @@ if ('onhashchange' in window) { <span id="L56" class="LineNr"> 56 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!new_code_pushed_to_stack<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L57" class="LineNr"> 57 </span> <span class="Conceal">¦</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">5</span><span class="Delimiter">);</span> <span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</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 id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</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><a href='101run_sandboxed.cc.html#L449'>trace_error_contents</a><span class="Delimiter">());</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</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><a href='101run_sandboxed.cc.html#L448'>trace_error_contents</a><span class="Delimiter">());</span> <span id="L60" class="LineNr"> 60 </span> <span class="Conceal">¦</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L61" class="LineNr"> 61 </span> <span class="Conceal">¦</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L463'>trace_app_contents</a><span class="Delimiter">());</span> +<span id="L61" class="LineNr"> 61 </span> <span class="Conceal">¦</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L462'>trace_app_contents</a><span class="Delimiter">());</span> <span id="L62" class="LineNr"> 62 </span> <span class="Conceal">¦</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// completed</span> <span id="L63" class="LineNr"> 63 </span> <span class="Conceal">¦</span> <a href='101run_sandboxed.cc.html#L155'>run_code_end</a><span class="Delimiter">();</span> <span id="L64" class="LineNr"> 64 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// done with this instruction</span> @@ -161,7 +161,7 @@ if ('onhashchange' in window) { <span id="L97" class="LineNr"> 97 </span> <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < Reserved_for_tests<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span id="L98" class="LineNr"> 98 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> Memory<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">}</span> -<span id="L100" class="LineNr">100 </span> string command = <a href='003trace.cc.html#L355'>trim</a><span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L428'>strip_comments</a><span class="Delimiter">(</span><a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span><a href='043space.cc.html#L76'>address</a><span class="Delimiter">)));</span> +<span id="L100" class="LineNr">100 </span> string command = <a href='003trace.cc.html#L355'>trim</a><span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L427'>strip_comments</a><span class="Delimiter">(</span><a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span><a href='043space.cc.html#L76'>address</a><span class="Delimiter">)));</span> <span id="L101" class="LineNr">101 </span> Name[get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"interactive"</span><span class="Delimiter">)</span>]<span class="Delimiter">.</span><a href='050scenario.cc.html#L60'>clear</a><span class="Delimiter">();</span> <span id="L102" class="LineNr">102 </span> <a href='101run_sandboxed.cc.html#L144'>run_code_begin</a><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">should_stash_snapshots</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span> <span id="L103" class="LineNr">103 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>command<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> @@ -355,7 +355,7 @@ if ('onhashchange' in window) { <span id="L291" class="LineNr">291 </span><span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span id="L292" class="LineNr">292 </span><span class="Normal">case</span> SAVE_ERRORS: <span class="Delimiter">{</span> <span id="L293" class="LineNr">293 </span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L294" class="LineNr">294 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L449'>trace_error_contents</a><span class="Delimiter">());</span> +<span id="L294" class="LineNr">294 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L448'>trace_error_contents</a><span class="Delimiter">());</span> <span id="L295" class="LineNr">295 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L296" class="LineNr">296 </span><span class="Delimiter">}</span> <span id="L297" class="LineNr">297 </span> @@ -370,7 +370,7 @@ if ('onhashchange' in window) { <span id="L306" class="LineNr">306 </span><span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span id="L307" class="LineNr">307 </span><span class="Normal">case</span> SAVE_APP_TRACE: <span class="Delimiter">{</span> <span id="L308" class="LineNr">308 </span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L309" class="LineNr">309 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L463'>trace_app_contents</a><span class="Delimiter">());</span> +<span id="L309" class="LineNr">309 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L462'>trace_app_contents</a><span class="Delimiter">());</span> <span id="L310" class="LineNr">310 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L311" class="LineNr">311 </span><span class="Delimiter">}</span> <span id="L312" class="LineNr">312 </span> @@ -401,222 +401,221 @@ if ('onhashchange' in window) { <span id="L337" class="LineNr">337 </span><span class="Delimiter">:(scenario "run_interactive_ignores_products_in_nested_functions")</span> <span id="L338" class="LineNr">338 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L339" class="LineNr">339 </span> <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [foo] -<span id="L340" class="LineNr">340 </span> stash [aaa] -<span id="L341" class="LineNr">341 </span> <span class="Constant">2</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text -<span id="L342" class="LineNr">342 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">2</span>:text -<span id="L343" class="LineNr">343 </span>] -<span id="L344" class="LineNr">344 </span><span class="muRecipe">def</span> foo [ -<span id="L345" class="LineNr">345 </span> <span class="Constant">20</span>:num<span class="Special"> <- </span>copy <span class="Constant">1234</span> -<span id="L346" class="LineNr">346 </span> <span class="Delimiter">{</span> -<span id="L347" class="LineNr">347 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span> -<span id="L348" class="LineNr">348 </span> <span class="Conceal">¦</span> reply <span class="Constant">5678</span> -<span id="L349" class="LineNr">349 </span> <span class="Delimiter">}</span> -<span id="L350" class="LineNr">350 </span>] -<span id="L351" class="LineNr">351 </span><span class="Comment"># no product should have been tracked</span> -<span id="L352" class="LineNr">352 </span><span class="traceContains">+mem: storing 0 in location 10</span> -<span id="L353" class="LineNr">353 </span> -<span id="L354" class="LineNr">354 </span><span class="Delimiter">:(scenario "run_interactive_returns_text")</span> -<span id="L355" class="LineNr">355 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L356" class="LineNr">356 </span> <span class="Comment"># try to interactively add 2 and 2</span> -<span id="L357" class="LineNr">357 </span> <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [ -<span id="L358" class="LineNr">358 </span> <span class="Conceal">¦</span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [a] -<span id="L359" class="LineNr">359 </span> <span class="Conceal">¦</span> <span class="Normal">y</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [b] -<span id="L360" class="LineNr">360 </span> <span class="Conceal">¦</span> <span class="Normal">z</span>:text<span class="Special"> <- </span>append x:text<span class="Delimiter">,</span> y:text -<span id="L361" class="LineNr">361 </span> ] -<span id="L362" class="LineNr">362 </span> <span class="Constant">2</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text -<span id="L363" class="LineNr">363 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">2</span>:text -<span id="L364" class="LineNr">364 </span>] -<span id="L365" class="LineNr">365 </span><span class="Comment"># output contains "ab"</span> -<span id="L366" class="LineNr">366 </span><span class="traceContains">+mem: storing 97 in location 11</span> -<span id="L367" class="LineNr">367 </span><span class="traceContains">+mem: storing 98 in location 12</span> -<span id="L368" class="LineNr">368 </span> -<span id="L369" class="LineNr">369 </span><span class="Delimiter">:(scenario "run_interactive_returns_errors")</span> -<span id="L370" class="LineNr">370 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L371" class="LineNr">371 </span> <span class="Comment"># run a command that generates an error</span> -<span id="L372" class="LineNr">372 </span> <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [x:num<span class="Special"> <- </span>copy <span class="Constant">34</span> -<span id="L373" class="LineNr">373 </span>get x:num<span class="Delimiter">,</span> <span class="Constant">foo:offset</span>] -<span id="L374" class="LineNr">374 </span> <span class="Constant">2</span>:text<span class="Delimiter">,</span> <span class="Constant">3</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text -<span id="L375" class="LineNr">375 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">3</span>:text -<span id="L376" class="LineNr">376 </span>] -<span id="L377" class="LineNr">377 </span><span class="Comment"># error should be "unknown element foo in container number"</span> -<span id="L378" class="LineNr">378 </span><span class="traceContains">+mem: storing 117 in location 11</span> -<span id="L379" class="LineNr">379 </span><span class="traceContains">+mem: storing 110 in location 12</span> -<span id="L380" class="LineNr">380 </span><span class="traceContains">+mem: storing 107 in location 13</span> -<span id="L381" class="LineNr">381 </span><span class="traceContains">+mem: storing 110 in location 14</span> -<span id="L382" class="LineNr">382 </span><span class="Comment"># ...</span> -<span id="L383" class="LineNr">383 </span> -<span id="L384" class="LineNr">384 </span><span class="Delimiter">:(scenario run_interactive_with_comment)</span> -<span id="L385" class="LineNr">385 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L386" class="LineNr">386 </span> <span class="Comment"># 2 instructions, with a comment after the first</span> -<span id="L387" class="LineNr">387 </span> <span class="Constant">1</span>:&:@:num<span class="Special"> <- </span><span class="Normal">new</span> [a:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abc</span> -<span id="L388" class="LineNr">388 </span><span class="Normal">b</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> -<span id="L389" class="LineNr">389 </span>] -<span id="L390" class="LineNr">390 </span> <span class="Constant">2</span>:text<span class="Delimiter">,</span> <span class="Constant">3</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text -<span id="L391" class="LineNr">391 </span>] -<span id="L392" class="LineNr">392 </span><span class="Comment"># no errors</span> -<span id="L393" class="LineNr">393 </span><span class="traceContains">+mem: storing 0 in location 3</span> -<span id="L394" class="LineNr">394 </span> -<span id="L395" class="LineNr">395 </span><span class="Delimiter">:(before "End Running One Instruction")</span> -<span id="L396" class="LineNr">396 </span><span class="Normal">if</span> <span class="Delimiter">(</span>Track_most_recent_products && <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">)</span> == Call_depth_to_track_most_recent_products_at<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L397" class="LineNr">397 </span> <a href='101run_sandboxed.cc.html#L400'>track_most_recent_products</a><span class="Delimiter">(</span>current_instruction<span class="Delimiter">(),</span> products<span class="Delimiter">);</span> -<span id="L398" class="LineNr">398 </span><span class="Delimiter">}</span> -<span id="L399" class="LineNr">399 </span><span class="Delimiter">:(code)</span> -<span id="L400" class="LineNr">400 </span><span class="Normal">void</span> <a href='101run_sandboxed.cc.html#L400'>track_most_recent_products</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& <a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">,</span> <span class="Normal">const</span> vector<vector<<span class="Normal">double</span>> >& products<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L401" class="LineNr">401 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L402" class="LineNr">402 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L403" class="LineNr">403 </span> <span class="Conceal">¦</span> <span class="Comment">// A sandbox can print a string result, but only if it is actually saved</span> -<span id="L404" class="LineNr">404 </span> <span class="Conceal">¦</span> <span class="Comment">// to a variable in the sandbox, because otherwise the results are</span> -<span id="L405" class="LineNr">405 </span> <span class="Conceal">¦</span> <span class="Comment">// reclaimed before the sandbox sees them. So you get these interactions</span> -<span id="L406" class="LineNr">406 </span> <span class="Conceal">¦</span> <span class="Comment">// in the sandbox:</span> -<span id="L407" class="LineNr">407 </span> <span class="Conceal">¦</span> <span class="Comment">//</span> -<span id="L408" class="LineNr">408 </span> <span class="Conceal">¦</span> <span class="Comment">// new [abc]</span> -<span id="L409" class="LineNr">409 </span> <span class="Conceal">¦</span> <span class="Comment">// => <address></span> -<span id="L410" class="LineNr">410 </span> <span class="Conceal">¦</span> <span class="Comment">//</span> -<span id="L411" class="LineNr">411 </span> <span class="Conceal">¦</span> <span class="Comment">// x:text <- new [abc]</span> -<span id="L412" class="LineNr">412 </span> <span class="Conceal">¦</span> <span class="Comment">// => abc</span> -<span id="L413" class="LineNr">413 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span><a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L414" class="LineNr">414 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='027call_ingredient.cc.html#L174'>is_mu_text</a><span class="Delimiter">(</span><a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L415" class="LineNr">415 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// error handled elsewhere</span> -<span id="L416" class="LineNr">416 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L417" class="LineNr">417 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L418" class="LineNr">418 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L419" class="LineNr">419 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L420" class="LineNr">420 </span> <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> -<span id="L421" class="LineNr">421 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L422" class="LineNr">422 </span> <span class="Conceal">¦</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L423" class="LineNr">423 </span> <span class="Delimiter">}</span> -<span id="L424" class="LineNr">424 </span> Most_recent_products = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L425" class="LineNr">425 </span><span class="Delimiter">}</span> -<span id="L426" class="LineNr">426 </span> -<span id="L427" class="LineNr">427 </span><span class="Delimiter">:(code)</span> -<span id="L428" class="LineNr">428 </span>string <a href='101run_sandboxed.cc.html#L428'>strip_comments</a><span class="Delimiter">(</span>string in<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L429" class="LineNr">429 </span> ostringstream result<span class="Delimiter">;</span> -<span id="L430" class="LineNr">430 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L431" class="LineNr">431 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L432" class="LineNr">432 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> result << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L433" class="LineNr">433 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L434" class="LineNr">434 </span> <span class="Conceal">¦</span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L435" class="LineNr">435 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">while</span> <span class="Delimiter">(</span>i+<span class="Constant">1</span> < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i+<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> -<span id="L436" class="LineNr">436 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ++i<span class="Delimiter">;</span> -<span id="L437" class="LineNr">437 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L438" class="LineNr">438 </span> <span class="Delimiter">}</span> -<span id="L439" class="LineNr">439 </span> <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L440" class="LineNr">440 </span><span class="Delimiter">}</span> -<span id="L441" class="LineNr">441 </span> -<span id="L442" class="LineNr">442 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L442'>stringified_value_of_location</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='043space.cc.html#L76'>address</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L443" class="LineNr">443 </span> <span class="Comment">// convert to string</span> -<span id="L444" class="LineNr">444 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L445" class="LineNr">445 </span> out << no_scientific<span class="Delimiter">(</span><a href='001help.cc.html#L225'>get_or_insert</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> <a href='043space.cc.html#L76'>address</a><span class="Delimiter">));</span> -<span id="L446" class="LineNr">446 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span>str<span class="Delimiter">());</span> -<span id="L447" class="LineNr">447 </span><span class="Delimiter">}</span> -<span id="L448" class="LineNr">448 </span> -<span id="L449" class="LineNr">449 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L449'>trace_error_contents</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L450" class="LineNr">450 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L451" class="LineNr">451 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L452" class="LineNr">452 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L453" class="LineNr">453 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>label != <span class="Constant">"error"</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L454" class="LineNr">454 </span> <span class="Conceal">¦</span> out << p<span class="Delimiter">-></span>contents<span class="Delimiter">;</span> -<span id="L455" class="LineNr">455 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*--p<span class="Delimiter">-></span>contents<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L456" class="LineNr">456 </span> <span class="Delimiter">}</span> -<span id="L457" class="LineNr">457 </span> string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L458" class="LineNr">458 </span> <a href='101run_sandboxed.cc.html#L477'>truncate</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L459" class="LineNr">459 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L460" class="LineNr">460 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L461" class="LineNr">461 </span><span class="Delimiter">}</span> -<span id="L462" class="LineNr">462 </span> -<span id="L463" class="LineNr">463 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L463'>trace_app_contents</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L464" class="LineNr">464 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L465" class="LineNr">465 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L466" class="LineNr">466 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L467" class="LineNr">467 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>depth != App_depth<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L468" class="LineNr">468 </span> <span class="Conceal">¦</span> out << p<span class="Delimiter">-></span>contents<span class="Delimiter">;</span> -<span id="L469" class="LineNr">469 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*--p<span class="Delimiter">-></span>contents<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L470" class="LineNr">470 </span> <span class="Delimiter">}</span> -<span id="L471" class="LineNr">471 </span> string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L472" class="LineNr">472 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L473" class="LineNr">473 </span> <a href='101run_sandboxed.cc.html#L477'>truncate</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L474" class="LineNr">474 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L475" class="LineNr">475 </span><span class="Delimiter">}</span> -<span id="L476" class="LineNr">476 </span> -<span id="L477" class="LineNr">477 </span><span class="Normal">void</span> <a href='101run_sandboxed.cc.html#L477'>truncate</a><span class="Delimiter">(</span>string& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L478" class="LineNr">478 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>x<span class="Delimiter">)</span> > <span class="Constant">1024</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L479" class="LineNr">479 </span> <span class="Conceal">¦</span> x<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">1024</span><span class="Delimiter">);</span> -<span id="L480" class="LineNr">480 </span> <span class="Conceal">¦</span> *x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L481" class="LineNr">481 </span> <span class="Conceal">¦</span> *++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> -<span id="L482" class="LineNr">482 </span> <span class="Conceal">¦</span> *++++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> -<span id="L483" class="LineNr">483 </span> <span class="Delimiter">}</span> -<span id="L484" class="LineNr">484 </span><span class="Delimiter">}</span> -<span id="L485" class="LineNr">485 </span> -<span id="L486" class="LineNr">486 </span><span class="Comment">//: simpler version of run-sandboxed: doesn't do any running, just loads</span> -<span id="L487" class="LineNr">487 </span><span class="Comment">//: recipes and reports errors.</span> -<span id="L488" class="LineNr">488 </span> -<span id="L489" class="LineNr">489 </span><span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -<span id="L490" class="LineNr">490 </span>RELOAD<span class="Delimiter">,</span> -<span id="L491" class="LineNr">491 </span><span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -<span id="L492" class="LineNr">492 </span><a href='001help.cc.html#L218'>put</a><span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"reload"</span><span class="Delimiter">,</span> RELOAD<span class="Delimiter">);</span> -<span id="L493" class="LineNr">493 </span><span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span id="L494" class="LineNr">494 </span><span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> -<span id="L495" class="LineNr">495 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><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 id="L496" class="LineNr">496 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'reload' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> -<span id="L497" class="LineNr">497 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L498" class="LineNr">498 </span> <span class="Delimiter">}</span> -<span id="L499" class="LineNr">499 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_text<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> -<span id="L500" class="LineNr">500 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><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 'reload' should be a string, but got '"</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> -<span id="L501" class="LineNr">501 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L502" class="LineNr">502 </span> <span class="Delimiter">}</span> -<span id="L503" class="LineNr">503 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L504" class="LineNr">504 </span><span class="Delimiter">}</span> -<span id="L505" class="LineNr">505 </span><span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> -<span id="L506" class="LineNr">506 </span><span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> -<span id="L507" class="LineNr">507 </span> restore_non_recipe_snapshots<span class="Delimiter">();</span> -<span id="L508" class="LineNr">508 </span> string code = <a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> -<span id="L509" class="LineNr">509 </span> <a href='101run_sandboxed.cc.html#L144'>run_code_begin</a><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">should_stash_snapshots</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span> -<span id="L510" class="LineNr">510 </span> routine* save_current_routine = Current_routine<span class="Delimiter">;</span> -<span id="L511" class="LineNr">511 </span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L512" class="LineNr">512 </span> Sandbox_mode = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L513" class="LineNr">513 </span> vector<recipe_ordinal> recipes_reloaded = load<span class="Delimiter">(</span>code<span class="Delimiter">);</span> -<span id="L514" class="LineNr">514 </span> <a href='012transform.cc.html#L46'>transform_all</a><span class="Delimiter">();</span> -<span id="L515" class="LineNr">515 </span> Trace_stream<span class="Delimiter">-></span><a href='003trace.cc.html#L127'>newline</a><span class="Delimiter">();</span> <span class="Comment">// flush trace</span> -<span id="L516" class="LineNr">516 </span> Sandbox_mode = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L517" class="LineNr">517 </span> Current_routine = save_current_routine<span class="Delimiter">;</span> -<span id="L518" class="LineNr">518 </span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L519" class="LineNr">519 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L449'>trace_error_contents</a><span class="Delimiter">());</span> -<span id="L520" class="LineNr">520 </span> <a href='101run_sandboxed.cc.html#L155'>run_code_end</a><span class="Delimiter">();</span> <span class="Comment">// wait until we're done with the trace contents</span> -<span id="L521" class="LineNr">521 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L522" class="LineNr">522 </span><span class="Delimiter">}</span> -<span id="L523" class="LineNr">523 </span> -<span id="L524" class="LineNr">524 </span><span class="Delimiter">:(scenario reload_continues_past_error)</span> -<span id="L525" class="LineNr">525 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L526" class="LineNr">526 </span> local-scope -<span id="L527" class="LineNr">527 </span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [recipe foo [ -<span id="L528" class="LineNr">528 </span> get <span class="Constant">1234</span>:num<span class="Delimiter">,</span> <span class="Constant">foo:offset</span> -<span id="L529" class="LineNr">529 </span>]] -<span id="L530" class="LineNr">530 </span> reload x -<span id="L531" class="LineNr">531 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy <span class="Constant">34</span> -<span id="L532" class="LineNr">532 </span>] -<span id="L533" class="LineNr">533 </span><span class="traceContains">+mem: storing 34 in location 1</span> -<span id="L534" class="LineNr">534 </span> -<span id="L535" class="LineNr">535 </span><span class="Delimiter">:(scenario reload_can_repeatedly_load_container_definitions)</span> -<span id="L536" class="LineNr">536 </span><span class="Comment"># define a container and try to create it (merge requires knowing container size)</span> -<span id="L537" class="LineNr">537 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L538" class="LineNr">538 </span> local-scope -<span id="L539" class="LineNr">539 </span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [ -<span id="L540" class="LineNr">540 </span> <span class="Conceal">¦</span> container foo [ -<span id="L541" class="LineNr">541 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">x</span>:num -<span id="L542" class="LineNr">542 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">y</span>:num -<span id="L543" class="LineNr">543 </span> <span class="Conceal">¦</span> ] -<span id="L544" class="LineNr">544 </span> <span class="Conceal">¦</span> <a href='010vm.cc.html#L19'>recipe</a> bar [ -<span id="L545" class="LineNr">545 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> local-scope -<span id="L546" class="LineNr">546 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">x</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> -<span id="L547" class="LineNr">547 </span> <span class="Conceal">¦</span> ] -<span id="L548" class="LineNr">548 </span> ] -<span id="L549" class="LineNr">549 </span> <span class="Comment"># save warning addresses in locations of type 'number' to avoid spurious changes to them due to 'abandon'</span> -<span id="L550" class="LineNr">550 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>reload x -<span id="L551" class="LineNr">551 </span> <span class="Constant">2</span>:num/<span class="Special">raw <- </span>reload x -<span id="L552" class="LineNr">552 </span>] -<span id="L553" class="LineNr">553 </span><span class="Comment"># no errors on either load</span> -<span id="L554" class="LineNr">554 </span><span class="traceContains">+mem: storing 0 in location 1</span> -<span id="L555" class="LineNr">555 </span><span class="traceContains">+mem: storing 0 in location 2</span> +<span id="L340" class="LineNr">340 </span> <span class="Constant">2</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text +<span id="L341" class="LineNr">341 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">2</span>:text +<span id="L342" class="LineNr">342 </span>] +<span id="L343" class="LineNr">343 </span><span class="muRecipe">def</span> foo [ +<span id="L344" class="LineNr">344 </span> <span class="Constant">20</span>:num<span class="Special"> <- </span>copy <span class="Constant">1234</span> +<span id="L345" class="LineNr">345 </span> <span class="Delimiter">{</span> +<span id="L346" class="LineNr">346 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span> +<span id="L347" class="LineNr">347 </span> <span class="Conceal">¦</span> reply <span class="Constant">5678</span> +<span id="L348" class="LineNr">348 </span> <span class="Delimiter">}</span> +<span id="L349" class="LineNr">349 </span>] +<span id="L350" class="LineNr">350 </span><span class="Comment"># no product should have been tracked</span> +<span id="L351" class="LineNr">351 </span><span class="traceContains">+mem: storing 0 in location 10</span> +<span id="L352" class="LineNr">352 </span> +<span id="L353" class="LineNr">353 </span><span class="Delimiter">:(scenario "run_interactive_returns_text")</span> +<span id="L354" class="LineNr">354 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L355" class="LineNr">355 </span> <span class="Comment"># try to interactively add 2 and 2</span> +<span id="L356" class="LineNr">356 </span> <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [ +<span id="L357" class="LineNr">357 </span> <span class="Conceal">¦</span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [a] +<span id="L358" class="LineNr">358 </span> <span class="Conceal">¦</span> <span class="Normal">y</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [b] +<span id="L359" class="LineNr">359 </span> <span class="Conceal">¦</span> <span class="Normal">z</span>:text<span class="Special"> <- </span>append x:text<span class="Delimiter">,</span> y:text +<span id="L360" class="LineNr">360 </span> ] +<span id="L361" class="LineNr">361 </span> <span class="Constant">2</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text +<span id="L362" class="LineNr">362 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">2</span>:text +<span id="L363" class="LineNr">363 </span>] +<span id="L364" class="LineNr">364 </span><span class="Comment"># output contains "ab"</span> +<span id="L365" class="LineNr">365 </span><span class="traceContains">+mem: storing 97 in location 11</span> +<span id="L366" class="LineNr">366 </span><span class="traceContains">+mem: storing 98 in location 12</span> +<span id="L367" class="LineNr">367 </span> +<span id="L368" class="LineNr">368 </span><span class="Delimiter">:(scenario "run_interactive_returns_errors")</span> +<span id="L369" class="LineNr">369 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L370" class="LineNr">370 </span> <span class="Comment"># run a command that generates an error</span> +<span id="L371" class="LineNr">371 </span> <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [x:num<span class="Special"> <- </span>copy <span class="Constant">34</span> +<span id="L372" class="LineNr">372 </span>get x:num<span class="Delimiter">,</span> <span class="Constant">foo:offset</span>] +<span id="L373" class="LineNr">373 </span> <span class="Constant">2</span>:text<span class="Delimiter">,</span> <span class="Constant">3</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text +<span id="L374" class="LineNr">374 </span> <span class="Constant">10</span>:@:<span class="Normal">char</span><span class="Special"> <- </span>copy *<span class="Constant">3</span>:text +<span id="L375" class="LineNr">375 </span>] +<span id="L376" class="LineNr">376 </span><span class="Comment"># error should be "unknown element foo in container number"</span> +<span id="L377" class="LineNr">377 </span><span class="traceContains">+mem: storing 117 in location 11</span> +<span id="L378" class="LineNr">378 </span><span class="traceContains">+mem: storing 110 in location 12</span> +<span id="L379" class="LineNr">379 </span><span class="traceContains">+mem: storing 107 in location 13</span> +<span id="L380" class="LineNr">380 </span><span class="traceContains">+mem: storing 110 in location 14</span> +<span id="L381" class="LineNr">381 </span><span class="Comment"># ...</span> +<span id="L382" class="LineNr">382 </span> +<span id="L383" class="LineNr">383 </span><span class="Delimiter">:(scenario run_interactive_with_comment)</span> +<span id="L384" class="LineNr">384 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L385" class="LineNr">385 </span> <span class="Comment"># 2 instructions, with a comment after the first</span> +<span id="L386" class="LineNr">386 </span> <span class="Constant">1</span>:&:@:num<span class="Special"> <- </span><span class="Normal">new</span> [a:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abc</span> +<span id="L387" class="LineNr">387 </span><span class="Normal">b</span>:num<span class="Special"> <- </span>copy <span class="Constant">0</span> +<span id="L388" class="LineNr">388 </span>] +<span id="L389" class="LineNr">389 </span> <span class="Constant">2</span>:text<span class="Delimiter">,</span> <span class="Constant">3</span>:text<span class="Special"> <- </span>run-sandboxed <span class="Constant">1</span>:text +<span id="L390" class="LineNr">390 </span>] +<span id="L391" class="LineNr">391 </span><span class="Comment"># no errors</span> +<span id="L392" class="LineNr">392 </span><span class="traceContains">+mem: storing 0 in location 3</span> +<span id="L393" class="LineNr">393 </span> +<span id="L394" class="LineNr">394 </span><span class="Delimiter">:(before "End Running One Instruction")</span> +<span id="L395" class="LineNr">395 </span><span class="Normal">if</span> <span class="Delimiter">(</span>Track_most_recent_products && <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">)</span> == Call_depth_to_track_most_recent_products_at<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L396" class="LineNr">396 </span> <a href='101run_sandboxed.cc.html#L399'>track_most_recent_products</a><span class="Delimiter">(</span>current_instruction<span class="Delimiter">(),</span> products<span class="Delimiter">);</span> +<span id="L397" class="LineNr">397 </span><span class="Delimiter">}</span> +<span id="L398" class="LineNr">398 </span><span class="Delimiter">:(code)</span> +<span id="L399" class="LineNr">399 </span><span class="Normal">void</span> <a href='101run_sandboxed.cc.html#L399'>track_most_recent_products</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& <a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">,</span> <span class="Normal">const</span> vector<vector<<span class="Normal">double</span>> >& products<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L400" class="LineNr">400 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L401" class="LineNr">401 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L402" class="LineNr">402 </span> <span class="Conceal">¦</span> <span class="Comment">// A sandbox can print a string result, but only if it is actually saved</span> +<span id="L403" class="LineNr">403 </span> <span class="Conceal">¦</span> <span class="Comment">// to a variable in the sandbox, because otherwise the results are</span> +<span id="L404" class="LineNr">404 </span> <span class="Conceal">¦</span> <span class="Comment">// reclaimed before the sandbox sees them. So you get these interactions</span> +<span id="L405" class="LineNr">405 </span> <span class="Conceal">¦</span> <span class="Comment">// in the sandbox:</span> +<span id="L406" class="LineNr">406 </span> <span class="Conceal">¦</span> <span class="Comment">//</span> +<span id="L407" class="LineNr">407 </span> <span class="Conceal">¦</span> <span class="Comment">// new [abc]</span> +<span id="L408" class="LineNr">408 </span> <span class="Conceal">¦</span> <span class="Comment">// => <address></span> +<span id="L409" class="LineNr">409 </span> <span class="Conceal">¦</span> <span class="Comment">//</span> +<span id="L410" class="LineNr">410 </span> <span class="Conceal">¦</span> <span class="Comment">// x:text <- new [abc]</span> +<span id="L411" class="LineNr">411 </span> <span class="Conceal">¦</span> <span class="Comment">// => abc</span> +<span id="L412" class="LineNr">412 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span><a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L413" class="LineNr">413 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='027call_ingredient.cc.html#L174'>is_mu_text</a><span class="Delimiter">(</span><a href='010vm.cc.html#L32'>instruction</a><span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> +<span id="L414" class="LineNr">414 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// error handled elsewhere</span> +<span id="L415" class="LineNr">415 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L416" class="LineNr">416 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L417" class="LineNr">417 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L418" class="LineNr">418 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L419" class="LineNr">419 </span> <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> +<span id="L420" class="LineNr">420 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << no_scientific<span class="Delimiter">(</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">))</span> << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L421" class="LineNr">421 </span> <span class="Conceal">¦</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L422" class="LineNr">422 </span> <span class="Delimiter">}</span> +<span id="L423" class="LineNr">423 </span> Most_recent_products = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L424" class="LineNr">424 </span><span class="Delimiter">}</span> +<span id="L425" class="LineNr">425 </span> +<span id="L426" class="LineNr">426 </span><span class="Delimiter">:(code)</span> +<span id="L427" class="LineNr">427 </span>string <a href='101run_sandboxed.cc.html#L427'>strip_comments</a><span class="Delimiter">(</span>string in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L428" class="LineNr">428 </span> ostringstream result<span class="Delimiter">;</span> +<span id="L429" class="LineNr">429 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L430" class="LineNr">430 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L431" class="LineNr">431 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> result << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L432" class="LineNr">432 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L433" class="LineNr">433 </span> <span class="Conceal">¦</span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L434" class="LineNr">434 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">while</span> <span class="Delimiter">(</span>i+<span class="Constant">1</span> < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i+<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> +<span id="L435" class="LineNr">435 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ++i<span class="Delimiter">;</span> +<span id="L436" class="LineNr">436 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L437" class="LineNr">437 </span> <span class="Delimiter">}</span> +<span id="L438" class="LineNr">438 </span> <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L439" class="LineNr">439 </span><span class="Delimiter">}</span> +<span id="L440" class="LineNr">440 </span> +<span id="L441" class="LineNr">441 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L441'>stringified_value_of_location</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='043space.cc.html#L76'>address</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L442" class="LineNr">442 </span> <span class="Comment">// convert to string</span> +<span id="L443" class="LineNr">443 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L444" class="LineNr">444 </span> out << no_scientific<span class="Delimiter">(</span><a href='001help.cc.html#L225'>get_or_insert</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> <a href='043space.cc.html#L76'>address</a><span class="Delimiter">));</span> +<span id="L445" class="LineNr">445 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span>str<span class="Delimiter">());</span> +<span id="L446" class="LineNr">446 </span><span class="Delimiter">}</span> +<span id="L447" class="LineNr">447 </span> +<span id="L448" class="LineNr">448 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L448'>trace_error_contents</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L449" class="LineNr">449 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L450" class="LineNr">450 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L451" class="LineNr">451 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L452" class="LineNr">452 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>label != <span class="Constant">"error"</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L453" class="LineNr">453 </span> <span class="Conceal">¦</span> out << p<span class="Delimiter">-></span>contents<span class="Delimiter">;</span> +<span id="L454" class="LineNr">454 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*--p<span class="Delimiter">-></span>contents<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L455" class="LineNr">455 </span> <span class="Delimiter">}</span> +<span id="L456" class="LineNr">456 </span> string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L457" class="LineNr">457 </span> <a href='101run_sandboxed.cc.html#L476'>truncate</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L458" class="LineNr">458 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L459" class="LineNr">459 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L460" class="LineNr">460 </span><span class="Delimiter">}</span> +<span id="L461" class="LineNr">461 </span> +<span id="L462" class="LineNr">462 </span><span class="Normal">int</span> <a href='101run_sandboxed.cc.html#L462'>trace_app_contents</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L463" class="LineNr">463 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L464" class="LineNr">464 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L465" class="LineNr">465 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L466" class="LineNr">466 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>depth != App_depth<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L467" class="LineNr">467 </span> <span class="Conceal">¦</span> out << p<span class="Delimiter">-></span>contents<span class="Delimiter">;</span> +<span id="L468" class="LineNr">468 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>*--p<span class="Delimiter">-></span>contents<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L469" class="LineNr">469 </span> <span class="Delimiter">}</span> +<span id="L470" class="LineNr">470 </span> string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L471" class="LineNr">471 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L472" class="LineNr">472 </span> <a href='101run_sandboxed.cc.html#L476'>truncate</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L473" class="LineNr">473 </span> <span class="Identifier">return</span> <a href='038new_text.cc.html#L38'>new_mu_text</a><span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L474" class="LineNr">474 </span><span class="Delimiter">}</span> +<span id="L475" class="LineNr">475 </span> +<span id="L476" class="LineNr">476 </span><span class="Normal">void</span> <a href='101run_sandboxed.cc.html#L476'>truncate</a><span class="Delimiter">(</span>string& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L477" class="LineNr">477 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>x<span class="Delimiter">)</span> > <span class="Constant">1024</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L478" class="LineNr">478 </span> <span class="Conceal">¦</span> x<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">1024</span><span class="Delimiter">);</span> +<span id="L479" class="LineNr">479 </span> <span class="Conceal">¦</span> *x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L480" class="LineNr">480 </span> <span class="Conceal">¦</span> *++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> +<span id="L481" class="LineNr">481 </span> <span class="Conceal">¦</span> *++++x<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> = <span class="Constant">'.'</span><span class="Delimiter">;</span> +<span id="L482" class="LineNr">482 </span> <span class="Delimiter">}</span> +<span id="L483" class="LineNr">483 </span><span class="Delimiter">}</span> +<span id="L484" class="LineNr">484 </span> +<span id="L485" class="LineNr">485 </span><span class="Comment">//: simpler version of run-sandboxed: doesn't do any running, just loads</span> +<span id="L486" class="LineNr">486 </span><span class="Comment">//: recipes and reports errors.</span> +<span id="L487" class="LineNr">487 </span> +<span id="L488" class="LineNr">488 </span><span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +<span id="L489" class="LineNr">489 </span>RELOAD<span class="Delimiter">,</span> +<span id="L490" class="LineNr">490 </span><span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +<span id="L491" class="LineNr">491 </span><a href='001help.cc.html#L218'>put</a><span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"reload"</span><span class="Delimiter">,</span> RELOAD<span class="Delimiter">);</span> +<span id="L492" class="LineNr">492 </span><span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span id="L493" class="LineNr">493 </span><span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> +<span id="L494" class="LineNr">494 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><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 id="L495" class="LineNr">495 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'reload' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L496" class="LineNr">496 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L497" class="LineNr">497 </span> <span class="Delimiter">}</span> +<span id="L498" class="LineNr">498 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_text<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> +<span id="L499" class="LineNr">499 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><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 'reload' should be a string, but got '"</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L500" class="LineNr">500 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L501" class="LineNr">501 </span> <span class="Delimiter">}</span> +<span id="L502" class="LineNr">502 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L503" class="LineNr">503 </span><span class="Delimiter">}</span> +<span id="L504" class="LineNr">504 </span><span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +<span id="L505" class="LineNr">505 </span><span class="Normal">case</span> RELOAD: <span class="Delimiter">{</span> +<span id="L506" class="LineNr">506 </span> restore_non_recipe_snapshots<span class="Delimiter">();</span> +<span id="L507" class="LineNr">507 </span> string code = <a href='038new_text.cc.html#L143'>read_mu_text</a><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> +<span id="L508" class="LineNr">508 </span> <a href='101run_sandboxed.cc.html#L144'>run_code_begin</a><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">should_stash_snapshots</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span> +<span id="L509" class="LineNr">509 </span> routine* save_current_routine = Current_routine<span class="Delimiter">;</span> +<span id="L510" class="LineNr">510 </span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L511" class="LineNr">511 </span> Sandbox_mode = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L512" class="LineNr">512 </span> vector<recipe_ordinal> recipes_reloaded = load<span class="Delimiter">(</span>code<span class="Delimiter">);</span> +<span id="L513" class="LineNr">513 </span> <a href='012transform.cc.html#L46'>transform_all</a><span class="Delimiter">();</span> +<span id="L514" class="LineNr">514 </span> Trace_stream<span class="Delimiter">-></span><a href='003trace.cc.html#L127'>newline</a><span class="Delimiter">();</span> <span class="Comment">// flush trace</span> +<span id="L515" class="LineNr">515 </span> Sandbox_mode = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L516" class="LineNr">516 </span> Current_routine = save_current_routine<span class="Delimiter">;</span> +<span id="L517" class="LineNr">517 </span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L518" class="LineNr">518 </span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><a href='101run_sandboxed.cc.html#L448'>trace_error_contents</a><span class="Delimiter">());</span> +<span id="L519" class="LineNr">519 </span> <a href='101run_sandboxed.cc.html#L155'>run_code_end</a><span class="Delimiter">();</span> <span class="Comment">// wait until we're done with the trace contents</span> +<span id="L520" class="LineNr">520 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L521" class="LineNr">521 </span><span class="Delimiter">}</span> +<span id="L522" class="LineNr">522 </span> +<span id="L523" class="LineNr">523 </span><span class="Delimiter">:(scenario reload_continues_past_error)</span> +<span id="L524" class="LineNr">524 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L525" class="LineNr">525 </span> local-scope +<span id="L526" class="LineNr">526 </span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [recipe foo [ +<span id="L527" class="LineNr">527 </span> get <span class="Constant">1234</span>:num<span class="Delimiter">,</span> <span class="Constant">foo:offset</span> +<span id="L528" class="LineNr">528 </span>]] +<span id="L529" class="LineNr">529 </span> reload x +<span id="L530" class="LineNr">530 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy <span class="Constant">34</span> +<span id="L531" class="LineNr">531 </span>] +<span id="L532" class="LineNr">532 </span><span class="traceContains">+mem: storing 34 in location 1</span> +<span id="L533" class="LineNr">533 </span> +<span id="L534" class="LineNr">534 </span><span class="Delimiter">:(scenario reload_can_repeatedly_load_container_definitions)</span> +<span id="L535" class="LineNr">535 </span><span class="Comment"># define a container and try to create it (merge requires knowing container size)</span> +<span id="L536" class="LineNr">536 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L537" class="LineNr">537 </span> local-scope +<span id="L538" class="LineNr">538 </span> <span class="Normal">x</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [ +<span id="L539" class="LineNr">539 </span> <span class="Conceal">¦</span> container foo [ +<span id="L540" class="LineNr">540 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">x</span>:num +<span id="L541" class="LineNr">541 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">y</span>:num +<span id="L542" class="LineNr">542 </span> <span class="Conceal">¦</span> ] +<span id="L543" class="LineNr">543 </span> <span class="Conceal">¦</span> <a href='010vm.cc.html#L19'>recipe</a> bar [ +<span id="L544" class="LineNr">544 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> local-scope +<span id="L545" class="LineNr">545 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">x</span>:foo<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> +<span id="L546" class="LineNr">546 </span> <span class="Conceal">¦</span> ] +<span id="L547" class="LineNr">547 </span> ] +<span id="L548" class="LineNr">548 </span> <span class="Comment"># save warning addresses in locations of type 'number' to avoid spurious changes to them due to 'abandon'</span> +<span id="L549" class="LineNr">549 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>reload x +<span id="L550" class="LineNr">550 </span> <span class="Constant">2</span>:num/<span class="Special">raw <- </span>reload x +<span id="L551" class="LineNr">551 </span>] +<span id="L552" class="LineNr">552 </span><span class="Comment"># no errors on either load</span> +<span id="L553" class="LineNr">553 </span><span class="traceContains">+mem: storing 0 in location 1</span> +<span id="L554" class="LineNr">554 </span><span class="traceContains">+mem: storing 0 in location 2</span> </pre> </body> </html> |