diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-05 01:08:00 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-05 01:08:00 -0700 |
commit | 298f8065857630e414d84e4ee785a6d17e5f99bb (patch) | |
tree | 8880a092ab59850a6f821ba892f3904ab464431c /html/056shape_shifting_recipe.cc.html | |
parent | f28f2636c6707e1a33bebacafd0486f4965978ea (diff) | |
download | mu-298f8065857630e414d84e4ee785a6d17e5f99bb.tar.gz |
3102
Diffstat (limited to 'html/056shape_shifting_recipe.cc.html')
-rw-r--r-- | html/056shape_shifting_recipe.cc.html | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index 7e44abbd..be795d37 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -275,6 +275,7 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla assert<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> new_recipe_ordinal<span class="Delimiter">));</span> recipe new_recipe = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> exemplar<span class="Delimiter">);</span> new_recipe<span class="Delimiter">.</span>name = new_name<span class="Delimiter">;</span> + new_recipe<span class="Delimiter">.</span>is_autogenerated = <span class="Constant">true</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"switching "</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">" to specialized "</span> << header_label<span class="Delimiter">(</span>new_recipe<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Comment">// Replace type ingredients with concrete types in new_recipe.</span> @@ -305,20 +306,20 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"compute type names: "</span> << variant<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> map<string<span class="Delimiter">,</span> type_tree*> type_names<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>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> + save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">,</span> <span class="Constant">""</span><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>variant<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> + save_or_deduce_type_name<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">,</span> <span class="Constant">""</span><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>variant<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> instruction& inst = variant<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">" instruction: "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> - save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> + save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">,</span> <span class="Constant">" in '"</span> + to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> + <span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> - save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">);</span> + save_or_deduce_type_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> type_names<span class="Delimiter">,</span> variant<span class="Delimiter">,</span> <span class="Constant">" in '"</span> + to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> + <span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> save_or_deduce_type_name<span class="Delimiter">(</span>reagent& x<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> type_tree*>& type<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> save_or_deduce_type_name<span class="Delimiter">(</span>reagent& x<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> type_tree*>& type<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">,</span> <span class="Normal">const</span> string& context<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9994</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">" checking "</span> << to_string<span class="Delimiter">(</span>x<span class="Delimiter">)</span> << <span class="Constant">": "</span> << names_to_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type && contains_key<span class="Delimiter">(</span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> x<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">));</span> @@ -326,7 +327,7 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>original_name<span class="Delimiter">)</span> << <span class="Constant">"unknown type for '"</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">"' (check the name for typos)</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>original_name<span class="Delimiter">)</span> << <span class="Constant">"unknown type for '"</span> << x<span class="Delimiter">.</span>original_string << <span class="Constant">"'"</span> << context << <span class="Constant">" (check the name for typos)</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -721,8 +722,6 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(code)</span> <span class="Comment">// this one needs a little more fine-grained control</span> <span class="Normal">void</span> test_shape_shifting_new_ingredient_does_not_pollute_global_namespace<span class="Delimiter">()</span> <span class="Delimiter">{</span> - Trace_file = <span class="Constant">"shape_shifting_new_ingredient_does_not_pollute_global_namespace"</span><span class="Delimiter">;</span> - <span class="Comment">// if you specialize a shape-shifting recipe that allocates a type-ingredient..</span> transform<span class="Delimiter">(</span><span class="Constant">"def barz x:_elem [</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">" local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> @@ -927,7 +926,7 @@ def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ container d1:_elem [ <span class="Normal">x</span>:_elem ] -<span class="traceContains">+error: foo: unknown type for 'e' (check the name for typos)</span> +<span class="traceContains">+error: foo: unknown type for 'e' in 'copy e' (check the name for typos)</span> <span class="traceContains">+error: specializing foo: missing type for 'e'</span> <span class="Comment"># and it doesn't crash</span> @@ -946,7 +945,7 @@ def foo a:d1:_elem <span class="Delimiter">-></span> b:number [ container d1:_elem [ <span class="Normal">x</span>:_elem ] -<span class="traceContains">+error: foo: unknown type for 'e' (check the name for typos)</span> +<span class="traceContains">+error: foo: unknown type for 'e' in 'get e, x:offset' (check the name for typos)</span> <span class="traceContains">+error: specializing foo: missing type for 'e'</span> <span class="Comment"># and it doesn't crash</span> |