diff options
Diffstat (limited to 'html/010vm.cc.html')
-rw-r--r-- | html/010vm.cc.html | 506 |
1 files changed, 260 insertions, 246 deletions
diff --git a/html/010vm.cc.html b/html/010vm.cc.html index eed4d75a..a00a002d 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -667,255 +667,269 @@ if ('onhashchange' in window) { <span id="L603" class="LineNr">603 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L604" class="LineNr">604 </span><span class="Delimiter">}</span> <span id="L605" class="LineNr">605 </span> -<span id="L606" class="LineNr">606 </span>string debug_string<span class="Delimiter">(</span><span class="Normal">const</span> recipe& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L606" class="LineNr">606 </span>string to_original_string<span class="Delimiter">(</span><span class="Normal">const</span> recipe& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L607" class="LineNr">607 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L608" class="LineNr">608 </span> out << <span class="Constant">"- <a href='010vm.cc.html#L19'>recipe</a> "</span> << x<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L609" class="LineNr">609 </span> <span class="Comment">// Begin debug_string(recipe x)</span> -<span id="L610" class="LineNr">610 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L611" class="LineNr">611 </span> <span class="Conceal">¦</span> <span class="Normal">const</span> instruction& inst = x<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> -<span id="L612" class="LineNr">612 </span> <span class="Conceal">¦</span> out << <span class="Constant">"inst: "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L613" class="LineNr">613 </span> <span class="Conceal">¦</span> out << <span class="Constant">" ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> -<span id="L614" class="LineNr">614 </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>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L615" class="LineNr">615 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << debug_string<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="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L616" class="LineNr">616 </span> <span class="Conceal">¦</span> out << <span class="Constant">" products</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> -<span id="L617" class="LineNr">617 </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>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L618" class="LineNr">618 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << debug_string<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 class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L619" class="LineNr">619 </span> <span class="Delimiter">}</span> -<span id="L620" class="LineNr">620 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L621" class="LineNr">621 </span><span class="Delimiter">}</span> -<span id="L622" class="LineNr">622 </span> -<span id="L623" class="LineNr">623 </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="L624" class="LineNr">624 </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="L625" class="LineNr">625 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L626" class="LineNr">626 </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="L627" class="LineNr">627 </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="L628" class="LineNr">628 </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="L629" class="LineNr">629 </span> <span class="Delimiter">}</span> -<span id="L630" class="LineNr">630 </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="L631" class="LineNr">631 </span> out << inst<span class="Delimiter">.</span>name<span class="Delimiter">;</span> -<span id="L632" class="LineNr">632 </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="L633" class="LineNr">633 </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="L634" class="LineNr">634 </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="L635" class="LineNr">635 </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="L636" class="LineNr">636 </span> <span class="Delimiter">}</span> -<span id="L637" class="LineNr">637 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L638" class="LineNr">638 </span><span class="Delimiter">}</span> -<span id="L639" class="LineNr">639 </span> -<span id="L640" class="LineNr">640 </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="L641" class="LineNr">641 </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="L642" class="LineNr">642 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L643" class="LineNr">643 </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="L644" class="LineNr">644 </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="L645" class="LineNr">645 </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="L646" class="LineNr">646 </span> <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>products<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> out << inst<span class="Delimiter">.</span>name << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L649" class="LineNr">649 </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="L650" class="LineNr">650 </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="L651" class="LineNr">651 </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="L652" class="LineNr">652 </span> <span class="Delimiter">}</span> -<span id="L653" class="LineNr">653 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L654" class="LineNr">654 </span><span class="Delimiter">}</span> -<span id="L655" class="LineNr">655 </span> -<span id="L656" class="LineNr">656 </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="L657" class="LineNr">657 </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="L658" class="LineNr">658 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L659" class="LineNr">659 </span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> -<span id="L660" class="LineNr">660 </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="L661" class="LineNr">661 </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="L662" class="LineNr">662 </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="L663" class="LineNr">663 </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="L664" class="LineNr">664 </span> <span class="Delimiter">}</span> -<span id="L665" class="LineNr">665 </span> out << <span class="Constant">"}"</span><span class="Delimiter">;</span> -<span id="L666" class="LineNr">666 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L667" class="LineNr">667 </span><span class="Delimiter">}</span> -<span id="L668" class="LineNr">668 </span> -<span id="L669" class="LineNr">669 </span><span class="Comment">// special name for ignoring some products</span> -<span id="L670" class="LineNr">670 </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="L671" class="LineNr">671 </span> <span class="Identifier">return</span> x<span class="Delimiter">.</span>name == <span class="Constant">"_"</span><span class="Delimiter">;</span> -<span id="L672" class="LineNr">672 </span><span class="Delimiter">}</span> -<span id="L673" class="LineNr">673 </span> -<span id="L674" class="LineNr">674 </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="L675" class="LineNr">675 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L676" class="LineNr">676 </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="L677" class="LineNr">677 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L678" class="LineNr">678 </span><span class="Delimiter">}</span> -<span id="L679" class="LineNr">679 </span> -<span id="L680" class="LineNr">680 </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="L681" class="LineNr">681 </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="L682" class="LineNr">682 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L683" class="LineNr">683 </span> dump<span class="Delimiter">(</span>property<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L684" class="LineNr">684 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L685" class="LineNr">685 </span><span class="Delimiter">}</span> -<span id="L686" class="LineNr">686 </span> -<span id="L687" class="LineNr">687 </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="L688" class="LineNr">688 </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="L689" class="LineNr">689 </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="L690" class="LineNr">690 </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="L691" class="LineNr">691 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L692" class="LineNr">692 </span> <span class="Delimiter">}</span> -<span id="L693" class="LineNr">693 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L694" class="LineNr">694 </span> <span class="Normal">const</span> string_tree* curr = x<span class="Delimiter">;</span> -<span id="L695" class="LineNr">695 </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="L696" class="LineNr">696 </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="L697" class="LineNr">697 </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="L698" class="LineNr">698 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L699" class="LineNr">699 </span> <span class="Delimiter">}</span> -<span id="L700" class="LineNr">700 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L701" class="LineNr">701 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L702" class="LineNr">702 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L703" class="LineNr">703 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L704" class="LineNr">704 </span> <span class="Delimiter">}</span> -<span id="L705" class="LineNr">705 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L706" class="LineNr">706 </span><span class="Delimiter">}</span> -<span id="L707" class="LineNr">707 </span> -<span id="L708" class="LineNr">708 </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="L709" class="LineNr">709 </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="L710" class="LineNr">710 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L711" class="LineNr">711 </span> dump<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L712" class="LineNr">712 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L713" class="LineNr">713 </span><span class="Delimiter">}</span> -<span id="L714" class="LineNr">714 </span> -<span id="L715" class="LineNr">715 </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="L716" class="LineNr">716 </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="L717" class="LineNr">717 </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="L718" class="LineNr">718 </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="L719" class="LineNr">719 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L720" class="LineNr">720 </span> <span class="Delimiter">}</span> -<span id="L721" class="LineNr">721 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L722" class="LineNr">722 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L723" class="LineNr">723 </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="L724" class="LineNr">724 </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="L725" class="LineNr">725 </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="L726" class="LineNr">726 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L727" class="LineNr">727 </span> <span class="Delimiter">}</span> -<span id="L728" class="LineNr">728 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L729" class="LineNr">729 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L730" class="LineNr">730 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L731" class="LineNr">731 </span> <span class="Conceal">¦</span> dump<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L732" class="LineNr">732 </span> <span class="Delimiter">}</span> -<span id="L733" class="LineNr">733 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L734" class="LineNr">734 </span><span class="Delimiter">}</span> -<span id="L735" class="LineNr">735 </span> -<span id="L736" class="LineNr">736 </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="L737" class="LineNr">737 </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="L738" class="LineNr">738 </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="L739" class="LineNr">739 </span> <span class="Normal">else</span> -<span id="L740" class="LineNr">740 </span> <span class="Conceal">¦</span> out << <span class="Constant">"?"</span> << type<span class="Delimiter">;</span> -<span id="L741" class="LineNr">741 </span><span class="Delimiter">}</span> -<span id="L742" class="LineNr">742 </span> -<span id="L743" class="LineNr">743 </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="L744" class="LineNr">744 </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="L745" class="LineNr">745 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L746" class="LineNr">746 </span> dump_names<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L747" class="LineNr">747 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L608" class="LineNr">608 </span> out << <span class="Constant">"recipe "</span> << r<span class="Delimiter">.</span>name << <span class="Constant">" [</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L609" class="LineNr">609 </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>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L610" class="LineNr">610 </span> <span class="Conceal">¦</span> <span class="Normal">const</span> instruction& inst = r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L611" class="LineNr">611 </span> <span class="Conceal">¦</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 id="L612" class="LineNr">612 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << to_original_string<span class="Delimiter">(</span>r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L613" class="LineNr">613 </span> <span class="Conceal">¦</span> <span class="Normal">else</span> +<span id="L614" class="LineNr">614 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << r<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L615" class="LineNr">615 </span> <span class="Delimiter">}</span> +<span id="L616" class="LineNr">616 </span> out << <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L617" class="LineNr">617 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L618" class="LineNr">618 </span><span class="Delimiter">}</span> +<span id="L619" class="LineNr">619 </span> +<span id="L620" class="LineNr">620 </span>string debug_string<span class="Delimiter">(</span><span class="Normal">const</span> recipe& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L621" class="LineNr">621 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L622" class="LineNr">622 </span> out << <span class="Constant">"- <a href='010vm.cc.html#L19'>recipe</a> "</span> << x<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L623" class="LineNr">623 </span> <span class="Comment">// Begin debug_string(recipe x)</span> +<span id="L624" class="LineNr">624 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> index < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L625" class="LineNr">625 </span> <span class="Conceal">¦</span> <span class="Normal">const</span> instruction& inst = x<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> +<span id="L626" class="LineNr">626 </span> <span class="Conceal">¦</span> out << <span class="Constant">"inst: "</span> << <a href='028call_return.cc.html#L158'>to_string</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L627" class="LineNr">627 </span> <span class="Conceal">¦</span> out << <span class="Constant">" ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L628" class="LineNr">628 </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>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L629" class="LineNr">629 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << debug_string<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="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L630" class="LineNr">630 </span> <span class="Conceal">¦</span> out << <span class="Constant">" products</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L631" class="LineNr">631 </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>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L632" class="LineNr">632 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> out << <span class="Constant">" "</span> << debug_string<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 class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L633" class="LineNr">633 </span> <span class="Delimiter">}</span> +<span id="L634" class="LineNr">634 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<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>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_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="L751" class="LineNr">751 </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="L752" class="LineNr">752 </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="L753" class="LineNr">753 </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="L754" class="LineNr">754 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L755" class="LineNr">755 </span> <span class="Delimiter">}</span> -<span id="L756" class="LineNr">756 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L757" class="LineNr">757 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L758" class="LineNr">758 </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="L759" class="LineNr">759 </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="L760" class="LineNr">760 </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="L761" class="LineNr">761 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L762" class="LineNr">762 </span> <span class="Delimiter">}</span> -<span id="L763" class="LineNr">763 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L764" class="LineNr">764 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L765" class="LineNr">765 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L766" class="LineNr">766 </span> <span class="Conceal">¦</span> dump_names<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L767" class="LineNr">767 </span> <span class="Delimiter">}</span> -<span id="L768" class="LineNr">768 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L769" class="LineNr">769 </span><span class="Delimiter">}</span> -<span id="L770" class="LineNr">770 </span> -<span id="L771" class="LineNr">771 </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="L772" class="LineNr">772 </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="L773" class="LineNr">773 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L774" class="LineNr">774 </span> dump_names_without_quotes<span class="Delimiter">(</span>type<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L775" class="LineNr">775 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L776" class="LineNr">776 </span><span class="Delimiter">}</span> -<span id="L777" class="LineNr">777 </span> -<span id="L778" class="LineNr">778 </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="L779" class="LineNr">779 </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="L780" class="LineNr">780 </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="L781" class="LineNr">781 </span> <span class="Conceal">¦</span> out << x<span class="Delimiter">-></span>name<span class="Delimiter">;</span> -<span id="L782" class="LineNr">782 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L783" class="LineNr">783 </span> <span class="Delimiter">}</span> -<span id="L784" class="LineNr">784 </span> out << <span class="Constant">'('</span><span class="Delimiter">;</span> -<span id="L785" class="LineNr">785 </span> <span class="Normal">const</span> type_tree* curr = x<span class="Delimiter">;</span> -<span id="L786" class="LineNr">786 </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="L787" class="LineNr">787 </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="L788" class="LineNr">788 </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="L789" class="LineNr">789 </span> <span class="Conceal">¦</span> curr = curr<span class="Delimiter">-></span>right<span class="Delimiter">;</span> -<span id="L790" class="LineNr">790 </span> <span class="Delimiter">}</span> -<span id="L791" class="LineNr">791 </span> <span class="Comment">// check for dotted list; should never happen</span> -<span id="L792" class="LineNr">792 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L793" class="LineNr">793 </span> <span class="Conceal">¦</span> out << <span class="Constant">". "</span><span class="Delimiter">;</span> -<span id="L794" class="LineNr">794 </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="L795" class="LineNr">795 </span> <span class="Delimiter">}</span> -<span id="L796" class="LineNr">796 </span> out << <span class="Constant">')'</span><span class="Delimiter">;</span> -<span id="L797" class="LineNr">797 </span><span class="Delimiter">}</span> -<span id="L798" class="LineNr">798 </span> -<span id="L799" class="LineNr">799 </span><span class="Comment">//: helper to print numbers without excessive precision</span> -<span id="L800" class="LineNr">800 </span> -<span id="L801" class="LineNr">801 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L802" class="LineNr">802 </span><span class="Normal">struct</span> no_scientific <span class="Delimiter">{</span> -<span id="L803" class="LineNr">803 </span> <span class="Normal">double</span> x<span class="Delimiter">;</span> -<span id="L804" class="LineNr">804 </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="L805" class="LineNr">805 </span><span class="Delimiter">};</span> -<span id="L806" class="LineNr">806 </span> -<span id="L807" class="LineNr">807 </span><span class="Delimiter">:(code)</span> -<span id="L808" class="LineNr">808 </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="L809" class="LineNr">809 </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="L810" class="LineNr">810 </span> <span class="Conceal">¦</span> <span class="Comment">// Infinity or NaN</span> -<span id="L811" class="LineNr">811 </span> <span class="Conceal">¦</span> os << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> -<span id="L812" class="LineNr">812 </span> <span class="Conceal">¦</span> <span class="Identifier">return</span> os<span class="Delimiter">;</span> -<span id="L813" class="LineNr">813 </span> <span class="Delimiter">}</span> -<span id="L814" class="LineNr">814 </span> ostringstream tmp<span class="Delimiter">;</span> -<span id="L815" class="LineNr">815 </span> <span class="Comment">// more accurate, but too slow</span> -<span id="L816" class="LineNr">816 </span><span class="CommentedCode">//? tmp.precision(308); // for 64-bit numbers</span> -<span id="L817" class="LineNr">817 </span> tmp << std::fixed << x<span class="Delimiter">.</span>x<span class="Delimiter">;</span> -<span id="L818" class="LineNr">818 </span> os << trim_floating_point<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>str<span class="Delimiter">());</span> -<span id="L819" class="LineNr">819 </span> <span class="Identifier">return</span> os<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>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="L823" class="LineNr">823 </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="L824" class="LineNr">824 </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="L825" class="LineNr">825 </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="L826" class="LineNr">826 </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="L827" class="LineNr">827 </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="L828" class="LineNr">828 </span> <span class="Conceal">¦</span> --length<span class="Delimiter">;</span> -<span id="L829" class="LineNr">829 </span> <span class="Delimiter">}</span> -<span id="L830" class="LineNr">830 </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="L831" class="LineNr">831 </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="L832" class="LineNr">832 </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="L833" class="LineNr">833 </span><span class="Delimiter">}</span> -<span id="L834" class="LineNr">834 </span> -<span id="L835" class="LineNr">835 </span><span class="Normal">void</span> test_trim_floating_point<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L836" class="LineNr">836 </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="L837" class="LineNr">837 </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="L838" class="LineNr">838 </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="L839" class="LineNr">839 </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="L840" class="LineNr">840 </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="L841" class="LineNr">841 </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="L842" class="LineNr">842 </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="L843" class="LineNr">843 </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="L844" class="LineNr">844 </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="L845" class="LineNr">845 </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="L846" class="LineNr">846 </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="L847" class="LineNr">847 </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="L848" class="LineNr">848 </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="L849" class="LineNr">849 </span><span class="Delimiter">}</span> -<span id="L850" class="LineNr">850 </span> -<span id="L851" class="LineNr">851 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L852" class="LineNr">852 </span><span class="PreProc">#include </span><span class="Constant"><utility></span> -<span id="L853" class="LineNr">853 </span><span class="Normal">using</span> std::pair<span class="Delimiter">;</span> -<span id="L854" class="LineNr">854 </span><span class="PreProc">#include </span><span class="Constant"><math.h></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> </pre> </body> </html> |