diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-12-01 14:13:33 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-12-01 14:13:33 -0800 |
commit | e4ac3c9e6e5464a0fc0f8fd3763a572e0e180c04 (patch) | |
tree | 7f6ca26afcdf8e3bf54459c6592ebf26fb968133 /html/020run.cc.html | |
parent | 54e5128a14dcea5b93a8a9402558f0736fb7dba3 (diff) | |
download | mu-e4ac3c9e6e5464a0fc0f8fd3763a572e0e180c04.tar.gz |
4814
Diffstat (limited to 'html/020run.cc.html')
-rw-r--r-- | html/020run.cc.html | 121 |
1 files changed, 62 insertions, 59 deletions
diff --git a/html/020run.cc.html b/html/020run.cc.html index c2f8248b..bc61e5f7 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -11,23 +11,25 @@ <style type="text/css"> <!-- pre { white-space: pre-wrap; font-family: monospace; color: #aaaaaa; background-color: #080808; } -body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color: #080808; } -a { color:#eeeeee; text-decoration: none; } -a:hover { text-decoration: underline; } -* { font-size: 12pt; font-size: 1em; } -.LineNr { color: #444444; } -.Delimiter { color: #800080; } +body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: #080808; } +.subxS2Comment a { color:inherit; } +.subxS1Comment a { color:inherit; } +.subxComment a { color:inherit; } +.subxH2Comment a { color:inherit; } +.subxH1Comment a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.LineNr { color:#444444; } +.Delimiter { color:#800080; } .Normal { color: #aaaaaa; background-color: #080808; padding-bottom: 1px; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } .traceAbsent { color: #c00000; } .muRecipe { color: #ff8700; } -.Constant { color: #00a0a0; } -.Special { color: #c00000; } -.Identifier { color: #c0a020; } +.Constant { color:#00a0a0; } +.Special { color:#c00000; } +.Identifier { color:#c0a020; } .cSpecial { color: #008000; } -.Comment { color: #9090ff; } -.Comment a { color:#0000ee; text-decoration:underline; } +.Comment { color: #8080ff; } .traceContains { color: #008000; } --> </style> @@ -62,6 +64,7 @@ if ('onhashchange' in window) { </script> </head> <body onload='JumpToLine();'> +<a href='https://github.com/akkartik/mu/blob/master/020run.cc'>https://github.com/akkartik/mu/blob/master/020run.cc</a> <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Phase 3: Start running a loaded and transformed recipe.</span> <span id="L2" class="LineNr"> 2 </span><span class="Comment">//:</span> @@ -112,27 +115,27 @@ if ('onhashchange' in window) { <span id="L47" class="LineNr"> 47 </span><span class="Delimiter">};</span> <span id="L48" class="LineNr"> 48 </span> <span id="L49" class="LineNr"> 49 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L50" class="LineNr"> 50 </span>routine* Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L50" class="LineNr"> 50 </span>routine* <span class="Special">Current_routine</span> = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span id="L51" class="LineNr"> 51 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L52" class="LineNr"> 52 </span>Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L52" class="LineNr"> 52 </span><span class="Special">Current_routine</span> = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span id="L53" class="LineNr"> 53 </span> <span id="L54" class="LineNr"> 54 </span><span class="Delimiter">:(code)</span> <span id="L55" class="LineNr"> 55 </span><span class="Normal">void</span> run<span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L56" class="LineNr"> 56 </span> routine rr<span class="Delimiter">(</span>r<span class="Delimiter">);</span> -<span id="L57" class="LineNr"> 57 </span> Current_routine = &rr<span class="Delimiter">;</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Special">Current_routine</span> = &rr<span class="Delimiter">;</span> <span id="L58" class="LineNr"> 58 </span> run_current_routine<span class="Delimiter">();</span> -<span id="L59" class="LineNr"> 59 </span> Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Special">Current_routine</span> = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span id="L60" class="LineNr"> 60 </span><span class="Delimiter">}</span> <span id="L61" class="LineNr"> 61 </span> <span id="L62" class="LineNr"> 62 </span><span class="Normal">void</span> run_current_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='073scheduler.cc.html#L28'>should_continue_running</a><span class="Delimiter">(</span>Current_routine<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// beware: may modify Current_routine</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='073scheduler.cc.html#L28'>should_continue_running</a><span class="Delimiter">(</span><span class="Special">Current_routine</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// beware: may modify Current_routine</span> <span id="L64" class="LineNr"> 64 </span> <span class="Comment">// Running One Instruction</span> <span id="L65" class="LineNr"> 65 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">().</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span> ++current_step_index<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span id="L66" class="LineNr"> 66 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span>Initial_callstack_depth + Trace_stream<span class="Delimiter">-></span>callstack_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">())</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> +<span id="L66" class="LineNr"> 66 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Special">Initial_callstack_depth</span> + <span class="Special">Trace_stream</span><span class="Delimiter">-></span>callstack_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">())</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L67" class="LineNr"> 67 </span><span class="CommentedCode">//? if (Foo) cerr << "run: " << to_string(current_instruction()) << '\n';</span> -<span id="L68" class="LineNr"> 68 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L69" class="LineNr"> 69 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"something wrote to location 0; this should never happen</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> -<span id="L70" class="LineNr"> 70 </span> <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L68" class="LineNr"> 68 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span><span class="Special">Memory</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">)</span> != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L69" class="LineNr"> 69 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"something wrote to location 0; this should never happen\n"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> +<span id="L70" class="LineNr"> 70 </span> <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span><span class="Special">Memory</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L71" class="LineNr"> 71 </span> <span class="Delimiter">}</span> <span id="L72" class="LineNr"> 72 </span> <span class="Comment">// read all ingredients from memory, each potentially spanning multiple locations</span> <span id="L73" class="LineNr"> 73 </span> vector<vector<<span class="Normal">double</span>> > ingredients<span class="Delimiter">;</span> @@ -162,7 +165,7 @@ if ('onhashchange' in window) { <span id="L97" class="LineNr"> 97 </span> <span class="Comment">//: used by a later layer</span> <span id="L98" class="LineNr"> 98 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>write_products<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L99" class="LineNr"> 99 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">)</span> < <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">().</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L100" class="LineNr">100 </span> <a href='003trace.cc.html#L196'>raise</a> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">().</span>products<span class="Delimiter">)</span> << <span class="Constant">": failed to write to all products in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> +<span id="L100" class="LineNr">100 </span> <a href='003trace.cc.html#L196'>raise</a> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>products<span class="Delimiter">)</span> << <span class="Constant">" vs "</span> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">().</span>products<span class="Delimiter">)</span> << <span class="Constant">": failed to write to all products in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'\n"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L101" class="LineNr">101 </span> <span class="Delimiter">}</span> <span id="L102" class="LineNr">102 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L103" class="LineNr">103 </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#L141'>SIZE</a><span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">().</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -181,8 +184,8 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr">116 </span><span class="Delimiter">:(code)</span> <span id="L117" class="LineNr">117 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L118" class="LineNr">118 </span><span class="Normal">bool</span> <a href='073scheduler.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> -<span id="L119" class="LineNr">119 </span> assert<span class="Delimiter">(</span>current_routine == Current_routine<span class="Delimiter">);</span> <span class="Comment">// argument passed in just to make caller readable above</span> -<span id="L120" class="LineNr">120 </span> <span class="Identifier">return</span> !Current_routine<span class="Delimiter">-></span>completed<span class="Delimiter">();</span> +<span id="L119" class="LineNr">119 </span> assert<span class="Delimiter">(</span>current_routine == <span class="Special">Current_routine</span><span class="Delimiter">);</span> <span class="Comment">// argument passed in just to make caller readable above</span> +<span id="L120" class="LineNr">120 </span> <span class="Identifier">return</span> !<span class="Special">Current_routine</span><span class="Delimiter">-></span>completed<span class="Delimiter">();</span> <span id="L121" class="LineNr">121 </span><span class="Delimiter">}</span> <span id="L122" class="LineNr">122 </span> <span id="L123" class="LineNr">123 </span><span class="Normal">bool</span> should_copy_ingredients<span class="Delimiter">()</span> <span class="Delimiter">{</span> @@ -214,7 +217,7 @@ if ('onhashchange' in window) { <span id="L149" class="LineNr">149 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"invalid type "</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L150" class="LineNr">150 </span> <span class="Identifier">return</span><span class="Constant"> false</span><span class="Delimiter">;</span> <span id="L151" class="LineNr">151 </span> <span class="Delimiter">}</span> -<span id="L152" class="LineNr">152 </span> <span class="Identifier">return</span> type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>value == Address_type_ordinal<span class="Delimiter">;</span> +<span id="L152" class="LineNr">152 </span> <span class="Identifier">return</span> type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>value == <span class="Special">Address_type_ordinal</span><span class="Delimiter">;</span> <span id="L153" class="LineNr">153 </span><span class="Delimiter">}</span> <span id="L154" class="LineNr">154 </span> <span id="L155" class="LineNr">155 </span><span class="Comment">//: Some helpers.</span> @@ -222,37 +225,37 @@ if ('onhashchange' in window) { <span id="L157" class="LineNr">157 </span> <span id="L158" class="LineNr">158 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L159" class="LineNr">159 </span><span class="Normal">int</span>& <a href='026call.cc.html#L84'>current_step_index</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L160" class="LineNr">160 </span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">;</span> +<span id="L160" class="LineNr">160 </span> <span class="Identifier">return</span> <span class="Special">Current_routine</span><span class="Delimiter">-></span>running_step_index<span class="Delimiter">;</span> <span id="L161" class="LineNr">161 </span><span class="Delimiter">}</span> <span id="L162" class="LineNr">162 </span> <span id="L163" class="LineNr">163 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L164" class="LineNr">164 </span><a href='010vm.cc.html#L14'>recipe_ordinal</a> <a href='026call.cc.html#L85'>currently_running_recipe</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L165" class="LineNr">165 </span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">;</span> +<span id="L165" class="LineNr">165 </span> <span class="Identifier">return</span> <span class="Special">Current_routine</span><span class="Delimiter">-></span>running_recipe<span class="Delimiter">;</span> <span id="L166" class="LineNr">166 </span><span class="Delimiter">}</span> <span id="L167" class="LineNr">167 </span> <span id="L168" class="LineNr">168 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L169" class="LineNr">169 </span><span class="Normal">const</span> string& <a href='026call.cc.html#L87'>current_recipe_name</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L170" class="LineNr">170 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>name<span class="Delimiter">;</span> +<span id="L170" class="LineNr">170 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> <span class="Special">Current_routine</span><span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span id="L171" class="LineNr">171 </span><span class="Delimiter">}</span> <span id="L172" class="LineNr">172 </span> <span id="L173" class="LineNr">173 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L174" class="LineNr">174 </span><span class="Normal">const</span> recipe& <a href='026call.cc.html#L86'>current_recipe</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L175" class="LineNr">175 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">);</span> +<span id="L175" class="LineNr">175 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> <span class="Special">Current_routine</span><span class="Delimiter">-></span>running_recipe<span class="Delimiter">);</span> <span id="L176" class="LineNr">176 </span><span class="Delimiter">}</span> <span id="L177" class="LineNr">177 </span> <span id="L178" class="LineNr">178 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L179" class="LineNr">179 </span><span class="Normal">const</span> instruction& <a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L180" class="LineNr">180 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">);</span> +<span id="L180" class="LineNr">180 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> <span class="Special">Current_routine</span><span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Special">Current_routine</span><span class="Delimiter">-></span>running_step_index<span class="Delimiter">);</span> <span id="L181" class="LineNr">181 </span><span class="Delimiter">}</span> <span id="L182" class="LineNr">182 </span> <span id="L183" class="LineNr">183 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L184" class="LineNr">184 </span><span class="Normal">bool</span> routine::completed<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> -<span id="L185" class="LineNr">185 </span> <span class="Identifier">return</span> running_step_index >= <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> +<span id="L185" class="LineNr">185 </span> <span class="Identifier">return</span> running_step_index >= <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> <span id="L186" class="LineNr">186 </span><span class="Delimiter">}</span> <span id="L187" class="LineNr">187 </span> <span id="L188" class="LineNr">188 </span><span class="Comment">//: hook replaced in a later layer</span> <span id="L189" class="LineNr">189 </span><span class="Normal">const</span> vector<instruction>& routine::steps<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> -<span id="L190" class="LineNr">190 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> +<span id="L190" class="LineNr">190 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> <span id="L191" class="LineNr">191 </span><span class="Delimiter">}</span> <span id="L192" class="LineNr">192 </span> <span id="L193" class="LineNr">193 </span><span class="SalientComment">//:: Startup flow</span> @@ -273,12 +276,12 @@ if ('onhashchange' in window) { <span id="L208" class="LineNr">208 </span> <span class="Comment">// ignore argv past '--'; that's commandline args for 'main'</span> <span id="L209" class="LineNr">209 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>string<span class="Delimiter">(</span>*argv<span class="Delimiter">)</span> == <span class="Constant">"--"</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L210" class="LineNr">210 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L77'>starts_with</a><span class="Delimiter">(</span>*argv<span class="Delimiter">,</span> <span class="Constant">"--"</span><span class="Delimiter">))</span> -<span id="L211" class="LineNr">211 </span> cerr << <span class="Constant">"treating "</span> << *argv << <span class="Constant">" as a file rather than an option</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L211" class="LineNr">211 </span> cerr << <span class="Constant">"treating "</span> << *argv << <span class="Constant">" as a file rather than an option\n"</span><span class="Delimiter">;</span> <span id="L212" class="LineNr">212 </span> load_file_or_directory<span class="Delimiter">(</span>*argv<span class="Delimiter">);</span> <span id="L213" class="LineNr">213 </span> --argc<span class="Delimiter">;</span> <span id="L214" class="LineNr">214 </span> ++argv<span class="Delimiter">;</span> <span id="L215" class="LineNr">215 </span> <span class="Delimiter">}</span> -<span id="L216" class="LineNr">216 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>Run_tests<span class="Delimiter">)</span> Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> +<span id="L216" class="LineNr">216 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special">Run_tests</span><span class="Delimiter">)</span> <span class="Special">Recipe</span><span class="Delimiter">.</span>erase<span class="Delimiter">(</span>get<span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> <span id="L217" class="LineNr">217 </span><span class="Delimiter">}</span> <span id="L218" class="LineNr">218 </span><a href='012transform.cc.html#L46'>transform_all</a><span class="Delimiter">();</span> <span id="L219" class="LineNr">219 </span><span class="CommentedCode">//? cerr << to_original_string(get(Type_ordinal, "editor")) << '\n';</span> @@ -286,26 +289,26 @@ if ('onhashchange' in window) { <span id="L221" class="LineNr">221 </span><span class="CommentedCode">//? DUMP("");</span> <span id="L222" class="LineNr">222 </span><span class="CommentedCode">//? exit(0);</span> <span id="L223" class="LineNr">223 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L220'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L224" class="LineNr">224 </span><span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream && Run_tests<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L224" class="LineNr">224 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special">Trace_stream</span> && <span class="Special">Run_tests</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L225" class="LineNr">225 </span> <span class="Comment">// We'll want a trace per test. Clear the trace.</span> -<span id="L226" class="LineNr">226 </span> <span class="Normal">delete</span> Trace_stream<span class="Delimiter">;</span> -<span id="L227" class="LineNr">227 </span> Trace_stream = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L226" class="LineNr">226 </span> <span class="Normal">delete</span> <span class="Special">Trace_stream</span><span class="Delimiter">;</span> +<span id="L227" class="LineNr">227 </span> <span class="Special">Trace_stream</span> = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span id="L228" class="LineNr">228 </span><span class="Delimiter">}</span> <span id="L229" class="LineNr">229 </span>save_snapshots<span class="Delimiter">();</span> <span id="L230" class="LineNr">230 </span> <span id="L231" class="LineNr">231 </span><span class="Comment">//: Step 3: if we aren't running tests, locate a recipe called 'main' and</span> <span id="L232" class="LineNr">232 </span><span class="Comment">//: start running it.</span> <span id="L233" class="LineNr">233 </span><span class="Delimiter">:(before "End Main")</span> -<span id="L234" class="LineNr">234 </span><span class="Normal">if</span> <span class="Delimiter">(</span>!Run_tests && <a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)</span> && <a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> +<span id="L234" class="LineNr">234 </span><span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special">Run_tests</span> && <a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)</span> && <a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> get<span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> <span id="L235" class="LineNr">235 </span> <span class="Comment">// Running Main</span> <span id="L236" class="LineNr">236 </span> <a href='000organization.cc.html#L134'>reset</a><span class="Delimiter">();</span> <span id="L237" class="LineNr">237 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"=== Starting to run"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> -<span id="L238" class="LineNr">238 </span> assert<span class="Delimiter">(</span>Num_calls_to_transform_all == <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L238" class="LineNr">238 </span> assert<span class="Delimiter">(</span><span class="Special">Num_calls_to_transform_all</span> == <span class="Constant">1</span><span class="Delimiter">);</span> <span id="L239" class="LineNr">239 </span> <a href='073scheduler.cc.html#L122'>run_main</a><span class="Delimiter">(</span>argc<span class="Delimiter">,</span> argv<span class="Delimiter">);</span> <span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> <span id="L241" class="LineNr">241 </span><span class="Delimiter">:(code)</span> <span id="L242" class="LineNr">242 </span><span class="Normal">void</span> <a href='073scheduler.cc.html#L122'>run_main</a><span class="Delimiter">(</span><span class="Normal">int</span> argc<span class="Delimiter">,</span> <span class="Normal">char</span>* argv[]<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L243" class="LineNr">243 </span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r = get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">);</span> +<span id="L243" class="LineNr">243 </span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r = get<span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">);</span> <span id="L244" class="LineNr">244 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>r<span class="Delimiter">)</span> run<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span id="L245" class="LineNr">245 </span><span class="Delimiter">}</span> <span id="L246" class="LineNr">246 </span> @@ -317,7 +320,7 @@ if ('onhashchange' in window) { <span id="L252" class="LineNr">252 </span> <span class="Delimiter">}</span> <span id="L253" class="LineNr">253 </span> ifstream fin<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> <span id="L254" class="LineNr">254 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!fin<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L255" class="LineNr">255 </span> cerr << <span class="Constant">"no such file '"</span> << filename << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span class="Comment">// don't raise, just warn. just in case it's just a name for a scenario to run.</span> +<span id="L255" class="LineNr">255 </span> cerr << <span class="Constant">"no such file '"</span> << filename << <span class="Constant">"'\n"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span class="Comment">// don't raise, just warn. just in case it's just a name for a scenario to run.</span> <span id="L256" class="LineNr">256 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L257" class="LineNr">257 </span> <span class="Delimiter">}</span> <span id="L258" class="LineNr">258 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"=== "</span> << filename << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> @@ -370,7 +373,7 @@ if ('onhashchange' in window) { <span id="L305" class="LineNr">305 </span> <span class="Comment">// End Preprocess read_memory(x)</span> <span id="L306" class="LineNr">306 </span> <span class="Normal">int</span> size = size_of<span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span id="L307" class="LineNr">307 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < size<span class="Delimiter">;</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L308" class="LineNr">308 </span> <span class="Normal">double</span> val = <a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">);</span> +<span id="L308" class="LineNr">308 </span> <span class="Normal">double</span> val = <a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span><span class="Special">Memory</span><span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">);</span> <span id="L309" class="LineNr">309 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << x<span class="Delimiter">.</span>value+offset << <span class="Constant">" is "</span> << no_scientific<span class="Delimiter">(</span>val<span class="Delimiter">)</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L310" class="LineNr">310 </span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>val<span class="Delimiter">);</span> <span id="L311" class="LineNr">311 </span> <span class="Delimiter">}</span> @@ -378,21 +381,21 @@ if ('onhashchange' in window) { <span id="L313" class="LineNr">313 </span><span class="Delimiter">}</span> <span id="L314" class="LineNr">314 </span> <span id="L315" class="LineNr">315 </span><span class="Normal">void</span> write_memory<span class="Delimiter">(</span>reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> x<span class="Delimiter">,</span> <span class="Normal">const</span> vector<<span class="Normal">double</span>>& data<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L316" class="LineNr">316 </span> assert<span class="Delimiter">(</span>Current_routine<span class="Delimiter">);</span> <span class="Comment">// run-time only</span> +<span id="L316" class="LineNr">316 </span> assert<span class="Delimiter">(</span><span class="Special">Current_routine</span><span class="Delimiter">);</span> <span class="Comment">// run-time only</span> <span id="L317" class="LineNr">317 </span> <span class="Comment">// Begin Preprocess write_memory(x, data)</span> <span id="L318" class="LineNr">318 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L319" class="LineNr">319 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"can't write to '"</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">)</span> << <span class="Constant">"'; no type</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L319" class="LineNr">319 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"can't write to '"</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">)</span> << <span class="Constant">"'; no type\n"</span> << end<span class="Delimiter">();</span> <span id="L320" class="LineNr">320 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L321" class="LineNr">321 </span> <span class="Delimiter">}</span> <span id="L322" class="LineNr">322 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L323" class="LineNr">323 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L324" class="LineNr">324 </span> <span class="Comment">// End Preprocess write_memory(x, data)</span> <span id="L325" class="LineNr">325 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L326" class="LineNr">326 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"can't write to location 0 in '"</span> << to_original_string<span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L326" class="LineNr">326 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"can't write to location 0 in '"</span> << to_original_string<span class="Delimiter">(</span><a href='026call.cc.html#L89'>current_instruction</a><span class="Delimiter">())</span> << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> <span id="L327" class="LineNr">327 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L328" class="LineNr">328 </span> <span class="Delimiter">}</span> <span id="L329" class="LineNr">329 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>size_mismatch<span class="Delimiter">(</span>x<span class="Delimiter">,</span> data<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L330" class="LineNr">330 </span> <a href='003trace.cc.html#L196'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span><a href='026call.cc.html#L87'>current_recipe_name</a><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> << <span class="Constant">" vs "</span> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="Constant">") at '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> +<span id="L330" class="LineNr">330 </span> <a href='003trace.cc.html#L196'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span><a href='026call.cc.html#L87'>current_recipe_name</a><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> << <span class="Constant">" vs "</span> << <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="Constant">") at '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'\n"</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L331" class="LineNr">331 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L332" class="LineNr">332 </span> <span class="Delimiter">}</span> <span id="L333" class="LineNr">333 </span> <span class="Comment">// End write_memory(x) Special-cases</span> @@ -400,7 +403,7 @@ if ('onhashchange' in window) { <span id="L335" class="LineNr">335 </span> assert<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value+offset > <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L336" class="LineNr">336 </span> <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << no_scientific<span class="Delimiter">(</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">))</span> << <span class="Constant">" in location "</span> << x<span class="Delimiter">.</span>value+offset << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L337" class="LineNr">337 </span><span class="CommentedCode">//? if (Foo) cerr << "mem: storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << '\n';</span> -<span id="L338" class="LineNr">338 </span> <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">,</span> data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> +<span id="L338" class="LineNr">338 </span> <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span><span class="Special">Memory</span><span class="Delimiter">,</span> x<span class="Delimiter">.</span>value+offset<span class="Delimiter">,</span> data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> <span id="L339" class="LineNr">339 </span> <span class="Delimiter">}</span> <span id="L340" class="LineNr">340 </span><span class="Delimiter">}</span> <span id="L341" class="LineNr">341 </span> @@ -422,7 +425,7 @@ if ('onhashchange' in window) { <span id="L357" class="LineNr">357 </span> <a href='003trace.cc.html#L196'>raise</a> << <span class="Constant">"invalid type "</span> << <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> <span id="L358" class="LineNr">358 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L359" class="LineNr">359 </span> <span class="Delimiter">}</span> -<span id="L360" class="LineNr">360 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>value == Address_type_ordinal<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">2</span><span class="Delimiter">;</span> <span class="Comment">// address and alloc id</span> +<span id="L360" class="LineNr">360 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>value == <span class="Special">Address_type_ordinal</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">2</span><span class="Delimiter">;</span> <span class="Comment">// address and alloc id</span> <span id="L361" class="LineNr">361 </span> <span class="Comment">// End size_of(type) Non-atom Special-cases</span> <span id="L362" class="LineNr">362 </span> <span class="Delimiter">}</span> <span id="L363" class="LineNr">363 </span> <span class="Comment">// End size_of(type) Special-cases</span> @@ -458,13 +461,13 @@ if ('onhashchange' in window) { <span id="L393" class="LineNr">393 </span> <a href='012transform.cc.html#L46'>transform_all</a><span class="Delimiter">();</span> <span id="L394" class="LineNr">394 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L395" class="LineNr">395 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L220'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L396" class="LineNr">396 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>Save_trace && Trace_stream<span class="Delimiter">)</span> Trace_stream<span class="Delimiter">-></span><a href='003trace.cc.html#L133'>save</a><span class="Delimiter">();</span> +<span id="L396" class="LineNr">396 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special">Save_trace</span> && <span class="Special">Trace_stream</span><span class="Delimiter">)</span> <span class="Special">Trace_stream</span><span class="Delimiter">-></span><a href='003trace.cc.html#L133'>save</a><span class="Delimiter">();</span> <span id="L397" class="LineNr">397 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L398" class="LineNr">398 </span> <span class="Delimiter">}</span> <span id="L399" class="LineNr">399 </span> <span class="Comment">// if a test defines main, it probably wants to start there regardless of</span> <span id="L400" class="LineNr">400 </span> <span class="Comment">// definition order</span> -<span id="L401" class="LineNr">401 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)))</span> -<span id="L402" class="LineNr">402 </span> run<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> +<span id="L401" class="LineNr">401 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L226'>contains_key</a><span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> get<span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">)))</span> +<span id="L402" class="LineNr">402 </span> run<span class="Delimiter">(</span>get<span class="Delimiter">(</span><span class="Special">Recipe_ordinal</span><span class="Delimiter">,</span> <span class="Constant">"main"</span><span class="Delimiter">));</span> <span id="L403" class="LineNr">403 </span> <span class="Normal">else</span> <span id="L404" class="LineNr">404 </span> run<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>front<span class="Delimiter">());</span> <span id="L405" class="LineNr">405 </span><span class="Delimiter">}</span> @@ -528,33 +531,33 @@ if ('onhashchange' in window) { <span id="L463" class="LineNr">463 </span><span class="SalientComment">//:: time.</span> <span id="L464" class="LineNr">464 </span> <span id="L465" class="LineNr">465 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L466" class="LineNr">466 </span><span class="Normal">bool</span> Run_profiler =<span class="Constant"> false</span><span class="Delimiter">;</span> +<span id="L466" class="LineNr">466 </span><span class="Normal">bool</span> <span class="Special">Run_profiler</span> =<span class="Constant"> false</span><span class="Delimiter">;</span> <span id="L467" class="LineNr">467 </span><span class="Comment">// We'll key profile information by recipe_ordinal rather than name because</span> <span id="L468" class="LineNr">468 </span><span class="Comment">// it's more efficient, and because later layers will show more than just the</span> <span id="L469" class="LineNr">469 </span><span class="Comment">// name of a recipe.</span> <span id="L470" class="LineNr">470 </span><span class="Comment">//</span> <span id="L471" class="LineNr">471 </span><span class="Comment">// One drawback: if you're clearing recipes your profile will be inaccurate.</span> <span id="L472" class="LineNr">472 </span><span class="Comment">// So far that happens in tests, and in 'run-sandboxed' in a later layer.</span> -<span id="L473" class="LineNr">473 </span>map<recipe_ordinal<span class="Delimiter">,</span> <span class="Normal">int</span>> Instructions_running<span class="Delimiter">;</span> +<span id="L473" class="LineNr">473 </span>map<recipe_ordinal<span class="Delimiter">,</span> <span class="Normal">int</span>> <span class="Special">Instructions_running</span><span class="Delimiter">;</span> <span id="L474" class="LineNr">474 </span><span class="Delimiter">:(before "End Commandline Options(*arg)")</span> <span id="L475" class="LineNr">475 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L73'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--profile"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L476" class="LineNr">476 </span> Run_profiler =<span class="Constant"> true</span><span class="Delimiter">;</span> +<span id="L476" class="LineNr">476 </span> <span class="Special">Run_profiler</span> =<span class="Constant"> true</span><span class="Delimiter">;</span> <span id="L477" class="LineNr">477 </span><span class="Delimiter">}</span> <span id="L478" class="LineNr">478 </span><span class="Delimiter">:(after "Running One Instruction")</span> -<span id="L479" class="LineNr">479 </span><span class="Normal">if</span> <span class="Delimiter">(</span>Run_profiler<span class="Delimiter">)</span> Instructions_running[currently_running_recipe<span class="Delimiter">()</span>]++<span class="Delimiter">;</span> +<span id="L479" class="LineNr">479 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special">Run_profiler</span><span class="Delimiter">)</span> <span class="Special">Instructions_running</span>[currently_running_recipe<span class="Delimiter">()</span>]++<span class="Delimiter">;</span> <span id="L480" class="LineNr">480 </span><span class="Delimiter">:(before "End One-time Setup")</span> <span id="L481" class="LineNr">481 </span>atexit<span class="Delimiter">(</span>dump_profile<span class="Delimiter">);</span> <span id="L482" class="LineNr">482 </span><span class="Delimiter">:(code)</span> <span id="L483" class="LineNr">483 </span><span class="Normal">void</span> dump_profile<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L484" class="LineNr">484 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!Run_profiler<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L485" class="LineNr">485 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>Run_tests<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L486" class="LineNr">486 </span> cerr << <span class="Constant">"It's not a good idea to profile a run with tests, since tests can create conflicting recipes and mislead you. To try it anyway, comment out this check in the code.</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L484" class="LineNr">484 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special">Run_profiler</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L485" class="LineNr">485 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special">Run_tests</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L486" class="LineNr">486 </span> cerr << <span class="Constant">"It's not a good idea to profile a run with tests, since tests can create conflicting recipes and mislead you. To try it anyway, comment out this check in the code.\n"</span><span class="Delimiter">;</span> <span id="L487" class="LineNr">487 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L488" class="LineNr">488 </span> <span class="Delimiter">}</span> <span id="L489" class="LineNr">489 </span> ofstream fout<span class="Delimiter">;</span> <span id="L490" class="LineNr">490 </span> fout<span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"profile.instructions"</span><span class="Delimiter">);</span> <span id="L491" class="LineNr">491 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>fout<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L492" class="LineNr">492 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<recipe_ordinal<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = Instructions_running<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Instructions_running<span class="Delimiter">.</span><a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L492" class="LineNr">492 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<recipe_ordinal<span class="Delimiter">,</span> <span class="Normal">int</span>>::iterator p = <span class="Special">Instructions_running</span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special">Instructions_running</span><span class="Delimiter">.</span><a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L493" class="LineNr">493 </span> fout << std::setw<span class="Delimiter">(</span><span class="Constant">9</span><span class="Delimiter">)</span> << p<span class="Delimiter">-></span>second << <span class="Constant">' '</span> << header_label<span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L494" class="LineNr">494 </span> <span class="Delimiter">}</span> <span id="L495" class="LineNr">495 </span> <span class="Delimiter">}</span> @@ -564,7 +567,7 @@ if ('onhashchange' in window) { <span id="L499" class="LineNr">499 </span> <span id="L500" class="LineNr">500 </span><span class="Comment">// overridden in a later layer</span> <span id="L501" class="LineNr">501 </span>string header_label<span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L502" class="LineNr">502 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">;</span> +<span id="L502" class="LineNr">502 </span> <span class="Identifier">return</span> get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span id="L503" class="LineNr">503 </span><span class="Delimiter">}</span> </pre> </body> |