<!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: recursivness.cpp File Reference</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 Page</span></a></li> <li><a href="pages.html"><span>Related 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> </div> <div class="contents"> <h1>recursivness.cpp File Reference</h1> <p>Annotate a signal expression with recursivness information. <a href="#_details">More...</a></p> <code>#include <assert.h></code><br/> <code>#include <stdio.h></code><br/> <code>#include <stdlib.h></code><br/> <code>#include <limits.h></code><br/> <code>#include "<a class="el" href="recursivness_8hh_source.html">recursivness.hh</a>"</code><br/> <div class="dynheader"> Include dependency graph for recursivness.cpp:</div> <div class="dynsection"> </div> <p><a href="recursivness_8cpp_source.html">Go to the source code of this file.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="recursivness_8cpp.html#ae84af43472c202883669180ea5452a2e">annotate</a> (<a class="el" href="classCTree.html">Tree</a> env, <a class="el" href="classCTree.html">Tree</a> sig)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Annotate a signal with recursivness. <a href="#ae84af43472c202883669180ea5452a2e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static int </td><td class="memItemRight" valign="bottom"><a class="el" href="recursivness_8cpp.html#aa9065b39904397aad91ca561ca539b79">position</a> (<a class="el" href="classCTree.html">Tree</a> env, <a class="el" href="classCTree.html">Tree</a> t, int p)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">return the position of a signal in the current recursive environment <a href="#aa9065b39904397aad91ca561ca539b79"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="recursivness_8cpp.html#ad6d53633cf1982b7d7b094188c7bfe17">recursivnessAnnotation</a> (<a class="el" href="classCTree.html">Tree</a> sig)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Annotate a signal with recursivness. <a href="#ad6d53633cf1982b7d7b094188c7bfe17"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="recursivness_8cpp.html#a5e771832d204d89a67f42e4a0b9b15a5">getRecursivness</a> (<a class="el" href="classCTree.html">Tree</a> sig)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Return the recursivness of a previously annotated signal. <a href="#a5e771832d204d89a67f42e4a0b9b15a5"></a><br/></td></tr> <tr><td colspan="2"><h2>Variables</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCTree.html">Tree</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a> = tree(symbol("RecursivnessProp"))</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Annotate a signal expression with recursivness information. </p> <p>Recursiveness indicates the amount of recursive dependencies of a signal. A closed signal has a recursivness of 0 because is has no recursive dependencies. This means that the succesive samples of this signal can be computed in parallel. In a signal of type .(...F(x)...), F(x) has a recursivness of 1. In a signal of type .(... .(...F(x)...G(y)...)...) F(x) has a recursivness of 2 while G(y) has a recursivness of 1. </p> <p>Definition in file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> <hr/><h2>Function Documentation</h2> <a class="anchor" id="ae84af43472c202883669180ea5452a2e"></a><!-- doxytag: member="recursivness.cpp::annotate" ref="ae84af43472c202883669180ea5452a2e" args="(Tree env, Tree sig)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int annotate </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>env</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>sig</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Annotate a signal with recursivness. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>env</em> </td><td>the current environment </td></tr> <tr><td valign="top"></td><td valign="top"><em>sig</em> </td><td>signal to annotate </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>recursivness of the signal </dd></dl> <p>Definition at line <a class="el" href="recursivness_8cpp_source.html#l00081">81</a> of file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> <p>References <a class="el" href="list_8hh_source.html#l00124">cons()</a>, <a class="el" href="list_8cpp_source.html#l00423">getProperty()</a>, <a class="el" href="subsignals_8cpp_source.html#l00010">getSubSignals()</a>, <a class="el" href="recursive-tree_8cpp_source.html#l00059">isRec()</a>, <a class="el" href="recursivness_8cpp_source.html#l00117">position()</a>, <a class="el" href="list_8cpp_source.html#l00418">setProperty()</a>, <a class="el" href="tree_8hh_source.html#l00173">tree()</a>, and <a class="el" href="tree_8cpp_source.html#l00244">tree2int()</a>.</p> <p>Referenced by <a class="el" href="recursivness_8cpp_source.html#l00051">recursivnessAnnotation()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00082"></a>00082 { <a name="l00083"></a>00083 <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> tr, var, body; <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keywordflow">if</span> (<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(sig, <a class="code" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a>, tr)) { <a name="l00086"></a>00086 <span class="keywordflow">return</span> <a class="code" href="tree_8cpp.html#a523bce65e2a281fe678f2362496061cf" title="if t has a node of type int, return it otherwise error">tree2int</a>(tr); <span class="comment">// already annotated</span> <a name="l00087"></a>00087 } <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>(sig, var, body)) { <a name="l00088"></a>00088 <span class="keywordtype">int</span> p = <a class="code" href="recursivness_8cpp.html#aa9065b39904397aad91ca561ca539b79" title="return the position of a signal in the current recursive environment">position</a>(env, sig); <a name="l00089"></a>00089 <span class="keywordflow">if</span> (p > 0) { <a name="l00090"></a>00090 <span class="keywordflow">return</span> p; <span class="comment">// we are inside \x.(...)</span> <a name="l00091"></a>00091 } <span class="keywordflow">else</span> { <a name="l00092"></a>00092 <span class="keywordtype">int</span> r = <a class="code" href="recursivness_8cpp.html#ae84af43472c202883669180ea5452a2e" title="Annotate a signal with recursivness.">annotate</a>(<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(sig, env), body) - 1; <a name="l00093"></a>00093 <span class="keywordflow">if</span> (r<0) r=0; <a name="l00094"></a>00094 <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(sig, <a class="code" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(r)); <a name="l00095"></a>00095 <span class="keywordflow">return</span> r; <a name="l00096"></a>00096 } <a name="l00097"></a>00097 } <span class="keywordflow">else</span> { <a name="l00098"></a>00098 <span class="keywordtype">int</span> rmax = 0; <a name="l00099"></a>00099 vector<Tree> v; <a class="code" href="signals_8hh.html#ae5dd2bb17d8df90f5561bb8084b3f10f" title="Extract the sub signals of a signal expression, that is not necesseraly all the subtrees...">getSubSignals</a>(sig, v); <a name="l00100"></a>00100 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<v.size(); i++) { <a name="l00101"></a>00101 <span class="keywordtype">int</span> r = <a class="code" href="recursivness_8cpp.html#ae84af43472c202883669180ea5452a2e" title="Annotate a signal with recursivness.">annotate</a>(env, v[i]); <a name="l00102"></a>00102 <span class="keywordflow">if</span> (r>rmax) rmax=r; <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(sig, <a class="code" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(rmax)); <a name="l00105"></a>00105 <span class="keywordflow">return</span> rmax; <a name="l00106"></a>00106 } <a name="l00107"></a>00107 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <a class="anchor" id="a5e771832d204d89a67f42e4a0b9b15a5"></a><!-- doxytag: member="recursivness.cpp::getRecursivness" ref="a5e771832d204d89a67f42e4a0b9b15a5" args="(Tree sig)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int getRecursivness </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>sig</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the recursivness of a previously annotated signal. </p> <p>An error is generated if the signal has no recursivness property </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>sig</em> </td><td>signal </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>recursivness of the signal </dd></dl> <p>Definition at line <a class="el" href="recursivness_8cpp_source.html#l00064">64</a> of file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> <p>References <a class="el" href="list_8cpp_source.html#l00423">getProperty()</a>, and <a class="el" href="tree_8cpp_source.html#l00244">tree2int()</a>.</p> <p>Referenced by <a class="el" href="occurences_8cpp_source.html#l00095">OccMarkup::incOcc()</a>, and <a class="el" href="sigtyperules_8cpp_source.html#l00577">infereRecType()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00065"></a>00065 { <a name="l00066"></a>00066 <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> tr; <a name="l00067"></a>00067 <span class="keywordflow">if</span> ( ! <a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(sig, <a class="code" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a>, tr)) { <a name="l00068"></a>00068 cerr << <span class="stringliteral">"Error in getRecursivness of "</span> << *sig << endl; <a name="l00069"></a>00069 exit(1); <a name="l00070"></a>00070 } <a name="l00071"></a>00071 <span class="keywordflow">return</span> <a class="code" href="tree_8cpp.html#a523bce65e2a281fe678f2362496061cf" title="if t has a node of type int, return it otherwise error">tree2int</a>(tr); <a name="l00072"></a>00072 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <a class="anchor" id="aa9065b39904397aad91ca561ca539b79"></a><!-- doxytag: member="recursivness.cpp::position" ref="aa9065b39904397aad91ca561ca539b79" args="(Tree env, Tree t, int p)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static int position </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>env</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>t</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>p</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>return the position of a signal in the current recursive environment </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>env</em> </td><td>the current recursive environment of the signal </td></tr> <tr><td valign="top"></td><td valign="top"><em>t</em> </td><td>signal we want to know the position </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the position in the recursive environment </dd></dl> <p>Definition at line <a class="el" href="recursivness_8cpp_source.html#l00117">117</a> of file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> <p>References <a class="el" href="list_8hh_source.html#l00133">hd()</a>, <a class="el" href="list_8hh_source.html#l00137">isNil()</a>, and <a class="el" href="list_8hh_source.html#l00134">tl()</a>.</p> <p>Referenced by <a class="el" href="recursivness_8cpp_source.html#l00081">annotate()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00118"></a>00118 { <a name="l00119"></a>00119 <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(env)) <span class="keywordflow">return</span> 0; <span class="comment">// was not in the environment</span> <a name="l00120"></a>00120 <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(env) == t) <span class="keywordflow">return</span> p; <a name="l00121"></a>00121 <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="recursivness_8cpp.html#aa9065b39904397aad91ca561ca539b79" title="return the position of a signal in the current recursive environment">position</a> (<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(env), t, p+1); <a name="l00122"></a>00122 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <a class="anchor" id="ad6d53633cf1982b7d7b094188c7bfe17"></a><!-- doxytag: member="recursivness.cpp::recursivnessAnnotation" ref="ad6d53633cf1982b7d7b094188c7bfe17" args="(Tree sig)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void recursivnessAnnotation </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>sig</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Annotate a signal with recursivness. </p> <p>Should be used before calling getRecursivness </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>sig</em> </td><td>signal to annotate </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="recursivness_8cpp_source.html#l00051">51</a> of file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> <p>References <a class="el" href="recursivness_8cpp_source.html#l00081">annotate()</a>, and <a class="el" href="list_8cpp_source.html#l00116">nil</a>.</p> <p>Referenced by <a class="el" href="doc__compile_8cpp_source.html#l00091">DocCompiler::annotate()</a>, <a class="el" href="compile__scal_8cpp_source.html#l00096">ScalarCompiler::prepare()</a>, and <a class="el" href="compile__scal_8cpp_source.html#l00113">ScalarCompiler::prepare2()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00052"></a>00052 { <a name="l00053"></a>00053 <a class="code" href="recursivness_8cpp.html#ae84af43472c202883669180ea5452a2e" title="Annotate a signal with recursivness.">annotate</a>(<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, sig); <a name="l00054"></a>00054 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <hr/><h2>Variable Documentation</h2> <a class="anchor" id="af2160822a1b0646b573fd5672fdd287a"></a><!-- doxytag: member="recursivness.cpp::RECURSIVNESS" ref="af2160822a1b0646b573fd5672fdd287a" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classCTree.html">Tree</a> <a class="el" href="recursivness_8cpp.html#af2160822a1b0646b573fd5672fdd287a">RECURSIVNESS</a> = tree(symbol("RecursivnessProp"))</td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="recursivness_8cpp_source.html#l00042">42</a> of file <a class="el" href="recursivness_8cpp_source.html">recursivness.cpp</a>.</p> </div> </div> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Apr 29 00:00:11 2010 for FAUST compiler by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>