<!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>CVC3: context.cpp 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.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">CVC3 <span id="projectnumber">2.4.1</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <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="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</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 id="navrow2" class="tabs2"> <ul class="tablist"> <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 class="header"> <div class="headertitle"> <div class="title">context.cpp</div> </div> </div> <div class="contents"> <a href="context_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************/</span><span class="comment"></span> <a name="l00002"></a>00002 <span class="comment">/*!</span> <a name="l00003"></a>00003 <span class="comment"> * \file context.cpp</span> <a name="l00004"></a>00004 <span class="comment"> * </span> <a name="l00005"></a>00005 <span class="comment"> * Author: Clark Barrett</span> <a name="l00006"></a>00006 <span class="comment"> * </span> <a name="l00007"></a>00007 <span class="comment"> * Created: Fri Jan 17 14:30:37 2003</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * <hr></span> <a name="l00010"></a>00010 <span class="comment"> *</span> <a name="l00011"></a>00011 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span> <a name="l00012"></a>00012 <span class="comment"> * and its documentation for any purpose is hereby granted without</span> <a name="l00013"></a>00013 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span> <a name="l00014"></a>00014 <span class="comment"> * LICENSE file provided with this distribution.</span> <a name="l00015"></a>00015 <span class="comment"> * </span> <a name="l00016"></a>00016 <span class="comment"> * <hr></span> <a name="l00017"></a>00017 <span class="comment"> * </span> <a name="l00018"></a>00018 <span class="comment"> */</span> <a name="l00019"></a>00019 <span class="comment">/*****************************************************************************/</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="context_8h.html">context.h</a>"</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="keyword">using namespace </span>CVC3; <a name="l00026"></a>00026 <span class="keyword">using namespace </span>std; <a name="l00027"></a>00027 <a name="l00028"></a>00028 <a name="l00029"></a>00029 vector<char*> <a class="code" href="classCVC3_1_1ContextMemoryManager.html#a5f5f52c997313f654d93e1f3d2dad128">ContextMemoryManager::s_freePages</a>; <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="comment"></span> <a name="l00032"></a>00032 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00033"></a>00033 <span class="comment"></span><span class="comment">// Scope methods //</span><span class="comment"></span> <a name="l00034"></a>00034 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00035"></a>00035 <span class="comment"></span> <a name="l00036"></a>00036 <a name="l00037"></a><a class="code" href="classCVC3_1_1Scope.html#a288d98e934b96112a131f0bbd068680f">00037</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Scope.html#a288d98e934b96112a131f0bbd068680f" title="Called by ~ContextManager.">Scope::finalize</a>(<span class="keywordtype">void</span>) <a name="l00038"></a>00038 { <a name="l00039"></a>00039 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* obj = d_restoreChain; <a name="l00040"></a>00040 <span class="keywordflow">while</span> (obj != NULL) { <a name="l00041"></a>00041 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* tmp = obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#afa940ba625d121fe37a659d7caf7f558" title="Next link in chain.">d_restoreChainNext</a>; <a name="l00042"></a>00042 <span class="comment">// When called from ~ContextManager(), the master objects may</span> <a name="l00043"></a>00043 <span class="comment">// still point to this scope. Disconnect them here.</span> <a name="l00044"></a>00044 <span class="keywordflow">if</span> (obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a> != NULL) { <a name="l00045"></a>00045 <span class="keywordflow">if</span> (obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a>-><a class="code" href="classCVC3_1_1ContextObj.html#ab4ce4a31b6ac3e9def89503a5bbaa365" title="Last scope in which this object was modified.">d_scope</a> == <span class="keyword">this</span>) <a name="l00046"></a>00046 obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a>-><a class="code" href="classCVC3_1_1ContextObj.html#ab4ce4a31b6ac3e9def89503a5bbaa365" title="Last scope in which this object was modified.">d_scope</a> = NULL; <a name="l00047"></a>00047 <span class="keywordflow">if</span> (obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a>-><a class="code" href="classCVC3_1_1ContextObj.html#a60c1d2e2b5f4b8055a2a6619ce173bdc" title="The list of values on previous scopes; our destructor should clean up those.">d_restore</a> == obj) <a name="l00048"></a>00048 obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a>-><a class="code" href="classCVC3_1_1ContextObj.html#a60c1d2e2b5f4b8055a2a6619ce173bdc" title="The list of values on previous scopes; our destructor should clean up those.">d_restore</a> = NULL; <a name="l00049"></a>00049 } <a name="l00050"></a>00050 obj = tmp; <a name="l00051"></a>00051 } <a name="l00052"></a>00052 } <a name="l00053"></a>00053 <a name="l00054"></a>00054 <a name="l00055"></a><a class="code" href="classCVC3_1_1Scope.html#a796f074fbe4834687942c43b6456dabb">00055</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Scope.html#a796f074fbe4834687942c43b6456dabb" title="Check for memory leaks.">Scope::check</a>(<span class="keywordtype">void</span>) <a name="l00056"></a>00056 { <a name="l00057"></a>00057 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00058"></a>00058 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* obj = d_restoreChain; <a name="l00059"></a>00059 <span class="keywordflow">if</span> (debugger.trace(<span class="stringliteral">"memory"</span>) && obj != NULL) { <a name="l00060"></a>00060 ostream& os = debugger.getOS(); <a name="l00061"></a>00061 <span class="keywordtype">int</span> n(0); <a name="l00062"></a>00062 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* tmp = obj; <a name="l00063"></a>00063 <span class="keywordflow">while</span>(tmp != NULL) { <a name="l00064"></a>00064 tmp = tmp-><a class="code" href="classCVC3_1_1ContextObjChain.html#afa940ba625d121fe37a659d7caf7f558" title="Next link in chain.">d_restoreChainNext</a>; <a name="l00065"></a>00065 n++; <a name="l00066"></a>00066 } <a name="l00067"></a>00067 os << <span class="stringliteral">"*** Warning: ~Scope(): found "</span><< n << <span class="stringliteral">" leaked objects "</span> <a name="l00068"></a>00068 << <span class="stringliteral">"in scope "</span> << d_level << <span class="stringliteral">":"</span> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00069"></a>00069 <span class="keywordflow">if</span> (debugger.flag(<span class="stringliteral">"memory leaks"</span>)) { <a name="l00070"></a>00070 tmp = obj; <a name="l00071"></a>00071 <span class="keywordflow">while</span>(tmp != NULL) { <a name="l00072"></a>00072 os << tmp->name() << <span class="stringliteral">"\n"</span>; <a name="l00073"></a>00073 tmp = tmp-><a class="code" href="classCVC3_1_1ContextObjChain.html#afa940ba625d121fe37a659d7caf7f558" title="Next link in chain.">d_restoreChainNext</a>; <a name="l00074"></a>00074 } <a name="l00075"></a>00075 } <a name="l00076"></a>00076 os << flush; <a name="l00077"></a>00077 } <a name="l00078"></a>00078 ) <a name="l00079"></a>00079 } <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a name="l00082"></a><a class="code" href="classCVC3_1_1Scope.html#a007e070f14d1158207a28293354ed106">00082</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1Scope.html#a007e070f14d1158207a28293354ed106" title="Compute memory used.">Scope::getMemory</a>(<span class="keywordtype">int</span> verbosity) <a name="l00083"></a>00083 { <a name="l00084"></a>00084 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = 0; <span class="comment">// scope is allocated in cmm</span> <a name="l00085"></a>00085 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00086"></a>00086 <a name="l00087"></a>00087 mem += getCMM()->getMemory(verbosity - 1); <a name="l00088"></a>00088 <span class="keywordflow">if</span> (d_prevScope != NULL) { <a name="l00089"></a>00089 mem += d_prevScope->getMemory(verbosity - 1); <a name="l00090"></a>00090 } <a name="l00091"></a>00091 <a name="l00092"></a>00092 <span class="comment">// TODO: d_restoreChain?</span> <a name="l00093"></a>00093 <a name="l00094"></a>00094 <span class="keywordflow">if</span> (verbosity > 0) { <a name="l00095"></a>00095 cout << <span class="stringliteral">"Scope "</span> << d_level << <span class="stringliteral">": "</span> << memSelf << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00096"></a>00096 cout << <span class="stringliteral">" Children: "</span> << mem << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00097"></a>00097 cout << <span class="stringliteral">" Total: "</span> << mem+memSelf << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00098"></a>00098 } <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keywordflow">return</span> mem + memSelf; <a name="l00101"></a>00101 <a name="l00102"></a>00102 <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment"></span> <a name="l00106"></a>00106 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00107"></a>00107 <span class="comment"></span><span class="comment">// ContextObjChain methods //</span><span class="comment"></span> <a name="l00108"></a>00108 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00109"></a>00109 <span class="comment"></span> <a name="l00110"></a>00110 <a name="l00111"></a><a class="code" href="classCVC3_1_1ContextObjChain.html#a83e5207b9d496337691b30f072c117c7">00111</a> <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* <a class="code" href="classCVC3_1_1ContextObjChain.html#a83e5207b9d496337691b30f072c117c7" title="Restore from d_data to d_master.">ContextObjChain::restore</a>(<span class="keywordtype">void</span>) <a name="l00112"></a>00112 { <a name="l00113"></a>00113 <span class="comment">// Assign 'next' pointer only when the master object is restored,</span> <a name="l00114"></a>00114 <span class="comment">// since this may change our next pointer (master may have other</span> <a name="l00115"></a>00115 <span class="comment">// context objects removed).</span> <a name="l00116"></a>00116 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(d_master != NULL, <span class="stringliteral">"How did this happen"</span>); <a name="l00117"></a>00117 <span class="comment">// if (d_master == NULL) return d_restoreChainNext;</span> <a name="l00118"></a>00118 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* next; <a name="l00119"></a>00119 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(d_data != NULL, <span class="stringliteral">"Shouldn't happen"</span>); <a name="l00120"></a>00120 <span class="comment">// if (d_data == NULL) {</span> <a name="l00121"></a>00121 <span class="comment">// d_master->setNull();</span> <a name="l00122"></a>00122 <span class="comment">// d_master->d_scope = d_master->d_scope->prevScope();</span> <a name="l00123"></a>00123 <span class="comment">// DebugAssert(d_restore==NULL,"Expected NULL");</span> <a name="l00124"></a>00124 <span class="comment">// next = d_restoreChainNext;</span> <a name="l00125"></a>00125 <span class="comment">// d_master->d_scope->addToChain(this);</span> <a name="l00126"></a>00126 <span class="comment">// }</span> <a name="l00127"></a>00127 <span class="comment">// else {</span> <a name="l00128"></a>00128 d_master->restoreData(d_data); <a name="l00129"></a>00129 d_master->d_scope = d_data->d_scope; <a name="l00130"></a>00130 d_master->d_restore = d_restore; <a name="l00131"></a>00131 next = d_restoreChainNext; <a name="l00132"></a>00132 <span class="keywordflow">if</span> (d_data != NULL) <span class="keyword">delete</span> d_data; <a name="l00133"></a>00133 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(d_master->d_restore != <span class="keyword">this</span>, <span class="stringliteral">"points to self"</span>); <a name="l00134"></a>00134 <span class="comment">// }</span> <a name="l00135"></a>00135 <span class="keywordflow">return</span> next; <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="preprocessor">#ifdef _CVC3_DEBUG_MODE</span> <a name="l00140"></a>00140 <span class="preprocessor"></span>std::string ContextObjChain::name()<span class="keyword"> const</span> <a name="l00141"></a>00141 <span class="keyword"></span>{ <a name="l00142"></a>00142 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(d_master != NULL, <span class="stringliteral">"NULL master"</span>); <a name="l00143"></a>00143 <span class="keywordflow">return</span> d_master->name(); <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <span class="preprocessor">#endif</span> <a name="l00146"></a>00146 <span class="preprocessor"></span> <a name="l00147"></a>00147 <span class="comment"></span> <a name="l00148"></a>00148 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00149"></a>00149 <span class="comment"></span><span class="comment">// ContextObj methods //</span><span class="comment"></span> <a name="l00150"></a>00150 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00151"></a>00151 <span class="comment"></span> <a name="l00152"></a>00152 <a name="l00153"></a><a class="code" href="classCVC3_1_1ContextObj.html#a90584d2833b9fe6451dcb1379170f285">00153</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ContextObj.html#a90584d2833b9fe6451dcb1379170f285" title="Update on the given scope, on the current scope if 'scope' == -1.">ContextObj::update</a>(<span class="keywordtype">int</span> scope) <a name="l00154"></a>00154 { <a name="l00155"></a>00155 <a class="code" href="classCVC3_1_1Scope.html">Scope</a>* tmpScope = d_scope; <a name="l00156"></a>00156 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(scope < 0 || d_scope->level() <= scope, <a name="l00157"></a>00157 <span class="stringliteral">"ContextObj::update(scope="</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(scope) <a name="l00158"></a>00158 +<span class="stringliteral">"): scope < d_scope->level() = "</span> <a name="l00159"></a>00159 +<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(d_scope->level())); <a name="l00160"></a>00160 d_scope = d_scope->topScope(); <a name="l00161"></a>00161 <span class="keywordflow">if</span> (scope >= 0) { <a name="l00162"></a>00162 <span class="comment">// Fetch the specified scope</span> <a name="l00163"></a>00163 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=level(); i>scope; --i) { <a name="l00164"></a>00164 d_scope = d_scope->prevScope(); <a name="l00165"></a>00165 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(d_scope != NULL, <span class="stringliteral">"ContextObj::update["</span> <a name="l00166"></a>00166 +name()+<span class="stringliteral">"]: d_scope == NULL"</span>); <a name="l00167"></a>00167 } <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a>* data = makeCopy(getCMM()); <a name="l00170"></a>00170 data-><a class="code" href="classCVC3_1_1ContextObj.html#ab4ce4a31b6ac3e9def89503a5bbaa365" title="Last scope in which this object was modified.">d_scope</a> = tmpScope; <a name="l00171"></a>00171 <span class="comment">// The destructor of the copy should not destroy our older copies</span> <a name="l00172"></a>00172 data-><a class="code" href="classCVC3_1_1ContextObj.html#a60c1d2e2b5f4b8055a2a6619ce173bdc" title="The list of values on previous scopes; our destructor should clean up those.">d_restore</a>=NULL; <a name="l00173"></a>00173 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(data->setName(name()+<span class="stringliteral">" [copy]"</span>);) <a name="l00174"></a>00174 d_restore = <span class="keyword">new</span>(getCMM()) <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>(data, <span class="keyword">this</span>, d_restore); <a name="l00175"></a>00175 d_scope->addToChain(d_restore); <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a>00178 <a name="l00179"></a><a class="code" href="classCVC3_1_1ContextObj.html#a8da7ac98e0ec75766b617f8dc99a464f">00179</a> <a class="code" href="classCVC3_1_1ContextObj.html#a8da7ac98e0ec75766b617f8dc99a464f">ContextObj::~ContextObj</a>() <a name="l00180"></a>00180 { <a name="l00181"></a>00181 <span class="comment">// Delete our restore copies</span> <a name="l00182"></a>00182 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(<a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_active, <span class="stringliteral">"~ContextObj["</span>+name()+<span class="stringliteral">"]"</span>);) <a name="l00183"></a>00183 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(d_active=<span class="keyword">false</span>);; <a name="l00184"></a>00184 <span class="keywordflow">for</span>(<a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* obj = d_restore; obj != NULL; ) { <a name="l00185"></a>00185 <a class="code" href="classCVC3_1_1ContextObjChain.html">ContextObjChain</a>* tmp = obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a64049e510cf64e4a96d6e1134479f467" title="Pointer to the previous copy which belongs to the same master.">d_restore</a>; <a name="l00186"></a>00186 <span class="comment">// Remove the object from the restore chain</span> <a name="l00187"></a>00187 <span class="keywordflow">if</span>(obj->d_restoreChainNext != NULL) <a name="l00188"></a>00188 obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#afa940ba625d121fe37a659d7caf7f558" title="Next link in chain.">d_restoreChainNext</a>-><a class="code" href="classCVC3_1_1ContextObjChain.html#af0e39b718fff489ee96dfb6b4e59d03d" title="Pointer to the pointer of the previous object which points to us. This makes a doubly-linked list for...">d_restoreChainPrev</a> = obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#af0e39b718fff489ee96dfb6b4e59d03d" title="Pointer to the pointer of the previous object which points to us. This makes a doubly-linked list for...">d_restoreChainPrev</a>; <a name="l00189"></a>00189 *(obj->d_restoreChainPrev) = obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#afa940ba625d121fe37a659d7caf7f558" title="Next link in chain.">d_restoreChainNext</a>; <a name="l00190"></a>00190 <span class="comment">// if (obj->d_data != NULL) delete obj->d_data;</span> <a name="l00191"></a>00191 obj-><a class="code" href="classCVC3_1_1ContextObjChain.html#a3f4c203169ba7c8f1528de48fa95eedf" title="Pointer to the master object.">d_master</a> = NULL; <a name="l00192"></a>00192 if (tmp == NULL) { <a name="l00193"></a>00193 <span class="keyword">delete</span> obj; <a name="l00194"></a>00194 free(obj); <a name="l00195"></a>00195 <span class="keywordflow">break</span>; <a name="l00196"></a>00196 } <a name="l00197"></a>00197 obj = tmp; <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <span class="comment">// TRACE("context verbose", "~ContextObj()[", this, "] }");</span> <a name="l00200"></a>00200 } <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="comment"></span> <a name="l00203"></a>00203 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00204"></a>00204 <span class="comment"></span><span class="comment">// Context methods //</span><span class="comment"></span> <a name="l00205"></a>00205 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00206"></a>00206 <span class="comment"></span> <a name="l00207"></a>00207 <a name="l00208"></a><a class="code" href="classCVC3_1_1Context.html#a93f73d1a1ce706e37b0e1a76a425a7d5">00208</a> <a class="code" href="classCVC3_1_1Context.html#a93f73d1a1ce706e37b0e1a76a425a7d5">Context::Context</a>(<a class="code" href="classCVC3_1_1ContextManager.html" title="Manager for multiple contexts. Also holds current context.">ContextManager</a>* cm, <span class="keyword">const</span> <span class="keywordtype">string</span>& name, <span class="keywordtype">int</span> <span class="keywordtype">id</span>) <a name="l00209"></a>00209 : d_cm(cm), d_name(name), d_id(id) <a name="l00210"></a>00210 { <a name="l00211"></a>00211 <a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>* cmm = <span class="keyword">new</span> <a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>(); <a name="l00212"></a>00212 <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a> = <span class="keyword">new</span>(cmm) <a class="code" href="classCVC3_1_1Scope.html">Scope</a>(<span class="keyword">this</span>, cmm); <a name="l00213"></a>00213 <a class="code" href="classCVC3_1_1Context.html#ad90387cfc51d161f939a8525eac7199b">d_bottomScope</a> = <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>; <a name="l00214"></a>00214 <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">"context"</span>, <span class="stringliteral">"*** [context] Creating new context: name = "</span> <a name="l00215"></a>00215 + name + <span class="stringliteral">"id = "</span>, <span class="keywordtype">id</span>, <span class="stringliteral">""</span>); <a name="l00216"></a>00216 } <a name="l00217"></a>00217 <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="comment">// Don't pop, just delete everything. At this point, most of the</span> <a name="l00220"></a>00220 <span class="comment">// system is already destroyed, popping may be dangerous.</span> <a name="l00221"></a><a class="code" href="classCVC3_1_1Context.html#a2d34e4556448e40693f61d15e091b604">00221</a> <a class="code" href="classCVC3_1_1Context.html#a2d34e4556448e40693f61d15e091b604">Context::~Context</a>() <a name="l00222"></a>00222 { <a name="l00223"></a>00223 <span class="comment">// popto(0);</span> <a name="l00224"></a>00224 <a class="code" href="classCVC3_1_1Scope.html">Scope</a>* top = <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>; <a name="l00225"></a>00225 <span class="keywordflow">while</span>(top != NULL) { <a name="l00226"></a>00226 top = <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>-><a class="code" href="classCVC3_1_1Scope.html#aaf14b7225ee54df52812aaa7f6d08a30" title="Access functions.">prevScope</a>(); <a name="l00227"></a>00227 <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>-><a class="code" href="classCVC3_1_1Scope.html#a288d98e934b96112a131f0bbd068680f" title="Called by ~ContextManager.">finalize</a>(); <a name="l00228"></a>00228 <span class="keyword">delete</span> <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>-><a class="code" href="classCVC3_1_1Scope.html#a95900e8234970f533045827446e05e64">getCMM</a>(); <a name="l00229"></a>00229 <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a> = top; <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <span class="keywordflow">while</span> (!<a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.empty()) { <a name="l00232"></a>00232 <span class="keyword">delete</span> <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.back(); <a name="l00233"></a>00233 <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.pop_back(); <a name="l00234"></a>00234 } <a name="l00235"></a>00235 <a class="code" href="classCVC3_1_1ContextMemoryManager.html#a887d1956727aeef95a09305d6e0cee7c">ContextMemoryManager::garbageCollect</a>(); <a name="l00236"></a>00236 <span class="comment">// Erase ourselves from the notify objects, so they don't call us</span> <a name="l00237"></a>00237 <span class="keywordflow">for</span>(vector<ContextNotifyObj*>::iterator i=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.begin(), <a name="l00238"></a>00238 iend=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.end(); i!=iend; ++i) { <a name="l00239"></a>00239 (*i)->d_context = NULL; <a name="l00240"></a>00240 } <a name="l00241"></a>00241 } <a name="l00242"></a>00242 <a name="l00243"></a>00243 <a name="l00244"></a><a class="code" href="classCVC3_1_1Context.html#a10d00d7e3da0c23f0c96d37b11a2a759">00244</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Context.html#a10d00d7e3da0c23f0c96d37b11a2a759">Context::push</a>() <a name="l00245"></a>00245 { <a name="l00246"></a>00246 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00247"></a>00247 <span class="keywordtype">string</span> indentStr(<a class="code" href="classCVC3_1_1Context.html#ac93285ad9ce68c161eedf7888414bffe">level</a>(), <span class="charliteral">' '</span>); <a name="l00248"></a>00248 <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">"pushpop"</span>, indentStr, <span class="stringliteral">"Push"</span>, <span class="stringliteral">" {"</span>); <a name="l00249"></a>00249 ) <a name="l00250"></a>00250 <a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>* cmm; <a name="l00251"></a>00251 <span class="keywordflow">if</span> (!<a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.empty()) { <a name="l00252"></a>00252 cmm = <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.back(); <a name="l00253"></a>00253 <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.pop_back(); <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <span class="keywordflow">else</span> { <a name="l00256"></a>00256 cmm = <span class="keyword">new</span> <a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>(); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 cmm->push(); <a name="l00259"></a>00259 <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a> = <span class="keyword">new</span>(cmm) <a class="code" href="classCVC3_1_1Scope.html">Scope</a>(<span class="keyword">this</span>, cmm, <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>); <a name="l00260"></a>00260 <span class="comment">// TRACE("context", "*** [context] Pushing scope to level ", level(), " {");</span> <a name="l00261"></a>00261 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(DebugCounter maxLevel(debugger.counter(<span class="stringliteral">"max scope level"</span>));) <a name="l00262"></a>00262 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(<span class="keywordflow">if</span>(maxLevel<<a class="code" href="classCVC3_1_1Context.html#ac93285ad9ce68c161eedf7888414bffe">level</a>()) maxLevel=<a class="code" href="classCVC3_1_1Context.html#ac93285ad9ce68c161eedf7888414bffe">level</a>();) <a name="l00263"></a>00263 } <a name="l00264"></a>00264 <a name="l00265"></a>00265 <a name="l00266"></a><a class="code" href="classCVC3_1_1Context.html#a0563875180c9af57c96d7458c281be68">00266</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Context.html#a0563875180c9af57c96d7458c281be68">Context::pop</a>() <a name="l00267"></a>00267 { <a name="l00268"></a>00268 <a class="code" href="classCVC3_1_1Scope.html">Scope</a>* top = <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>; <a name="l00269"></a>00269 <span class="comment">// TRACE("context", "*** [context] Popping scope from level ", level(), "...");</span> <a name="l00270"></a>00270 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(top-><a class="code" href="classCVC3_1_1Scope.html#aaf14b7225ee54df52812aaa7f6d08a30" title="Access functions.">prevScope</a>() != NULL, <a name="l00271"></a>00271 <span class="stringliteral">"Illegal to pop last scope off of stack."</span>); <a name="l00272"></a>00272 <span class="comment">// Notify before popping the scope</span> <a name="l00273"></a>00273 <span class="keywordflow">for</span>(vector<ContextNotifyObj*>::iterator i=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.begin(), <a name="l00274"></a>00274 iend=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.end(); i != iend; ++i) <a name="l00275"></a>00275 (*i)->notifyPre(); <a name="l00276"></a>00276 <span class="comment">// Pop the scope</span> <a name="l00277"></a>00277 <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a> = top-><a class="code" href="classCVC3_1_1Scope.html#aaf14b7225ee54df52812aaa7f6d08a30" title="Access functions.">prevScope</a>(); <a name="l00278"></a>00278 top-><a class="code" href="group__Context.html#ga1b0a5ef8d8aef498218f0dfddea851a7" title="Restore all the values.">restore</a>(); <a name="l00279"></a>00279 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(top-><a class="code" href="classCVC3_1_1Scope.html#a796f074fbe4834687942c43b6456dabb" title="Check for memory leaks.">check</a>();) <a name="l00280"></a>00280 <a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>* cmm = top-><a class="code" href="classCVC3_1_1Scope.html#a95900e8234970f533045827446e05e64">getCMM</a>(); <a name="l00281"></a>00281 cmm-><a class="code" href="classCVC3_1_1ContextMemoryManager.html#aa5e3be22f8255467351992c64d97a7a7">pop</a>(); <a name="l00282"></a>00282 <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>.push_back(cmm); <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="comment">// Notify after the pop is done</span> <a name="l00285"></a>00285 <span class="keywordflow">for</span>(vector<ContextNotifyObj*>::iterator i=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.begin(), <a name="l00286"></a>00286 iend=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.end(); i != iend; ++i) <a name="l00287"></a>00287 (*i)->notify(); <a name="l00288"></a>00288 <span class="comment">// TRACE("context", "*** [context] Popped scope to level ", level(), "}");</span> <a name="l00289"></a>00289 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00290"></a>00290 <span class="keywordtype">string</span> indentStr(<a class="code" href="classCVC3_1_1Context.html#ac93285ad9ce68c161eedf7888414bffe">level</a>(), <span class="charliteral">' '</span>); <a name="l00291"></a>00291 <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">"pushpop"</span>, indentStr, <span class="stringliteral">"}"</span>, <span class="stringliteral">" Pop"</span>); <a name="l00292"></a>00292 ) <a name="l00293"></a>00293 } <a name="l00294"></a>00294 <a name="l00295"></a>00295 <a name="l00296"></a><a class="code" href="classCVC3_1_1Context.html#aafa05e8311b168404a73d22167ae3a55">00296</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Context.html#aafa05e8311b168404a73d22167ae3a55">Context::popto</a>(<span class="keywordtype">int</span> toLevel) <a name="l00297"></a>00297 { <a name="l00298"></a>00298 <span class="keywordflow">while</span> (toLevel < <a class="code" href="classCVC3_1_1Context.html#ab898cecdad657568057e6bf989833b35">topScope</a>()-><a class="code" href="classCVC3_1_1Scope.html#ad5c67e42cab76cf985c2aff1fab5f16e">level</a>()) <a class="code" href="classCVC3_1_1Context.html#a0563875180c9af57c96d7458c281be68">pop</a>(); <a name="l00299"></a>00299 } <a name="l00300"></a>00300 <a name="l00301"></a>00301 <a name="l00302"></a><a class="code" href="classCVC3_1_1Context.html#ac73dfb88ea87b69f3164ac95ee3d0ff7">00302</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1Context.html#ac73dfb88ea87b69f3164ac95ee3d0ff7">Context::deleteNotifyObj</a>(<a class="code" href="classCVC3_1_1ContextNotifyObj.html">ContextNotifyObj</a>* obj) { <a name="l00303"></a>00303 <span class="keywordtype">size_t</span> i(0), iend(<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.size()); <a name="l00304"></a>00304 <span class="keywordflow">for</span>(; i<iend && <a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>[i]!=obj; ++i); <a name="l00305"></a>00305 <span class="keywordflow">if</span>(i<iend) { <span class="comment">// Found obj; delete it from the vector</span> <a name="l00306"></a>00306 <a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>[i]=<a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.back(); <a name="l00307"></a>00307 <a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>.pop_back(); <a name="l00308"></a>00308 } <a name="l00309"></a>00309 } <a name="l00310"></a>00310 <a name="l00311"></a>00311 <a name="l00312"></a><a class="code" href="classCVC3_1_1Context.html#a6355931baf5aae2a0fc0e42ac87b2d3c">00312</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1Context.html#a6355931baf5aae2a0fc0e42ac87b2d3c">Context::getMemory</a>(<span class="keywordtype">int</span> verbosity) <a name="l00313"></a>00313 { <a name="l00314"></a>00314 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(<a class="code" href="classCVC3_1_1Context.html#a93f73d1a1ce706e37b0e1a76a425a7d5">Context</a>); <a name="l00315"></a>00315 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00316"></a>00316 mem += <a class="code" href="classCVC3_1_1MemoryTracker.html#add7e68c278aae046a5f5a4df50402114">MemoryTracker::getString</a>(verbosity - 1, <a class="code" href="classCVC3_1_1Context.html#a0c8783f0025ea074a884e1e3e812e0c3" title="Name of context.">d_name</a>); <a name="l00317"></a>00317 mem += <a class="code" href="classCVC3_1_1Context.html#a144c6c91ffad1f3df7f9532aaa534695" title="Pointer to top and bottom scopes of context.">d_topScope</a>-><a class="code" href="classCVC3_1_1Scope.html#a007e070f14d1158207a28293354ed106" title="Compute memory used.">getMemory</a>(verbosity - 1); <a name="l00318"></a>00318 mem += <a class="code" href="classCVC3_1_1MemoryTracker.html#a64b4a49e5d957a73f3a8f05921c65471">MemoryTracker::getVecAndDataP</a>(verbosity - 1, <a class="code" href="classCVC3_1_1Context.html#aa6bb646c4dbf761ca323a1103810f25a" title="List of objects to notify with every pop.">d_notifyObjList</a>); <a name="l00319"></a>00319 mem += <a class="code" href="classCVC3_1_1MemoryTracker.html#a64b4a49e5d957a73f3a8f05921c65471">MemoryTracker::getVecAndDataP</a>(verbosity - 1, <a class="code" href="classCVC3_1_1Context.html#a17d9c2d8a1cd6d75be47348e17ba9505" title="Stack of free ContextMemoryManager's.">d_cmmStack</a>); <a name="l00320"></a>00320 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">MemoryTracker::print</a>(<span class="stringliteral">"Context "</span>+<a class="code" href="classCVC3_1_1Context.html#a0c8783f0025ea074a884e1e3e812e0c3" title="Name of context.">d_name</a>, verbosity, memSelf, mem); <a name="l00321"></a>00321 <span class="keywordflow">return</span> mem + memSelf; <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <a name="l00324"></a>00324 <span class="comment"></span> <a name="l00325"></a>00325 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00326"></a>00326 <span class="comment"></span><span class="comment">// ContextManager methods //</span><span class="comment"></span> <a name="l00327"></a>00327 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span> <a name="l00328"></a>00328 <span class="comment"></span> <a name="l00329"></a>00329 <a name="l00330"></a><a class="code" href="classCVC3_1_1ContextManager.html#ab7127081052aede6625ea6e9b4b19299">00330</a> <a class="code" href="classCVC3_1_1ContextManager.html#ab7127081052aede6625ea6e9b4b19299">ContextManager::ContextManager</a>() <a name="l00331"></a>00331 { <a name="l00332"></a>00332 d_curContext = createContext(<span class="stringliteral">"default"</span>); <a name="l00333"></a>00333 } <a name="l00334"></a>00334 <a name="l00335"></a>00335 <a name="l00336"></a><a class="code" href="classCVC3_1_1ContextManager.html#a35f3b48747e7b3d6297571d70d2c7fb6">00336</a> <a class="code" href="classCVC3_1_1ContextManager.html#a35f3b48747e7b3d6297571d70d2c7fb6">ContextManager::~ContextManager</a>() <a name="l00337"></a>00337 { <a name="l00338"></a>00338 <span class="keywordflow">while</span> (d_contexts.size()) { <a name="l00339"></a>00339 <span class="keyword">delete</span> d_contexts.back(); <a name="l00340"></a>00340 d_contexts.pop_back(); <a name="l00341"></a>00341 } <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 <a name="l00345"></a><a class="code" href="classCVC3_1_1ContextManager.html#a0439f0d299fe5eda534af4ab4aa7141d">00345</a> <a class="code" href="classCVC3_1_1Context.html">Context</a>* <a class="code" href="classCVC3_1_1ContextManager.html#a0439f0d299fe5eda534af4ab4aa7141d">ContextManager::createContext</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& <a class="code" href="classCVC3_1_1Context.html#a7e9ab76906d4f823b1d17daf52c65846">name</a>) <a name="l00346"></a>00346 { <a name="l00347"></a>00347 d_contexts.push_back(<span class="keyword">new</span> <a class="code" href="classCVC3_1_1Context.html#a93f73d1a1ce706e37b0e1a76a425a7d5">Context</a>(<span class="keyword">this</span>, name, d_contexts.size())); <a name="l00348"></a>00348 <span class="keywordflow">return</span> d_contexts.back(); <a name="l00349"></a>00349 } <a name="l00350"></a>00350 <a name="l00351"></a>00351 <a name="l00352"></a><a class="code" href="classCVC3_1_1ContextManager.html#a988df1d478f7c3a6b3d8448a42a0f610">00352</a> <a class="code" href="classCVC3_1_1Context.html">Context</a>* <a class="code" href="classCVC3_1_1ContextManager.html#a988df1d478f7c3a6b3d8448a42a0f610">ContextManager::switchContext</a>(<a class="code" href="classCVC3_1_1Context.html">Context</a>* context) <a name="l00353"></a>00353 { <a name="l00354"></a>00354 <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(<span class="keyword">false</span>, <span class="stringliteral">"Multiple contexts not yet implemented"</span>); <a name="l00355"></a>00355 <a class="code" href="classCVC3_1_1Context.html">Context</a>* old = d_curContext; <a name="l00356"></a>00356 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(context && context == d_contexts[context-><a class="code" href="classCVC3_1_1Context.html#a6fdea8b10aa19405ddee68cfe56f3fda">id</a>()], <a name="l00357"></a>00357 <span class="stringliteral">"Unknown context"</span>); <a name="l00358"></a>00358 d_curContext = context; <a name="l00359"></a>00359 <span class="comment">// TODO: Fix up all Context Objects</span> <a name="l00360"></a>00360 <span class="keywordflow">return</span> old; <a name="l00361"></a>00361 } <a name="l00362"></a>00362 <a name="l00363"></a>00363 <a name="l00364"></a><a class="code" href="classCVC3_1_1ContextManager.html#a844fa1da4016c3381890760bac82dbc2">00364</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1Context.html#a6355931baf5aae2a0fc0e42ac87b2d3c">ContextManager::getMemory</a>(<span class="keywordtype">int</span> verbosity) <a name="l00365"></a>00365 { <a name="l00366"></a>00366 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(<a class="code" href="classCVC3_1_1ContextManager.html" title="Manager for multiple contexts. Also holds current context.">ContextManager</a>); <a name="l00367"></a>00367 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="comment">// free pages in the context memory manager need to be counted somewhere</span> <a name="l00370"></a>00370 <span class="comment">// this seems as good a place as any</span> <a name="l00371"></a>00371 mem += <a class="code" href="classCVC3_1_1ContextMemoryManager.html#ae104e086ca2d2fb2d6f04645ee98c5d7">ContextMemoryManager::getStaticMemory</a>(verbosity - 1); <a name="l00372"></a>00372 <a name="l00373"></a>00373 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < d_contexts.size(); ++i) { <a name="l00374"></a>00374 mem += d_contexts[i]->getMemory(verbosity - 1); <a name="l00375"></a>00375 } <a name="l00376"></a>00376 <a name="l00377"></a>00377 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">MemoryTracker::print</a>(<span class="stringliteral">"ContextManager"</span>, verbosity, memSelf, mem); <a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="keywordflow">return</span> mem + memSelf; <a name="l00380"></a>00380 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>