diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/010vm.cc.html | 461 | ||||
-rw-r--r-- | html/042name.cc.html | 2 | ||||
-rw-r--r-- | html/053recipe_header.cc.html | 283 |
3 files changed, 377 insertions, 369 deletions
diff --git a/html/010vm.cc.html b/html/010vm.cc.html index a00a002d..a450da45 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -700,236 +700,237 @@ if ('onhashchange' in window) { <span id="L636" class="LineNr">636 </span> <span id="L637" class="LineNr">637 </span>string to_original_string<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L638" class="LineNr">638 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span> -<span id="L639" class="LineNr">639 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L640" class="LineNr">640 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L641" class="LineNr">641 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> -<span id="L642" class="LineNr">642 </span> <span class="Conceal">¦</span> out << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> -<span id="L643" class="LineNr">643 </span> <span class="Delimiter">}</span> -<span id="L644" class="LineNr">644 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> -<span id="L645" class="LineNr">645 </span> out << inst<span class="Delimiter">.</span>name<span class="Delimiter">;</span> -<span id="L646" class="LineNr">646 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L647" class="LineNr">647 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L648" class="LineNr">648 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> -<span id="L649" class="LineNr">649 </span> <span class="Conceal">¦</span> out << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> -<span id="L650" class="LineNr">650 </span> <span class="Delimiter">}</span> -<span id="L651" class="LineNr">651 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L652" class="LineNr">652 </span><span class="Delimiter">}</span> -<span id="L653" class="LineNr">653 </span> -<span id="L654" class="LineNr">654 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L655" class="LineNr">655 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span> -<span id="L656" class="LineNr">656 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L657" class="LineNr">657 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L658" class="LineNr">658 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> -<span id="L659" class="LineNr">659 </span> <span class="Conceal">¦</span> out << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span id="L660" class="LineNr">660 </span> <span class="Delimiter">}</span> -<span id="L661" class="LineNr">661 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> -<span id="L662" class="LineNr">662 </span> out << inst<span class="Delimiter">.</span>name << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L663" class="LineNr">663 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L664" class="LineNr">664 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> -<span id="L665" class="LineNr">665 </span> <span class="Conceal">¦</span> out << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span id="L666" class="LineNr">666 </span> <span class="Delimiter">}</span> -<span id="L667" class="LineNr">667 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L668" class="LineNr">668 </span><span class="Delimiter">}</span> -<span id="L669" class="LineNr">669 </span> -<span id="L670" class="LineNr">670 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L671" class="LineNr">671 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">"_"</span><span class="Delimiter">;</span> -<span id="L672" class="LineNr">672 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L673" class="LineNr">673 </span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> -<span id="L674" class="LineNr">674 </span> out << r<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << names_to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> -<span id="L675" class="LineNr">675 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L676" class="LineNr">676 </span> <span class="Conceal">¦</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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L677" class="LineNr">677 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">", </span><span class="cSpecial">\"</span><span class="Constant">"</span> << r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">);</span> -<span id="L678" class="LineNr">678 </span> <span class="Delimiter">}</span> -<span id="L679" class="LineNr">679 </span> out << <span class="Constant">"}"</span><span class="Delimiter">;</span> -<span id="L680" class="LineNr">680 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L681" class="LineNr">681 </span><span class="Delimiter">}</span> -<span id="L682" class="LineNr">682 </span> -<span id="L683" class="LineNr">683 </span><span class="Comment">// special name for ignoring some products</span> -<span id="L684" class="LineNr">684 </span><span class="Normal">bool</span> is_dummy<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L685" class="LineNr">685 </span> <span class="Identifier">return</span> x<span class="Delimiter">.</span>name == <span class="Constant">"_"</span><span class="Delimiter">;</span> -<span id="L686" class="LineNr">686 </span><span class="Delimiter">}</span> -<span id="L687" class="LineNr">687 </span> -<span id="L688" class="LineNr">688 </span>string debug_string<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L689" class="LineNr">689 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L690" class="LineNr">690 </span> out << x<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << x<span class="Delimiter">.</span>value << <span class="Constant">' '</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" -- "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">);</span> -<span id="L691" class="LineNr">691 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L692" class="LineNr">692 </span><span class="Delimiter">}</span> -<span id="L693" class="LineNr">693 </span> -<span id="L694" class="LineNr">694 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> string_tree* property<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L695" class="LineNr">695 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!property<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> -<span id="L696" class="LineNr">696 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L697" class="LineNr">697 </span> dump<span class="Delimiter">(</span>property<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L698" class="LineNr">698 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L699" class="LineNr">699 </span><span class="Delimiter">}</span> -<span id="L700" class="LineNr">700 </span> -<span id="L701" class="LineNr">701 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><span class="Normal">const</span> string_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L702" class="LineNr">702 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L703" class="LineNr">703 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L704" class="LineNr">704 </span> <span class="Conceal">¦</span> out << <span class="Constant">'"'</span> << x<span class="Delimiter">-></span>value << <span class="Constant">'"'</span><span class="Delimiter">;</span> -<span id="L705" class="LineNr">705 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L706" class="LineNr">706 </span> <span class="Delimiter">}</span> -<span id="L707" class="LineNr">707 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L708" class="LineNr">708 </span> <span class="Normal">const</span> string_tree* curr = x<span class="Delimiter">;</span> -<span id="L709" class="LineNr">709 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L710" class="LineNr">710 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L711" class="LineNr">711 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L712" class="LineNr">712 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L713" class="LineNr">713 </span> <span class="Delimiter">}</span> -<span id="L714" class="LineNr">714 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L715" class="LineNr">715 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L716" class="LineNr">716 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L717" class="LineNr">717 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L718" class="LineNr">718 </span> <span class="Delimiter">}</span> -<span id="L719" class="LineNr">719 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L720" class="LineNr">720 </span><span class="Delimiter">}</span> -<span id="L721" class="LineNr">721 </span> -<span id="L722" class="LineNr">722 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L723" class="LineNr">723 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> -<span id="L724" class="LineNr">724 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L725" class="LineNr">725 </span> dump<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L726" class="LineNr">726 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L727" class="LineNr">727 </span><span class="Delimiter">}</span> -<span id="L728" class="LineNr">728 </span> -<span id="L729" class="LineNr">729 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L730" class="LineNr">730 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L731" class="LineNr">731 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L732" class="LineNr">732 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>x<span class="Delimiter">-></span>value<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L733" class="LineNr">733 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L734" class="LineNr">734 </span> <span class="Delimiter">}</span> -<span id="L735" class="LineNr">735 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L736" class="LineNr">736 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L737" class="LineNr">737 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L738" class="LineNr">738 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L739" class="LineNr">739 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L740" class="LineNr">740 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L741" class="LineNr">741 </span> <span class="Delimiter">}</span> -<span id="L742" class="LineNr">742 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L743" class="LineNr">743 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L744" class="LineNr">744 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L745" class="LineNr">745 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L746" class="LineNr">746 </span> <span class="Delimiter">}</span> -<span id="L747" class="LineNr">747 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L748" class="LineNr">748 </span><span class="Delimiter">}</span> -<span id="L749" class="LineNr">749 </span> -<span id="L750" class="LineNr">750 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><a href='010vm.cc.html#L123'>type_ordinal</a> type<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L751" class="LineNr">751 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">))</span> -<span id="L752" class="LineNr">752 </span> <span class="Conceal">¦</span> out << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">).</span>name<span class="Delimiter">;</span> -<span id="L753" class="LineNr">753 </span> <span class="Normal">else</span> -<span id="L754" class="LineNr">754 </span> <span class="Conceal">¦</span> out << <span class="Constant">"?"</span> << type<span class="Delimiter">;</span> -<span id="L755" class="LineNr">755 </span><span class="Delimiter">}</span> -<span id="L756" class="LineNr">756 </span> -<span id="L757" class="LineNr">757 </span>string names_to_string<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L758" class="LineNr">758 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> <span class="Comment">// should never happen</span> -<span id="L759" class="LineNr">759 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L760" class="LineNr">760 </span> dump_names<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L761" class="LineNr">761 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L762" class="LineNr">762 </span><span class="Delimiter">}</span> -<span id="L763" class="LineNr">763 </span> -<span id="L764" class="LineNr">764 </span><span class="Normal">void</span> dump_names<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L765" class="LineNr">765 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L766" class="LineNr">766 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L767" class="LineNr">767 </span> <span class="Conceal">¦</span> out << <span class="Constant">'"'</span> << x<span class="Delimiter">-></span>name << <span class="Constant">'"'</span><span class="Delimiter">;</span> -<span id="L768" class="LineNr">768 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L769" class="LineNr">769 </span> <span class="Delimiter">}</span> -<span id="L770" class="LineNr">770 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L771" class="LineNr">771 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L772" class="LineNr">772 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L773" class="LineNr">773 </span> <span class="Conceal">¦</span> dump_names<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L774" class="LineNr">774 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L775" class="LineNr">775 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L776" class="LineNr">776 </span> <span class="Delimiter">}</span> -<span id="L777" class="LineNr">777 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L778" class="LineNr">778 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L779" class="LineNr">779 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L780" class="LineNr">780 </span> <span class="Conceal">¦</span> dump_names<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L781" class="LineNr">781 </span> <span class="Delimiter">}</span> -<span id="L782" class="LineNr">782 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L783" class="LineNr">783 </span><span class="Delimiter">}</span> -<span id="L784" class="LineNr">784 </span> -<span id="L785" class="LineNr">785 </span>string names_to_string_without_quotes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L786" class="LineNr">786 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> -<span id="L787" class="LineNr">787 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L788" class="LineNr">788 </span> dump_names_without_quotes<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L789" class="LineNr">789 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L790" class="LineNr">790 </span><span class="Delimiter">}</span> -<span id="L791" class="LineNr">791 </span> -<span id="L792" class="LineNr">792 </span><span class="Normal">void</span> dump_names_without_quotes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L793" class="LineNr">793 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L794" class="LineNr">794 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L795" class="LineNr">795 </span> <span class="Conceal">¦</span> out << x<span class="Delimiter">-></span>name<span class="Delimiter">;</span> -<span id="L796" class="LineNr">796 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L797" class="LineNr">797 </span> <span class="Delimiter">}</span> -<span id="L798" class="LineNr">798 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L799" class="LineNr">799 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L800" class="LineNr">800 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L801" class="LineNr">801 </span> <span class="Conceal">¦</span> dump_names_without_quotes<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L802" class="LineNr">802 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L803" class="LineNr">803 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L804" class="LineNr">804 </span> <span class="Delimiter">}</span> -<span id="L805" class="LineNr">805 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L806" class="LineNr">806 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L807" class="LineNr">807 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L808" class="LineNr">808 </span> <span class="Conceal">¦</span> dump_names_without_quotes<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L809" class="LineNr">809 </span> <span class="Delimiter">}</span> -<span id="L810" class="LineNr">810 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L811" class="LineNr">811 </span><span class="Delimiter">}</span> -<span id="L812" class="LineNr">812 </span> -<span id="L813" class="LineNr">813 </span><span class="Comment">//: helper to print numbers without excessive precision</span> -<span id="L814" class="LineNr">814 </span> -<span id="L815" class="LineNr">815 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L816" class="LineNr">816 </span><span class="Normal">struct</span> no_scientific <span class="Delimiter">{</span> -<span id="L817" class="LineNr">817 </span> <span class="Normal">double</span> x<span class="Delimiter">;</span> -<span id="L818" class="LineNr">818 </span> <span class="Normal">explicit</span> no_scientific<span class="Delimiter">(</span><span class="Normal">double</span> y<span class="Delimiter">)</span> :x<span class="Delimiter">(</span>y<span class="Delimiter">)</span> <span class="Delimiter">{}</span> -<span id="L819" class="LineNr">819 </span><span class="Delimiter">};</span> -<span id="L820" class="LineNr">820 </span> -<span id="L821" class="LineNr">821 </span><span class="Delimiter">:(code)</span> -<span id="L822" class="LineNr">822 </span>ostream& <span class="Normal">operator</span><<<span class="Delimiter">(</span>ostream& os<span class="Delimiter">,</span> no_scientific x<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L823" class="LineNr">823 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!isfinite<span class="Delimiter">(</span>x<span class="Delimiter">.</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L824" class="LineNr">824 </span> <span class="Conceal">¦</span> <span class="Comment">// Infinity or NaN</span> -<span id="L825" class="LineNr">825 </span> <span class="Conceal">¦</span> os << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> -<span id="L826" class="LineNr">826 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span> os<span class="Delimiter">;</span> -<span id="L827" class="LineNr">827 </span> <span class="Delimiter">}</span> -<span id="L828" class="LineNr">828 </span> ostringstream tmp<span class="Delimiter">;</span> -<span id="L829" class="LineNr">829 </span> <span class="Comment">// more accurate, but too slow</span> -<span id="L830" class="LineNr">830 </span><span class="CommentedCode">//? tmp.precision(308); // for 64-bit numbers</span> -<span id="L831" class="LineNr">831 </span> tmp << std::fixed << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> -<span id="L832" class="LineNr">832 </span> os << trim_floating_point<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>str<span class="Delimiter">());</span> -<span id="L833" class="LineNr">833 </span> <span class="Identifier">return</span> os<span class="Delimiter">;</span> -<span id="L834" class="LineNr">834 </span><span class="Delimiter">}</span> -<span id="L835" class="LineNr">835 </span> -<span id="L836" class="LineNr">836 </span>string trim_floating_point<span class="Delimiter">(</span><span class="Normal">const</span> string& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L837" class="LineNr">837 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L838" class="LineNr">838 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'.'</span><span class="Delimiter">)</span> == string::npos<span class="Delimiter">)</span> <span class="Identifier">return</span> in<span class="Delimiter">;</span> -<span id="L839" class="LineNr">839 </span> <span class="Normal">int</span> length = <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> -<span id="L840" class="LineNr">840 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>length > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L841" class="LineNr">841 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>length-<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="Constant">'0'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L842" class="LineNr">842 </span> <span class="Conceal">¦</span> --length<span class="Delimiter">;</span> -<span id="L843" class="LineNr">843 </span> <span class="Delimiter">}</span> -<span id="L844" class="LineNr">844 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>length-<span class="Constant">1</span><span class="Delimiter">)</span> == <span class="Constant">'.'</span><span class="Delimiter">)</span> --length<span class="Delimiter">;</span> -<span id="L845" class="LineNr">845 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>length == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"0"</span><span class="Delimiter">;</span> -<span id="L846" class="LineNr">846 </span> <span class="Identifier">return</span> in<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> length<span class="Delimiter">);</span> -<span id="L847" class="LineNr">847 </span><span class="Delimiter">}</span> -<span id="L848" class="LineNr">848 </span> -<span id="L849" class="LineNr">849 </span><span class="Normal">void</span> test_trim_floating_point<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L850" class="LineNr">850 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> -<span id="L851" class="LineNr">851 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">".0"</span><span class="Delimiter">),</span> <span class="Constant">"0"</span><span class="Delimiter">);</span> -<span id="L852" class="LineNr">852 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"1.5000"</span><span class="Delimiter">),</span> <span class="Constant">"1.5"</span><span class="Delimiter">);</span> -<span id="L853" class="LineNr">853 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"1.000001"</span><span class="Delimiter">),</span> <span class="Constant">"1.000001"</span><span class="Delimiter">);</span> -<span id="L854" class="LineNr">854 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23.000000"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> -<span id="L855" class="LineNr">855 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23.0"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> -<span id="L856" class="LineNr">856 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23."</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> -<span id="L857" class="LineNr">857 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> -<span id="L858" class="LineNr">858 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"230"</span><span class="Delimiter">),</span> <span class="Constant">"230"</span><span class="Delimiter">);</span> -<span id="L859" class="LineNr">859 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3.000000"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> -<span id="L860" class="LineNr">860 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3.0"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> -<span id="L861" class="LineNr">861 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3."</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> -<span id="L862" class="LineNr">862 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> -<span id="L863" class="LineNr">863 </span><span class="Delimiter">}</span> -<span id="L864" class="LineNr">864 </span> -<span id="L865" class="LineNr">865 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L866" class="LineNr">866 </span><span class="PreProc">#include </span><span class="Constant"><utility></span> -<span id="L867" class="LineNr">867 </span><span class="Normal">using</span> std::pair<span class="Delimiter">;</span> -<span id="L868" class="LineNr">868 </span><span class="PreProc">#include </span><span class="Constant"><math.h></span> +<span id="L639" class="LineNr">639 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>original_string<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>original_string<span class="Delimiter">;</span> +<span id="L640" class="LineNr">640 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L641" class="LineNr">641 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L642" class="LineNr">642 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> +<span id="L643" class="LineNr">643 </span> <span class="Conceal">¦</span> out << inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> +<span id="L644" class="LineNr">644 </span> <span class="Delimiter">}</span> +<span id="L645" class="LineNr">645 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> +<span id="L646" class="LineNr">646 </span> out << inst<span class="Delimiter">.</span>name<span class="Delimiter">;</span> +<span id="L647" class="LineNr">647 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L648" class="LineNr">648 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L649" class="LineNr">649 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> +<span id="L650" class="LineNr">650 </span> <span class="Conceal">¦</span> out << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string<span class="Delimiter">;</span> +<span id="L651" class="LineNr">651 </span> <span class="Delimiter">}</span> +<span id="L652" class="LineNr">652 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L653" class="LineNr">653 </span><span class="Delimiter">}</span> +<span id="L654" class="LineNr">654 </span> +<span id="L655" class="LineNr">655 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L656" class="LineNr">656 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span> +<span id="L657" class="LineNr">657 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L658" class="LineNr">658 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L659" class="LineNr">659 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> +<span id="L660" class="LineNr">660 </span> <span class="Conceal">¦</span> out << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L661" class="LineNr">661 </span> <span class="Delimiter">}</span> +<span id="L662" class="LineNr">662 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> out << <span class="Constant">" <- "</span><span class="Delimiter">;</span> +<span id="L663" class="LineNr">663 </span> out << inst<span class="Delimiter">.</span>name << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L664" class="LineNr">664 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L665" class="LineNr">665 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">", "</span><span class="Delimiter">;</span> +<span id="L666" class="LineNr">666 </span> <span class="Conceal">¦</span> out << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L667" class="LineNr">667 </span> <span class="Delimiter">}</span> +<span id="L668" class="LineNr">668 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L669" class="LineNr">669 </span><span class="Delimiter">}</span> +<span id="L670" class="LineNr">670 </span> +<span id="L671" class="LineNr">671 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L672" class="LineNr">672 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">"_"</span><span class="Delimiter">;</span> +<span id="L673" class="LineNr">673 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L674" class="LineNr">674 </span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> +<span id="L675" class="LineNr">675 </span> out << r<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << names_to_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> +<span id="L676" class="LineNr">676 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L677" class="LineNr">677 </span> <span class="Conceal">¦</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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L678" class="LineNr">678 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">", </span><span class="cSpecial">\"</span><span class="Constant">"</span> << r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first << <span class="Constant">"</span><span class="cSpecial">\"</span><span class="Constant">: "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">);</span> +<span id="L679" class="LineNr">679 </span> <span class="Delimiter">}</span> +<span id="L680" class="LineNr">680 </span> out << <span class="Constant">"}"</span><span class="Delimiter">;</span> +<span id="L681" class="LineNr">681 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L682" class="LineNr">682 </span><span class="Delimiter">}</span> +<span id="L683" class="LineNr">683 </span> +<span id="L684" class="LineNr">684 </span><span class="Comment">// special name for ignoring some products</span> +<span id="L685" class="LineNr">685 </span><span class="Normal">bool</span> is_dummy<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L686" class="LineNr">686 </span> <span class="Identifier">return</span> x<span class="Delimiter">.</span>name == <span class="Constant">"_"</span><span class="Delimiter">;</span> +<span id="L687" class="LineNr">687 </span><span class="Delimiter">}</span> +<span id="L688" class="LineNr">688 </span> +<span id="L689" class="LineNr">689 </span>string debug_string<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L690" class="LineNr">690 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L691" class="LineNr">691 </span> out << x<span class="Delimiter">.</span>name << <span class="Constant">": "</span> << x<span class="Delimiter">.</span>value << <span class="Constant">' '</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" -- "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">);</span> +<span id="L692" class="LineNr">692 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L693" class="LineNr">693 </span><span class="Delimiter">}</span> +<span id="L694" class="LineNr">694 </span> +<span id="L695" class="LineNr">695 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> string_tree* property<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L696" class="LineNr">696 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!property<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> +<span id="L697" class="LineNr">697 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L698" class="LineNr">698 </span> dump<span class="Delimiter">(</span>property<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L699" class="LineNr">699 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L700" class="LineNr">700 </span><span class="Delimiter">}</span> +<span id="L701" class="LineNr">701 </span> +<span id="L702" class="LineNr">702 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><span class="Normal">const</span> string_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L703" class="LineNr">703 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L704" class="LineNr">704 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L705" class="LineNr">705 </span> <span class="Conceal">¦</span> out << <span class="Constant">'"'</span> << x<span class="Delimiter">-></span>value << <span class="Constant">'"'</span><span class="Delimiter">;</span> +<span id="L706" class="LineNr">706 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L707" class="LineNr">707 </span> <span class="Delimiter">}</span> +<span id="L708" class="LineNr">708 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> +<span id="L709" class="LineNr">709 </span> <span class="Normal">const</span> string_tree* curr = x<span class="Delimiter">;</span> +<span id="L710" class="LineNr">710 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L711" class="LineNr">711 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L712" class="LineNr">712 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L713" class="LineNr">713 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> +<span id="L714" class="LineNr">714 </span> <span class="Delimiter">}</span> +<span id="L715" class="LineNr">715 </span> <span class="Comment">// check for dotted list; should never happen</span> +<span id="L716" class="LineNr">716 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L717" class="LineNr">717 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> +<span id="L718" class="LineNr">718 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L719" class="LineNr">719 </span> <span class="Delimiter">}</span> +<span id="L720" class="LineNr">720 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> +<span id="L721" class="LineNr">721 </span><span class="Delimiter">}</span> +<span id="L722" class="LineNr">722 </span> +<span id="L723" class="LineNr">723 </span>string <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L724" class="LineNr">724 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> +<span id="L725" class="LineNr">725 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L726" class="LineNr">726 </span> dump<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L727" class="LineNr">727 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L728" class="LineNr">728 </span><span class="Delimiter">}</span> +<span id="L729" class="LineNr">729 </span> +<span id="L730" class="LineNr">730 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L731" class="LineNr">731 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L732" class="LineNr">732 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L733" class="LineNr">733 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>x<span class="Delimiter">-></span>value<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L734" class="LineNr">734 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L735" class="LineNr">735 </span> <span class="Delimiter">}</span> +<span id="L736" class="LineNr">736 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> +<span id="L737" class="LineNr">737 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> +<span id="L738" class="LineNr">738 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L739" class="LineNr">739 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L740" class="LineNr">740 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L741" class="LineNr">741 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> +<span id="L742" class="LineNr">742 </span> <span class="Delimiter">}</span> +<span id="L743" class="LineNr">743 </span> <span class="Comment">// check for dotted list; should never happen</span> +<span id="L744" class="LineNr">744 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L745" class="LineNr">745 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> +<span id="L746" class="LineNr">746 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L747" class="LineNr">747 </span> <span class="Delimiter">}</span> +<span id="L748" class="LineNr">748 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> +<span id="L749" class="LineNr">749 </span><span class="Delimiter">}</span> +<span id="L750" class="LineNr">750 </span> +<span id="L751" class="LineNr">751 </span><span class="Normal">void</span> dump<span class="Delimiter">(</span><a href='010vm.cc.html#L123'>type_ordinal</a> type<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L752" class="LineNr">752 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">))</span> +<span id="L753" class="LineNr">753 </span> <span class="Conceal">¦</span> out << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">).</span>name<span class="Delimiter">;</span> +<span id="L754" class="LineNr">754 </span> <span class="Normal">else</span> +<span id="L755" class="LineNr">755 </span> <span class="Conceal">¦</span> out << <span class="Constant">"?"</span> << type<span class="Delimiter">;</span> +<span id="L756" class="LineNr">756 </span><span class="Delimiter">}</span> +<span id="L757" class="LineNr">757 </span> +<span id="L758" class="LineNr">758 </span>string names_to_string<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L759" class="LineNr">759 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> <span class="Comment">// should never happen</span> +<span id="L760" class="LineNr">760 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L761" class="LineNr">761 </span> dump_names<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L762" class="LineNr">762 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L763" class="LineNr">763 </span><span class="Delimiter">}</span> +<span id="L764" class="LineNr">764 </span> +<span id="L765" class="LineNr">765 </span><span class="Normal">void</span> dump_names<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L766" class="LineNr">766 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L767" class="LineNr">767 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L768" class="LineNr">768 </span> <span class="Conceal">¦</span> out << <span class="Constant">'"'</span> << x<span class="Delimiter">-></span>name << <span class="Constant">'"'</span><span class="Delimiter">;</span> +<span id="L769" class="LineNr">769 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L770" class="LineNr">770 </span> <span class="Delimiter">}</span> +<span id="L771" class="LineNr">771 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> +<span id="L772" class="LineNr">772 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> +<span id="L773" class="LineNr">773 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L774" class="LineNr">774 </span> <span class="Conceal">¦</span> dump_names<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L775" class="LineNr">775 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L776" class="LineNr">776 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> +<span id="L777" class="LineNr">777 </span> <span class="Delimiter">}</span> +<span id="L778" class="LineNr">778 </span> <span class="Comment">// check for dotted list; should never happen</span> +<span id="L779" class="LineNr">779 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L780" class="LineNr">780 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> +<span id="L781" class="LineNr">781 </span> <span class="Conceal">¦</span> dump_names<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L782" class="LineNr">782 </span> <span class="Delimiter">}</span> +<span id="L783" class="LineNr">783 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> +<span id="L784" class="LineNr">784 </span><span class="Delimiter">}</span> +<span id="L785" class="LineNr">785 </span> +<span id="L786" class="LineNr">786 </span>string names_to_string_without_quotes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L787" class="LineNr">787 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>type == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"()"</span><span class="Delimiter">;</span> +<span id="L788" class="LineNr">788 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L789" class="LineNr">789 </span> dump_names_without_quotes<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L790" class="LineNr">790 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L791" class="LineNr">791 </span><span class="Delimiter">}</span> +<span id="L792" class="LineNr">792 </span> +<span id="L793" class="LineNr">793 </span><span class="Normal">void</span> dump_names_without_quotes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* x<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L794" class="LineNr">794 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L795" class="LineNr">795 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L796" class="LineNr">796 </span> <span class="Conceal">¦</span> out << x<span class="Delimiter">-></span>name<span class="Delimiter">;</span> +<span id="L797" class="LineNr">797 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L798" class="LineNr">798 </span> <span class="Delimiter">}</span> +<span id="L799" class="LineNr">799 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> +<span id="L800" class="LineNr">800 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> +<span id="L801" class="LineNr">801 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr && !curr<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L802" class="LineNr">802 </span> <span class="Conceal">¦</span> dump_names_without_quotes<span class="Delimiter">(</span>curr<span class="Delimiter">-></span>left<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L803" class="LineNr">803 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">-></span>right<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L804" class="LineNr">804 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> +<span id="L805" class="LineNr">805 </span> <span class="Delimiter">}</span> +<span id="L806" class="LineNr">806 </span> <span class="Comment">// check for dotted list; should never happen</span> +<span id="L807" class="LineNr">807 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L808" class="LineNr">808 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> +<span id="L809" class="LineNr">809 </span> <span class="Conceal">¦</span> dump_names_without_quotes<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L810" class="LineNr">810 </span> <span class="Delimiter">}</span> +<span id="L811" class="LineNr">811 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> +<span id="L812" class="LineNr">812 </span><span class="Delimiter">}</span> +<span id="L813" class="LineNr">813 </span> +<span id="L814" class="LineNr">814 </span><span class="Comment">//: helper to print numbers without excessive precision</span> +<span id="L815" class="LineNr">815 </span> +<span id="L816" class="LineNr">816 </span><span class="Delimiter">:(before "End Types")</span> +<span id="L817" class="LineNr">817 </span><span class="Normal">struct</span> no_scientific <span class="Delimiter">{</span> +<span id="L818" class="LineNr">818 </span> <span class="Normal">double</span> x<span class="Delimiter">;</span> +<span id="L819" class="LineNr">819 </span> <span class="Normal">explicit</span> no_scientific<span class="Delimiter">(</span><span class="Normal">double</span> y<span class="Delimiter">)</span> :x<span class="Delimiter">(</span>y<span class="Delimiter">)</span> <span class="Delimiter">{}</span> +<span id="L820" class="LineNr">820 </span><span class="Delimiter">};</span> +<span id="L821" class="LineNr">821 </span> +<span id="L822" class="LineNr">822 </span><span class="Delimiter">:(code)</span> +<span id="L823" class="LineNr">823 </span>ostream& <span class="Normal">operator</span><<<span class="Delimiter">(</span>ostream& os<span class="Delimiter">,</span> no_scientific x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L824" class="LineNr">824 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!isfinite<span class="Delimiter">(</span>x<span class="Delimiter">.</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L825" class="LineNr">825 </span> <span class="Conceal">¦</span> <span class="Comment">// Infinity or NaN</span> +<span id="L826" class="LineNr">826 </span> <span class="Conceal">¦</span> os << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> +<span id="L827" class="LineNr">827 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span> os<span class="Delimiter">;</span> +<span id="L828" class="LineNr">828 </span> <span class="Delimiter">}</span> +<span id="L829" class="LineNr">829 </span> ostringstream tmp<span class="Delimiter">;</span> +<span id="L830" class="LineNr">830 </span> <span class="Comment">// more accurate, but too slow</span> +<span id="L831" class="LineNr">831 </span><span class="CommentedCode">//? tmp.precision(308); // for 64-bit numbers</span> +<span id="L832" class="LineNr">832 </span> tmp << std::fixed << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> +<span id="L833" class="LineNr">833 </span> os << trim_floating_point<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>str<span class="Delimiter">());</span> +<span id="L834" class="LineNr">834 </span> <span class="Identifier">return</span> os<span class="Delimiter">;</span> +<span id="L835" class="LineNr">835 </span><span class="Delimiter">}</span> +<span id="L836" class="LineNr">836 </span> +<span id="L837" class="LineNr">837 </span>string trim_floating_point<span class="Delimiter">(</span><span class="Normal">const</span> string& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L838" class="LineNr">838 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L839" class="LineNr">839 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'.'</span><span class="Delimiter">)</span> == string::npos<span class="Delimiter">)</span> <span class="Identifier">return</span> in<span class="Delimiter">;</span> +<span id="L840" class="LineNr">840 </span> <span class="Normal">int</span> length = <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> +<span id="L841" class="LineNr">841 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>length > <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L842" class="LineNr">842 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>length-<span class="Constant">1</span><span class="Delimiter">)</span> != <span class="Constant">'0'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L843" class="LineNr">843 </span> <span class="Conceal">¦</span> --length<span class="Delimiter">;</span> +<span id="L844" class="LineNr">844 </span> <span class="Delimiter">}</span> +<span id="L845" class="LineNr">845 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>length-<span class="Constant">1</span><span class="Delimiter">)</span> == <span class="Constant">'.'</span><span class="Delimiter">)</span> --length<span class="Delimiter">;</span> +<span id="L846" class="LineNr">846 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>length == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">"0"</span><span class="Delimiter">;</span> +<span id="L847" class="LineNr">847 </span> <span class="Identifier">return</span> in<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> length<span class="Delimiter">);</span> +<span id="L848" class="LineNr">848 </span><span class="Delimiter">}</span> +<span id="L849" class="LineNr">849 </span> +<span id="L850" class="LineNr">850 </span><span class="Normal">void</span> test_trim_floating_point<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L851" class="LineNr">851 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> +<span id="L852" class="LineNr">852 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">".0"</span><span class="Delimiter">),</span> <span class="Constant">"0"</span><span class="Delimiter">);</span> +<span id="L853" class="LineNr">853 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"1.5000"</span><span class="Delimiter">),</span> <span class="Constant">"1.5"</span><span class="Delimiter">);</span> +<span id="L854" class="LineNr">854 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"1.000001"</span><span class="Delimiter">),</span> <span class="Constant">"1.000001"</span><span class="Delimiter">);</span> +<span id="L855" class="LineNr">855 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23.000000"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> +<span id="L856" class="LineNr">856 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23.0"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> +<span id="L857" class="LineNr">857 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23."</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> +<span id="L858" class="LineNr">858 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"23"</span><span class="Delimiter">),</span> <span class="Constant">"23"</span><span class="Delimiter">);</span> +<span id="L859" class="LineNr">859 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"230"</span><span class="Delimiter">),</span> <span class="Constant">"230"</span><span class="Delimiter">);</span> +<span id="L860" class="LineNr">860 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3.000000"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> +<span id="L861" class="LineNr">861 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3.0"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> +<span id="L862" class="LineNr">862 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3."</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> +<span id="L863" class="LineNr">863 </span> <a href='002test.cc.html#L32'>CHECK_EQ</a><span class="Delimiter">(</span>trim_floating_point<span class="Delimiter">(</span><span class="Constant">"3"</span><span class="Delimiter">),</span> <span class="Constant">"3"</span><span class="Delimiter">);</span> +<span id="L864" class="LineNr">864 </span><span class="Delimiter">}</span> +<span id="L865" class="LineNr">865 </span> +<span id="L866" class="LineNr">866 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L867" class="LineNr">867 </span><span class="PreProc">#include </span><span class="Constant"><utility></span> +<span id="L868" class="LineNr">868 </span><span class="Normal">using</span> std::pair<span class="Delimiter">;</span> +<span id="L869" class="LineNr">869 </span><span class="PreProc">#include </span><span class="Constant"><math.h></span> </pre> </body> </html> diff --git a/html/042name.cc.html b/html/042name.cc.html index 91ce16e3..cf22f218 100644 --- a/html/042name.cc.html +++ b/html/042name.cc.html @@ -120,7 +120,7 @@ if ('onhashchange' in window) { <span id="L55" class="LineNr"> 55 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='042name.cc.html#L148'>is_named_location</a><span class="Delimiter">(</span>ingredient<span class="Delimiter">))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L56" class="LineNr"> 56 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='002test.cc.html#L86'>is_integer</a><span class="Delimiter">(</span>ingredient<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L57" class="LineNr"> 57 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!already_transformed<span class="Delimiter">(</span>ingredient<span class="Delimiter">,</span> names<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"tried to read ingredient '"</span> << ingredient<span class="Delimiter">.</span>name << <span class="Constant">"' in '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' but it hasn't been written to yet</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"tried to read ingredient '"</span> << ingredient<span class="Delimiter">.</span>name << <span class="Constant">"' in '"</span> << to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' but it hasn't been written to yet</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Comment">// use-before-set Error</span> <span id="L60" class="LineNr"> 60 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L61" class="LineNr"> 61 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> diff --git a/html/053recipe_header.cc.html b/html/053recipe_header.cc.html index bf306f1f..641c91b9 100644 --- a/html/053recipe_header.cc.html +++ b/html/053recipe_header.cc.html @@ -565,144 +565,151 @@ if ('onhashchange' in window) { <span id="L499" class="LineNr">499 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> add_header_products<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">);</span> <span id="L500" class="LineNr">500 </span> <span class="Delimiter">}</span> <span id="L501" class="LineNr">501 </span> <span class="Comment">// fall through return</span> -<span id="L502" class="LineNr">502 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// error will be raised elsewhere if there's a product in the header; just give up</span> -<span id="L503" class="LineNr">503 </span> <span class="Normal">const</span> instruction& final_instruction = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L504" class="LineNr">504 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>final_instruction<span class="Delimiter">.</span>name != <span class="Constant">"reply"</span> && final_instruction<span class="Delimiter">.</span>name != <span class="Constant">"return"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L505" class="LineNr">505 </span> <span class="Conceal">¦</span> <a href='010vm.cc.html#L32'>instruction</a> inst<span class="Delimiter">;</span> -<span id="L506" class="LineNr">506 </span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>name = <span class="Constant">"return"</span><span class="Delimiter">;</span> -<span id="L507" class="LineNr">507 </span> <span class="Conceal">¦</span> add_header_products<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">);</span> -<span id="L508" class="LineNr">508 </span> <span class="Conceal">¦</span> caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> -<span id="L509" class="LineNr">509 </span> <span class="Delimiter">}</span> -<span id="L510" class="LineNr">510 </span><span class="Delimiter">}</span> -<span id="L511" class="LineNr">511 </span> -<span id="L512" class="LineNr">512 </span><span class="Normal">void</span> add_header_products<span class="Delimiter">(</span>instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L513" class="LineNr">513 </span> assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"return"</span><span class="Delimiter">);</span> -<span id="L514" class="LineNr">514 </span> <span class="Comment">// collect any products with the same names as ingredients</span> -<span id="L515" class="LineNr">515 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L516" class="LineNr">516 </span> <span class="Conceal">¦</span> <span class="Comment">// if the ingredient is missing, add it from the header</span> -<span id="L517" class="LineNr">517 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> == i<span class="Delimiter">)</span> -<span id="L518" class="LineNr">518 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span id="L519" class="LineNr">519 </span> <span class="Conceal">¦</span> <span class="Comment">// if it's missing /same_as_ingredient, try to fill it in</span> -<span id="L520" class="LineNr">520 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> && !has_property<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same_as_ingredient"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L521" class="LineNr">521 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ostringstream same_as_ingredient<span class="Delimiter">;</span> -<span id="L522" class="LineNr">522 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> same_as_ingredient << get<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">);</span> -<span id="L523" class="LineNr">523 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"same-as-ingredient"</span><span class="Delimiter">,</span> <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>same_as_ingredient<span class="Delimiter">.</span>str<span class="Delimiter">())));</span> -<span id="L524" class="LineNr">524 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L525" class="LineNr">525 </span> <span class="Delimiter">}</span> -<span id="L526" class="LineNr">526 </span><span class="Delimiter">}</span> -<span id="L527" class="LineNr">527 </span> -<span id="L528" class="LineNr">528 </span><span class="Delimiter">:(scenario explicit_return_ignores_header)</span> -<span id="L529" class="LineNr">529 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L530" class="LineNr">530 </span> <span class="Constant">1</span>:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> -<span id="L531" class="LineNr">531 </span>] -<span id="L532" class="LineNr">532 </span><span class="muRecipe">def</span> add2 a:num<span class="Delimiter">,</span> b:num<span class="muRecipe"> -> </span>y:num<span class="Delimiter">,</span> z:num [ -<span id="L533" class="LineNr">533 </span> local-scope -<span id="L534" class="LineNr">534 </span> load-ingredients -<span id="L535" class="LineNr">535 </span> y<span class="Special"> <- </span>add a<span class="Delimiter">,</span> b -<span id="L536" class="LineNr">536 </span> z<span class="Special"> <- </span>subtract a<span class="Delimiter">,</span> b -<span id="L537" class="LineNr">537 </span> <span class="Identifier">return</span> a<span class="Delimiter">,</span> z -<span id="L538" class="LineNr">538 </span>] -<span id="L539" class="LineNr">539 </span><span class="traceContains">+mem: storing 3 in location 1</span> -<span id="L540" class="LineNr">540 </span><span class="traceContains">+mem: storing -2 in location 2</span> -<span id="L541" class="LineNr">541 </span> -<span id="L542" class="LineNr">542 </span><span class="Delimiter">:(scenario return_on_fallthrough_based_on_header)</span> -<span id="L543" class="LineNr">543 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L544" class="LineNr">544 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> -<span id="L545" class="LineNr">545 </span>] -<span id="L546" class="LineNr">546 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ -<span id="L547" class="LineNr">547 </span> local-scope -<span id="L548" class="LineNr">548 </span> load-ingredients -<span id="L549" class="LineNr">549 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y -<span id="L550" class="LineNr">550 </span>] -<span id="L551" class="LineNr">551 </span><span class="traceContains">+transform: <a href='010vm.cc.html#L32'>instruction</a>: return {z: "number"}</span> -<span id="L552" class="LineNr">552 </span><span class="traceContains">+mem: storing 8 in location 1</span> -<span id="L553" class="LineNr">553 </span> -<span id="L554" class="LineNr">554 </span><span class="Delimiter">:(scenario return_on_fallthrough_already_exists)</span> -<span id="L555" class="LineNr">555 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L556" class="LineNr">556 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> -<span id="L557" class="LineNr">557 </span>] -<span id="L558" class="LineNr">558 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ -<span id="L559" class="LineNr">559 </span> local-scope -<span id="L560" class="LineNr">560 </span> load-ingredients -<span id="L561" class="LineNr">561 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Comment"># no type for z</span> -<span id="L562" class="LineNr">562 </span> <span class="Identifier">return</span> z -<span id="L563" class="LineNr">563 </span>] -<span id="L564" class="LineNr">564 </span><span class="traceContains">+transform: <a href='010vm.cc.html#L32'>instruction</a>: return {z: ()}</span> -<span id="L565" class="LineNr">565 </span><span class="traceAbsent">-transform: <a href='010vm.cc.html#L32'>instruction</a>: return z:num</span> -<span id="L566" class="LineNr">566 </span><span class="traceContains">+mem: storing 8 in location 1</span> -<span id="L567" class="LineNr">567 </span> -<span id="L568" class="LineNr">568 </span><span class="Delimiter">:(scenario return_after_conditional_return_based_on_header)</span> -<span id="L569" class="LineNr">569 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L570" class="LineNr">570 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> -<span id="L571" class="LineNr">571 </span>] -<span id="L572" class="LineNr">572 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ -<span id="L573" class="LineNr">573 </span> local-scope -<span id="L574" class="LineNr">574 </span> load-ingredients -<span id="L575" class="LineNr">575 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Comment"># no type for z</span> -<span id="L576" class="LineNr">576 </span> <span class="Identifier">return</span>-<span class="Normal">if</span> <span class="Constant">0</span>/<span class="Constant">false</span><span class="Delimiter">,</span> <span class="Constant">34</span> -<span id="L577" class="LineNr">577 </span>] -<span id="L578" class="LineNr">578 </span><span class="traceContains">+mem: storing 8 in location 1</span> -<span id="L579" class="LineNr">579 </span> -<span id="L580" class="LineNr">580 </span><span class="Delimiter">:(scenario recipe_headers_perform_same_ingredient_check)</span> -<span id="L581" class="LineNr">581 </span><span class="Special">% Hide_errors = true;</span> -<span id="L582" class="LineNr">582 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ -<span id="L583" class="LineNr">583 </span> <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> -<span id="L584" class="LineNr">584 </span> <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> -<span id="L585" class="LineNr">585 </span> <span class="Constant">3</span>:num<span class="Special"> <- </span>add2 <span class="Constant">1</span>:num<span class="Delimiter">,</span> <span class="Constant">2</span>:num -<span id="L586" class="LineNr">586 </span>] -<span id="L587" class="LineNr">587 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>x:num [ -<span id="L588" class="LineNr">588 </span> local-scope -<span id="L589" class="LineNr">589 </span> load-ingredients -<span id="L590" class="LineNr">590 </span>] -<span id="L591" class="LineNr">591 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: '3:num <- add2 1:num, 2:num' should write to '1:num' rather than '3:num'</span> -<span id="L592" class="LineNr">592 </span> -<span id="L593" class="LineNr">593 </span><span class="Comment">//: One special-case is recipe 'main'. Make sure it's only ever taking in text</span> -<span id="L594" class="LineNr">594 </span><span class="Comment">//: ingredients, and returning a single number.</span> -<span id="L595" class="LineNr">595 </span> -<span id="L596" class="LineNr">596 </span><span class="Delimiter">:(scenario recipe_header_ingredients_constrained_for_main)</span> -<span id="L597" class="LineNr">597 </span><span class="Special">% Hide_errors = true;</span> -<span id="L598" class="LineNr">598 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> x:num [ -<span id="L599" class="LineNr">599 </span>] -<span id="L600" class="LineNr">600 </span><span class="traceContains">+error: ingredients of <a href='010vm.cc.html#L19'>recipe</a> 'main' must all be text (address:array:character)</span> -<span id="L601" class="LineNr">601 </span> -<span id="L602" class="LineNr">602 </span><span class="Delimiter">:(scenario recipe_header_products_constrained_for_main)</span> -<span id="L603" class="LineNr">603 </span><span class="Special">% Hide_errors = true;</span> -<span id="L604" class="LineNr">604 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a><span class="muRecipe"> -> </span>x:text [ -<span id="L605" class="LineNr">605 </span>] -<span id="L606" class="LineNr">606 </span><span class="traceContains">+error: <a href='010vm.cc.html#L19'>recipe</a> 'main' must return at most a single product, a number</span> -<span id="L607" class="LineNr">607 </span> -<span id="L608" class="LineNr">608 </span><span class="Delimiter">:(scenario recipe_header_products_constrained_for_main_2)</span> -<span id="L609" class="LineNr">609 </span><span class="Special">% Hide_errors = true;</span> -<span id="L610" class="LineNr">610 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a><span class="muRecipe"> -> </span>x:num<span class="Delimiter">,</span> y:num [ -<span id="L611" class="LineNr">611 </span>] -<span id="L612" class="LineNr">612 </span><span class="traceContains">+error: <a href='010vm.cc.html#L19'>recipe</a> 'main' must return at most a single product, a number</span> -<span id="L613" class="LineNr">613 </span> -<span id="L614" class="LineNr">614 </span><span class="Delimiter">:(after "Transform.push_back(expand_type_abbreviations)")</span> -<span id="L615" class="LineNr">615 </span>Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_recipe_header_constraints<span class="Delimiter">);</span> -<span id="L616" class="LineNr">616 </span><span class="Delimiter">:(code)</span> -<span id="L617" class="LineNr">617 </span><span class="Normal">void</span> check_recipe_header_constraints<span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L618" class="LineNr">618 </span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> -<span id="L619" class="LineNr">619 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name != <span class="Constant">"main"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L620" class="LineNr">620 </span> <a href='003trace.cc.html#L161'>trace</a><span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"check <a href='010vm.cc.html#L19'>recipe</a> header constraints for <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> -<span id="L621" class="LineNr">621 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L622" class="LineNr">622 </span> reagent<span class="Comment">/*</span><span class="Comment">local</span><span class="Comment">*/</span> expected_ingredient<span class="Delimiter">(</span><span class="Constant">"x:<a href='043space.cc.html#L76'>address</a>:array:character"</span><span class="Delimiter">);</span> -<span id="L623" class="LineNr">623 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L624" class="LineNr">624 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>expected_ingredient<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L625" class="LineNr">625 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"ingredients of <a href='010vm.cc.html#L19'>recipe</a> 'main' must all be text (address:array:character)</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> -<span id="L626" class="LineNr">626 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L627" class="LineNr">627 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L628" class="LineNr">628 </span> <span class="Delimiter">}</span> -<span id="L629" class="LineNr">629 </span> <span class="Normal">int</span> nprod = <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> -<span id="L630" class="LineNr">630 </span> reagent<span class="Comment">/*</span><span class="Comment">local</span><span class="Comment">*/</span> expected_product<span class="Delimiter">(</span><span class="Constant">"x:number"</span><span class="Delimiter">);</span> -<span id="L631" class="LineNr">631 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>nprod > <span class="Constant">1</span> -<span id="L632" class="LineNr">632 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> || <span class="Delimiter">(</span>nprod == <span class="Constant">1</span> && !types_strictly_match<span class="Delimiter">(</span>expected_product<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))))</span> <span class="Delimiter">{</span> -<span id="L633" class="LineNr">633 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"recipe 'main' must return at most a single product, a number</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> -<span id="L634" class="LineNr">634 </span> <span class="Delimiter">}</span> -<span id="L635" class="LineNr">635 </span><span class="Delimiter">}</span> -<span id="L636" class="LineNr">636 </span> -<span id="L637" class="LineNr">637 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L638" class="LineNr">638 </span><span class="Normal">using</span> std::min<span class="Delimiter">;</span> -<span id="L639" class="LineNr">639 </span><span class="Normal">using</span> std::max<span class="Delimiter">;</span> +<span id="L502" class="LineNr">502 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L503" class="LineNr">503 </span> <span class="Conceal">¦</span> <span class="Normal">const</span> instruction& final_instruction = caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L504" class="LineNr">504 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>final_instruction<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> || final_instruction<span class="Delimiter">.</span>name == <span class="Constant">"return"</span><span class="Delimiter">)</span> +<span id="L505" class="LineNr">505 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L506" class="LineNr">506 </span> <span class="Delimiter">}</span> +<span id="L507" class="LineNr">507 </span> <a href='010vm.cc.html#L32'>instruction</a> inst<span class="Delimiter">;</span> +<span id="L508" class="LineNr">508 </span> inst<span class="Delimiter">.</span>name = <span class="Constant">"return"</span><span class="Delimiter">;</span> +<span id="L509" class="LineNr">509 </span> add_header_products<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">);</span> +<span id="L510" class="LineNr">510 </span> caller_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> +<span id="L511" class="LineNr">511 </span><span class="Delimiter">}</span> +<span id="L512" class="LineNr">512 </span> +<span id="L513" class="LineNr">513 </span><span class="Normal">void</span> add_header_products<span class="Delimiter">(</span>instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller_recipe<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L514" class="LineNr">514 </span> assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"reply"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"return"</span><span class="Delimiter">);</span> +<span id="L515" class="LineNr">515 </span> <span class="Comment">// collect any products with the same names as ingredients</span> +<span id="L516" class="LineNr">516 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L517" class="LineNr">517 </span> <span class="Conceal">¦</span> <span class="Comment">// if the ingredient is missing, add it from the header</span> +<span id="L518" class="LineNr">518 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> == i<span class="Delimiter">)</span> +<span id="L519" class="LineNr">519 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L520" class="LineNr">520 </span> <span class="Conceal">¦</span> <span class="Comment">// if it's missing /same_as_ingredient, try to fill it in</span> +<span id="L521" class="LineNr">521 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">)</span> && !has_property<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same_as_ingredient"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L522" class="LineNr">522 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ostringstream same_as_ingredient<span class="Delimiter">;</span> +<span id="L523" class="LineNr">523 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> same_as_ingredient << get<span class="Delimiter">(</span>caller_recipe<span class="Delimiter">.</span>ingredient_index<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">);</span> +<span id="L524" class="LineNr">524 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"same-as-ingredient"</span><span class="Delimiter">,</span> <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>same_as_ingredient<span class="Delimiter">.</span>str<span class="Delimiter">())));</span> +<span id="L525" class="LineNr">525 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L526" class="LineNr">526 </span> <span class="Delimiter">}</span> +<span id="L527" class="LineNr">527 </span><span class="Delimiter">}</span> +<span id="L528" class="LineNr">528 </span> +<span id="L529" class="LineNr">529 </span><span class="Delimiter">:(scenario explicit_return_ignores_header)</span> +<span id="L530" class="LineNr">530 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L531" class="LineNr">531 </span> <span class="Constant">1</span>:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">2</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> +<span id="L532" class="LineNr">532 </span>] +<span id="L533" class="LineNr">533 </span><span class="muRecipe">def</span> add2 a:num<span class="Delimiter">,</span> b:num<span class="muRecipe"> -> </span>y:num<span class="Delimiter">,</span> z:num [ +<span id="L534" class="LineNr">534 </span> local-scope +<span id="L535" class="LineNr">535 </span> load-ingredients +<span id="L536" class="LineNr">536 </span> y<span class="Special"> <- </span>add a<span class="Delimiter">,</span> b +<span id="L537" class="LineNr">537 </span> z<span class="Special"> <- </span>subtract a<span class="Delimiter">,</span> b +<span id="L538" class="LineNr">538 </span> <span class="Identifier">return</span> a<span class="Delimiter">,</span> z +<span id="L539" class="LineNr">539 </span>] +<span id="L540" class="LineNr">540 </span><span class="traceContains">+mem: storing 3 in location 1</span> +<span id="L541" class="LineNr">541 </span><span class="traceContains">+mem: storing -2 in location 2</span> +<span id="L542" class="LineNr">542 </span> +<span id="L543" class="LineNr">543 </span><span class="Delimiter">:(scenario return_on_fallthrough_based_on_header)</span> +<span id="L544" class="LineNr">544 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L545" class="LineNr">545 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> +<span id="L546" class="LineNr">546 </span>] +<span id="L547" class="LineNr">547 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ +<span id="L548" class="LineNr">548 </span> local-scope +<span id="L549" class="LineNr">549 </span> load-ingredients +<span id="L550" class="LineNr">550 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y +<span id="L551" class="LineNr">551 </span>] +<span id="L552" class="LineNr">552 </span><span class="traceContains">+transform: <a href='010vm.cc.html#L32'>instruction</a>: return {z: "number"}</span> +<span id="L553" class="LineNr">553 </span><span class="traceContains">+mem: storing 8 in location 1</span> +<span id="L554" class="LineNr">554 </span> +<span id="L555" class="LineNr">555 </span><span class="Delimiter">:(scenario return_on_fallthrough_already_exists)</span> +<span id="L556" class="LineNr">556 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L557" class="LineNr">557 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> +<span id="L558" class="LineNr">558 </span>] +<span id="L559" class="LineNr">559 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ +<span id="L560" class="LineNr">560 </span> local-scope +<span id="L561" class="LineNr">561 </span> load-ingredients +<span id="L562" class="LineNr">562 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Comment"># no type for z</span> +<span id="L563" class="LineNr">563 </span> <span class="Identifier">return</span> z +<span id="L564" class="LineNr">564 </span>] +<span id="L565" class="LineNr">565 </span><span class="traceContains">+transform: <a href='010vm.cc.html#L32'>instruction</a>: return {z: ()}</span> +<span id="L566" class="LineNr">566 </span><span class="traceAbsent">-transform: <a href='010vm.cc.html#L32'>instruction</a>: return z:num</span> +<span id="L567" class="LineNr">567 </span><span class="traceContains">+mem: storing 8 in location 1</span> +<span id="L568" class="LineNr">568 </span> +<span id="L569" class="LineNr">569 </span><span class="Delimiter">:(scenario return_causes_error_in_empty_recipe)</span> +<span id="L570" class="LineNr">570 </span><span class="Special">% Hide_errors = true;</span> +<span id="L571" class="LineNr">571 </span><span class="muRecipe">def</span> foo<span class="muRecipe"> -> </span>x:num [ +<span id="L572" class="LineNr">572 </span>] +<span id="L573" class="LineNr">573 </span><span class="traceContains">+error: foo: tried to read ingredient 'x' in 'return x:num' but it hasn't been written to yet</span> +<span id="L574" class="LineNr">574 </span> +<span id="L575" class="LineNr">575 </span><span class="Delimiter">:(scenario return_after_conditional_return_based_on_header)</span> +<span id="L576" class="LineNr">576 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L577" class="LineNr">577 </span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>add2 <span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">5</span> +<span id="L578" class="LineNr">578 </span>] +<span id="L579" class="LineNr">579 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>z:num [ +<span id="L580" class="LineNr">580 </span> local-scope +<span id="L581" class="LineNr">581 </span> load-ingredients +<span id="L582" class="LineNr">582 </span> z<span class="Special"> <- </span>add x<span class="Delimiter">,</span> y <span class="Comment"># no type for z</span> +<span id="L583" class="LineNr">583 </span> <span class="Identifier">return</span>-<span class="Normal">if</span> <span class="Constant">0</span>/<span class="Constant">false</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L584" class="LineNr">584 </span>] +<span id="L585" class="LineNr">585 </span><span class="traceContains">+mem: storing 8 in location 1</span> +<span id="L586" class="LineNr">586 </span> +<span id="L587" class="LineNr">587 </span><span class="Delimiter">:(scenario recipe_headers_perform_same_ingredient_check)</span> +<span id="L588" class="LineNr">588 </span><span class="Special">% Hide_errors = true;</span> +<span id="L589" class="LineNr">589 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ +<span id="L590" class="LineNr">590 </span> <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> +<span id="L591" class="LineNr">591 </span> <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">34</span> +<span id="L592" class="LineNr">592 </span> <span class="Constant">3</span>:num<span class="Special"> <- </span>add2 <span class="Constant">1</span>:num<span class="Delimiter">,</span> <span class="Constant">2</span>:num +<span id="L593" class="LineNr">593 </span>] +<span id="L594" class="LineNr">594 </span><span class="muRecipe">def</span> add2 x:num<span class="Delimiter">,</span> y:num<span class="muRecipe"> -> </span>x:num [ +<span id="L595" class="LineNr">595 </span> local-scope +<span id="L596" class="LineNr">596 </span> load-ingredients +<span id="L597" class="LineNr">597 </span>] +<span id="L598" class="LineNr">598 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: '3:num <- add2 1:num, 2:num' should write to '1:num' rather than '3:num'</span> +<span id="L599" class="LineNr">599 </span> +<span id="L600" class="LineNr">600 </span><span class="Comment">//: One special-case is recipe 'main'. Make sure it's only ever taking in text</span> +<span id="L601" class="LineNr">601 </span><span class="Comment">//: ingredients, and returning a single number.</span> +<span id="L602" class="LineNr">602 </span> +<span id="L603" class="LineNr">603 </span><span class="Delimiter">:(scenario recipe_header_ingredients_constrained_for_main)</span> +<span id="L604" class="LineNr">604 </span><span class="Special">% Hide_errors = true;</span> +<span id="L605" class="LineNr">605 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> x:num [ +<span id="L606" class="LineNr">606 </span>] +<span id="L607" class="LineNr">607 </span><span class="traceContains">+error: ingredients of <a href='010vm.cc.html#L19'>recipe</a> 'main' must all be text (address:array:character)</span> +<span id="L608" class="LineNr">608 </span> +<span id="L609" class="LineNr">609 </span><span class="Delimiter">:(scenario recipe_header_products_constrained_for_main)</span> +<span id="L610" class="LineNr">610 </span><span class="Special">% Hide_errors = true;</span> +<span id="L611" class="LineNr">611 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a><span class="muRecipe"> -> </span>x:text [ +<span id="L612" class="LineNr">612 </span>] +<span id="L613" class="LineNr">613 </span><span class="traceContains">+error: <a href='010vm.cc.html#L19'>recipe</a> 'main' must return at most a single product, a number</span> +<span id="L614" class="LineNr">614 </span> +<span id="L615" class="LineNr">615 </span><span class="Delimiter">:(scenario recipe_header_products_constrained_for_main_2)</span> +<span id="L616" class="LineNr">616 </span><span class="Special">% Hide_errors = true;</span> +<span id="L617" class="LineNr">617 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a><span class="muRecipe"> -> </span>x:num<span class="Delimiter">,</span> y:num [ +<span id="L618" class="LineNr">618 </span>] +<span id="L619" class="LineNr">619 </span><span class="traceContains">+error: <a href='010vm.cc.html#L19'>recipe</a> 'main' must return at most a single product, a number</span> +<span id="L620" class="LineNr">620 </span> +<span id="L621" class="LineNr">621 </span><span class="Delimiter">:(after "Transform.push_back(expand_type_abbreviations)")</span> +<span id="L622" class="LineNr">622 </span>Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_recipe_header_constraints<span class="Delimiter">);</span> +<span id="L623" class="LineNr">623 </span><span class="Delimiter">:(code)</span> +<span id="L624" class="LineNr">624 </span><span class="Normal">void</span> check_recipe_header_constraints<span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L625" class="LineNr">625 </span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> +<span id="L626" class="LineNr">626 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name != <span class="Constant">"main"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L627" class="LineNr">627 </span> <a href='003trace.cc.html#L161'>trace</a><span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"check <a href='010vm.cc.html#L19'>recipe</a> header constraints for <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L628" class="LineNr">628 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L629" class="LineNr">629 </span> reagent<span class="Comment">/*</span><span class="Comment">local</span><span class="Comment">*/</span> expected_ingredient<span class="Delimiter">(</span><span class="Constant">"x:<a href='043space.cc.html#L76'>address</a>:array:character"</span><span class="Delimiter">);</span> +<span id="L630" class="LineNr">630 </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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L631" class="LineNr">631 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>expected_ingredient<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> +<span id="L632" class="LineNr">632 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"ingredients of <a href='010vm.cc.html#L19'>recipe</a> 'main' must all be text (address:array:character)</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L633" class="LineNr">633 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L634" class="LineNr">634 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L635" class="LineNr">635 </span> <span class="Delimiter">}</span> +<span id="L636" class="LineNr">636 </span> <span class="Normal">int</span> nprod = <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>products<span class="Delimiter">);</span> +<span id="L637" class="LineNr">637 </span> reagent<span class="Comment">/*</span><span class="Comment">local</span><span class="Comment">*/</span> expected_product<span class="Delimiter">(</span><span class="Constant">"x:number"</span><span class="Delimiter">);</span> +<span id="L638" class="LineNr">638 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>nprod > <span class="Constant">1</span> +<span id="L639" class="LineNr">639 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> || <span class="Delimiter">(</span>nprod == <span class="Constant">1</span> && !types_strictly_match<span class="Delimiter">(</span>expected_product<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))))</span> <span class="Delimiter">{</span> +<span id="L640" class="LineNr">640 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"recipe 'main' must return at most a single product, a number</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L641" class="LineNr">641 </span> <span class="Delimiter">}</span> +<span id="L642" class="LineNr">642 </span><span class="Delimiter">}</span> +<span id="L643" class="LineNr">643 </span> +<span id="L644" class="LineNr">644 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L645" class="LineNr">645 </span><span class="Normal">using</span> std::min<span class="Delimiter">;</span> +<span id="L646" class="LineNr">646 </span><span class="Normal">using</span> std::max<span class="Delimiter">;</span> </pre> </body> </html> |