Paradiseo-eo sources added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
bc1f453978
commit
c3aec878e5
3609 changed files with 342772 additions and 0 deletions
124
trunk/paradiseo-eo/doc/html/_sym_impl_8cpp-source.html
Normal file
124
trunk/paradiseo-eo/doc/html/_sym_impl_8cpp-source.html
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>EO: SymImpl.cpp Source File</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body>
|
||||
<!-- Generated by Doxygen 1.3.9.1 -->
|
||||
<div class="qindex"> <form class="search" action="search.php" method="get">
|
||||
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
|
||||
<div class="nav">
|
||||
<a class="el" href="dir_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>SymImpl.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00018
|
||||
00019 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00020 <span class="keyword">namespace </span>detail {
|
||||
00021
|
||||
00022 <span class="keyword">class </span>SymArgsImpl {
|
||||
00023 <span class="keyword">public</span>:
|
||||
00024 std::vector<Sym> owned_args;
|
||||
00025 };
|
||||
00026
|
||||
00027 size_t SymArgs::len()<span class="keyword"> const </span>{
|
||||
00028 <span class="keywordflow">return</span> vec().size();
|
||||
00029 }
|
||||
00030
|
||||
00031 SymArgs::SymArgs() : pimpl( new SymArgsImpl ) {
|
||||
00032 args_ptr = &pimpl->owned_args;
|
||||
00033 }
|
||||
00034
|
||||
00035 SymArgs::SymArgs(<span class="keyword">const</span> std::vector<Sym>& v) : pimpl(0) {
|
||||
00036 args_ptr = &v;
|
||||
00037 }
|
||||
00038
|
||||
00039 SymArgs::~SymArgs() {
|
||||
00040 <span class="keyword">delete</span> pimpl;
|
||||
00041 }
|
||||
00042
|
||||
00043 SymArgs::SymArgs(<span class="keyword">const</span> SymArgs& args) : pimpl(0), args_ptr(args.args_ptr) {
|
||||
00044 <span class="keywordflow">if</span> (args.pimpl && args.args_ptr == &args.pimpl->owned_args) {
|
||||
00045 pimpl = <span class="keyword">new</span> SymArgsImpl(*args.pimpl);
|
||||
00046 args_ptr = &pimpl->owned_args;
|
||||
00047 }
|
||||
00048 }
|
||||
00049
|
||||
00050 <span class="keyword">const</span> SymArgs& SymArgs::operator=(<span class="keyword">const</span> SymArgs& args) {
|
||||
00051 <span class="keywordflow">if</span> (args.pimpl && args.args_ptr == &args.pimpl->owned_args) {
|
||||
00052 pimpl = <span class="keyword">new</span> SymArgsImpl(*args.pimpl);
|
||||
00053 args_ptr = &pimpl->owned_args;
|
||||
00054 } <span class="keywordflow">else</span> {
|
||||
00055 args_ptr = args.args_ptr;
|
||||
00056 }
|
||||
00057
|
||||
00058 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00059 }
|
||||
00060
|
||||
00061 <span class="keywordtype">void</span> SymArgs::fixate()<span class="keyword"> const </span>{
|
||||
00062 assert(pimpl == 0);
|
||||
00063 pimpl = <span class="keyword">new</span> SymArgsImpl;
|
||||
00064 pimpl->owned_args = *args_ptr;
|
||||
00065 args_ptr = &pimpl->owned_args;
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="comment">// For Tackett's hashcode</span>
|
||||
00069 <span class="preprocessor">#define PRIMET 21523</span>
|
||||
00070 <span class="preprocessor"></span><span class="preprocessor">#define HASHMOD 277218551</span>
|
||||
00071 <span class="preprocessor"></span>
|
||||
00072 <span class="keyword">const</span> <span class="keywordtype">int</span> nprimes = 4;
|
||||
00073 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> primes[] = {3221225473ul, 201326611ul, 1610612741ul, 805306457ul};
|
||||
00074
|
||||
00075 <span class="keywordtype">int</span> SymKey::calc_hash()<span class="keyword"> const </span>{
|
||||
00076 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> hash = unsigned(token);
|
||||
00077 hash *= PRIMET;
|
||||
00078
|
||||
00079 <span class="keyword">const</span> std::vector<Sym>& v = args.vec();
|
||||
00080 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < v.size(); ++i) {
|
||||
00081 hash += ( (v[i].address() >> 3) * primes[i%nprimes]) % HASHMOD;
|
||||
00082 }
|
||||
00083
|
||||
00084 <span class="keywordflow">return</span> hash;<span class="comment">// % HASHMOD;</span>
|
||||
00085 }
|
||||
00086
|
||||
00087 <span class="keywordtype">bool</span> SymKey::operator==(<span class="keyword">const</span> SymKey& other)<span class="keyword"> const </span>{
|
||||
00088 <span class="keywordflow">if</span> (token != other.token) <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00089 <span class="keywordflow">return</span> args.vec() == other.args.vec();
|
||||
00090 }
|
||||
00091
|
||||
00092 <span class="comment">/* Just to store this info somewhere:</span>
|
||||
00093 <span class="comment"> * </span>
|
||||
00094 <span class="comment"> * Address Based Hash Function Implementation</span>
|
||||
00095 <span class="comment"> * uint32 address_hash(char* addr)</span>
|
||||
00096 <span class="comment"> * {</span>
|
||||
00097 <span class="comment"> * register uint32 key;</span>
|
||||
00098 <span class="comment"> * key = (uint32) addr;</span>
|
||||
00099 <span class="comment"> * return (key >> 3) * 2654435761;</span>
|
||||
00100 <span class="comment"> * }</span>
|
||||
00101 <span class="comment"> */</span>
|
||||
00102
|
||||
00103 SymValue::SymValue() : refcount(0), size(0), depth(0), uniqueNodeStats(0) {}
|
||||
00104
|
||||
00105 SymValue::~SymValue() { <span class="keyword">delete</span> uniqueNodeStats; }
|
||||
00106
|
||||
00107
|
||||
00108
|
||||
00109 } <span class="comment">// namespace detail</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 2006 for EO by
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue