diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-12 00:11:56 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-12 00:11:56 -0700 |
commit | d5d908dda655c791329563522faad42d7e4ee618 (patch) | |
tree | 628b8a23e13878c45ef39dfbffb860c676da5304 /html/037recipe.cc.html | |
parent | 9864bdd0792b697d7b03e692ba7f82cf5669c41c (diff) | |
download | mu-d5d908dda655c791329563522faad42d7e4ee618.tar.gz |
1766
Diffstat (limited to 'html/037recipe.cc.html')
-rw-r--r-- | html/037recipe.cc.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/html/037recipe.cc.html b/html/037recipe.cc.html new file mode 100644 index 00000000..a84b95ef --- /dev/null +++ b/html/037recipe.cc.html @@ -0,0 +1,90 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 037recipe.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-family: monospace; color: #eeeeee; background-color: #080808; } +* { font-size: 1.05em; } +.traceContains { color: #008000; } +.Constant { color: #00a0a0; } +.Comment { color: #9090ff; } +.Delimiter { color: #a04060; } +.Special { color: #ff6060; } +.CommentedCode { color: #6c6c6c; } +.Identifier { color: #804000; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: So far we've been calling a fixed recipe in each instruction, but we'd</span> +<span class="Comment">//: also like to make the recipe a variable, pass recipes to "higher-order"</span> +<span class="Comment">//: recipes, return recipes from recipes and so on.</span> + +<span class="Delimiter">:(scenario call_literal_recipe)</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>call f:recipe<span class="Delimiter">,</span> <span class="Constant">34</span>:literal +] +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>:literal +] +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="CommentedCode">#? ?</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> +<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> + +<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>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> + <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> + assert<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="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> complete_call<span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> |