diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-15 01:01:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-15 01:01:58 -0700 |
commit | 0ca56ed853c3d9bc8c26d1b014d8b665363fc2d0 (patch) | |
tree | abd2d2e4b65c34797a635aeb2f7d06c9d65c7bf9 /html/053recipe_header.cc.html | |
parent | 36b927a63cb25e9fc64cf4ae079b32d23d528b1b (diff) | |
download | mu-0ca56ed853c3d9bc8c26d1b014d8b665363fc2d0.tar.gz |
3355
Diffstat (limited to 'html/053recipe_header.cc.html')
-rw-r--r-- | html/053recipe_header.cc.html | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index 3d785dc4..aa26c35c 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -179,6 +179,28 @@ def test [ trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"recipe "</span> << result<span class="Delimiter">.</span>name << <span class="Constant">" has a header"</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> +<span class="Comment">//: Support type abbreviations in headers.</span> + +<span class="Delimiter">:(scenario type_abbreviations_in_recipe_headers)</span> +type string = address:array:character +def main [ + local-scope + <span class="Normal">a</span>:string<span class="Special"> <- </span>foo + <span class="Constant">1</span>:character/<span class="Special">raw <- </span>index *a<span class="Delimiter">,</span> <span class="Constant">0</span> +] +def foo <span class="Delimiter">-></span> a:string [ + local-scope + load-ingredients + a<span class="Special"> <- </span><span class="Normal">new</span> [abc] +] +<span class="traceContains">+mem: storing 97 in location 1</span> + +<span class="Delimiter">:(before "End Expand Type Abbreviations(caller)")</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + expand_type_abbreviations<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> +<span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> + expand_type_abbreviations<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> + <span class="Comment">//: Rewrite 'load-ingredients' to instructions to create all reagents in the header.</span> <span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> @@ -258,8 +280,8 @@ def foo x:number <span class="Delimiter">-></span> y:number [ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_calls_against_header<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> check_calls_against_header<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check calls inside recipe "</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << end<span class="Delimiter">();</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- type-check calls inside recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</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 < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation < MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> |