Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > aaf33964de706a538481c929c1da6a44 > files > 6569

faust-doc-0.9.10-5mdv2010.1.x86_64.rpm

<!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>FAUST compiler: simplify.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.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</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 class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>simplify.cpp</h1><a href="simplify_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>
<a name="l00002"></a>00002 <span class="comment"> ************************************************************************</span>
<a name="l00003"></a>00003 <span class="comment">    FAUST compiler</span>
<a name="l00004"></a>00004 <span class="comment">    Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale</span>
<a name="l00005"></a>00005 <span class="comment">    ---------------------------------------------------------------------</span>
<a name="l00006"></a>00006 <span class="comment">    This program is free software; you can redistribute it and/or modify</span>
<a name="l00007"></a>00007 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00008"></a>00008 <span class="comment">    the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00009"></a>00009 <span class="comment">    (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment">    This program is distributed in the hope that it will be useful,</span>
<a name="l00012"></a>00012 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00013"></a>00013 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00014"></a>00014 <span class="comment">    GNU General Public License for more details.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment">    You should have received a copy of the GNU General Public License</span>
<a name="l00017"></a>00017 <span class="comment">    along with this program; if not, write to the Free Software</span>
<a name="l00018"></a>00018 <span class="comment">    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00019"></a>00019 <span class="comment"> ************************************************************************</span>
<a name="l00020"></a>00020 <span class="comment"> ************************************************************************/</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="signals_8hh.html">signals.hh</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="sigtype_8hh.html">sigtype.hh</a>&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="sigtyperules_8hh.html">sigtyperules.hh</a>&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="sigorderrules_8hh.html">sigorderrules.hh</a>&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="sigprint_8hh.html">sigprint.hh</a>&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="simplify_8hh.html">simplify.hh</a>&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="num_8hh.html">num.hh</a>&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="xtended_8hh.html">xtended.hh</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="normalize_8hh.html">normalize.hh</a>&quot;</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="preprocessor">#undef TRACE</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="comment">// declarations</span>
<a name="l00041"></a><a class="code" href="simplify_8cpp.html#a1f636fd69986781f5d26ec775109daa4">00041</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a1f636fd69986781f5d26ec775109daa4">SIMPLIFIED</a> = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a>(<span class="stringliteral">&quot;sigSimplifiedProp&quot;</span>));
<a name="l00042"></a>00042 <span class="comment">//static Tree binequiv (Tree sig, int opnum, Tree a, Tree b);</span>
<a name="l00043"></a>00043 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a7b22c54137b97107c3b85e47673b31fb">simplification</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig);
<a name="l00044"></a>00044 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> key, <a class="code" href="list_8hh.html#af77d25f8b1016f673088d066636124f0">tfun</a> f, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t);
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="simplify_8cpp.html#a35da54b35dd0185d20bc701858e7ee78">00046</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a35da54b35dd0185d20bc701858e7ee78">traced_simplification</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048     assert(sig);
<a name="l00049"></a>00049 <span class="preprocessor">#ifdef TRACE</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span>    cerr &lt;&lt; ++<a class="code" href="tree_8cpp.html#a559d741ee88818bb48d7ea8caf7419c1">TABBER</a> &lt;&lt; <span class="stringliteral">&quot;Start simplification of : &quot;</span> &lt;&lt; *sig &lt;&lt; endl;
<a name="l00051"></a>00051     <span class="comment">/*</span>
<a name="l00052"></a>00052 <span class="comment">    fprintf(stderr, &quot;\nStart simplification of : &quot;);</span>
<a name="l00053"></a>00053 <span class="comment">    printSignal(sig, stderr);</span>
<a name="l00054"></a>00054 <span class="comment">    fprintf(stderr, &quot;\n&quot;);</span>
<a name="l00055"></a>00055 <span class="comment">    */</span>
<a name="l00056"></a>00056 <span class="preprocessor">#endif</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>    <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> r = <a class="code" href="simplify_8cpp.html#a7b22c54137b97107c3b85e47673b31fb">simplification</a>(sig);
<a name="l00058"></a>00058     assert(r!=0);
<a name="l00059"></a>00059 <span class="preprocessor">#ifdef TRACE</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span>    cerr &lt;&lt; --<a class="code" href="tree_8cpp.html#a559d741ee88818bb48d7ea8caf7419c1">TABBER</a> &lt;&lt; <span class="stringliteral">&quot;Simplification of : &quot;</span> &lt;&lt; *sig &lt;&lt; <span class="stringliteral">&quot; Returns : &quot;</span> &lt;&lt; *r &lt;&lt; endl;
<a name="l00061"></a>00061     <span class="comment">/*</span>
<a name="l00062"></a>00062 <span class="comment">    fprintf(stderr, &quot;Simplification of : &quot;);</span>
<a name="l00063"></a>00063 <span class="comment">    printSignal(sig, stderr);</span>
<a name="l00064"></a>00064 <span class="comment">    fprintf(stderr, &quot; -&gt; &quot;);</span>
<a name="l00065"></a>00065 <span class="comment">    printSignal(r, stderr);</span>
<a name="l00066"></a>00066 <span class="comment">    fprintf(stderr, &quot;\n&quot;);</span>
<a name="l00067"></a>00067 <span class="comment">    */</span>
<a name="l00068"></a>00068 <span class="preprocessor">#endif</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>    <span class="keywordflow">return</span> r;
<a name="l00070"></a>00070 }
<a name="l00071"></a>00071 
<a name="l00072"></a><a class="code" href="simplify_8hh.html#aa58ab1a209023cba186f077cfdcc5339">00072</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074     <span class="keywordflow">return</span> <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(SIMPLIFIED, <a class="code" href="simplify_8cpp.html#a35da54b35dd0185d20bc701858e7ee78">traced_simplification</a>, sig);
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 <span class="comment">// Implementation</span>
<a name="l00079"></a>00079 
<a name="l00080"></a><a class="code" href="simplify_8cpp.html#a7b22c54137b97107c3b85e47673b31fb">00080</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a7b22c54137b97107c3b85e47673b31fb">simplification</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig)
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082     assert(sig);
<a name="l00083"></a>00083     <span class="keywordtype">int</span>     opnum;
<a name="l00084"></a>00084     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    t1, t2;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <a class="code" href="classxtended.html">xtended</a>* xt = (<a class="code" href="classxtended.html">xtended</a>*) <a class="code" href="symbol_8hh.html#a603fcb6c07eacf2688c2a8470637d0ff" title="Returns user data.">getUserData</a>(sig);
<a name="l00087"></a>00087     <span class="comment">// primitive elements</span>
<a name="l00088"></a>00088     <span class="keywordflow">if</span> (xt)
<a name="l00089"></a>00089     {
<a name="l00090"></a>00090         <span class="comment">//return 3;</span>
<a name="l00091"></a>00091         vector&lt;Tree&gt; args;
<a name="l00092"></a>00092         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;sig-&gt;<a class="code" href="classCTree.html#a68f2be5e845407bc956a2893fe6f0d03" title="return the number of branches (subtrees) of a tree">arity</a>(); i++) { args.push_back( sig-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(i) ); }
<a name="l00093"></a>00093         <span class="keywordflow">return</span> xt-&gt;<a class="code" href="classxtended.html#a0a088a599b3cdd9bcd1854446f145af8">computeSigOutput</a>(args);
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a8705584c3c319be54be73dc391d25634">isSigBinOp</a>(sig, &amp;opnum, t1, t2)) {
<a name="l00096"></a>00096 
<a name="l00097"></a>00097         <a class="code" href="structBinOp.html">BinOp</a>* op = <a class="code" href="binop_8cpp.html#a2d55d4b4acaed7188a432ffdb646395a">gBinOpTable</a>[opnum];
<a name="l00098"></a>00098 
<a name="l00099"></a>00099         <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a> n1 = t1-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>();
<a name="l00100"></a>00100         <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a> n2 = t2-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>();
<a name="l00101"></a>00101 
<a name="l00102"></a>00102         <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#acd2773c99643a2dcc1c5409991c211e9">isNum</a>(n1) &amp;&amp; <a class="code" href="signals_8hh.html#acd2773c99643a2dcc1c5409991c211e9">isNum</a>(n2))         <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(op-&gt;<a class="code" href="structBinOp.html#aa2a29825af89ac6dd8e08cac1261e5b8">compute</a>(n1,n2));
<a name="l00103"></a>00103 
<a name="l00104"></a>00104         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op-&gt;<a class="code" href="structBinOp.html#ac568fcce2d8708501528703bae2d91b2">isLeftNeutral</a>(n1))     <span class="keywordflow">return</span> t2;
<a name="l00105"></a>00105 
<a name="l00106"></a>00106         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op-&gt;<a class="code" href="structBinOp.html#a16d591d0d171f8b5cf8aef9f1324e95d">isRightNeutral</a>(n2))    <span class="keywordflow">return</span> t1;
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         <span class="keywordflow">else</span>                                <span class="keywordflow">return</span> <a class="code" href="normalize_8cpp.html#a84f5cc6ddcbd1db7e6f442b3bdf71363" title="Compute the Add-Normal form of a term t.">normalizeAddTerm</a>(sig);
<a name="l00109"></a>00109 
<a name="l00110"></a>00110     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a0899d7e2a69a467b0dcf62242397367f">isSigDelay1</a>(sig, t1)) {
<a name="l00111"></a>00111         
<a name="l00112"></a>00112         <span class="keywordflow">return</span> <a class="code" href="normalize_8cpp.html#abe85547196d79f5d315c81af052f8b2e" title="Compute the normal form of a 1-sample delay term s&amp;#39;.">normalizeDelay1Term</a> (t1);
<a name="l00113"></a>00113 
<a name="l00114"></a>00114     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#af55cdefee258834b3b8f6c070d4970c9">isSigFixDelay</a>(sig, t1, t2)) {
<a name="l00115"></a>00115 
<a name="l00116"></a>00116         <span class="keywordflow">return</span> <a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a> (t1, t2);
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a3ef48f0da2ef5b8e3ee7371a1e4059ae">isSigIntCast</a>(sig, t1)) {
<a name="l00119"></a>00119 
<a name="l00120"></a>00120         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    tx;
<a name="l00121"></a>00121         <span class="keywordtype">int</span>     i;
<a name="l00122"></a>00122         <span class="keywordtype">double</span>  x;
<a name="l00123"></a>00123         <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a>    n1 = t1-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>();
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#a8c9b968ac68f6cac1c361002da8afe99">isInt</a>(n1, &amp;i))          <span class="keywordflow">return</span> t1; 
<a name="l00126"></a>00126         <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#aab6c20fb5dce797e97ac8ec8591258af">isDouble</a>(n1, &amp;x))       <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<span class="keywordtype">int</span>(x));
<a name="l00127"></a>00127         <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a3ef48f0da2ef5b8e3ee7371a1e4059ae">isSigIntCast</a>(t1, tx))   <span class="keywordflow">return</span> t1;
<a name="l00128"></a>00128         
<a name="l00129"></a>00129         <span class="keywordflow">return</span> sig;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a52448156d86125bbc8de23d641217de2">isSigFloatCast</a>(sig, t1)) {
<a name="l00132"></a>00132 
<a name="l00133"></a>00133         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    tx;
<a name="l00134"></a>00134         <span class="keywordtype">int</span>     i;
<a name="l00135"></a>00135         <span class="keywordtype">double</span>  x;
<a name="l00136"></a>00136         <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a>    n1 = t1-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>();
<a name="l00137"></a>00137 
<a name="l00138"></a>00138         <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#a8c9b968ac68f6cac1c361002da8afe99">isInt</a>(n1, &amp;i))              <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<span class="keywordtype">double</span>(i));
<a name="l00139"></a>00139         <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#aab6c20fb5dce797e97ac8ec8591258af">isDouble</a>(n1, &amp;x))           <span class="keywordflow">return</span> t1;
<a name="l00140"></a>00140         <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a52448156d86125bbc8de23d641217de2">isSigFloatCast</a>(t1, tx))     <span class="keywordflow">return</span> t1;
<a name="l00141"></a>00141         
<a name="l00142"></a>00142         <span class="keywordflow">return</span> sig;
<a name="l00143"></a>00143 
<a name="l00144"></a>00144     } <span class="keywordflow">else</span> {
<a name="l00145"></a>00145 
<a name="l00146"></a>00146         <span class="keywordflow">return</span> sig;
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149 
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 
<a name="l00154"></a><a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">00154</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> key, <a class="code" href="list_8hh.html#af77d25f8b1016f673088d066636124f0">tfun</a> f, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t)
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156     <span class="comment">//printf(&quot;start sigMap\n&quot;);</span>
<a name="l00157"></a>00157     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> p,id,body;
<a name="l00158"></a>00158 
<a name="l00159"></a>00159     <span class="keywordflow">if</span> (<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(t, key, p)) {
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         <span class="keywordflow">return</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(p)) ? t : p;  <span class="comment">// truc pour eviter les boucles</span>
<a name="l00162"></a>00162 
<a name="l00163"></a>00163     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="recursive-tree_8cpp.html#a4cb44c6e41e21da830e748dc35f16ba5" title="is t a de Bruijn recursive tree">isRec</a>(t, <span class="keywordtype">id</span>, body)) {
<a name="l00164"></a>00164 
<a name="l00165"></a>00165         <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(t, key, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);   <span class="comment">// avoid infinite loop</span>
<a name="l00166"></a>00166         <span class="keywordflow">return</span> <a class="code" href="recursive-tree_8cpp.html#aa598f21268aa7198407d2eb6929d09ab" title="create a de Bruijn recursive tree">rec</a>(<span class="keywordtype">id</span>, <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key, f, body));
<a name="l00167"></a>00167 
<a name="l00168"></a>00168     } <span class="keywordflow">else</span> {
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> r1=<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l00171"></a>00171         <span class="keywordflow">switch</span> (t-&gt;<a class="code" href="classCTree.html#a68f2be5e845407bc956a2893fe6f0d03" title="return the number of branches (subtrees) of a tree">arity</a>()) {
<a name="l00172"></a>00172 
<a name="l00173"></a>00173             <span class="keywordflow">case</span> 0 :
<a name="l00174"></a>00174                 r1 = t;
<a name="l00175"></a>00175                 <span class="keywordflow">break</span>;
<a name="l00176"></a>00176             <span class="keywordflow">case</span> 1 :
<a name="l00177"></a>00177                 r1 = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(t-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>(), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0)));
<a name="l00178"></a>00178                 <span class="keywordflow">break</span>;
<a name="l00179"></a>00179             <span class="keywordflow">case</span> 2 :
<a name="l00180"></a>00180                 r1 = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(t-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>(), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0)), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(1)));
<a name="l00181"></a>00181                 <span class="keywordflow">break</span>;
<a name="l00182"></a>00182             <span class="keywordflow">case</span> 3 :
<a name="l00183"></a>00183                 r1 = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(t-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>(), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0)), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(1)),
<a name="l00184"></a>00184                                            <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(2)));
<a name="l00185"></a>00185                 <span class="keywordflow">break</span>;
<a name="l00186"></a>00186             <span class="keywordflow">case</span> 4 :
<a name="l00187"></a>00187                 r1 = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(t-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>(), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0)), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(1)),
<a name="l00188"></a>00188                                            <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(2)), <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(key,f,t-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(3)));
<a name="l00189"></a>00189                 <span class="keywordflow">break</span>;
<a name="l00190"></a>00190         }
<a name="l00191"></a>00191         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> r2 = f(r1);
<a name="l00192"></a>00192         <span class="keywordflow">if</span> (r2 == t) {
<a name="l00193"></a>00193             <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(t, key, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);
<a name="l00194"></a>00194         } <span class="keywordflow">else</span> {
<a name="l00195"></a>00195             <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(t, key, r2);
<a name="l00196"></a>00196         }
<a name="l00197"></a>00197         <span class="keywordflow">return</span> r2;
<a name="l00198"></a>00198     }
<a name="l00199"></a>00199 }
<a name="l00200"></a>00200 
<a name="l00206"></a><a class="code" href="simplify_8cpp.html#a8c1271398d8698aad1778fd8482fdd99">00206</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a8c1271398d8698aad1778fd8482fdd99" title="Converts regular tables into doc tables in order to facilitate the mathematical documentation...">DOCTABLES</a> = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a>(<span class="stringliteral">&quot;DocTablesProp&quot;</span>));
<a name="l00207"></a>00207 
<a name="l00208"></a>00208 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#af76e31bf9418c0058e1e53fe1f28fd37">docTableConverter</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig);
<a name="l00209"></a>00209 
<a name="l00210"></a><a class="code" href="simplify_8hh.html#a6a3298b9c61dc3351c7460dab1c9bbde">00210</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#a6a3298b9c61dc3351c7460dab1c9bbde">docTableConvertion</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212     <span class="keywordflow">return</span> <a class="code" href="simplify_8cpp.html#ace56a3d5066db13e82962b20d9db195e">sigMap</a>(DOCTABLES, <a class="code" href="simplify_8cpp.html#af76e31bf9418c0058e1e53fe1f28fd37">docTableConverter</a>, sig);
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214 
<a name="l00215"></a>00215 
<a name="l00216"></a>00216 <span class="comment">// Implementation</span>
<a name="l00217"></a>00217 
<a name="l00218"></a><a class="code" href="simplify_8cpp.html#af76e31bf9418c0058e1e53fe1f28fd37">00218</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="simplify_8cpp.html#af76e31bf9418c0058e1e53fe1f28fd37">docTableConverter</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig)
<a name="l00219"></a>00219 {
<a name="l00220"></a>00220     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> tbl, tbl2, id, id2, size, igen, isig, ridx, widx, wsig;
<a name="l00221"></a>00221 
<a name="l00222"></a>00222     <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a9d9cbd375c200fa4e666de6ffb72dbca">isSigRDTbl</a>(sig, tbl, ridx)) {
<a name="l00223"></a>00223         <span class="comment">// we are in a table to convert</span>
<a name="l00224"></a>00224         <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#aa9b2ad7a65566fbc382d60e315b42740">isSigTable</a>(tbl, <span class="keywordtype">id</span>, size, igen)) {
<a name="l00225"></a>00225             <span class="comment">// it&#39;s a read only table</span>
<a name="l00226"></a>00226             assert(<a class="code" href="signals_8cpp.html#a771720237ca174a55a6823cc6623d602">isSigGen</a>(igen, isig));
<a name="l00227"></a>00227             <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#abd470373166f165e8f30f3fd97e05221">sigDocAccessTbl</a>(<a class="code" href="signals_8cpp.html#a36c185c79cf8b98f470efba0af2efc69">sigDocConstantTbl</a>(size,isig),ridx);
<a name="l00228"></a>00228         } <span class="keywordflow">else</span> {
<a name="l00229"></a>00229             <span class="comment">// it&#39;s a read write table</span>
<a name="l00230"></a>00230             assert(<a class="code" href="signals_8cpp.html#ab5b22110acbd38b7d4634dc94bcc8d22">isSigWRTbl</a>(tbl,<span class="keywordtype">id</span>,tbl2,widx,wsig));
<a name="l00231"></a>00231             assert(<a class="code" href="signals_8cpp.html#aa9b2ad7a65566fbc382d60e315b42740">isSigTable</a>(tbl2, id2, size, igen));
<a name="l00232"></a>00232             assert(<a class="code" href="signals_8cpp.html#a771720237ca174a55a6823cc6623d602">isSigGen</a>(igen, isig));
<a name="l00233"></a>00233 
<a name="l00234"></a>00234             <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#abd470373166f165e8f30f3fd97e05221">sigDocAccessTbl</a>(<a class="code" href="signals_8cpp.html#a800922251924a88b4cda1a07422af14c">sigDocWriteTbl</a>(size,isig,widx,wsig),ridx);
<a name="l00235"></a>00235         }
<a name="l00236"></a>00236 
<a name="l00237"></a>00237     } <span class="keywordflow">else</span> {
<a name="l00238"></a>00238         <span class="comment">// nothing to convert</span>
<a name="l00239"></a>00239         <span class="keywordflow">return</span> sig;
<a name="l00240"></a>00240     }
<a name="l00241"></a>00241 }
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:59 2010 for FAUST compiler by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>