<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>CVC3: expr_stream.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">CVC3 <span id="projectnumber">2.4.1</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">expr_stream.cpp</div> </div> </div> <div class="contents"> <a href="expr__stream_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************/</span><span class="comment"></span> <a name="l00002"></a>00002 <span class="comment">/*!</span> <a name="l00003"></a>00003 <span class="comment"> * \file expr_stream.cpp</span> <a name="l00004"></a>00004 <span class="comment"> * </span> <a name="l00005"></a>00005 <span class="comment"> * Author: Sergey Berezin</span> <a name="l00006"></a>00006 <span class="comment"> * </span> <a name="l00007"></a>00007 <span class="comment"> * Created: Mon Jun 16 13:57:29 2003</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * <hr></span> <a name="l00010"></a>00010 <span class="comment"> *</span> <a name="l00011"></a>00011 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span> <a name="l00012"></a>00012 <span class="comment"> * and its documentation for any purpose is hereby granted without</span> <a name="l00013"></a>00013 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span> <a name="l00014"></a>00014 <span class="comment"> * LICENSE file provided with this distribution.</span> <a name="l00015"></a>00015 <span class="comment"> * </span> <a name="l00016"></a>00016 <span class="comment"> * <hr></span> <a name="l00017"></a>00017 <span class="comment"> * </span> <a name="l00018"></a>00018 <span class="comment"> */</span> <a name="l00019"></a>00019 <span class="comment">/*****************************************************************************/</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="pretty__printer_8h.html">pretty_printer.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="expr__stream_8h.html">expr_stream.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="theory__core_8h.html">theory_core.h</a>"</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="keyword">using namespace </span>std; <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="keyword">namespace </span>CVC3 { <a name="l00028"></a>00028 <a name="l00029"></a><a class="code" href="classCVC3_1_1ExprStream.html#a758b310ee5459a56722b13b0f18b297f">00029</a> ExprStream::ExprStream(<a class="code" href="classCVC3_1_1ExprManager.html">ExprManager</a> *em) <a name="l00030"></a>00030 : d_em(em), d_os(&cout), d_depth(em->printDepth()), d_currDepth(0), <a name="l00031"></a>00031 d_lang(em->getOutputLang()), <a name="l00032"></a>00032 d_indent(em->withIndentation()), d_col(em->indent()), <a name="l00033"></a>00033 d_lineWidth(em->lineWidth()), d_indentReg(0), d_beginningOfLine(false), <a name="l00034"></a>00034 d_dag(em->dagPrinting()), d_dagBuilt(false), d_idCounter(0), <a name="l00035"></a>00035 d_nodag(false) { <a name="l00036"></a>00036 <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.push_back(<a class="code" href="classCVC3_1_1ExprStream.html#a7ab1b6602b49bf13867877bf5f7a5873" title="The ExprManager to use.">d_em</a>-><a class="code" href="group__EM__Priv.html#ga54ddb950b6bd35316d1cefe3fd506149" title="Get initial indentation.">indent</a>()); <a name="l00037"></a>00037 <a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a> = <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size(); <a name="l00038"></a>00038 <a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.push_back(0); <a name="l00039"></a>00039 <a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a>=<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.size(); <a name="l00040"></a>00040 } <a name="l00041"></a>00041 <span class="comment"></span> <a name="l00042"></a>00042 <span class="comment"> //! Generating unique names in DAG expr</span> <a name="l00043"></a><a class="code" href="classCVC3_1_1ExprStream.html#a1c0a58ef36e93c45d8ee3e7cf58b604b">00043</a> <span class="comment"></span> <span class="keywordtype">string</span> <a class="code" href="classCVC3_1_1ExprStream.html#a1c0a58ef36e93c45d8ee3e7cf58b604b" title="Generating unique names in DAG expr.">ExprStream::newName</a>() { <a name="l00044"></a>00044 ostringstream name; <a name="l00045"></a>00045 name << <span class="stringliteral">"v_"</span> << <a class="code" href="classCVC3_1_1ExprStream.html#aa2a427ab0f2adc805cfd3cab42b8363a" title="Counter for generating unique LET var names.">d_idCounter</a>++; <a name="l00046"></a>00046 <span class="keywordflow">return</span> name.str(); <a name="l00047"></a>00047 } <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="namespaceCVC3.html#a9451064d346e3d7aab9056a2ff9b7a89">00049</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceCVC3.html#a9451064d346e3d7aab9056a2ff9b7a89">isTrivialExpr</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) { <a name="l00050"></a>00050 <span class="keywordflow">return</span> (e.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>()==0 && !e.<a class="code" href="group__ExprPkg.html#ga3127f52184d5bcb2d4056cb23f3a292b">isClosure</a>()); <a name="l00051"></a>00051 } <a name="l00052"></a>00052 <span class="comment"></span> <a name="l00053"></a>00053 <span class="comment"> //! Traverse the Expr, collect shared subexpressions in d_dagMap</span> <a name="l00054"></a><a class="code" href="classCVC3_1_1ExprStream.html#a26a9afb803961536e2b0f74be900300f">00054</a> <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a26a9afb803961536e2b0f74be900300f" title="Traverse the Expr, collect shared subexpressions in d_dagMap.">ExprStream::collectShared</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e, <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap<bool></a>& cache) { <a name="l00055"></a>00055 <span class="comment">// If seen before, and it's not something trivial, add to d_dagMap</span> <a name="l00056"></a>00056 <span class="keywordflow">if</span>(!<a class="code" href="namespaceCVC3.html#a9451064d346e3d7aab9056a2ff9b7a89">isTrivialExpr</a>(e) && cache.<a class="code" href="classCVC3_1_1ExprMap.html#aa96dfa3a54a131cdb0964ef4b80e324f">count</a>(e) > 0) { <a name="l00057"></a>00057 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a5613bd2f13161fe6846776dbb328bd34" title="Mapping subexpressions to names for DAG printing.">d_dagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#aa96dfa3a54a131cdb0964ef4b80e324f">count</a>(e) == 0) { <a name="l00058"></a>00058 <span class="keywordtype">string</span> s(<a class="code" href="classCVC3_1_1ExprStream.html#a1c0a58ef36e93c45d8ee3e7cf58b604b" title="Generating unique names in DAG expr.">newName</a>()); <a name="l00059"></a>00059 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprStream.html#a0db5c8c81be1cdcdeba4c2873572b519" title="Output language.">d_lang</a> == <a class="code" href="namespaceCVC3.html#a3aaaf7bc1fc47a4860ef6e59ddb0db0ea548619427a4d459d859ccd041ced9bfa" title="SMT-LIB format.">SMTLIB_LANG</a>) { <a name="l00060"></a>00060 <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a> type(e.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>()); <a name="l00061"></a>00061 <span class="keywordflow">if</span> (type.isBool()) { <a name="l00062"></a>00062 s = <span class="stringliteral">"$"</span> + s; <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <span class="keywordflow">else</span> { <a name="l00065"></a>00065 s = <span class="stringliteral">"?"</span> + s; <a name="l00066"></a>00066 } <a name="l00067"></a>00067 } <a name="l00068"></a>00068 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprStream.html#a0db5c8c81be1cdcdeba4c2873572b519" title="Output language.">d_lang</a> == <a class="code" href="namespaceCVC3.html#a3aaaf7bc1fc47a4860ef6e59ddb0db0eaed2643c62e36b9b222804a1ab5b4809e" title="SMT-LIB v2 format.">SMTLIB_V2_LANG</a>) { <a name="l00069"></a>00069 s = <span class="stringliteral">"?"</span> + s; <a name="l00070"></a>00070 } <a name="l00071"></a>00071 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprStream.html#a0db5c8c81be1cdcdeba4c2873572b519" title="Output language.">d_lang</a> == <a class="code" href="namespaceCVC3.html#a3aaaf7bc1fc47a4860ef6e59ddb0db0ea5a0016ee7e592d6cc61821bfb0a0697c" title="for output in TPTP format">TPTP_LANG</a>) { <a name="l00072"></a>00072 <a name="l00073"></a>00073 s = <a class="code" href="namespaceCVC3.html#ac42ee3d1e39e0e5bbef72b5fc544db24">to_upper</a>( s); <a name="l00074"></a>00074 } <a name="l00075"></a>00075 <a name="l00076"></a>00076 <a class="code" href="classCVC3_1_1ExprStream.html#a5613bd2f13161fe6846776dbb328bd34" title="Mapping subexpressions to names for DAG printing.">d_dagMap</a>[e] = s; <a name="l00077"></a>00077 <a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>[e] = s; <a name="l00078"></a>00078 <a class="code" href="classCVC3_1_1ExprStream.html#ad1dc7ed42d81dd3de3a3ec4328c1d6c2" title="Stack of shared subexpressions (same as in d_dagMap)">d_dagStack</a>.push_back(e); <a name="l00079"></a>00079 } <a name="l00080"></a>00080 <span class="keywordflow">return</span>; <a name="l00081"></a>00081 } <a name="l00082"></a>00082 cache[e] = <span class="keyword">true</span>; <a name="l00083"></a>00083 <span class="keywordflow">for</span>(<a class="code" href="classCVC3_1_1Expr_1_1iterator.html">Expr::iterator</a> i=e.<a class="code" href="group__ExprPkg.html#gac890e13db184610276fc533fa4b4fe99" title="Begin iterator.">begin</a>(), iend=e.<a class="code" href="group__ExprPkg.html#gaf6048a5030c8fa2511bf5dfee868e653" title="End iterator.">end</a>(); i!=iend; ++i) <a name="l00084"></a>00084 <a class="code" href="classCVC3_1_1ExprStream.html#a26a9afb803961536e2b0f74be900300f" title="Traverse the Expr, collect shared subexpressions in d_dagMap.">collectShared</a>(*i, cache); <a name="l00085"></a>00085 <a class="code" href="classCVC3_1_1ExprStream.html#a5fb7d3cacc87b22ea0ca79efd35a038f" title="Flag whether the dagMap is already built.">d_dagBuilt</a> = <span class="keyword">true</span>; <a name="l00086"></a>00086 } <a name="l00087"></a>00087 <span class="comment"></span> <a name="l00088"></a>00088 <span class="comment"> //! Wrap e into the top-level LET ... IN header from the dagMap</span> <a name="l00089"></a>00089 <span class="comment"></span><span class="comment"> /*! </span> <a name="l00090"></a>00090 <span class="comment"> * We rely on the fact that d_dagMap is ordered by the Expr creation</span> <a name="l00091"></a>00091 <span class="comment"> * order, so earlier expressions cannot depend on later ones.</span> <a name="l00092"></a>00092 <span class="comment"> */</span> <a name="l00093"></a><a class="code" href="classCVC3_1_1ExprStream.html#a44b1833a153b0ecaa46616c557039dd8">00093</a> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> <a class="code" href="classCVC3_1_1ExprStream.html#a44b1833a153b0ecaa46616c557039dd8" title="Wrap e into the top-level LET ... IN header from the dagMap.">ExprStream::addLetHeader</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) { <a name="l00094"></a>00094 <a class="code" href="classCVC3_1_1ExprManager.html">ExprManager</a>* em = e.<a class="code" href="group__ExprPkg.html#gab57ce3dfa78947a906241d090c7cf34d">getEM</a>(); <a name="l00095"></a>00095 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a62589c597d245f3245df6d6a5fe6f4f1">size</a>() == 0) <span class="keywordflow">return</span> e; <a name="l00096"></a>00096 vector<Expr> decls; <a name="l00097"></a>00097 <span class="keywordflow">for</span>(<a class="code" href="classCVC3_1_1ExprMap_1_1iterator.html">ExprMap<string>::iterator</a> i=<a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a3db85401f8535daf4054fde531cd46b1">begin</a>(), <a name="l00098"></a>00098 iend=<a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>(); i!=iend; ++i) { <a name="l00099"></a>00099 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> var(em-><a class="code" href="group__EM__Priv.html#ga4d52ed373636679c2dd651d10822a3ee">newVarExpr</a>((*i).second)); <a name="l00100"></a>00100 <span class="keywordflow">if</span>(((*i).first).isType()) <a name="l00101"></a>00101 decls.push_back(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9508dd8c8e7db280a5dacc19bd74d92d">LETDECL</a>, var, em-><a class="code" href="group__EM__Priv.html#gacd77df1dbcc429e06a75047e2f609822">newLeafExpr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5bab47ea8bb955afd0adc0ef98517dd6084">TYPE</a>), <a name="l00102"></a>00102 (*i).first)); <a name="l00103"></a>00103 <span class="keywordflow">else</span> <a name="l00104"></a>00104 decls.push_back(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9508dd8c8e7db280a5dacc19bd74d92d">LETDECL</a>, var, (*i).first)); <a name="l00105"></a>00105 } <a name="l00106"></a>00106 <a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a173c2cf4753189d956073d74c36c7c58">clear</a>(); <a name="l00107"></a>00107 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5bafb72619a5a922e816967c4aa49301754">LET</a>, <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba2cd77861cfba212beedbf4245c990f72">LETDECLS</a>, decls), e); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00110"></a><a class="code" href="classCVC3_1_1ExprStream.html#a32a666cc0a71503770b88e3a7362808c">00110</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a32a666cc0a71503770b88e3a7362808c" title="Restore the indentation (user cannot pop more than pushed)">ExprStream::popIndent</a>() { <a name="l00111"></a>00111 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() > 0 <a name="l00112"></a>00112 && <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a>, <a name="l00113"></a>00113 <span class="stringliteral">"ExprStream::popIndent(): popped too much: "</span> <a name="l00114"></a>00114 <span class="stringliteral">"stack size = "</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size()) <a name="l00115"></a>00115 +<span class="stringliteral">", indentLast = "</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a>)); <a name="l00116"></a>00116 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() > 0 && <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a>) <a name="l00117"></a>00117 <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.pop_back(); <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <span class="comment"></span> <a name="l00120"></a>00120 <span class="comment"> //! Reset indentation to what it was at this level</span> <a name="l00121"></a><a class="code" href="classCVC3_1_1ExprStream.html#a946110c3457868fe38ce8c1d4cdde916">00121</a> <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a946110c3457868fe38ce8c1d4cdde916" title="Reset indentation to what it was at this level.">ExprStream::resetIndent</a>() { <a name="l00122"></a>00122 <span class="keywordflow">while</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a>) <a name="l00123"></a>00123 <a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.pop_back(); <a name="l00124"></a>00124 } <a name="l00125"></a>00125 <a name="l00126"></a>00126 <a name="l00127"></a><a class="code" href="classCVC3_1_1ExprStream.html#a2c93d862ed9b3cb1480a1d12cb510841">00127</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a2c93d862ed9b3cb1480a1d12cb510841" title="Recompute shared subexpression for the next Expr.">ExprStream::pushDag</a>() { <a name="l00128"></a>00128 <a class="code" href="classCVC3_1_1ExprStream.html#a5fb7d3cacc87b22ea0ca79efd35a038f" title="Flag whether the dagMap is already built.">d_dagBuilt</a> = <span class="keyword">false</span>; <a name="l00129"></a>00129 <a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.push_back(<a class="code" href="classCVC3_1_1ExprStream.html#ad1dc7ed42d81dd3de3a3ec4328c1d6c2" title="Stack of shared subexpressions (same as in d_dagMap)">d_dagStack</a>.size()); <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a name="l00132"></a><a class="code" href="classCVC3_1_1ExprStream.html#a7d1aa8566189d9b03a12bc56d3514979">00132</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a7d1aa8566189d9b03a12bc56d3514979" title="Delete shared subexpressions previously added with pushdag.">ExprStream::popDag</a>() { <a name="l00133"></a>00133 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a>, <a name="l00134"></a>00134 <span class="stringliteral">"ExprStream::popDag: popping more than pushed"</span>); <a name="l00135"></a>00135 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a> > 0, <span class="stringliteral">"ExprStream::popDag: this cannot happen!"</span>); <a name="l00136"></a>00136 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a>) { <a name="l00137"></a>00137 <span class="keywordtype">size_t</span> size(<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.back()); <a name="l00138"></a>00138 <a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.pop_back(); <a name="l00139"></a>00139 <span class="keywordflow">while</span>(<a class="code" href="classCVC3_1_1ExprStream.html#ad1dc7ed42d81dd3de3a3ec4328c1d6c2" title="Stack of shared subexpressions (same as in d_dagMap)">d_dagStack</a>.size() > size) { <a name="l00140"></a>00140 <a class="code" href="classCVC3_1_1ExprStream.html#a5613bd2f13161fe6846776dbb328bd34" title="Mapping subexpressions to names for DAG printing.">d_dagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a2997aa3f20d09f6bf49b09da9a177003">erase</a>(<a class="code" href="classCVC3_1_1ExprStream.html#ad1dc7ed42d81dd3de3a3ec4328c1d6c2" title="Stack of shared subexpressions (same as in d_dagMap)">d_dagStack</a>.back()); <a name="l00141"></a>00141 <a class="code" href="classCVC3_1_1ExprStream.html#ad1dc7ed42d81dd3de3a3ec4328c1d6c2" title="Stack of shared subexpressions (same as in d_dagMap)">d_dagStack</a>.pop_back(); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a class="code" href="classCVC3_1_1ExprStream.html#a8281aa65a9abe1cbbb3b1b43f9ab28c5" title="New subexpressions not yet printed in a LET header.">d_newDagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a173c2cf4753189d956073d74c36c7c58">clear</a>(); <a name="l00144"></a>00144 } <a name="l00145"></a>00145 } <a name="l00146"></a>00146 <a name="l00147"></a><a class="code" href="classCVC3_1_1ExprStream.html#a004714bd282bfa11595d21bce94e72ec">00147</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprStream.html#a004714bd282bfa11595d21bce94e72ec" title="Reset the DAG to what it was at this level.">ExprStream::resetDag</a>() { <a name="l00148"></a>00148 <span class="keywordflow">while</span>(<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.size() > <a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a>) <a class="code" href="classCVC3_1_1ExprStream.html#a7d1aa8566189d9b03a12bc56d3514979" title="Delete shared subexpressions previously added with pushdag.">popDag</a>(); <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <span class="comment"></span> <a name="l00151"></a>00151 <span class="comment"> /*! \defgroup ExprStream_Op Overloaded operator<< </span> <a name="l00152"></a>00152 <span class="comment"> * \ingroup PrettyPrinting</span> <a name="l00153"></a>00153 <span class="comment"> * @{</span> <a name="l00154"></a>00154 <span class="comment"> */</span><span class="comment"></span> <a name="l00155"></a>00155 <span class="comment"> //! Use manipulators which are functions over ExprStream&</span> <a name="l00156"></a><a class="code" href="group__ExprStream__Op.html#gafb08bfac859c5f0ed96a159243a47a03">00156</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <a name="l00157"></a>00157 <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& (*manip)(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>&)) { <a name="l00158"></a>00158 <span class="keywordflow">return</span> (*manip)(os); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <span class="comment"></span> <a name="l00161"></a>00161 <span class="comment"> //! Print Expr</span> <a name="l00162"></a><a class="code" href="group__ExprStream__Op.html#ga807ec90201aad047af2334bf44a1c8c1">00162</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) { <a name="l00163"></a>00163 <span class="comment">//os << "Printing in expr_stream";</span> <a name="l00164"></a>00164 <span class="comment">// If the max print depth is reached, print "..."</span> <a name="l00165"></a>00165 <span class="keywordflow">if</span>(os.<a class="code" href="classCVC3_1_1ExprStream.html#a82d42f256f0775a3b4c9c3a4bed346d0" title="Printing only upto this depth; -1 == unlimited.">d_depth</a> >= 0 && os.<a class="code" href="classCVC3_1_1ExprStream.html#a83bf8b10c32e6a579ace151f35ce7e08" title="Current depth of Expr.">d_currDepth</a> > os.<a class="code" href="classCVC3_1_1ExprStream.html#a82d42f256f0775a3b4c9c3a4bed346d0" title="Printing only upto this depth; -1 == unlimited.">d_depth</a>) <span class="keywordflow">return</span> os << <span class="stringliteral">"..."</span>; <a name="l00166"></a>00166 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e2(e); <a name="l00167"></a>00167 <span class="comment">// Don't LET-ify commands like ASSERT, QUERY, TRANSFORM</span> <a name="l00168"></a>00168 <span class="keywordflow">switch</span>(e.<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>()) { <a name="l00169"></a>00169 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba21043ddfa5289b4cf14cd4e3f5a89b62">QUERY</a>: <a name="l00170"></a>00170 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba61d9e0e93eb9635173764c5ba45666f1">ASSERT</a>: <a name="l00171"></a>00171 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba262553c759e1d1a9398bc406b1fadcb7">RESTART</a>: <a name="l00172"></a>00172 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba25f73324dc93d9024c0c75b4e6815335">TRANSFORM</a>: <a name="l00173"></a>00173 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5bab47ea8bb955afd0adc0ef98517dd6084">TYPE</a>: <a name="l00174"></a>00174 <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3d044162d972156d897cea80f216b9ca">CONST</a>: <a name="l00175"></a>00175 os.<a class="code" href="classCVC3_1_1ExprStream.html#a00ed22d62da899833285f2bbf20754fd" title="nodag() manipulator has been applied">d_nodag</a> = <span class="keyword">true</span>; <a name="l00176"></a>00176 <span class="keywordflow">break</span>; <a name="l00177"></a>00177 <span class="keywordflow">default</span>: <span class="keywordflow">break</span>; <a name="l00178"></a>00178 } <a name="l00179"></a>00179 <span class="comment">// Check cache for DAG printing</span> <a name="l00180"></a>00180 <span class="keywordflow">if</span>(os.<a class="code" href="classCVC3_1_1ExprStream.html#abc448835fcc31cd355c90606822ed42c">d_dag</a> && !os.<a class="code" href="classCVC3_1_1ExprStream.html#a00ed22d62da899833285f2bbf20754fd" title="nodag() manipulator has been applied">d_nodag</a> && <a name="l00181"></a>00181 os.<a class="code" href="classCVC3_1_1ExprStream.html#a0db5c8c81be1cdcdeba4c2873572b519" title="Output language.">d_lang</a> != <a class="code" href="namespaceCVC3.html#a3aaaf7bc1fc47a4860ef6e59ddb0db0ea7bdae8b250b94f50cea68f05c563cdca" title="for output in SPASS format">SPASS_LANG</a>) { <span class="comment">// SPASS doesn't support LET</span> <a name="l00182"></a>00182 <span class="keywordflow">if</span>(os.<a class="code" href="classCVC3_1_1ExprStream.html#a5fb7d3cacc87b22ea0ca79efd35a038f" title="Flag whether the dagMap is already built.">d_dagBuilt</a>) { <a name="l00183"></a>00183 <a class="code" href="classCVC3_1_1ExprMap_1_1iterator.html">ExprMap<string>::iterator</a> i(os.<a class="code" href="classCVC3_1_1ExprStream.html#a5613bd2f13161fe6846776dbb328bd34" title="Mapping subexpressions to names for DAG printing.">d_dagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#ae50ab1874dd63b575553e7db769abe28">find</a>(e)); <a name="l00184"></a>00184 <span class="keywordflow">if</span>(i != os.<a class="code" href="classCVC3_1_1ExprStream.html#a5613bd2f13161fe6846776dbb328bd34" title="Mapping subexpressions to names for DAG printing.">d_dagMap</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>()) { <a name="l00185"></a>00185 ostringstream ss; <a name="l00186"></a>00186 ss << (*i).second; <a name="l00187"></a>00187 <span class="keywordflow">return</span> os << ss.str(); <a name="l00188"></a>00188 } <a name="l00189"></a>00189 } <span class="keywordflow">else</span> { <a name="l00190"></a>00190 <span class="comment">// We are at the top level; build dagMap and print LET header</span> <a name="l00191"></a>00191 <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap<bool></a> cache; <a name="l00192"></a>00192 os.<a class="code" href="classCVC3_1_1ExprStream.html#a26a9afb803961536e2b0f74be900300f" title="Traverse the Expr, collect shared subexpressions in d_dagMap.">collectShared</a>(e, cache); <a name="l00193"></a>00193 e2 = os.<a class="code" href="classCVC3_1_1ExprStream.html#a44b1833a153b0ecaa46616c557039dd8" title="Wrap e into the top-level LET ... IN header from the dagMap.">addLetHeader</a>(e); <a name="l00194"></a>00194 } <a name="l00195"></a>00195 } <a name="l00196"></a>00196 os.<a class="code" href="classCVC3_1_1ExprStream.html#a00ed22d62da899833285f2bbf20754fd" title="nodag() manipulator has been applied">d_nodag</a>=<span class="keyword">false</span>; <a name="l00197"></a>00197 <a name="l00198"></a>00198 <span class="comment">// Increase the depth before the (possibly) recursive call</span> <a name="l00199"></a>00199 os.<a class="code" href="classCVC3_1_1ExprStream.html#a83bf8b10c32e6a579ace151f35ce7e08" title="Current depth of Expr.">d_currDepth</a>++; <a name="l00200"></a>00200 <span class="comment">// Save the indentation stack position and register</span> <a name="l00201"></a>00201 <span class="keywordtype">int</span> indentLast = os.<a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a>; <a name="l00202"></a>00202 <span class="keywordtype">int</span> reg = os.<a class="code" href="classCVC3_1_1ExprStream.html#a6961d32e92cc350b1fd591888f037289" title="Indentation register for popSave() and pushRestore()">d_indentReg</a>; <a name="l00203"></a>00203 <span class="keywordtype">size_t</span> lastDagSize = os.<a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a>; <a name="l00204"></a>00204 <a name="l00205"></a>00205 os.<a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a> = os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size(); <a name="l00206"></a>00206 os.<a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a> = os.<a class="code" href="classCVC3_1_1ExprStream.html#a78aa8e292d7555fdfb7a94c00c0b3a6f" title="Stack of pointers to d_dagStack for pushing/popping shared subexprs.">d_dagPtr</a>.size(); <a name="l00207"></a>00207 <a name="l00208"></a>00208 <a class="code" href="classCVC3_1_1PrettyPrinter.html" title="Abstract API to a pretty-printer for Expr.">PrettyPrinter</a>* pp = os.<a class="code" href="classCVC3_1_1ExprStream.html#a7ab1b6602b49bf13867877bf5f7a5873" title="The ExprManager to use.">d_em</a>-><a class="code" href="group__EM__Priv.html#ga3762b5bfe4264bd35b4e887084835fa6" title="Return the pretty-printer if there is one; otherwise return NULL.">getPrinter</a>(); <a name="l00209"></a>00209 <span class="comment">// If no pretty-printer, or the language is AST, print the AST</span> <a name="l00210"></a>00210 <span class="keywordflow">if</span>(pp == NULL || os.<a class="code" href="classCVC3_1_1ExprStream.html#a0db5c8c81be1cdcdeba4c2873572b519" title="Output language.">d_lang</a> == <a class="code" href="namespaceCVC3.html#a3aaaf7bc1fc47a4860ef6e59ddb0db0ea0ee28952d729595b97a9e592975d1521">AST_LANG</a>) e2.<a class="code" href="group__ExprPkg.html#ga092308b0a88e12a5c7ff2fc0a2eca818" title="Print the top node and then recurse through the children */.">printAST</a>(os); <a name="l00211"></a>00211 <span class="comment">// Otherwise simply call the pretty-printer</span> <a name="l00212"></a>00212 <span class="keywordflow">else</span> pp-><a class="code" href="classCVC3_1_1PrettyPrinter.html#af07c9cf0d127e81d41c8819fb51c5430" title="The pretty-printer which subclasses must implement.">print</a>(os, e2); <a name="l00213"></a>00213 <span class="comment">// Restore the depth after the (possibly) recursive call</span> <a name="l00214"></a>00214 os.<a class="code" href="classCVC3_1_1ExprStream.html#a83bf8b10c32e6a579ace151f35ce7e08" title="Current depth of Expr.">d_currDepth</a>--; <a name="l00215"></a>00215 <a name="l00216"></a>00216 <span class="comment">// Restore the indentation stack and register</span> <a name="l00217"></a>00217 os.<a class="code" href="classCVC3_1_1ExprStream.html#a946110c3457868fe38ce8c1d4cdde916" title="Reset indentation to what it was at this level.">resetIndent</a>(); <a name="l00218"></a>00218 os.<a class="code" href="classCVC3_1_1ExprStream.html#a004714bd282bfa11595d21bce94e72ec" title="Reset the DAG to what it was at this level.">resetDag</a>(); <a name="l00219"></a>00219 os.<a class="code" href="classCVC3_1_1ExprStream.html#aa77050ac6ae56a6d4a45736e89521e0f" title="The lowest position of the indent stack the user can pop.">d_indentLast</a> = indentLast; <a name="l00220"></a>00220 os.<a class="code" href="classCVC3_1_1ExprStream.html#a6961d32e92cc350b1fd591888f037289" title="Indentation register for popSave() and pushRestore()">d_indentReg</a> = reg; <a name="l00221"></a>00221 os.<a class="code" href="classCVC3_1_1ExprStream.html#ae19d943560a35d7b9f4042a152420262" title="The smallest size of d_dagPtr the user can `popDag'.">d_lastDagSize</a> = lastDagSize; <a name="l00222"></a>00222 <span class="keywordflow">return</span> os; <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <span class="comment"></span> <a name="l00225"></a>00225 <span class="comment"> //! Print Type</span> <a name="l00226"></a><a class="code" href="group__ExprStream__Op.html#ga9108360cf03bb43170d573ffa52a9646">00226</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a>& t) { <a name="l00227"></a>00227 <span class="keywordflow">return</span> os << t.<a class="code" href="classCVC3_1_1Type.html#a0bc1eebf8dbd9d2880e1f18d7804e5c2">getExpr</a>(); <a name="l00228"></a>00228 } <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="comment"></span> <a name="l00231"></a>00231 <span class="comment"> //! Print string</span> <a name="l00232"></a>00232 <span class="comment"></span><span class="comment"> /*! This is where all the indentation is happening.</span> <a name="l00233"></a>00233 <span class="comment"></span> <a name="l00234"></a>00234 <span class="comment"> The algorithm for determining whether to go to the next line is the</span> <a name="l00235"></a>00235 <span class="comment"> following:</span> <a name="l00236"></a>00236 <span class="comment"> </span> <a name="l00237"></a>00237 <span class="comment"> - If the new d_col does not exceed d_lineWidth/2 or current</span> <a name="l00238"></a>00238 <span class="comment"> indentation, don't bother.</span> <a name="l00239"></a>00239 <span class="comment"> </span> <a name="l00240"></a>00240 <span class="comment"> - If the difference between the new d_col and the current</span> <a name="l00241"></a>00241 <span class="comment"> indentation is less than d_lineWidth/4, don't bother either, so</span> <a name="l00242"></a>00242 <span class="comment"> that we don't get lots of very short lines clumped to the right</span> <a name="l00243"></a>00243 <span class="comment"> side.</span> <a name="l00244"></a>00244 <span class="comment"></span> <a name="l00245"></a>00245 <span class="comment"> - Similarly, if the difference between the old d_col and the current</span> <a name="l00246"></a>00246 <span class="comment"> indentation is less than d_lineWidth/6, keep the same line.</span> <a name="l00247"></a>00247 <span class="comment"> Otherwise, for long atomic strings, we may get useless line breaks.</span> <a name="l00248"></a>00248 <span class="comment"> </span> <a name="l00249"></a>00249 <span class="comment"> - Otherwise, go to the next line.</span> <a name="l00250"></a>00250 <span class="comment"> */</span> <a name="l00251"></a><a class="code" href="group__ExprStream__Op.html#ga56b415642ba1c4dc5290f94b52b37e40">00251</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keyword">const</span> <span class="keywordtype">string</span>& s) { <a name="l00252"></a>00252 <span class="comment">// Save the old position</span> <a name="l00253"></a>00253 <span class="keywordtype">int</span> oldCol(os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a>); <a name="l00254"></a>00254 <span class="comment">// The new position after printing s</span> <a name="l00255"></a>00255 os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> += s.size(); <a name="l00256"></a>00256 <span class="keywordflow">if</span>(os.<a class="code" href="classCVC3_1_1ExprStream.html#a376d7f29bf587b712bc9302ed27d8b77" title="Whether to print with indentations.">d_indent</a>) { <a name="l00257"></a>00257 <span class="comment">// Current indentation position</span> <a name="l00258"></a>00258 <span class="keywordtype">int</span> n(os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size()? os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.back() : 0); <a name="l00259"></a>00259 <span class="comment">// See if we need to go to the next line before printing.</span> <a name="l00260"></a>00260 <span class="keywordflow">if</span>(2*os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> > os.<a class="code" href="classCVC3_1_1ExprStream.html#aa954bdbaf953b6f059d2cd6252130095">d_lineWidth</a> && 4*(os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> - n) > os.<a class="code" href="classCVC3_1_1ExprStream.html#aa954bdbaf953b6f059d2cd6252130095">d_lineWidth</a> <a name="l00261"></a>00261 && 6*(oldCol - n) > os.<a class="code" href="classCVC3_1_1ExprStream.html#aa954bdbaf953b6f059d2cd6252130095">d_lineWidth</a>) { <a name="l00262"></a>00262 os << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00263"></a>00263 <span class="comment">// Recompute the new column</span> <a name="l00264"></a>00264 os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> += s.size(); <a name="l00265"></a>00265 } <a name="l00266"></a>00266 } <a name="l00267"></a>00267 *os.<a class="code" href="classCVC3_1_1ExprStream.html#acc3438cd65369ea0dad38ea59c93343a" title="The ostream to print into.">d_os</a> << s; <a name="l00268"></a>00268 os.<a class="code" href="classCVC3_1_1ExprStream.html#a0e9d4e03372235a23da6a965aa05f742" title="Whether it is a beginning of line (for eating up extra spaces)">d_beginningOfLine</a> = <span class="keyword">false</span>; <a name="l00269"></a>00269 <span class="keywordflow">return</span> os; <a name="l00270"></a>00270 } <a name="l00271"></a>00271 <span class="comment"></span> <a name="l00272"></a>00272 <span class="comment"> //! Print char* string</span> <a name="l00273"></a><a class="code" href="group__ExprStream__Op.html#gae8a3e2bbabccd414740c931cbaee870a">00273</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keyword">const</span> <span class="keywordtype">char</span>* s) { <a name="l00274"></a>00274 <span class="keywordflow">return</span> os << string(s); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <span class="comment"></span> <a name="l00277"></a>00277 <span class="comment"> //! Print Rational</span> <a name="l00278"></a><a class="code" href="group__ExprStream__Op.html#ga8c910f52b3cc7c72213650230d3a6787">00278</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Rational.html">Rational</a>& r) { <a name="l00279"></a>00279 ostringstream ss; <a name="l00280"></a>00280 ss << r; <a name="l00281"></a>00281 <span class="keywordflow">return</span> os << ss.str(); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <span class="comment"></span> <a name="l00284"></a>00284 <span class="comment"> //! Print int</span> <a name="l00285"></a><a class="code" href="group__ExprStream__Op.html#gab3f2a7f9dc3d1685ab3266d86f4ab678">00285</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="namespaceCVC3.html#a6b7e38d3c97da1e91e12a6c9555b8163">operator<<</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os, <span class="keywordtype">int</span> i) { <a name="l00286"></a>00286 ostringstream ss; <a name="l00287"></a>00287 ss << i; <a name="l00288"></a>00288 <span class="keywordflow">return</span> os << ss.str(); <a name="l00289"></a>00289 }<span class="comment"></span> <a name="l00290"></a>00290 <span class="comment"> /*! @} */</span> <span class="comment">// End of group ExprStream_Op</span> <a name="l00291"></a>00291 <span class="comment"></span> <a name="l00292"></a>00292 <span class="comment"> /*! \defgroup ExprStream_Manip Manipulators </span> <a name="l00293"></a>00293 <span class="comment"> * \ingroup PrettyPrinting</span> <a name="l00294"></a>00294 <span class="comment"> * @{</span> <a name="l00295"></a>00295 <span class="comment"> */</span> <a name="l00296"></a>00296 <span class="comment"></span> <a name="l00297"></a>00297 <span class="comment"> //! Set the indentation to the current position</span> <a name="l00298"></a><a class="code" href="group__ExprStream__Manip.html#ga2a0348c6d3f94f2f8febc6dd0a9c3218">00298</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga2a0348c6d3f94f2f8febc6dd0a9c3218" title="Set the indentation to the current position.">push</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { os.<a class="code" href="classCVC3_1_1ExprStream.html#a92fe55e5f00f52ac00db56afcaaba80c" title="Set the indentation to the current column.">pushIndent</a>(); <span class="keywordflow">return</span> os; } <a name="l00299"></a>00299 <span class="comment"></span> <a name="l00300"></a>00300 <span class="comment"> //! Restore the indentation</span> <a name="l00301"></a><a class="code" href="group__ExprStream__Manip.html#gaddb050a787be87116afc51791293d3be">00301</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#gaddb050a787be87116afc51791293d3be" title="Restore the indentation.">pop</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { os.<a class="code" href="classCVC3_1_1ExprStream.html#a32a666cc0a71503770b88e3a7362808c" title="Restore the indentation (user cannot pop more than pushed)">popIndent</a>(); <span class="keywordflow">return</span> os; }<span class="comment"></span> <a name="l00302"></a>00302 <span class="comment"> //! Remember the current indentation and pop to the previous position</span> <a name="l00303"></a>00303 <span class="comment"></span><span class="comment"> /*! There is only one register to save the previous position. If</span> <a name="l00304"></a>00304 <span class="comment"> you use popSave() more than once, only the latest position can be</span> <a name="l00305"></a>00305 <span class="comment"> restored with pushRestore(). */</span> <a name="l00306"></a><a class="code" href="group__ExprStream__Manip.html#gacf04af76c8233f27762ad6ebb73a58c0">00306</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#gacf04af76c8233f27762ad6ebb73a58c0" title="Remember the current indentation and pop to the previous position.">popSave</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { <a name="l00307"></a>00307 os.<a class="code" href="classCVC3_1_1ExprStream.html#a6961d32e92cc350b1fd591888f037289" title="Indentation register for popSave() and pushRestore()">d_indentReg</a> = os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size() ? os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.back() : 0; <a name="l00308"></a>00308 os.<a class="code" href="classCVC3_1_1ExprStream.html#a32a666cc0a71503770b88e3a7362808c" title="Restore the indentation (user cannot pop more than pushed)">popIndent</a>(); <a name="l00309"></a>00309 <span class="keywordflow">return</span> os; <a name="l00310"></a>00310 }<span class="comment"></span> <a name="l00311"></a>00311 <span class="comment"> //! Set the indentation to the position saved by popSave()</span> <a name="l00312"></a>00312 <span class="comment"></span><span class="comment"> /*! There is only one register to save the previous position. Using</span> <a name="l00313"></a>00313 <span class="comment"> pushRestore() several times will set intendation to the same</span> <a name="l00314"></a>00314 <span class="comment"> position. */</span> <a name="l00315"></a><a class="code" href="group__ExprStream__Manip.html#ga7a2134042b4ae9b096b0003d8f3c869a">00315</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga7a2134042b4ae9b096b0003d8f3c869a" title="Set the indentation to the position saved by popSave()">pushRestore</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { <a name="l00316"></a>00316 os.<a class="code" href="classCVC3_1_1ExprStream.html#a92fe55e5f00f52ac00db56afcaaba80c" title="Set the indentation to the current column.">pushIndent</a>(os.<a class="code" href="classCVC3_1_1ExprStream.html#a6961d32e92cc350b1fd591888f037289" title="Indentation register for popSave() and pushRestore()">d_indentReg</a>); <a name="l00317"></a>00317 <span class="keywordflow">return</span> os; <a name="l00318"></a>00318 }<span class="comment"></span> <a name="l00319"></a>00319 <span class="comment"> //! Reset the indentation to the default at this level</span> <a name="l00320"></a><a class="code" href="group__ExprStream__Manip.html#ga90deb7348703ae1a59a11d9af77aa8ad">00320</a> <span class="comment"></span> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga90deb7348703ae1a59a11d9af77aa8ad" title="Reset the indentation to the default at this level.">reset</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { os.<a class="code" href="classCVC3_1_1ExprStream.html#a946110c3457868fe38ce8c1d4cdde916" title="Reset indentation to what it was at this level.">resetIndent</a>(); <span class="keywordflow">return</span> os; }<span class="comment"></span> <a name="l00321"></a>00321 <span class="comment"> //! Insert a single white space separator</span> <a name="l00322"></a>00322 <span class="comment"></span><span class="comment"> /*! It is preferred to use 'space' rather than a string of spaces</span> <a name="l00323"></a>00323 <span class="comment"> (" ") because ExprStream needs to delete extra white space if it</span> <a name="l00324"></a>00324 <span class="comment"> decides to end the line. If you use strings for spaces, you'll</span> <a name="l00325"></a>00325 <span class="comment"> mess up the indentation. */</span> <a name="l00326"></a><a class="code" href="group__ExprStream__Manip.html#ga02670eb229648e9e2d888f21f91b6810">00326</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga02670eb229648e9e2d888f21f91b6810" title="Insert a single white space separator.">space</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { <a name="l00327"></a>00327 <span class="comment">// Prevent " " to carry to the next line</span> <a name="l00328"></a>00328 <span class="keywordflow">if</span>(!os.<a class="code" href="classCVC3_1_1ExprStream.html#a0e9d4e03372235a23da6a965aa05f742" title="Whether it is a beginning of line (for eating up extra spaces)">d_beginningOfLine</a>) os << <a class="code" href="group__ExprStream__Manip.html#ga2a0348c6d3f94f2f8febc6dd0a9c3218" title="Set the indentation to the current position.">push</a> << <span class="stringliteral">" "</span> << <a class="code" href="group__ExprStream__Manip.html#gaddb050a787be87116afc51791293d3be" title="Restore the indentation.">pop</a>; <a name="l00329"></a>00329 <span class="keywordflow">return</span> os; <a name="l00330"></a>00330 } <a name="l00331"></a>00331 <a name="l00332"></a><a class="code" href="group__ExprStream__Manip.html#gab9909b3108229b630956179ebd71f3ef">00332</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#gab9909b3108229b630956179ebd71f3ef">nodag</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { <a name="l00333"></a>00333 os.<a class="code" href="classCVC3_1_1ExprStream.html#a00ed22d62da899833285f2bbf20754fd" title="nodag() manipulator has been applied">d_nodag</a> = <span class="keyword">true</span>; <a name="l00334"></a>00334 <span class="keywordflow">return</span> os; <a name="l00335"></a>00335 } <a name="l00336"></a>00336 <a name="l00337"></a><a class="code" href="group__ExprStream__Manip.html#ga1475185296de10fdbe07f0b498e8ed36">00337</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga1475185296de10fdbe07f0b498e8ed36">pushdag</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { os.<a class="code" href="classCVC3_1_1ExprStream.html#a2c93d862ed9b3cb1480a1d12cb510841" title="Recompute shared subexpression for the next Expr.">pushDag</a>(); <span class="keywordflow">return</span> os; } <a name="l00338"></a>00338 <a name="l00339"></a><a class="code" href="group__ExprStream__Manip.html#ga07ae0c39b4082065891134536f2fa91c">00339</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga07ae0c39b4082065891134536f2fa91c">popdag</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">ExprStream</a>& os) { os.<a class="code" href="classCVC3_1_1ExprStream.html#a7d1aa8566189d9b03a12bc56d3514979" title="Delete shared subexpressions previously added with pushdag.">popDag</a>(); <span class="keywordflow">return</span> os; } <a name="l00340"></a>00340 <span class="comment"></span> <a name="l00341"></a>00341 <span class="comment"> /*! @} */</span> <span class="comment">// End of group ExprStream_Manip</span> <a name="l00342"></a>00342 <a name="l00343"></a>00343 } <span class="comment">// End of namespace CVC3</span> <a name="l00344"></a>00344 <a name="l00345"></a><a class="code" href="namespacestd.html">00345</a> <span class="keyword">namespace </span>std { <a name="l00346"></a>00346 <span class="comment"></span> <a name="l00347"></a>00347 <span class="comment"> //! Print the end-of-line</span> <a name="l00348"></a>00348 <span class="comment"></span><span class="comment"> /*! </span> <a name="l00349"></a>00349 <span class="comment"> * The new line will not necessarily start at column 0 because of</span> <a name="l00350"></a>00350 <span class="comment"> * indentation.</span> <a name="l00351"></a>00351 <span class="comment"> * \ingroup ExprStream_Manip </span> <a name="l00352"></a>00352 <span class="comment"> */</span> <a name="l00353"></a><a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8">00353</a> <a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">CVC3::ExprStream</a>& <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>(<a class="code" href="classCVC3_1_1ExprStream.html" title="Pretty-printing output stream for Expr. READ THE DOCS BEFORE USING!">CVC3::ExprStream</a>& os) { <a name="l00354"></a>00354 <span class="keywordflow">if</span>(os.<a class="code" href="classCVC3_1_1ExprStream.html#a376d7f29bf587b712bc9302ed27d8b77" title="Whether to print with indentations.">d_indent</a>) { <a name="l00355"></a>00355 <span class="comment">// Current indentation</span> <a name="l00356"></a>00356 <span class="keywordtype">int</span> n(os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.size()? os.<a class="code" href="classCVC3_1_1ExprStream.html#a3141312e4ccf7ea7d15adf6af193a6db" title="Indentation stack.">d_indentStack</a>.back() : 0); <a name="l00357"></a>00357 <span class="comment">// Create a string of n white spaces</span> <a name="l00358"></a>00358 <span class="keywordtype">string</span> spaces(n, <span class="charliteral">' '</span>); <a name="l00359"></a>00359 (*os.<a class="code" href="classCVC3_1_1ExprStream.html#acc3438cd65369ea0dad38ea59c93343a" title="The ostream to print into.">d_os</a>) << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a> << spaces; <a name="l00360"></a>00360 os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> = n; <a name="l00361"></a>00361 } <span class="keywordflow">else</span> { <a name="l00362"></a>00362 (*os.<a class="code" href="classCVC3_1_1ExprStream.html#acc3438cd65369ea0dad38ea59c93343a" title="The ostream to print into.">d_os</a>) << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00363"></a>00363 os.<a class="code" href="classCVC3_1_1ExprStream.html#a92f85002e3bc476e5879b9012ff4c2c9" title="Current column in a line.">d_col</a> = 0; <a name="l00364"></a>00364 } <a name="l00365"></a>00365 os.<a class="code" href="classCVC3_1_1ExprStream.html#a0e9d4e03372235a23da6a965aa05f742" title="Whether it is a beginning of line (for eating up extra spaces)">d_beginningOfLine</a> = <span class="keyword">true</span>; <a name="l00366"></a>00366 <span class="keywordflow">return</span> os; <a name="l00367"></a>00367 } <a name="l00368"></a>00368 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>