<!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: compile.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>compile.cpp File Reference</h1><code>#include "<a class="el" href="timing_8hh_source.html">timing.hh</a>"</code><br/> <code>#include "<a class="el" href="compile_8cpp_source.html">compile.hh</a>"</code><br/> <code>#include "<a class="el" href="signals_8hh_source.html">signals.hh</a>"</code><br/> <code>#include <string></code><br/> <code>#include <list></code><br/> <code>#include <set></code><br/> <code>#include <map></code><br/> <code>#include "<a class="el" href="sigtype_8hh_source.html">sigtype.hh</a>"</code><br/> <code>#include "<a class="el" href="smartpointer_8hh_source.html">smartpointer.hh</a>"</code><br/> <code>#include "<a class="el" href="tlib_8hh_source.html">tlib.hh</a>"</code><br/> <code>#include "<a class="el" href="property_8hh_source.html">property.hh</a>"</code><br/> <code>#include "<a class="el" href="loop_8hh_source.html">loop.hh</a>"</code><br/> <code>#include "<a class="el" href="graphSorting_8hh_source.html">graphSorting.hh</a>"</code><br/> <code>#include <vector></code><br/> <code>#include "<a class="el" href="uitree_8hh_source.html">uitree.hh</a>"</code><br/> <code>#include <stack></code><br/> <code>#include <iostream></code><br/> <code>#include <stdio.h></code><br/> <code>#include "<a class="el" href="sigprint_8hh_source.html">sigprint.hh</a>"</code><br/> <code>#include "<a class="el" href="ppsig_8hh_source.html">ppsig.hh</a>"</code><br/> <code>#include "<a class="el" href="sigtyperules_8hh_source.html">sigtyperules.hh</a>"</code><br/> <code>#include "<a class="el" href="simplify_8hh_source.html">simplify.hh</a>"</code><br/> <code>#include "<a class="el" href="privatise_8hh_source.html">privatise.hh</a>"</code><br/> <div class="dynheader"> Include dependency graph for compile.cpp:</div> <div class="dynsection"> </div> <div class="dynheader"> This graph shows which files directly or indirectly include this file:</div> <div class="dynsection"> </div> <p><a href="compile_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 string </td><td class="memItemRight" valign="bottom"><a class="el" href="compile_8cpp.html#ae01701676fb3301fa2a53fccac7d87f9">wdel</a> (const string &s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Removes enclosing whitespaces : ' toto ' -> 'toto'. <a href="#ae01701676fb3301fa2a53fccac7d87f9"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static string </td><td class="memItemRight" valign="bottom"><a class="el" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075">rmWhiteSpaces</a> (const string &s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces()</a>: Remove the leading and trailing white spaces of a string (but not those in the middle of the string) <a href="#a96e69d2d939df869ffe8081b135df075"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="compile_8cpp.html#af40d9db717982956ede067d6eeab6105">extractMetadata</a> (const string &fulllabel, string &label, map< string, set< string > > &metadata)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata. <a href="#af40d9db717982956ede067d6eeab6105"></a><br/></td></tr> <tr><td colspan="2"><h2>Variables</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="compile_8cpp.html#a65e358120a7c96bacd59071ab0b32cd1">gDetailsSwitch</a></td></tr> <tr><td class="memItemLeft" align="right" valign="top">string </td><td class="memItemRight" valign="bottom"><a class="el" href="compile_8cpp.html#ac8a7f14cf003853871e19ebab4cfaaf3">gMasterName</a></td></tr> </table> <hr/><h2>Function Documentation</h2> <a class="anchor" id="af40d9db717982956ede067d6eeab6105"></a><!-- doxytag: member="compile.cpp::extractMetadata" ref="af40d9db717982956ede067d6eeab6105" args="(const string &fulllabel, string &label, map< string, set< string > > &metadata)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static void extractMetadata </td> <td>(</td> <td class="paramtype">const string & </td> <td class="paramname"> <em>fulllabel</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">string & </td> <td class="paramname"> <em>label</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">map< string, set< string > > & </td> <td class="paramname"> <em>metadata</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>Extracts metdata from a label : 'vol [unit: dB]' -> 'vol' + metadata. </p> <p>Definition at line <a class="el" href="compile_8cpp_source.html#l00178">178</a> of file <a class="el" href="compile_8cpp_source.html">compile.cpp</a>.</p> <p>References <a class="el" href="compile_8cpp_source.html#l00163">rmWhiteSpaces()</a>.</p> <p>Referenced by <a class="el" href="compile_8cpp_source.html#l00327">Compiler::generateWidgetCode()</a>, and <a class="el" href="compile_8cpp_source.html#l00450">Compiler::generateWidgetMacro()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00179"></a>00179 { <a name="l00180"></a>00180 <span class="keyword">enum</span> {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue}; <a name="l00181"></a>00181 <span class="keywordtype">int</span> state = kLabel; <span class="keywordtype">int</span> deep = 0; <a name="l00182"></a>00182 <span class="keywordtype">string</span> key, value; <a name="l00183"></a>00183 <a name="l00184"></a>00184 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i < fulllabel.size(); i++) { <a name="l00185"></a>00185 <span class="keywordtype">char</span> c = fulllabel[i]; <a name="l00186"></a>00186 <span class="keywordflow">switch</span> (state) { <a name="l00187"></a>00187 <span class="keywordflow">case</span> kLabel : <a name="l00188"></a>00188 assert (deep == 0); <a name="l00189"></a>00189 <span class="keywordflow">switch</span> (c) { <a name="l00190"></a>00190 <span class="keywordflow">case</span> <span class="charliteral">'\\'</span> : state = kEscape1; <span class="keywordflow">break</span>; <a name="l00191"></a>00191 <span class="keywordflow">case</span> <span class="charliteral">'['</span> : state = kKey; deep++; <span class="keywordflow">break</span>; <a name="l00192"></a>00192 <span class="keywordflow">default</span> : label += c; <a name="l00193"></a>00193 } <a name="l00194"></a>00194 <span class="keywordflow">break</span>; <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keywordflow">case</span> kEscape1 : <a name="l00197"></a>00197 label += c; <a name="l00198"></a>00198 state = kLabel; <a name="l00199"></a>00199 <span class="keywordflow">break</span>; <a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="keywordflow">case</span> kEscape2 : <a name="l00202"></a>00202 key += c; <a name="l00203"></a>00203 state = kKey; <a name="l00204"></a>00204 <span class="keywordflow">break</span>; <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="keywordflow">case</span> kEscape3 : <a name="l00207"></a>00207 value += c; <a name="l00208"></a>00208 state = kValue; <a name="l00209"></a>00209 <span class="keywordflow">break</span>; <a name="l00210"></a>00210 <a name="l00211"></a>00211 <span class="keywordflow">case</span> kKey : <a name="l00212"></a>00212 assert (deep > 0); <a name="l00213"></a>00213 <span class="keywordflow">switch</span> (c) { <a name="l00214"></a>00214 <span class="keywordflow">case</span> <span class="charliteral">'\\'</span> : state = kEscape2; <a name="l00215"></a>00215 <span class="keywordflow">break</span>; <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keywordflow">case</span> <span class="charliteral">'['</span> : deep++; <a name="l00218"></a>00218 key += c; <a name="l00219"></a>00219 <span class="keywordflow">break</span>; <a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="keywordflow">case</span> <span class="charliteral">':'</span> : <span class="keywordflow">if</span> (deep == 1) { <a name="l00222"></a>00222 state = kValue; <a name="l00223"></a>00223 } <span class="keywordflow">else</span> { <a name="l00224"></a>00224 key += c; <a name="l00225"></a>00225 } <a name="l00226"></a>00226 <span class="keywordflow">break</span>; <a name="l00227"></a>00227 <span class="keywordflow">case</span> <span class="charliteral">']'</span> : deep--; <a name="l00228"></a>00228 <span class="keywordflow">if</span> (deep < 1) { <a name="l00229"></a>00229 metadata[<a class="code" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces</a>(key)].insert(<span class="stringliteral">""</span>); <a name="l00230"></a>00230 state = kLabel; <a name="l00231"></a>00231 key=<span class="stringliteral">""</span>; <a name="l00232"></a>00232 value=<span class="stringliteral">""</span>; <a name="l00233"></a>00233 } <span class="keywordflow">else</span> { <a name="l00234"></a>00234 key += c; <a name="l00235"></a>00235 } <a name="l00236"></a>00236 <span class="keywordflow">break</span>; <a name="l00237"></a>00237 <span class="keywordflow">default</span> : key += c; <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <span class="keywordflow">break</span>; <a name="l00240"></a>00240 <a name="l00241"></a>00241 <span class="keywordflow">case</span> kValue : <a name="l00242"></a>00242 assert (deep > 0); <a name="l00243"></a>00243 <span class="keywordflow">switch</span> (c) { <a name="l00244"></a>00244 <span class="keywordflow">case</span> <span class="charliteral">'\\'</span> : state = kEscape3; <a name="l00245"></a>00245 <span class="keywordflow">break</span>; <a name="l00246"></a>00246 <a name="l00247"></a>00247 <span class="keywordflow">case</span> <span class="charliteral">'['</span> : deep++; <a name="l00248"></a>00248 value += c; <a name="l00249"></a>00249 <span class="keywordflow">break</span>; <a name="l00250"></a>00250 <a name="l00251"></a>00251 <span class="keywordflow">case</span> <span class="charliteral">']'</span> : deep--; <a name="l00252"></a>00252 <span class="keywordflow">if</span> (deep < 1) { <a name="l00253"></a>00253 metadata[<a class="code" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces</a>(key)].insert(<a class="code" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces</a>(value)); <a name="l00254"></a>00254 state = kLabel; <a name="l00255"></a>00255 key=<span class="stringliteral">""</span>; <a name="l00256"></a>00256 value=<span class="stringliteral">""</span>; <a name="l00257"></a>00257 } <span class="keywordflow">else</span> { <a name="l00258"></a>00258 value += c; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="keywordflow">break</span>; <a name="l00261"></a>00261 <span class="keywordflow">default</span> : value += c; <a name="l00262"></a>00262 } <a name="l00263"></a>00263 <span class="keywordflow">break</span>; <a name="l00264"></a>00264 <a name="l00265"></a>00265 <span class="keywordflow">default</span> : <a name="l00266"></a>00266 cerr << <span class="stringliteral">"ERROR unrecognized state "</span> << state << endl; <a name="l00267"></a>00267 } <a name="l00268"></a>00268 } <a name="l00269"></a>00269 label = <a class="code" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces</a>(label); <a name="l00270"></a>00270 } </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="a96e69d2d939df869ffe8081b135df075"></a><!-- doxytag: member="compile.cpp::rmWhiteSpaces" ref="a96e69d2d939df869ffe8081b135df075" args="(const string &s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static string rmWhiteSpaces </td> <td>(</td> <td class="paramtype">const string & </td> <td class="paramname"> <em>s</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p><a class="el" href="compile_8cpp.html#a96e69d2d939df869ffe8081b135df075" title="rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not...">rmWhiteSpaces()</a>: Remove the leading and trailing white spaces of a string (but not those in the middle of the string) </p> <p>Definition at line <a class="el" href="compile_8cpp_source.html#l00163">163</a> of file <a class="el" href="compile_8cpp_source.html">compile.cpp</a>.</p> <p>Referenced by <a class="el" href="compile_8cpp_source.html#l00178">extractMetadata()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00164"></a>00164 { <a name="l00165"></a>00165 <span class="keywordtype">size_t</span> i = s.find_first_not_of(<span class="stringliteral">" \t"</span>); <a name="l00166"></a>00166 <span class="keywordtype">size_t</span> j = s.find_last_not_of(<span class="stringliteral">" \t"</span>); <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="keywordflow">if</span> ( (i != string::npos) & (j != string::npos) ) { <a name="l00169"></a>00169 <span class="keywordflow">return</span> s.substr(i, 1+j-i); <a name="l00170"></a>00170 } <span class="keywordflow">else</span> { <a name="l00171"></a>00171 <span class="keywordflow">return</span> <span class="stringliteral">""</span>; <a name="l00172"></a>00172 } <a name="l00173"></a>00173 } </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="ae01701676fb3301fa2a53fccac7d87f9"></a><!-- doxytag: member="compile.cpp::wdel" ref="ae01701676fb3301fa2a53fccac7d87f9" args="(const string &s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static string wdel </td> <td>(</td> <td class="paramtype">const string & </td> <td class="paramname"> <em>s</em></td> <td> ) </td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Removes enclosing whitespaces : ' toto ' -> 'toto'. </p> <p>Definition at line <a class="el" href="compile_8cpp_source.html#l00148">148</a> of file <a class="el" href="compile_8cpp_source.html">compile.cpp</a>.</p> <p>Referenced by <a class="el" href="compile_8cpp_source.html#l00327">Compiler::generateWidgetCode()</a>.</p> <p><div class="fragment"><pre class="fragment"><a name="l00149"></a>00149 { <a name="l00150"></a>00150 <span class="keywordtype">size_t</span> i = 0; <a name="l00151"></a>00151 <span class="keywordtype">size_t</span> j = s.size(); <a name="l00152"></a>00152 <span class="keywordflow">while</span> (i<j && s[i]==<span class="charliteral">' '</span>) i++; <a name="l00153"></a>00153 <span class="keywordflow">while</span> (j>i && s[j-1] == <span class="charliteral">' '</span>) j--; <a name="l00154"></a>00154 <span class="keywordflow">return</span> s.substr(i,j-i); <a name="l00155"></a>00155 } </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>Variable Documentation</h2> <a class="anchor" id="a65e358120a7c96bacd59071ab0b32cd1"></a><!-- doxytag: member="compile.cpp::gDetailsSwitch" ref="a65e358120a7c96bacd59071ab0b32cd1" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int <a class="el" href="main_8cpp.html#a4741733b16ad8f554a8b5c0ca5045d14">gDetailsSwitch</a></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="main_8cpp_source.html#l00110">110</a> of file <a class="el" href="main_8cpp_source.html">main.cpp</a>.</p> </div> </div> <a class="anchor" id="ac8a7f14cf003853871e19ebab4cfaaf3"></a><!-- doxytag: member="compile.cpp::gMasterName" ref="ac8a7f14cf003853871e19ebab4cfaaf3" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">string <a class="el" href="main_8cpp.html#ac8a7f14cf003853871e19ebab4cfaaf3">gMasterName</a></td> </tr> </table> </div> <div class="memdoc"> <p>Definition at line <a class="el" href="main_8cpp_source.html#l00102">102</a> of file <a class="el" href="main_8cpp_source.html">main.cpp</a>.</p> <p>Referenced by <a class="el" href="main_8cpp_source.html#l00452">initFaustDirectories()</a>.</p> </div> </div> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Apr 29 00:00:03 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>