diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-29 15:55:05 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-29 15:55:05 -0700 |
commit | 9570363aec35e187e2395b1760a4b94e71580ac9 (patch) | |
tree | 5b0d9cf65b5d5a403ab29e88535ba158efb276fe /html/034call.cc.html | |
parent | b318b7fb127a2bdf3e394b315a45d339dc738447 (diff) | |
download | mu-9570363aec35e187e2395b1760a4b94e71580ac9.tar.gz |
1885
Diffstat (limited to 'html/034call.cc.html')
-rw-r--r-- | html/034call.cc.html | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/html/034call.cc.html b/html/034call.cc.html index 9b978a5d..5e9d93b0 100644 --- a/html/034call.cc.html +++ b/html/034call.cc.html @@ -13,17 +13,16 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.SalientComment { color: #00ffff; } .Constant { color: #00a0a0; } -.CommentedCode { color: #6c6c6c; } -.PreProc { color: #c000c0; } -.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } -.traceContains { color: #008000; } +.PreProc { color: #c000c0; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -42,37 +41,37 @@ recipe main [ f ] recipe f [ - <span class="Constant">3</span>:number<span class="Special"> <- </span>add <span class="Constant">2</span>:literal<span class="Delimiter">,</span> <span class="Constant">2</span>:literal + <span class="Constant">3</span>:number<span class="Special"> <- </span>add <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">2</span> ] <span class="traceContains">+mem: storing 4 in location 3</span> <span class="Delimiter">:(scenario return_on_fallthrough)</span> recipe main [ f - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal - <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] recipe f [ - <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal - <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal + <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+run: f</span> <span class="Comment"># running f</span> -<span class="traceContains">+run: 4:number <- copy 0:literal</span> -<span class="traceContains">+run: 5:number <- copy 0:literal</span> +<span class="traceContains">+run: 4:number <- copy 0</span> +<span class="traceContains">+run: 5:number <- copy 0</span> <span class="Comment"># back out to main</span> -<span class="traceContains">+run: 1:number <- copy 0:literal</span> -<span class="traceContains">+run: 2:number <- copy 0:literal</span> -<span class="traceContains">+run: 3:number <- copy 0:literal</span> +<span class="traceContains">+run: 1:number <- copy 0</span> +<span class="traceContains">+run: 2:number <- copy 0</span> +<span class="traceContains">+run: 3:number <- copy 0</span> <span class="Delimiter">:(before "struct routine {")</span> <span class="Comment">// Everytime a recipe runs another, we interrupt it and start running the new</span> <span class="Comment">// recipe. When that finishes, we continue this one where we left off.</span> <span class="Comment">// This requires maintaining a 'stack' of interrupted recipes or 'calls'.</span> -<span class="Normal">struct</span> call <span class="Delimiter">{</span> +struct call <span class="Delimiter">{</span> recipe_ordinal running_recipe<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> running_step_index<span class="Delimiter">;</span> + long long int running_step_index<span class="Delimiter">;</span> <span class="Comment">// End call Fields</span> call<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> running_recipe = r<span class="Delimiter">;</span> @@ -80,15 +79,15 @@ recipe f [ <span class="Comment">// End call Constructor</span> <span class="Delimiter">}</span> <span class="Delimiter">};</span> -<span class="Normal">typedef</span> list<call> call_stack<span class="Delimiter">;</span> +typedef list<call> call_stack<span class="Delimiter">;</span> <span class="Delimiter">:(replace{} "struct routine")</span> -<span class="Normal">struct</span> routine <span class="Delimiter">{</span> +struct routine <span class="Delimiter">{</span> call_stack calls<span class="Delimiter">;</span> <span class="Comment">// End routine Fields</span> routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">);</span> - <span class="Normal">bool</span> completed<span class="Delimiter">()</span> <span class="Normal">const</span><span class="Delimiter">;</span> - <span class="Normal">const</span> vector<instruction>& steps<span class="Delimiter">()</span> <span class="Normal">const</span><span class="Delimiter">;</span> + bool completed<span class="Delimiter">()</span> const<span class="Delimiter">;</span> + const vector<instruction>& steps<span class="Delimiter">()</span> const<span class="Delimiter">;</span> <span class="Delimiter">};</span> <span class="Delimiter">:(code)</span> routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -99,30 +98,30 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="SalientComment">//:: now update routine's helpers</span> <span class="Delimiter">:(replace{} "inline long long int& current_step_index()")</span> -<span class="Normal">inline</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> +inline long long int& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_step_index<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(replace{} "inline const string& current_recipe_name()")</span> -<span class="Normal">inline</span> <span class="Normal">const</span> string& current_recipe_name<span class="Delimiter">()</span> <span class="Delimiter">{</span> +inline const string& current_recipe_name<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> Recipe[Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_recipe]<span class="Delimiter">.</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(replace{} "inline const instruction& current_instruction()")</span> -<span class="Normal">inline</span> <span class="Normal">const</span> instruction& current_instruction<span class="Delimiter">()</span> <span class="Delimiter">{</span> +inline const instruction& current_instruction<span class="Delimiter">()</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> Recipe[Current_routine<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>at<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_step_index<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(replace{} "default:" following "End Primitive Recipe Implementations")</span> -<span class="Normal">default</span>: <span class="Delimiter">{</span> +default: <span class="Delimiter">{</span> <span class="Comment">// not a primitive; try to look up the book of recipes</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Recipe<span class="Delimiter">.</span>find<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation<span class="Delimiter">)</span> == Recipe<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Recipe<span class="Delimiter">.</span>find<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation<span class="Delimiter">)</span> == Recipe<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> raise << <span class="Constant">"undefined operation "</span> << current_instruction<span class="Delimiter">().</span>operation << <span class="Constant">": "</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation<span class="Delimiter">));</span> - <span class="Normal">call_housekeeping</span>: + call_housekeeping: ++Callstack_depth<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>Callstack_depth < <span class="Constant">9000</span><span class="Delimiter">);</span> <span class="Comment">// 9998-101 plus cushion</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not done with caller; don't increment current_step_index()</span> @@ -131,11 +130,11 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="SalientComment">//:: finally, we need to fix the termination conditions for the run loop</span> <span class="Delimiter">:(replace{} "inline bool routine::completed() const")</span> -<span class="Normal">inline</span> <span class="Normal">bool</span> routine::completed<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> +inline bool routine::completed<span class="Delimiter">()</span> const <span class="Delimiter">{</span> <span class="Identifier">return</span> calls<span class="Delimiter">.</span>empty<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">inline</span> <span class="Normal">const</span> vector<instruction>& routine::steps<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> +inline const vector<instruction>& routine::steps<span class="Delimiter">()</span> const <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>!calls<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span class="Identifier">return</span> Recipe[calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>running_recipe]<span class="Delimiter">.</span>steps<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -143,12 +142,12 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="Delimiter">:(before "Running One Instruction")</span> <span class="Comment">// when we reach the end of one call, we may reach the end of the one below</span> <span class="Comment">// it, and the one below that, and so on</span> -<span class="Normal">while</span> <span class="Delimiter">(</span>current_step_index<span class="Delimiter">()</span> >= SIZE<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>steps<span class="Delimiter">()))</span> <span class="Delimiter">{</span> +while <span class="Delimiter">(</span>current_step_index<span class="Delimiter">()</span> >= SIZE<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>steps<span class="Delimiter">()))</span> <span class="Delimiter">{</span> <span class="Comment">// Falling Through End Of Recipe</span> --Callstack_depth<span class="Delimiter">;</span> <span class="CommentedCode">//? cerr << "reply " << SIZE(Current_routine->calls) << '\n'; //? 2</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>pop_front<span class="Delimiter">();</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// Complete Call Fallthrough</span> <span class="Comment">// todo: no products returned warning</span> ++current_step_index<span class="Delimiter">();</span> @@ -156,7 +155,7 @@ routine::routine<span class="Delimiter">(</span>recipe_ordinal r<span class="Del <span class="Delimiter">:(before "End Includes")</span> <span class="PreProc">#include </span><span class="Constant"><stack></span> -<span class="Normal">using</span> std::stack<span class="Delimiter">;</span> +using std::stack<span class="Delimiter">;</span> </pre> </body> </html> |