diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-10 21:35:42 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-10 21:43:45 -0800 |
commit | 76755b2836b0dadd88f82635f661f9d9df77604d (patch) | |
tree | f4f4429510c739fd1f9e51edd10e03c27107acba /html/037recipe.cc.html | |
parent | 080e9cb73fa55cdc862f1dd7593df56e0a6302b8 (diff) | |
download | mu-76755b2836b0dadd88f82635f661f9d9df77604d.tar.gz |
2423 - describe shape-shifting in html docs
Diffstat (limited to 'html/037recipe.cc.html')
-rw-r--r-- | html/037recipe.cc.html | 62 |
1 files changed, 12 insertions, 50 deletions
diff --git a/html/037recipe.cc.html b/html/037recipe.cc.html index 856e671c..44573495 100644 --- a/html/037recipe.cc.html +++ b/html/037recipe.cc.html @@ -13,13 +13,10 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.cSpecial { color: #008000; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } -.Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } -.traceContains { color: #008000; } --> </style> @@ -35,61 +32,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment">//: also like to make the recipe a variable, pass recipes to "higher-order"</span> <span class="Comment">//: recipes, return recipes from recipes and so on.</span> -<span class="Delimiter">:(scenario call_literal_recipe)</span> -recipe main [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>call f:recipe<span class="Delimiter">,</span> <span class="Constant">34</span> -] -recipe f [ - <span class="Constant">2</span>:number<span class="Special"> <- </span>next-ingredient - reply <span class="Constant">2</span>:number -] -<span class="traceContains">+mem: storing 34 in location 1</span> - -<span class="Delimiter">:(scenario call_variable)</span> -recipe main [ - <span class="Constant">1</span>:recipe-ordinal<span class="Special"> <- </span>copy f:recipe - <span class="Constant">2</span>:number<span class="Special"> <- </span>call <span class="Constant">1</span>:recipe-ordinal<span class="Delimiter">,</span> <span class="Constant">34</span> -] -recipe f [ - <span class="Constant">3</span>:number<span class="Special"> <- </span>next-ingredient - reply <span class="Constant">3</span>:number -] -<span class="traceContains">+mem: storing 34 in location 2</span> - <span class="Delimiter">:(before "End Mu Types Initialization")</span> <span class="Comment">// 'recipe' is a literal</span> -Type_ordinal[<span class="Constant">"recipe"</span>] = <span class="Constant">0</span><span class="Delimiter">;</span> +put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// 'recipe-ordinal' is the literal that can store recipe literals</span> -type_ordinal recipe_ordinal = Type_ordinal[<span class="Constant">"recipe-ordinal"</span>] = Next_type_ordinal++<span class="Delimiter">;</span> -Type[recipe_ordinal]<span class="Delimiter">.</span>name = <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">;</span> +type_ordinal recipe_ordinal = put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> +get_or_insert<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> recipe_ordinal<span class="Delimiter">).</span>name = <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Reagent-parsing Exceptions")</span> -if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">"recipe"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - r<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>Recipe_ordinal[r<span class="Delimiter">.</span>name]<span class="Delimiter">);</span> +if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second && r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"recipe"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + r<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> r<span class="Delimiter">.</span>name<span class="Delimiter">));</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -CALL<span class="Delimiter">,</span> -<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -Recipe_ordinal[<span class="Constant">"call"</span>] = CALL<span class="Delimiter">;</span> -<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> -case CALL: <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> - raise << current_recipe_name<span class="Delimiter">()</span> << <span class="Constant">": 'call' requires at least one ingredient (the recipe to call)</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Comment">// Begin Call</span> - if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> - raise << current_recipe_name<span class="Delimiter">()</span> << <span class="Constant">": first ingredient of 'call' should be a recipe, but got "</span> << current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Comment">// todo: when we start doing type checking this will be a prime point of</span> - <span class="Comment">// attention, so we don't accidentally allow external data to a program to</span> - <span class="Comment">// run as code.</span> - Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span> - ingredients<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>begin<span class="Delimiter">());</span> <span class="Comment">// drop the callee</span> - <span class="Identifier">goto</span> call_housekeeping<span class="Delimiter">;</span> +<span class="Delimiter">:(code)</span> +bool is_mu_recipe<span class="Delimiter">(</span>reagent r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"recipe-ordinal"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Comment">// End is_mu_recipe Cases</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> </pre> </body> |