<!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: loopDetector Class 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 class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> </div> <div class="contents"> <h1>loopDetector Class Reference</h1><!-- doxytag: class="loopDetector" --> <p><code>#include <<a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>></code></p> <p><a href="classloopDetector-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#a3f320a4d2c3bf8b9021e8c285e610dac">loopDetector</a> (int buffersize, int checkperiod)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#abfc1f154b059a4994891882b3d481796">detect</a> (<a class="el" href="classCTree.html">Tree</a> t)</td></tr> <tr><td colspan="2"><h2>Private Member Functions</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="classloopDetector.html#a77db05821952f2c8d4cae852f0812343">get</a> (int n)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#ae0f1308bade228c742eb859b81868058">listPossibleCycles</a> (vector< int > &v)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#af8865a4040a30fafcbe7faf039667c14">isCycle</a> (int period)</td></tr> <tr><td colspan="2"><h2>Private Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">const int </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">const int </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#a9fe35ad994097bfecf6db4d221b1b055">fCheckperiod</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">vector< <a class="el" href="classCTree.html">Tree</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#a07fe0c957ced096900527dc19c1be67c">fBuffer</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00041">41</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a3f320a4d2c3bf8b9021e8c285e610dac"></a><!-- doxytag: member="loopDetector::loopDetector" ref="a3f320a4d2c3bf8b9021e8c285e610dac" args="(int buffersize, int checkperiod)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">loopDetector::loopDetector </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>buffersize</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>checkperiod</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00049">49</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00049"></a>00049 : <a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>(buffersize), <a class="code" href="classloopDetector.html#a9fe35ad994097bfecf6db4d221b1b055">fCheckperiod</a>(checkperiod), <a class="code" href="classloopDetector.html#a07fe0c957ced096900527dc19c1be67c">fBuffer</a>(buffersize), <a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a>(<a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>) {} </pre></div></p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="abfc1f154b059a4994891882b3d481796"></a><!-- doxytag: member="loopDetector::detect" ref="abfc1f154b059a4994891882b3d481796" args="(Tree t)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool loopDetector::detect </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>t</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8cpp_source.html#l00016">16</a> of file <a class="el" href="loopDetector_8cpp_source.html">loopDetector.cpp</a>.</p> <p>References <a class="el" href="loopDetector_8hh_source.html#l00045">fBuffer</a>, <a class="el" href="loopDetector_8hh_source.html#l00043">fBuffersize</a>, <a class="el" href="loopDetector_8hh_source.html#l00044">fCheckperiod</a>, <a class="el" href="loopDetector_8hh_source.html#l00046">fPhase</a>, <a class="el" href="loopDetector_8cpp_source.html#l00044">isCycle()</a>, and <a class="el" href="loopDetector_8cpp_source.html#l00004">listPossibleCycles()</a>.</p> <p>Referenced by <a class="el" href="eval_8cpp_source.html#l00279">eval()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00017"></a>00017 { <a name="l00018"></a>00018 <span class="comment">//cerr << "detect " << t << endl;</span> <a name="l00019"></a>00019 <a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a>++; <a name="l00020"></a>00020 <a class="code" href="classloopDetector.html#a07fe0c957ced096900527dc19c1be67c">fBuffer</a>[<a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a>%<a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>] = t; <a name="l00021"></a>00021 <span class="keywordflow">if</span> ((<a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a>%<a class="code" href="classloopDetector.html#a9fe35ad994097bfecf6db4d221b1b055">fCheckperiod</a>) == 0) { <a name="l00022"></a>00022 <span class="comment">// list possible cycles</span> <a name="l00023"></a>00023 vector<int> vc; <a name="l00024"></a>00024 <a class="code" href="classloopDetector.html#ae0f1308bade228c742eb859b81868058">listPossibleCycles</a>(vc); <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="comment">// check each possible cycle</span> <a name="l00027"></a>00027 <span class="comment">//for (int i = vc.size(); i > 0;) {</span> <a name="l00028"></a>00028 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < vc.size(); i++) { <a name="l00029"></a>00029 <span class="comment">//i--;</span> <a name="l00030"></a>00030 <span class="keywordflow">if</span> (<a class="code" href="classloopDetector.html#af8865a4040a30fafcbe7faf039667c14">isCycle</a>(vc[i])) { <a name="l00031"></a>00031 cerr << <span class="stringliteral">"ERROR : the Faust compiler has detected an endless cycle of "</span> <a name="l00032"></a>00032 << vc[i] <a name="l00033"></a>00033 << <span class="stringliteral">" evaluations. Last evaluated expression : "</span> <a name="l00034"></a>00034 << <a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a> << endl; <a name="l00035"></a>00035 exit(1); <a name="l00036"></a>00036 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00037"></a>00037 } <a name="l00038"></a>00038 } <a name="l00039"></a>00039 } <a name="l00040"></a>00040 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00041"></a>00041 } </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="a77db05821952f2c8d4cae852f0812343"></a><!-- doxytag: member="loopDetector::get" ref="a77db05821952f2c8d4cae852f0812343" args="(int n)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classCTree.html">Tree</a> loopDetector::get </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>n</em></td> <td> ) </td> <td><code> [inline, private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00052">52</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p>References <a class="el" href="loopDetector_8hh_source.html#l00045">fBuffer</a>, <a class="el" href="loopDetector_8hh_source.html#l00043">fBuffersize</a>, and <a class="el" href="loopDetector_8hh_source.html#l00046">fPhase</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00052"></a>00052 { <span class="keywordflow">return</span> <a class="code" href="classloopDetector.html#a07fe0c957ced096900527dc19c1be67c">fBuffer</a>[(<a class="code" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">fPhase</a>-n)%<a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>]; } </pre></div></p> </div> </div> <a class="anchor" id="af8865a4040a30fafcbe7faf039667c14"></a><!-- doxytag: member="loopDetector::isCycle" ref="af8865a4040a30fafcbe7faf039667c14" args="(int period)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool loopDetector::isCycle </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>period</em></td> <td> ) </td> <td><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8cpp_source.html#l00044">44</a> of file <a class="el" href="loopDetector_8cpp_source.html">loopDetector.cpp</a>.</p> <p>References <a class="el" href="loopDetector_8hh_source.html#l00043">fBuffersize</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00045"></a>00045 { <a name="l00046"></a>00046 <span class="comment">//cerr << "check cycle " << period << endl;</span> <a name="l00047"></a>00047 <span class="keywordtype">int</span> n = <a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>/period; <span class="comment">// number of periods</span> <a name="l00048"></a>00048 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<period; i++) { <a name="l00049"></a>00049 <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> x = <span class="keyword">get</span>(i); <a name="l00050"></a>00050 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> p=1; p<n; p++) { <a name="l00051"></a>00051 <span class="keywordflow">if</span> (x != <span class="keyword">get</span>(i+p*period)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00052"></a>00052 } <a name="l00053"></a>00053 } <a name="l00054"></a>00054 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00055"></a>00055 } </pre></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="ae0f1308bade228c742eb859b81868058"></a><!-- doxytag: member="loopDetector::listPossibleCycles" ref="ae0f1308bade228c742eb859b81868058" args="(vector< int > &v)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void loopDetector::listPossibleCycles </td> <td>(</td> <td class="paramtype">vector< int > & </td> <td class="paramname"> <em>v</em></td> <td> ) </td> <td><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8cpp_source.html#l00004">4</a> of file <a class="el" href="loopDetector_8cpp_source.html">loopDetector.cpp</a>.</p> <p>References <a class="el" href="loopDetector_8hh_source.html#l00043">fBuffersize</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00005"></a>00005 { <a name="l00006"></a>00006 <span class="comment">//cerr << "list possible cycles" << endl;</span> <a name="l00007"></a>00007 <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 = <span class="keyword">get</span>(0); <a name="l00008"></a>00008 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i<=(<a class="code" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">fBuffersize</a>/2); i++) { <a name="l00009"></a>00009 <span class="keywordflow">if</span> (t == <span class="keyword">get</span>(i)) { <a name="l00010"></a>00010 <span class="comment">//cout << "possible cycle at " << i << endl;</span> <a name="l00011"></a>00011 v.push_back(i); <a name="l00012"></a>00012 } <a name="l00013"></a>00013 } <a name="l00014"></a>00014 } </pre></div></p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="a07fe0c957ced096900527dc19c1be67c"></a><!-- doxytag: member="loopDetector::fBuffer" ref="a07fe0c957ced096900527dc19c1be67c" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">vector<<a class="el" href="classCTree.html">Tree</a>> <a class="el" href="classloopDetector.html#a07fe0c957ced096900527dc19c1be67c">loopDetector::fBuffer</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00045">45</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>, and <a class="el" href="loopDetector_8hh_source.html#l00052">get()</a>.</p> </div> </div> <a class="anchor" id="a3f04dfc6e31dd6bfd8cf6a26b8d07798"></a><!-- doxytag: member="loopDetector::fBuffersize" ref="a3f04dfc6e31dd6bfd8cf6a26b8d07798" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const int <a class="el" href="classloopDetector.html#a3f04dfc6e31dd6bfd8cf6a26b8d07798">loopDetector::fBuffersize</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00043">43</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>, <a class="el" href="loopDetector_8hh_source.html#l00052">get()</a>, <a class="el" href="loopDetector_8cpp_source.html#l00044">isCycle()</a>, and <a class="el" href="loopDetector_8cpp_source.html#l00004">listPossibleCycles()</a>.</p> </div> </div> <a class="anchor" id="a9fe35ad994097bfecf6db4d221b1b055"></a><!-- doxytag: member="loopDetector::fCheckperiod" ref="a9fe35ad994097bfecf6db4d221b1b055" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const int <a class="el" href="classloopDetector.html#a9fe35ad994097bfecf6db4d221b1b055">loopDetector::fCheckperiod</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00044">44</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>.</p> </div> </div> <a class="anchor" id="ab4392435d391c6ce5736fbdb362e152e"></a><!-- doxytag: member="loopDetector::fPhase" ref="ab4392435d391c6ce5736fbdb362e152e" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="classloopDetector.html#ab4392435d391c6ce5736fbdb362e152e">loopDetector::fPhase</a><code> [private]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="loopDetector_8hh_source.html#l00046">46</a> of file <a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a>.</p> <p>Referenced by <a class="el" href="loopDetector_8cpp_source.html#l00016">detect()</a>, and <a class="el" href="loopDetector_8hh_source.html#l00052">get()</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="loopDetector_8hh_source.html">loopDetector.hh</a></li> <li><a class="el" href="loopDetector_8cpp_source.html">loopDetector.cpp</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Apr 29 00:00:21 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>