Sophie

Sophie

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

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: symbol.hh 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>symbol.hh</h1><a href="symbol_8hh.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="l00040"></a>00040 <span class="preprocessor">#ifndef     __SYMBOL__</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#define     __SYMBOL__</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="keyword">using namespace </span>std;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="comment">//--------------------------------SYMBOL-------------------------------------</span>
<a name="l00049"></a>00049 
<a name="l00053"></a><a class="code" href="classSymbol.html">00053</a> <span class="keyword">class </span><a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055     
<a name="l00056"></a>00056  <span class="keyword">private</span>:
<a name="l00057"></a>00057          
<a name="l00058"></a><a class="code" href="classSymbol.html#abb8b44fb98513a5d545a684c6024be4d">00058</a>     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span>    <a class="code" href="classSymbol.html#abb8b44fb98513a5d545a684c6024be4d" title="Size of the hash table (a prime number is recommended).">kHashTableSize</a> = 511;                   
<a name="l00059"></a><a class="code" href="classSymbol.html#ad28a6fe0f613177e77bc29b98ad22ecd">00059</a>     <span class="keyword">static</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*      <a class="code" href="classSymbol.html#ad28a6fe0f613177e77bc29b98ad22ecd" title="Hash table used to store the symbols.">gSymbolTable</a>[<a class="code" href="classSymbol.html#abb8b44fb98513a5d545a684c6024be4d" title="Size of the hash table (a prime number is recommended).">kHashTableSize</a>];           
<a name="l00060"></a>00060     
<a name="l00061"></a>00061     
<a name="l00062"></a>00062  <span class="comment">// Fields</span>
<a name="l00063"></a><a class="code" href="classSymbol.html#a500120e613d60cba8faffc9544c06ad1">00063</a>     <span class="keywordtype">char</span>*           <a class="code" href="classSymbol.html#a500120e613d60cba8faffc9544c06ad1" title="Name of the symbol.">fName</a>;                                      
<a name="l00064"></a><a class="code" href="classSymbol.html#a96342ef5b450e2edbdb9149798c7d435">00064</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            <a class="code" href="classSymbol.html#a96342ef5b450e2edbdb9149798c7d435" title="Hash key computed from the name and used to determine the hash table entry.">fHash</a>;                                      
<a name="l00065"></a><a class="code" href="classSymbol.html#a2fc73a8c7c4a86ed96c48236e397bbf0">00065</a>     <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*         <a class="code" href="classSymbol.html#a2fc73a8c7c4a86ed96c48236e397bbf0" title="Next symbol in the hash table entry.">fNext</a>;                                      
<a name="l00066"></a><a class="code" href="classSymbol.html#a43a1fda1b5819fc200c19509a0eae03e">00066</a>     <span class="keywordtype">void</span>*           <a class="code" href="classSymbol.html#a43a1fda1b5819fc200c19509a0eae03e" title="Field to user disposal to store additional data.">fData</a>;                                      
<a name="l00067"></a>00067     
<a name="l00068"></a>00068  <span class="comment">// Constructors &amp; destructors</span>
<a name="l00069"></a>00069     <a class="code" href="classSymbol.html#a28b3233002ab61fa790e1d3281bd5f4e" title="Constructs a new symbol ready to be placed in the hash table.">Symbol</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hsh, <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* nxt);    
<a name="l00070"></a>00070    <a class="code" href="classSymbol.html#a505360ad4bd2e0bd1e3954eca1b05723" title="The Destructor is never used.">~Symbol</a> ();                                                  
<a name="l00071"></a>00071     
<a name="l00072"></a>00072  <span class="comment">// Others</span>
<a name="l00073"></a>00073     <span class="keywordtype">bool</span>            <a class="code" href="classSymbol.html#ae5e90343699911affcc3372bcb131c50" title="Check if the name of the symbol is equal to string str.">equiv</a> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hash, <span class="keyword">const</span> <span class="keywordtype">char</span>* str) <span class="keyword">const</span> ;  
<a name="l00074"></a>00074     <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     <a class="code" href="classSymbol.html#a5c9ccccee95f2d09e34b060076d52a29" title="Compute the 32-bits hash key of string str.">calcHashKey</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);              
<a name="l00075"></a>00075 
<a name="l00076"></a>00076  <span class="comment">// Static methods</span>
<a name="l00077"></a>00077     <span class="keyword">static</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*      <span class="keyword">get</span> (<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; str);                
<a name="l00078"></a>00078     <span class="keyword">static</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*      <span class="keyword">get</span> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);                  
<a name="l00079"></a>00079     <span class="keyword">static</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*      <a class="code" href="classSymbol.html#acab6dd6c1c62c49b03ca629f7e0dab36" title="Creates a new symbol of name prefixed by str.">prefix</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);               
<a name="l00080"></a>00080     <span class="keyword">static</span> <span class="keywordtype">bool</span>         <a class="code" href="classSymbol.html#a2fd22ca0779942ebaafcdf24a0d758f6" title="Returns true if no symbol of name str exists.">isnew</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);                
<a name="l00081"></a>00081     
<a name="l00082"></a>00082  <span class="keyword">public</span>:
<a name="l00083"></a>00083     ostream&amp;                <a class="code" href="classSymbol.html#a80aa251523a4a1c24e9e9e679205f18e" title="print a symbol on a stream">print</a> (ostream&amp; fout) <span class="keyword">const</span>;                                
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     <span class="keyword">friend</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="classSymbol.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);
<a name="l00086"></a>00086     <span class="keyword">friend</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="classSymbol.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a> (<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; str);
<a name="l00087"></a>00087     <span class="keyword">friend</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="classSymbol.html#a377309446e0e86ae663cd6709e02889d" title="Returns a new unique symbol of name strxxx.">unique</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str);
<a name="l00088"></a>00088     <span class="keyword">friend</span> <span class="keyword">const</span> <span class="keywordtype">char</span>*  <a class="code" href="classSymbol.html#a8243134fbbd9d924ebbb3f833922e310" title="Returns the name of a symbol.">name</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym);
<a name="l00089"></a>00089     
<a name="l00090"></a>00090     <span class="keyword">friend</span> <span class="keywordtype">void</span>*            <a class="code" href="classSymbol.html#a603fcb6c07eacf2688c2a8470637d0ff" title="Returns user data.">getUserData</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym);
<a name="l00091"></a>00091     <span class="keyword">friend</span> <span class="keywordtype">void</span>             <a class="code" href="classSymbol.html#a936471e3b0afa59ffec0a94f7d1b6570" title="Set user data.">setUserData</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym, <span class="keywordtype">void</span>* d);
<a name="l00092"></a>00092         
<a name="l00093"></a>00093 };
<a name="l00094"></a>00094 
<a name="l00095"></a><a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8">00095</a> <span class="keyword">inline</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str)    { <span class="keywordflow">return</span> <a class="code" href="classSymbol.html#af8badc954a2122bb8087e084224af76e" title="Get the symbol of name str.">Symbol::get</a>(str); }    
<a name="l00096"></a><a class="code" href="symbol_8hh.html#abfc1191889039b578e061d8c7780ec5f">00096</a> <span class="keyword">inline</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a> (<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; str)  { <span class="keywordflow">return</span> <a class="code" href="classSymbol.html#af8badc954a2122bb8087e084224af76e" title="Get the symbol of name str.">Symbol::get</a>(str); }    
<a name="l00097"></a><a class="code" href="symbol_8hh.html#a377309446e0e86ae663cd6709e02889d">00097</a> <span class="keyword">inline</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>*          <a class="code" href="symbol_8hh.html#a377309446e0e86ae663cd6709e02889d" title="Returns a new unique symbol of name strxxx.">unique</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* str)    { <span class="keywordflow">return</span> <a class="code" href="classSymbol.html#acab6dd6c1c62c49b03ca629f7e0dab36" title="Creates a new symbol of name prefixed by str.">Symbol::prefix</a>(str);}  
<a name="l00098"></a><a class="code" href="symbol_8hh.html#a8243134fbbd9d924ebbb3f833922e310">00098</a> <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span>*  <a class="code" href="symbol_8hh.html#a8243134fbbd9d924ebbb3f833922e310" title="Returns the name of a symbol.">name</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym)          { <span class="keywordflow">return</span> sym-&gt;<a class="code" href="classSymbol.html#a500120e613d60cba8faffc9544c06ad1" title="Name of the symbol.">fName</a>; }          
<a name="l00099"></a>00099     
<a name="l00100"></a><a class="code" href="symbol_8hh.html#a603fcb6c07eacf2688c2a8470637d0ff">00100</a> <span class="keyword">inline</span> <span class="keywordtype">void</span>*            <a class="code" href="symbol_8hh.html#a603fcb6c07eacf2688c2a8470637d0ff" title="Returns user data.">getUserData</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym)           { <span class="keywordflow">return</span> sym-&gt;<a class="code" href="classSymbol.html#a43a1fda1b5819fc200c19509a0eae03e" title="Field to user disposal to store additional data.">fData</a>; }      
<a name="l00101"></a><a class="code" href="symbol_8hh.html#a936471e3b0afa59ffec0a94f7d1b6570">00101</a> <span class="keyword">inline</span> <span class="keywordtype">void</span>             <a class="code" href="symbol_8hh.html#a936471e3b0afa59ffec0a94f7d1b6570" title="Set user data.">setUserData</a> (<a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* sym, <span class="keywordtype">void</span>* d)  { sym-&gt;<a class="code" href="classSymbol.html#a43a1fda1b5819fc200c19509a0eae03e" title="Field to user disposal to store additional data.">fData</a>=d; }           
<a name="l00102"></a>00102 
<a name="l00103"></a><a class="code" href="symbol_8hh.html#a40eefc5733d79133c3aaa825313a6486">00103</a> <span class="keyword">inline</span> ostream&amp; <a class="code" href="ppbox_8hh.html#a23b1718100bac6cb41d43dd01f226eef">operator &lt;&lt; </a>(ostream&amp; s, <span class="keyword">const</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>&amp; n) { <span class="keywordflow">return</span> n.<a class="code" href="classSymbol.html#a80aa251523a4a1c24e9e9e679205f18e" title="print a symbol on a stream">print</a>(s); }
<a name="l00104"></a>00104 
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="symbol_8hh.html#aac141e9ff20c575ad4887682c055da9a">00106</a> <span class="keyword">typedef</span> <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Symbol</a>* <a class="code" href="classSymbol.html" title="Symbols are unique objects with a name stored in a hash table.">Sym</a>;
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="preprocessor">#endif    </span>
</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>