Sophie

Sophie

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

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: eval.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.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>eval.cpp</h1><a href="eval_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>
<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><a class="code" href="eval_8cpp.html#aad9cc64d45a76ba0d37c00f8cd9caa37">00021</a> <span class="preprocessor"> #define TRACE</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="eval_8hh.html" title="Interface of the block diagram evaluator.">eval.hh</a>&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="errormsg_8hh.html">errormsg.hh</a>&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="ppbox_8hh.html">ppbox.hh</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="simplify_8hh.html">simplify.hh</a>&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="propagate_8hh.html">propagate.hh</a>&quot;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &quot;<a class="code" href="patternmatcher_8hh.html">patternmatcher.hh</a>&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="signals_8hh.html">signals.hh</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &quot;<a class="code" href="xtended_8hh.html">xtended.hh</a>&quot;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &quot;<a class="code" href="loopDetector_8hh.html" title="Detect evaluation loops.">loopDetector.hh</a>&quot;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &quot;<a class="code" href="property_8hh.html">property.hh</a>&quot;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &quot;<a class="code" href="names_8hh.html" title="Interface for names management.">names.hh</a>&quot;</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00047"></a>00047 <span class="keyword">extern</span> <a class="code" href="classSourceReader.html">SourceReader</a> <a class="code" href="doc_8cpp.html#af59bae68e0652dd8c1ecbf661cbe8373">gReader</a>;
<a name="l00048"></a>00048 <span class="keyword">extern</span> <span class="keywordtype">int</span>  <a class="code" href="eval_8cpp.html#a5cc4e35ec800bd5a558fb4aeb93a592c">gMaxNameSize</a>;
<a name="l00049"></a>00049 <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a66d9e4214550a34a76936a4ccecea387">gPatternEvalMode</a>;
<a name="l00050"></a>00050 <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a80b87fb400c892e011350f61b4033589">gSimpleNames</a>;
<a name="l00051"></a>00051 <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a094486d102488d0dcefd4b040a70b51c">gSimplifyDiagrams</a>;
<a name="l00052"></a>00052 <span class="comment">// History</span>
<a name="l00053"></a>00053 <span class="comment">// 23/05/2005 : New environment management</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="comment">//-------------- prototypes ---------------------------------------------------------</span>
<a name="l00057"></a>00057 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp);
<a name="l00058"></a>00058 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00059"></a>00059 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a75a33440c37f9c17cc3934d963d02e0e" title="Eval a block diagram expression.">realeval</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00060"></a>00060 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#aa2524d1fe9427038c5a6f17fb9d82ca9" title="Eval a list of expression in reverse order.">revEvalList</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lexp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00061"></a>00061 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> fun, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg);
<a name="l00062"></a>00062 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#ac5442557b2a87fe493033e706efda21f" title="Iterate a parallel construction.">iteratePar</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> var, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00063"></a>00063 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#ae97aa34fb590ca644438444f424fce9b" title="Iterate a sequential construction.">iterateSeq</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00064"></a>00064 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a3bf9dcd6b7ee25510038adc4caad8319" title="Iterate an addition construction.">iterateSum</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00065"></a>00065 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a6d5638ac86cc3c168fe1b963a41eebd4" title="Iterate a product construction.">iterateProd</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00066"></a>00066 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg);
<a name="l00067"></a>00067 <span class="keyword">static</span> <span class="keywordtype">int</span>      <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">double</span>   <a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* l, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv);
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> ldefs, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv);
<a name="l00072"></a>00072 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a7ffa665e4f7b3e382092983e2022bc3e" title="Search the environment for the definition of a symbol ID and evaluate it.">evalIdDef</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a5cdcbf148322e2141fbda30bc40169ec" title="Eval a case expression containing a list of pattern matching rules.">evalCase</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rules, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00077"></a>00077 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#af2948c445ab2eb35a4f493b881c7c018" title="Evaluates each rule of the list.">evalRuleList</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rules, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00078"></a>00078 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a8e449962e5f7f4addd0e5a91291d88c2" title="Evaluates the list of patterns and closure the rhs.">evalRule</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rule, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00079"></a>00079 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a875de3721ef9aa963b3dd9a19541d94f" title="Evaluates each pattern of the list.">evalPatternList</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> patterns, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00080"></a>00080 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#acecb528a08d2f78b2eabc7a1468bf03c" title="Evaluates a pattern using a special mode so that free variables are wrapped into...">evalPattern</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pattern, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env);
<a name="l00081"></a>00081 
<a name="l00082"></a>00082 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">patternSimplification</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pattern);
<a name="l00083"></a>00083 <span class="keyword">static</span> <span class="keywordtype">bool</span>     <a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">isBoxNumeric</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> in, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; out);
<a name="l00084"></a>00084 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a28e3c9d91f1366233a6dfcc7f84c39bd">replaceBoxNumeric</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp);
<a name="l00085"></a>00085 
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a3bb3b3ad867f202d28310ced4b28d8ef">vec2list</a>(<span class="keyword">const</span> vector&lt;Tree&gt;&amp; v);
<a name="l00088"></a>00088 <span class="keyword">static</span> <span class="keywordtype">void</span>     <a class="code" href="eval_8cpp.html#a8f59eee8151ff777c98d0727811de61f">list2vec</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> l, vector&lt;Tree&gt;&amp; v);
<a name="l00089"></a>00089 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>     <a class="code" href="eval_8cpp.html#a941ff6f07c593501956c0e94cb1c8b79" title="Creates a list of n elements.">listn</a> (<span class="keywordtype">int</span> n, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> e);
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="comment">// Public Interface</span>
<a name="l00092"></a>00092 <span class="comment">//----------------------</span>
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 
<a name="l00102"></a><a class="code" href="eval_8hh.html#a11fbac16c4eda5f687d7aa92551039c9">00102</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a11fbac16c4eda5f687d7aa92551039c9" title="Eval &amp;quot;process&amp;quot; from a list of definitions.">evalprocess</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> eqlist)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104     <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(<a class="code" href="boxes_8cpp.html#ab32253e24dd40d91b770b381da0d35b1">boxIdent</a>(<span class="stringliteral">&quot;process&quot;</span>), <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(eqlist, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>)));
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="comment">/* Eval a documentation expression. */</span>
<a name="l00109"></a>00109 
<a name="l00110"></a><a class="code" href="eval_8hh.html#a4d1e61c6742d24447d08bddbbe341c1f">00110</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a4d1e61c6742d24447d08bddbbe341c1f">evaldocexpr</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> docexpr, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> eqlist)
<a name="l00111"></a>00111 {
<a name="l00112"></a>00112     <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(docexpr, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(eqlist, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>)));
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 <span class="comment">// Private Implementation</span>
<a name="l00118"></a>00118 <span class="comment">//------------------------</span>
<a name="l00119"></a>00119 
<a name="l00127"></a><a class="code" href="eval_8cpp.html#a76db84fd17c1d4bff80a17f6fb762553">00127</a> <a class="code" href="classproperty_3_01Tree_01_4.html">property&lt;Tree&gt;</a> <a class="code" href="eval_8cpp.html#a76db84fd17c1d4bff80a17f6fb762553" title="Transform unused (unapplied) closures into symbolic boxes.">gSymbolicBoxProperty</a>;
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a5d8fcb5307c71e0a661a59cccccfc4f5">real_a2sb</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp);
<a name="l00130"></a>00130 
<a name="l00131"></a><a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">00131</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    result;
<a name="l00134"></a>00134     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    id;
<a name="l00135"></a>00135 
<a name="l00136"></a>00136     <span class="keywordflow">if</span> (gSymbolicBoxProperty.get(exp, result)) {
<a name="l00137"></a>00137         <span class="keywordflow">return</span> result;
<a name="l00138"></a>00138     }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140     result = <a class="code" href="eval_8cpp.html#a5d8fcb5307c71e0a661a59cccccfc4f5">real_a2sb</a>(exp);
<a name="l00141"></a>00141     <span class="keywordflow">if</span> (result != exp &amp;&amp; <a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(exp, <span class="keywordtype">id</span>)) {
<a name="l00142"></a>00142         <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(result, <span class="keywordtype">id</span>);     <span class="comment">// propagate definition name property when needed</span>
<a name="l00143"></a>00143     }
<a name="l00144"></a>00144     gSymbolicBoxProperty.set(exp, result);
<a name="l00145"></a>00145     <span class="keywordflow">return</span> result;
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="eval_8cpp.html#a1b4d6eef2c09e14d0fcd95f1c0acce82">00148</a> <span class="keyword">static</span> <span class="keywordtype">int</span>  <a class="code" href="eval_8cpp.html#a1b4d6eef2c09e14d0fcd95f1c0acce82" title="counter for unique slot number">gBoxSlotNumber</a> = 0;     
<a name="l00149"></a>00149 
<a name="l00150"></a><a class="code" href="eval_8cpp.html#a5d8fcb5307c71e0a661a59cccccfc4f5">00150</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a5d8fcb5307c71e0a661a59cccccfc4f5">real_a2sb</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp)
<a name="l00151"></a>00151 {
<a name="l00152"></a>00152     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> abstr, visited, unusedEnv, localValEnv, var, <a class="code" href="symbol_8hh.html#a8243134fbbd9d924ebbb3f833922e310" title="Returns the name of a symbol.">name</a>, body;
<a name="l00153"></a>00153 
<a name="l00154"></a>00154     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a06b09fa05baf1a2567fb4aae3d1ce544">isClosure</a>(exp, abstr, unusedEnv, visited, localValEnv)) {
<a name="l00155"></a>00155 
<a name="l00156"></a>00156         <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a15452e8c3476a87963f8a52cb1e905db">isBoxIdent</a>(abstr)) {
<a name="l00157"></a>00157             <span class="comment">// special case introduced with access and components</span>
<a name="l00158"></a>00158             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> result = <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(abstr, visited, localValEnv));
<a name="l00159"></a>00159 
<a name="l00160"></a>00160             <span class="comment">// propagate definition name property when needed</span>
<a name="l00161"></a>00161             <span class="keywordflow">if</span> (<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(exp, name))  <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(result, name);
<a name="l00162"></a>00162             <span class="keywordflow">return</span> result;
<a name="l00163"></a>00163 
<a name="l00164"></a>00164         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab0b15f29743df4080b8b1c38e64a2cc1">isBoxAbstr</a>(abstr, var, body)) {
<a name="l00165"></a>00165             <span class="comment">// Here we have remaining abstraction that we will try to </span>
<a name="l00166"></a>00166             <span class="comment">// transform in a symbolic box by applying it to a slot</span>
<a name="l00167"></a>00167 
<a name="l00168"></a>00168             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> slot = <a class="code" href="boxes_8cpp.html#a25d857ff11c486793e99095d26ed36ba">boxSlot</a>(++<a class="code" href="eval_8cpp.html#a1b4d6eef2c09e14d0fcd95f1c0acce82" title="counter for unique slot number">gBoxSlotNumber</a>); 
<a name="l00169"></a>00169             stringstream s; s &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(var);
<a name="l00170"></a>00170             <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(slot, s.str() ); <span class="comment">// ajout YO</span>
<a name="l00171"></a>00171             
<a name="l00172"></a>00172             <span class="comment">// Apply the abstraction to the slot</span>
<a name="l00173"></a>00173             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> result = <a class="code" href="boxes_8cpp.html#a2df8043d88f55391102ea7878a0a9b5e">boxSymbolic</a>(slot, <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(var, slot, localValEnv))));
<a name="l00174"></a>00174 
<a name="l00175"></a>00175             <span class="comment">// propagate definition name property when needed</span>
<a name="l00176"></a>00176             <span class="keywordflow">if</span> (<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(exp, name)) <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(result, name);
<a name="l00177"></a>00177             <span class="keywordflow">return</span> result;
<a name="l00178"></a>00178 
<a name="l00179"></a>00179         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a37fc5c4fbb1931425e6bfe12f637ee87">isBoxEnvironment</a>(abstr)) {
<a name="l00180"></a>00180             <span class="keywordflow">return</span> abstr;
<a name="l00181"></a>00181     
<a name="l00182"></a>00182         } <span class="keywordflow">else</span> {
<a name="l00183"></a>00183             <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a>(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, -1, <span class="stringliteral">&quot; a2sb : internal error : not an abstraction inside closure &quot;</span>, exp);
<a name="l00184"></a>00184             exit(1);
<a name="l00185"></a>00185         }
<a name="l00186"></a>00186         
<a name="l00187"></a>00187     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a23a555bb65c1a6a4af53c7c1f24ff124">isBoxPatternMatcher</a>(exp)) {
<a name="l00188"></a>00188         <span class="comment">// Here we have remaining PM rules that we will try to </span>
<a name="l00189"></a>00189         <span class="comment">// transform in a symbolic box by applying it to a slot</span>
<a name="l00190"></a>00190         
<a name="l00191"></a>00191         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> slot = <a class="code" href="boxes_8cpp.html#a25d857ff11c486793e99095d26ed36ba">boxSlot</a>(++<a class="code" href="eval_8cpp.html#a1b4d6eef2c09e14d0fcd95f1c0acce82" title="counter for unique slot number">gBoxSlotNumber</a>);          
<a name="l00192"></a>00192         stringstream s; s &lt;&lt; <span class="stringliteral">&quot;PM&quot;</span> &lt;&lt; <a class="code" href="eval_8cpp.html#a1b4d6eef2c09e14d0fcd95f1c0acce82" title="counter for unique slot number">gBoxSlotNumber</a>;
<a name="l00193"></a>00193         <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(slot, s.str() ); 
<a name="l00194"></a>00194         
<a name="l00195"></a>00195         <span class="comment">// apply the PM rules to the slot and transfoms the result in a symbolic box</span>
<a name="l00196"></a>00196         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> result = <a class="code" href="boxes_8cpp.html#a2df8043d88f55391102ea7878a0a9b5e">boxSymbolic</a>(slot, <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(<a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a>(exp, <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(slot,<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>))));
<a name="l00197"></a>00197 
<a name="l00198"></a>00198         <span class="comment">// propagate definition name property when needed</span>
<a name="l00199"></a>00199         <span class="keywordflow">if</span> (<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(exp, name)) <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(result, name);
<a name="l00200"></a>00200         <span class="keywordflow">return</span> result;
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     } <span class="keywordflow">else</span> {
<a name="l00203"></a>00203         <span class="comment">// it is a constructor : transform each branches</span>
<a name="l00204"></a>00204         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    ar = exp-&gt;<a class="code" href="classCTree.html#a68f2be5e845407bc956a2893fe6f0d03" title="return the number of branches (subtrees) of a tree">arity</a>();
<a name="l00205"></a>00205         <a class="code" href="tree_8hh.html#ad425127c677ce9f82f03e6dc57a87937">tvec</a>            B(ar);
<a name="l00206"></a>00206         <span class="keywordtype">bool</span>            modified = <span class="keyword">false</span>;
<a name="l00207"></a>00207         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; ar; i++) {
<a name="l00208"></a>00208             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> b = exp-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(i);
<a name="l00209"></a>00209             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> m = <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(b);
<a name="l00210"></a>00210             B[i] = m;
<a name="l00211"></a>00211             <span class="keywordflow">if</span> (b != m) modified=<span class="keyword">true</span>;
<a name="l00212"></a>00212         }
<a name="l00213"></a>00213         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> r = (modified) ? <a class="code" href="classCTree.html#a3184c572cef05308f59e36ea2bdf537e" title="return a new tree or an existing equivalent one">CTree::make</a>(exp-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>(), B) : exp;
<a name="l00214"></a>00214         <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#a094486d102488d0dcefd4b040a70b51c">gSimplifyDiagrams</a>) {
<a name="l00215"></a>00215             <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a28e3c9d91f1366233a6dfcc7f84c39bd">replaceBoxNumeric</a>(r);
<a name="l00216"></a>00216         } <span class="keywordflow">else</span> {
<a name="l00217"></a>00217             <span class="keywordflow">return</span> r;
<a name="l00218"></a>00218         }
<a name="l00219"></a>00219 <span class="comment">/*</span>
<a name="l00220"></a>00220 <span class="comment">        if (modified) {</span>
<a name="l00221"></a>00221 <span class="comment">        return replaceBoxNumeric(CTree::make(exp-&gt;node(), exp-&gt;arity(), B));*/</span>
<a name="l00222"></a>00222     }
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 
<a name="l00225"></a><a class="code" href="eval_8cpp.html#ad1278031fff62c93e2dc951d5c79e426">00225</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#ad1278031fff62c93e2dc951d5c79e426">autoName</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp , <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; <span class="keywordtype">id</span>)
<a name="l00226"></a>00226 {
<a name="l00227"></a>00227     stringstream s; s &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(exp);
<a name="l00228"></a>00228     <span class="keywordtype">id</span> = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(s.str().c_str());
<a name="l00229"></a>00229     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00230"></a>00230 }
<a name="l00231"></a>00231 
<a name="l00232"></a><a class="code" href="eval_8cpp.html#a4930bc14e0b4ef0d2842f0e19d88372e">00232</a> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a4930bc14e0b4ef0d2842f0e19d88372e">getArgName</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; <span class="keywordtype">id</span>)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234     <span class="comment">//return getDefNameProperty(t, id) || autoName(t, id) ;</span>
<a name="l00235"></a>00235     <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#ad1278031fff62c93e2dc951d5c79e426">autoName</a>(t, <span class="keywordtype">id</span>) ;
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237 
<a name="l00238"></a>00238 
<a name="l00239"></a>00239 
<a name="l00249"></a>00249 <span class="keyword">static</span> <a class="code" href="classloopDetector.html">loopDetector</a> <a class="code" href="eval_8cpp.html#aa1f5839eaa9610fd250d7ec81c7d4cf7" title="Eval a block diagram expression.">LD</a>(1024, 1);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 <span class="keyword">static</span> <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a> <a class="code" href="eval_8cpp.html#a8a392881f6eeeab76bbca31a6e26d62d">EVALPROPERTY</a>(<a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a>(<span class="stringliteral">&quot;EvalProperty&quot;</span>));
<a name="l00253"></a>00253 
<a name="l00259"></a><a class="code" href="eval_8cpp.html#af2f59569f1996745dd35a362ec1d66f7">00259</a> <span class="keywordtype">void</span> <a class="code" href="eval_8cpp.html#af2f59569f1996745dd35a362ec1d66f7" title="set the type annotation of sig">setEvalProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> box, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> value)
<a name="l00260"></a>00260 {
<a name="l00261"></a>00261     <span class="comment">//cerr &lt;&lt; &quot;setSigType(&quot; &lt;&lt; *sig &lt;&lt; &quot;, &quot; &lt;&lt; t &lt;&lt; &quot;)&quot; &lt;&lt; endl;</span>
<a name="l00262"></a>00262     <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(box, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#a8a392881f6eeeab76bbca31a6e26d62d">EVALPROPERTY</a>,env), value);
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264 
<a name="l00265"></a>00265 
<a name="l00273"></a><a class="code" href="eval_8cpp.html#a3fe856701802a67ed3bc58c0b7f024ee">00273</a> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a3fe856701802a67ed3bc58c0b7f024ee" title="retrieve the value of box in the environment env">getEvalProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> box, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; value)
<a name="l00274"></a>00274 {
<a name="l00275"></a>00275     <span class="keywordflow">return</span> <a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(box, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#a8a392881f6eeeab76bbca31a6e26d62d">EVALPROPERTY</a>,env), value);
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277 
<a name="l00278"></a>00278 
<a name="l00279"></a><a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">00279</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00280"></a>00280 {
<a name="l00281"></a>00281     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    id;
<a name="l00282"></a>00282     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    result;
<a name="l00283"></a>00283     
<a name="l00284"></a>00284     <a class="code" href="eval_8cpp.html#aa1f5839eaa9610fd250d7ec81c7d4cf7" title="Eval a block diagram expression.">LD</a>.<a class="code" href="classloopDetector.html#abfc1f154b059a4994891882b3d481796">detect</a>(<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(exp,localValEnv));
<a name="l00285"></a>00285     
<a name="l00286"></a>00286     <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#a3fe856701802a67ed3bc58c0b7f024ee" title="retrieve the value of box in the environment env">getEvalProperty</a>(exp, localValEnv, result)) {
<a name="l00287"></a>00287         result = <a class="code" href="eval_8cpp.html#a75a33440c37f9c17cc3934d963d02e0e" title="Eval a block diagram expression.">realeval</a>(exp, visited, localValEnv);
<a name="l00288"></a>00288         <a class="code" href="eval_8cpp.html#af2f59569f1996745dd35a362ec1d66f7" title="set the type annotation of sig">setEvalProperty</a>(exp, localValEnv, result);
<a name="l00289"></a>00289         
<a name="l00290"></a>00290         
<a name="l00291"></a>00291         
<a name="l00292"></a>00292         <span class="keywordflow">if</span> (<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(exp, <span class="keywordtype">id</span>)) {
<a name="l00293"></a>00293             <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(result, <span class="keywordtype">id</span>);     <span class="comment">// propagate definition name property </span>
<a name="l00294"></a>00294         }
<a name="l00295"></a>00295     }
<a name="l00296"></a>00296     <span class="keywordflow">return</span> result;
<a name="l00297"></a>00297 }
<a name="l00298"></a>00298 
<a name="l00309"></a><a class="code" href="eval_8cpp.html#a75a33440c37f9c17cc3934d963d02e0e">00309</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a75a33440c37f9c17cc3934d963d02e0e" title="Eval a block diagram expression.">realeval</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00310"></a>00310 {
<a name="l00311"></a>00311     <span class="comment">//Tree  def;</span>
<a name="l00312"></a>00312     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    fun;
<a name="l00313"></a>00313     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    arg;
<a name="l00314"></a>00314     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    var, <a class="code" href="classnum.html">num</a>, body, ldef;
<a name="l00315"></a>00315     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    label;
<a name="l00316"></a>00316     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    cur, lo, hi, step;
<a name="l00317"></a>00317     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    e1, e2, exp2, notused, visited2, lenv2;
<a name="l00318"></a>00318     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    rules;
<a name="l00319"></a>00319     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    id;
<a name="l00320"></a>00320 
<a name="l00321"></a>00321     <span class="comment">//cerr &lt;&lt; &quot;EVAL &quot; &lt;&lt; *exp &lt;&lt; &quot; (visited : &quot; &lt;&lt; *visited &lt;&lt; &quot;)&quot; &lt;&lt; endl;</span>
<a name="l00322"></a>00322     <span class="comment">//cerr &lt;&lt; &quot;REALEVAL of &quot; &lt;&lt; boxpp(exp) &lt;&lt; endl;</span>
<a name="l00323"></a>00323     
<a name="l00324"></a>00324     <a class="code" href="classxtended.html">xtended</a>* xt = (<a class="code" href="classxtended.html">xtended</a>*) <a class="code" href="symbol_8hh.html#a603fcb6c07eacf2688c2a8470637d0ff" title="Returns user data.">getUserData</a>(exp);
<a name="l00325"></a>00325 
<a name="l00326"></a>00326 
<a name="l00327"></a>00327     <span class="comment">// constants</span>
<a name="l00328"></a>00328     <span class="comment">//-----------</span>
<a name="l00329"></a>00329     
<a name="l00330"></a>00330     <span class="keywordflow">if</span> (    xt || 
<a name="l00331"></a>00331             <a class="code" href="boxes_8cpp.html#a7904414896442fcfa0947156b6563d52">isBoxInt</a>(exp) || <a class="code" href="boxes_8cpp.html#a292a68d93ea73f703bc880cca4d01bc2">isBoxReal</a>(exp) || 
<a name="l00332"></a>00332             <a class="code" href="boxes_8cpp.html#ac32713127f8c8c3cb26e28a31580b257">isBoxWire</a>(exp) || <a class="code" href="boxes_8cpp.html#acf54df78e7e909644907619a03b3f695">isBoxCut</a>(exp) ||
<a name="l00333"></a>00333             <a class="code" href="boxes_8cpp.html#af6596889fd117b00a85ca9ee837f2988">isBoxPrim0</a>(exp) || <a class="code" href="boxes_8cpp.html#a261369dc82c96fbfa1978859ca4cf2e3">isBoxPrim1</a>(exp) || 
<a name="l00334"></a>00334             <a class="code" href="boxes_8cpp.html#a9c79105875b22a5b09a0b6f768375d09">isBoxPrim2</a>(exp) || <a class="code" href="boxes_8cpp.html#a826142cbc8a1a762612f22273303794e">isBoxPrim3</a>(exp) || 
<a name="l00335"></a>00335             <a class="code" href="boxes_8cpp.html#a5cae175b6153210d76c153feb2af908c">isBoxPrim4</a>(exp) || <a class="code" href="boxes_8cpp.html#aba4a65a9f30e78759da0796c55b13e8e">isBoxPrim5</a>(exp) ||
<a name="l00336"></a>00336             <a class="code" href="boxes_8cpp.html#a70f7ab7aecc722355d6096ca89a7658f">isBoxFFun</a>(exp) || <a class="code" href="boxes_8cpp.html#a8744a0451eacde8e56290b3fd74bc0b1">isBoxFConst</a>(exp) || <a class="code" href="boxes_8cpp.html#aed6793582932079092255c2643b45f91">isBoxFVar</a>(exp) ) {
<a name="l00337"></a>00337         <span class="keywordflow">return</span> exp;
<a name="l00338"></a>00338 
<a name="l00339"></a>00339     <span class="comment">// block-diagram constructors</span>
<a name="l00340"></a>00340     <span class="comment">//---------------------------</span>
<a name="l00341"></a>00341     
<a name="l00342"></a>00342     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="boxes_8cpp.html#ad7c79f7a1c0aa3109ab0548e59194d48">isBoxSeq</a>(exp, e1, e2) ) {
<a name="l00343"></a>00343         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e1, visited, localValEnv), <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e2, visited, localValEnv));
<a name="l00344"></a>00344 
<a name="l00345"></a>00345     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="boxes_8cpp.html#a8a24d365092cfdabb32218ab8e446dc6">isBoxPar</a>(exp, e1, e2) ) {
<a name="l00346"></a>00346         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a9d0633a71eaa42ce8af4decc9e172321">boxPar</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e1, visited, localValEnv), <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e2, visited, localValEnv));
<a name="l00347"></a>00347 
<a name="l00348"></a>00348     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="boxes_8cpp.html#a97de4dc9680e2d0820a5d1d18255fa35">isBoxRec</a>(exp, e1, e2) ) {
<a name="l00349"></a>00349         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#aa52c8bd74ff76718393d955dce780197">boxRec</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e1, visited, localValEnv), <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e2, visited, localValEnv));
<a name="l00350"></a>00350 
<a name="l00351"></a>00351     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="boxes_8cpp.html#a654a2a97bdc734448e669899976bdbd0">isBoxSplit</a>(exp, e1, e2) ) {
<a name="l00352"></a>00352         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a62c680e700c94c5738513b2f79af180a">boxSplit</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e1, visited, localValEnv), <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e2, visited, localValEnv));
<a name="l00353"></a>00353 
<a name="l00354"></a>00354     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="boxes_8cpp.html#a7b7d0ce5bacf1a799517f7b50dfe7a3e">isBoxMerge</a>(exp, e1, e2) ) {
<a name="l00355"></a>00355         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a748692b443f7f0b37e7f0f63dc98be4a">boxMerge</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e1, visited, localValEnv), <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(e2, visited, localValEnv));
<a name="l00356"></a>00356         
<a name="l00357"></a>00357     <span class="comment">// Modules</span>
<a name="l00358"></a>00358     <span class="comment">//--------</span>
<a name="l00359"></a>00359 
<a name="l00360"></a>00360     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a342ac3176f21f2f11931cd0b004d78d3">isBoxAccess</a>(exp, body, var)) {
<a name="l00361"></a>00361         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> val = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, localValEnv);
<a name="l00362"></a>00362         <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a06b09fa05baf1a2567fb4aae3d1ce544">isClosure</a>(val, exp2, notused, visited2, lenv2)) {
<a name="l00363"></a>00363             <span class="comment">// it is a closure, we have an environment to access</span>
<a name="l00364"></a>00364             <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(<a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(var,notused,visited2,lenv2), visited, localValEnv);
<a name="l00365"></a>00365         } <span class="keywordflow">else</span> {
<a name="l00366"></a>00366             <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a>(<a class="code" href="errormsg_8cpp.html#acf26c50cd21dfe5d71dff434d53e227e">getDefFileProp</a>(exp), <a class="code" href="errormsg_8cpp.html#a3ab477cf5a9b38099d85324b47820d1b">getDefLineProp</a>(exp), <span class="stringliteral">&quot;No environment to access &quot;</span>, exp);
<a name="l00367"></a>00367             exit(1);
<a name="l00368"></a>00368         }
<a name="l00369"></a>00369 
<a name="l00370"></a>00370     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#abc1bd1c9718505ba602a6b5ed9d918b6">isBoxComponent</a>(exp, label)) {
<a name="l00371"></a>00371         <span class="keywordtype">string</span>  fname   = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00372"></a>00372         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    eqlst   = gReader.<a class="code" href="classSourceReader.html#a5c9ca766c1efb427ffdd419517775f44" title="Return the list of definitions where all imports have been expanded.">expandlist</a>(gReader.<a class="code" href="classSourceReader.html#a74a22bf0b47f7c6684999ad82f72b713" title="Return the list of definitions file contains.">getlist</a>(fname));
<a name="l00373"></a>00373         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    res     = <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(<a class="code" href="boxes_8cpp.html#ab32253e24dd40d91b770b381da0d35b1">boxIdent</a>(<span class="stringliteral">&quot;process&quot;</span>), <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(eqlst, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>));
<a name="l00374"></a>00374         <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(res, label);
<a name="l00375"></a>00375         <span class="comment">//cerr &lt;&lt; &quot;component is &quot; &lt;&lt; boxpp(res) &lt;&lt; endl;</span>
<a name="l00376"></a>00376         <span class="keywordflow">return</span> res;
<a name="l00377"></a>00377 
<a name="l00378"></a>00378     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a8a529d26442422fd10a2c1a8ed7d7044">isBoxLibrary</a>(exp, label)) {
<a name="l00379"></a>00379         <span class="keywordtype">string</span>  fname   = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00380"></a>00380         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    eqlst   = gReader.<a class="code" href="classSourceReader.html#a5c9ca766c1efb427ffdd419517775f44" title="Return the list of definitions where all imports have been expanded.">expandlist</a>(gReader.<a class="code" href="classSourceReader.html#a74a22bf0b47f7c6684999ad82f72b713" title="Return the list of definitions file contains.">getlist</a>(fname));
<a name="l00381"></a>00381         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    res     = <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(<a class="code" href="boxes_8cpp.html#a133b62e31befea771cf81e68577ac59b">boxEnvironment</a>(), <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(eqlst, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>));
<a name="l00382"></a>00382         <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(res, label);
<a name="l00383"></a>00383         <span class="comment">//cerr &lt;&lt; &quot;component is &quot; &lt;&lt; boxpp(res) &lt;&lt; endl;</span>
<a name="l00384"></a>00384         <span class="keywordflow">return</span> res;
<a name="l00385"></a>00385 
<a name="l00386"></a>00386 
<a name="l00387"></a>00387     <span class="comment">// user interface elements</span>
<a name="l00388"></a>00388     <span class="comment">//------------------------</span>
<a name="l00389"></a>00389     
<a name="l00390"></a>00390     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a83b021a73e7c4af2535efcfe0832c690">isBoxButton</a>(exp, label)) {
<a name="l00391"></a>00391         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00392"></a>00392         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00393"></a>00393         <span class="comment">//cout &lt;&lt; &quot;button label : &quot; &lt;&lt; l1 &lt;&lt; &quot; become &quot; &lt;&lt; l2 &lt;&lt; endl;</span>
<a name="l00394"></a>00394         <span class="keywordflow">return</span> ((l1 == l2) ? exp : <a class="code" href="boxes_8cpp.html#aed2a94f879bfaf62a16ac818c6a9ccf4">boxButton</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2)));
<a name="l00395"></a>00395 
<a name="l00396"></a>00396     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a635dcccb574f9a9c911b89a756126473">isBoxCheckbox</a>(exp, label)) {
<a name="l00397"></a>00397         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00398"></a>00398         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00399"></a>00399         <span class="comment">//cout &lt;&lt; &quot;check box label : &quot; &lt;&lt; l1 &lt;&lt; &quot; become &quot; &lt;&lt; l2 &lt;&lt; endl;</span>
<a name="l00400"></a>00400         <span class="keywordflow">return</span> ((l1 == l2) ? exp : <a class="code" href="boxes_8cpp.html#a713a9e3db4c41ea0372cb2d5cc9236d9">boxCheckbox</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2)));
<a name="l00401"></a>00401 
<a name="l00402"></a>00402     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a4bf55c2d9a65d986d0d19da98d14db16">isBoxVSlider</a>(exp, label, cur, lo, hi, step)) {
<a name="l00403"></a>00403         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00404"></a>00404         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00405"></a>00405         <span class="keywordflow">return</span> ( <a class="code" href="boxes_8cpp.html#a58077eabcc68d3519f757fe8a200e12b">boxVSlider</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),
<a name="l00406"></a>00406                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(cur, visited, localValEnv)),
<a name="l00407"></a>00407                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(lo, visited, localValEnv)),
<a name="l00408"></a>00408                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(hi, visited, localValEnv)),
<a name="l00409"></a>00409                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(step, visited, localValEnv))));
<a name="l00410"></a>00410 
<a name="l00411"></a>00411     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#adf3ec537a021d2a50ddc8e029d540451">isBoxHSlider</a>(exp, label, cur, lo, hi, step)) {
<a name="l00412"></a>00412         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00413"></a>00413         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00414"></a>00414         <span class="keywordflow">return</span> ( <a class="code" href="boxes_8cpp.html#a691fec078031347758ff4e100618b3aa">boxHSlider</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),
<a name="l00415"></a>00415                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(cur, visited, localValEnv)),
<a name="l00416"></a>00416                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(lo, visited, localValEnv)),
<a name="l00417"></a>00417                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(hi, visited, localValEnv)),
<a name="l00418"></a>00418                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(step, visited, localValEnv))));
<a name="l00419"></a>00419 
<a name="l00420"></a>00420     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aa135a488b7d54dcce1249f5761ab014a">isBoxNumEntry</a>(exp, label, cur, lo, hi, step)) {
<a name="l00421"></a>00421         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00422"></a>00422         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00423"></a>00423         <span class="keywordflow">return</span> (<a class="code" href="boxes_8cpp.html#a7a7c245e6177e2803fdbd4697d406833">boxNumEntry</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),
<a name="l00424"></a>00424                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(cur, visited, localValEnv)),
<a name="l00425"></a>00425                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(lo, visited, localValEnv)),
<a name="l00426"></a>00426                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(hi, visited, localValEnv)),
<a name="l00427"></a>00427                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(step, visited, localValEnv))));
<a name="l00428"></a>00428 
<a name="l00429"></a>00429     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a5643302db2568cf9eaa48fd6f7d336a9">isBoxVGroup</a>(exp, label, arg)) {
<a name="l00430"></a>00430         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00431"></a>00431         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00432"></a>00432         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#af7b9d97c17af0321c0d5fc16c119086a">boxVGroup</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),  <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(arg, visited, localValEnv) );
<a name="l00433"></a>00433 
<a name="l00434"></a>00434     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a1b73cc14722de085e72c0a008fa56af3">isBoxHGroup</a>(exp, label, arg)) {
<a name="l00435"></a>00435         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00436"></a>00436         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00437"></a>00437         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a28277e5b31c07655d3f2661009de8ba5">boxHGroup</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),  <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(arg, visited, localValEnv) );
<a name="l00438"></a>00438 
<a name="l00439"></a>00439     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a3e76d86869cc8b1df759a4bcb972cf2d">isBoxTGroup</a>(exp, label, arg)) {
<a name="l00440"></a>00440         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00441"></a>00441         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00442"></a>00442         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#aa8dae06145f9c156c31c40e325c00c2d">boxTGroup</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),  <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(arg, visited, localValEnv) );
<a name="l00443"></a>00443 
<a name="l00444"></a>00444     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aa34cc27fbf6e04a6825ba4461af2a9e0">isBoxHBargraph</a>(exp, label, lo, hi)) {
<a name="l00445"></a>00445         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00446"></a>00446         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00447"></a>00447         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ac6deb880e0ad589b32b6c38dbdce5fd2">boxHBargraph</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),
<a name="l00448"></a>00448                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(lo, visited, localValEnv)),
<a name="l00449"></a>00449                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(hi, visited, localValEnv)));
<a name="l00450"></a>00450 
<a name="l00451"></a>00451     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a1f17c731544a73f907993681b57e7461">isBoxVBargraph</a>(exp, label, lo, hi)) {
<a name="l00452"></a>00452         <span class="keyword">const</span> <span class="keywordtype">char</span>* l1 = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(label);
<a name="l00453"></a>00453         <span class="keyword">const</span> <span class="keywordtype">char</span>* l2= <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a>(l1, visited, localValEnv);
<a name="l00454"></a>00454         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a19d3c8f4a2a6a6691215e4ce9b6f30f0">boxVBargraph</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(l2),
<a name="l00455"></a>00455                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(lo, visited, localValEnv)),
<a name="l00456"></a>00456                     <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a>(hi, visited, localValEnv)));
<a name="l00457"></a>00457 
<a name="l00458"></a>00458     <span class="comment">// lambda calculus</span>
<a name="l00459"></a>00459     <span class="comment">//----------------</span>
<a name="l00460"></a>00460         
<a name="l00461"></a>00461     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a15452e8c3476a87963f8a52cb1e905db">isBoxIdent</a>(exp)) {
<a name="l00462"></a>00462         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a7ffa665e4f7b3e382092983e2022bc3e" title="Search the environment for the definition of a symbol ID and evaluate it.">evalIdDef</a>(exp, visited, localValEnv);
<a name="l00463"></a>00463 
<a name="l00464"></a>00464     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab7f1921185dc888aee8f041a96989eb3">isBoxWithLocalDef</a>(exp, body, ldef)) {
<a name="l00465"></a>00465         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(ldef, visited, localValEnv));
<a name="l00466"></a>00466     
<a name="l00467"></a>00467     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a25bfc1d2b8e1649e3f5ca468771c08f6">isBoxAppl</a>(exp, fun, arg)) {
<a name="l00468"></a>00468         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a>(   <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(fun, visited, localValEnv),
<a name="l00469"></a>00469                             <a class="code" href="eval_8cpp.html#aa2524d1fe9427038c5a6f17fb9d82ca9" title="Eval a list of expression in reverse order.">revEvalList</a>(arg, visited, localValEnv) );
<a name="l00470"></a>00470 
<a name="l00471"></a>00471     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab0b15f29743df4080b8b1c38e64a2cc1">isBoxAbstr</a>(exp)) {
<a name="l00472"></a>00472         <span class="comment">// it is an abstraction : return a closure</span>
<a name="l00473"></a>00473         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(exp, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, visited, localValEnv);
<a name="l00474"></a>00474 
<a name="l00475"></a>00475     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a37fc5c4fbb1931425e6bfe12f637ee87">isBoxEnvironment</a>(exp)) {
<a name="l00476"></a>00476         <span class="comment">// environment : return also a closure</span>
<a name="l00477"></a>00477         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(exp, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, visited, localValEnv);
<a name="l00478"></a>00478 
<a name="l00479"></a>00479     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a06b09fa05baf1a2567fb4aae3d1ce544">isClosure</a>(exp, exp2, notused, visited2, lenv2)) {
<a name="l00480"></a>00480 
<a name="l00481"></a>00481         <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab0b15f29743df4080b8b1c38e64a2cc1">isBoxAbstr</a>(exp2)) {
<a name="l00482"></a>00482             <span class="comment">// a &#39;real&#39; closure</span>
<a name="l00483"></a>00483             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(exp2, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#ae026c6267f2f51cdb483c2fd62a3f9fc">setUnion</a>(visited,visited2), lenv2);
<a name="l00484"></a>00484         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a37fc5c4fbb1931425e6bfe12f637ee87">isBoxEnvironment</a>(exp2)) {
<a name="l00485"></a>00485             <span class="comment">// a &#39;real&#39; closure</span>
<a name="l00486"></a>00486             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(exp2, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#ae026c6267f2f51cdb483c2fd62a3f9fc">setUnion</a>(visited,visited2), lenv2);
<a name="l00487"></a>00487         } <span class="keywordflow">else</span> {
<a name="l00488"></a>00488             <span class="comment">// it was a suspended evaluation</span>
<a name="l00489"></a>00489             <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(exp2, <a class="code" href="list_8cpp.html#ae026c6267f2f51cdb483c2fd62a3f9fc">setUnion</a>(visited,visited2), lenv2);
<a name="l00490"></a>00490         }
<a name="l00491"></a>00491 
<a name="l00492"></a>00492     <span class="comment">// Algorithmic constructions</span>
<a name="l00493"></a>00493     <span class="comment">//--------------------------</span>
<a name="l00494"></a>00494     
<a name="l00495"></a>00495     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aaee8867be9aa585c10a24e8bcfda8be8">isBoxIPar</a>(exp, var, num, body)) {
<a name="l00496"></a>00496         <span class="keywordtype">int</span> n = <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a>(num, visited, localValEnv);
<a name="l00497"></a>00497         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#ac5442557b2a87fe493033e706efda21f" title="Iterate a parallel construction.">iteratePar</a>(var, n, body, visited, localValEnv);
<a name="l00498"></a>00498 
<a name="l00499"></a>00499     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a941c97af1f77596438700760de8556b4">isBoxISeq</a>(exp, var, num, body)) {
<a name="l00500"></a>00500         <span class="keywordtype">int</span> n = <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a>(num, visited, localValEnv);
<a name="l00501"></a>00501         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#ae97aa34fb590ca644438444f424fce9b" title="Iterate a sequential construction.">iterateSeq</a>(var, n, body, visited, localValEnv);
<a name="l00502"></a>00502 
<a name="l00503"></a>00503     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#adb2b3be73061b6840374339d0a111dd5">isBoxISum</a>(exp, var, num, body)) {
<a name="l00504"></a>00504         <span class="keywordtype">int</span> n = <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a>(num, visited, localValEnv);
<a name="l00505"></a>00505         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a3bf9dcd6b7ee25510038adc4caad8319" title="Iterate an addition construction.">iterateSum</a>(var, n, body, visited, localValEnv);
<a name="l00506"></a>00506 
<a name="l00507"></a>00507     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ac0013317ab94b61d9e25f026316487b3">isBoxIProd</a>(exp, var, num, body)) {
<a name="l00508"></a>00508         <span class="keywordtype">int</span> n = <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a>(num, visited, localValEnv);
<a name="l00509"></a>00509         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a6d5638ac86cc3c168fe1b963a41eebd4" title="Iterate a product construction.">iterateProd</a>(var, n, body, visited, localValEnv);
<a name="l00510"></a>00510         
<a name="l00511"></a>00511     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#af4b23a35faec0884c4591ff92576c3d4">isBoxSlot</a>(exp))      { 
<a name="l00512"></a>00512         <span class="keywordflow">return</span> exp; 
<a name="l00513"></a>00513     
<a name="l00514"></a>00514     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab73899d732fd2181be3d72f28c11ab3d">isBoxSymbolic</a>(exp))  {
<a name="l00515"></a>00515      
<a name="l00516"></a>00516         <span class="keywordflow">return</span> exp;
<a name="l00517"></a>00517     
<a name="l00518"></a>00518 
<a name="l00519"></a>00519     <span class="comment">// Pattern matching extension</span>
<a name="l00520"></a>00520     <span class="comment">//---------------------------</span>
<a name="l00521"></a>00521     
<a name="l00522"></a>00522     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a345a4cfac5657c40640b503058b300f9">isBoxCase</a>(exp, rules)) {
<a name="l00523"></a>00523         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a5cdcbf148322e2141fbda30bc40169ec" title="Eval a case expression containing a list of pattern matching rules.">evalCase</a>(rules, localValEnv);
<a name="l00524"></a>00524 
<a name="l00525"></a>00525     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ad166878e0270e4eab4adf2fb5f81fc31">isBoxPatternVar</a>(exp, <span class="keywordtype">id</span>)) {
<a name="l00526"></a>00526         <span class="keywordflow">return</span> exp;
<a name="l00527"></a>00527         <span class="comment">//return evalIdDef(id, visited, localValEnv);</span>
<a name="l00528"></a>00528 
<a name="l00529"></a>00529     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a23a555bb65c1a6a4af53c7c1f24ff124">isBoxPatternMatcher</a>(exp)) {
<a name="l00530"></a>00530         <span class="keywordflow">return</span> exp;
<a name="l00531"></a>00531 
<a name="l00532"></a>00532     } <span class="keywordflow">else</span> {
<a name="l00533"></a>00533         cerr &lt;&lt; <span class="stringliteral">&quot;ERROR : EVAL don&#39;t intercept : &quot;</span> &lt;&lt; *exp &lt;&lt; endl;
<a name="l00534"></a>00534         assert(<span class="keyword">false</span>);
<a name="l00535"></a>00535     }
<a name="l00536"></a>00536 }
<a name="l00537"></a>00537 
<a name="l00538"></a>00538 <span class="comment">/* Deconstruct a (BDA) op pattern (YO). */</span>
<a name="l00539"></a>00539 
<a name="l00540"></a><a class="code" href="eval_8cpp.html#a34cbd25863b5da67208a859cd4e39bb8">00540</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a34cbd25863b5da67208a859cd4e39bb8">isBoxPatternOp</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> box, <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a>&amp; n, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; t1, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; t2)
<a name="l00541"></a>00541 {
<a name="l00542"></a>00542     <span class="keywordflow">if</span> (    <a class="code" href="boxes_8cpp.html#a8a24d365092cfdabb32218ab8e446dc6">isBoxPar</a>(box, t1, t2) ||
<a name="l00543"></a>00543             <a class="code" href="boxes_8cpp.html#ad7c79f7a1c0aa3109ab0548e59194d48">isBoxSeq</a>(box, t1, t2) ||
<a name="l00544"></a>00544             <a class="code" href="boxes_8cpp.html#a654a2a97bdc734448e669899976bdbd0">isBoxSplit</a>(box, t1, t2) ||
<a name="l00545"></a>00545             <a class="code" href="boxes_8cpp.html#a7b7d0ce5bacf1a799517f7b50dfe7a3e">isBoxMerge</a>(box, t1, t2) ||
<a name="l00546"></a>00546             <a class="code" href="boxes_8cpp.html#a97de4dc9680e2d0820a5d1d18255fa35">isBoxRec</a>(box, t1, t2)    )
<a name="l00547"></a>00547     {
<a name="l00548"></a>00548         n = box-&gt;<a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>();
<a name="l00549"></a>00549         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00550"></a>00550     } <span class="keywordflow">else</span> {
<a name="l00551"></a>00551         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00552"></a>00552     }
<a name="l00553"></a>00553 }
<a name="l00554"></a>00554 
<a name="l00555"></a>00555 
<a name="l00556"></a><a class="code" href="eval_8cpp.html#a891d06ccfa394ddeeea9480e4b5af407">00556</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a891d06ccfa394ddeeea9480e4b5af407">NUMERICPROPERTY</a> = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a>(<span class="stringliteral">&quot;NUMERICPROPERTY&quot;</span>));
<a name="l00557"></a>00557 
<a name="l00558"></a><a class="code" href="eval_8cpp.html#a5f7473c40d765c93ecad984cb9338334">00558</a> <span class="keywordtype">void</span> <a class="code" href="eval_8cpp.html#a5f7473c40d765c93ecad984cb9338334">setNumericProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="classnum.html">num</a>)
<a name="l00559"></a>00559 {
<a name="l00560"></a>00560     <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(t, NUMERICPROPERTY, num);
<a name="l00561"></a>00561 }
<a name="l00562"></a>00562 
<a name="l00563"></a><a class="code" href="eval_8cpp.html#ac91fbe8e83a3c6b44c1e699521f8d960">00563</a> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#ac91fbe8e83a3c6b44c1e699521f8d960">getNumericProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; <a class="code" href="classnum.html">num</a>)
<a name="l00564"></a>00564 {
<a name="l00565"></a>00565     <span class="keywordflow">return</span> <a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(t, NUMERICPROPERTY, num);
<a name="l00566"></a>00566 }
<a name="l00567"></a>00567 
<a name="l00568"></a>00568 
<a name="l00569"></a><a class="code" href="eval_8cpp.html#a28e3c9d91f1366233a6dfcc7f84c39bd">00569</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a28e3c9d91f1366233a6dfcc7f84c39bd">replaceBoxNumeric</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp)
<a name="l00570"></a>00570 {
<a name="l00571"></a>00571     <span class="keywordtype">int</span>     numInputs, numOutputs;
<a name="l00572"></a>00572     <span class="keywordtype">double</span>  x; 
<a name="l00573"></a>00573     <span class="keywordtype">int</span>     i;
<a name="l00574"></a>00574     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    out;
<a name="l00575"></a>00575     
<a name="l00576"></a>00576     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a7904414896442fcfa0947156b6563d52">isBoxInt</a>(exp, &amp;i) || <a class="code" href="boxes_8cpp.html#a292a68d93ea73f703bc880cca4d01bc2">isBoxReal</a>(exp, &amp;x)) {
<a name="l00577"></a>00577         <span class="keywordflow">return</span> exp;
<a name="l00578"></a>00578     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#ac91fbe8e83a3c6b44c1e699521f8d960">getNumericProperty</a>(exp, out)) {
<a name="l00579"></a>00579         <span class="keywordflow">return</span> out;
<a name="l00580"></a>00580     } <span class="keywordflow">else</span> {
<a name="l00581"></a>00581         <span class="keywordflow">if</span> ( <a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(exp, &amp;numInputs, &amp;numOutputs) &amp;&amp; (numInputs == 0) &amp;&amp; (numOutputs == 1) ) {
<a name="l00582"></a>00582             <span class="comment">// potential numerical expression</span>
<a name="l00583"></a>00583             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lsignals = <a class="code" href="propagate_8cpp.html#a2c94521fac4766648f41758d1be4b089">boxPropagateSig</a>(<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, exp , <a class="code" href="propagate_8cpp.html#a06328b74db9d4726b9144cf9da9a3a17" title="Fabrique une liste de n entrées.">makeSigInputList</a>(numInputs) );
<a name="l00584"></a>00584             assert(<a class="code" href="list_8hh.html#a8bdd73641276e0c0f999f504348eacc1">isList</a>(lsignals));
<a name="l00585"></a>00585             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lsignals));
<a name="l00586"></a>00586             <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a305497ed8593020624204f9d359743f2">isSigReal</a>(res, &amp;x))         out = <a class="code" href="boxes_8cpp.html#a8317435afefe21442cf381334d61bf58">boxReal</a>(x);
<a name="l00587"></a>00587             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a75cc925deac1e031e75ae72271dd5995">isSigInt</a>(res, &amp;i))     out = <a class="code" href="boxes_8cpp.html#add4e510a062bf67762e0ae3ac6112b81">boxInt</a>(i);
<a name="l00588"></a>00588             <span class="keywordflow">else</span> out =  exp;
<a name="l00589"></a>00589         } <span class="keywordflow">else</span> {
<a name="l00590"></a>00590             out = exp;
<a name="l00591"></a>00591         }
<a name="l00592"></a>00592         <a class="code" href="eval_8cpp.html#a5f7473c40d765c93ecad984cb9338334">setNumericProperty</a>(exp,out);
<a name="l00593"></a>00593         <span class="keywordflow">return</span> out;
<a name="l00594"></a>00594     }
<a name="l00595"></a>00595 }
<a name="l00596"></a>00596 
<a name="l00603"></a>00603 <span class="comment">/* uncomment for debugging output */</span>
<a name="l00604"></a>00604 <span class="comment">//#define DEBUG</span>
<a name="l00605"></a><a class="code" href="names_8hh.html#af924c3151bebd01af733bb0a1e39237c">00605</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a49268100cc006f566fec7f848c65d27a" title="Simplify a block-diagram pattern by computing its numerical sub-expressions.">simplifyPattern</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> value)
<a name="l00606"></a>00606 {
<a name="l00607"></a>00607     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="classnum.html">num</a>;
<a name="l00608"></a>00608     <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#ac91fbe8e83a3c6b44c1e699521f8d960">getNumericProperty</a>(value,num)) {
<a name="l00609"></a>00609         <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">isBoxNumeric</a>(value,num)) {
<a name="l00610"></a>00610             num = value;
<a name="l00611"></a>00611         }
<a name="l00612"></a>00612         <a class="code" href="eval_8cpp.html#a5f7473c40d765c93ecad984cb9338334">setNumericProperty</a>(value,num);
<a name="l00613"></a>00613     }
<a name="l00614"></a>00614     <span class="keywordflow">return</span> num;
<a name="l00615"></a>00615 }
<a name="l00616"></a>00616 
<a name="l00617"></a>00617 
<a name="l00618"></a><a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">00618</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">isBoxNumeric</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> in, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; out)
<a name="l00619"></a>00619 {
<a name="l00620"></a>00620     <span class="keywordtype">int</span>     numInputs, numOutputs;
<a name="l00621"></a>00621     <span class="keywordtype">double</span>  x; 
<a name="l00622"></a>00622     <span class="keywordtype">int</span>     i;
<a name="l00623"></a>00623     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    v;
<a name="l00624"></a>00624     
<a name="l00625"></a>00625     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a7904414896442fcfa0947156b6563d52">isBoxInt</a>(in, &amp;i) || <a class="code" href="boxes_8cpp.html#a292a68d93ea73f703bc880cca4d01bc2">isBoxReal</a>(in, &amp;x)) {
<a name="l00626"></a>00626         out = in;
<a name="l00627"></a>00627         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00628"></a>00628     } <span class="keywordflow">else</span> {
<a name="l00629"></a>00629         v = <a class="code" href="eval_8cpp.html#ab218db6f96ba6409f52548e525897685">a2sb</a>(in);
<a name="l00630"></a>00630         <span class="keywordflow">if</span> ( <a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(v, &amp;numInputs, &amp;numOutputs) &amp;&amp; (numInputs == 0) &amp;&amp; (numOutputs == 1) ) {
<a name="l00631"></a>00631             <span class="comment">// potential numerical expression</span>
<a name="l00632"></a>00632             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lsignals = <a class="code" href="propagate_8cpp.html#a2c94521fac4766648f41758d1be4b089">boxPropagateSig</a>(<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, v , <a class="code" href="propagate_8cpp.html#a06328b74db9d4726b9144cf9da9a3a17" title="Fabrique une liste de n entrées.">makeSigInputList</a>(numInputs) );
<a name="l00633"></a>00633             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lsignals));
<a name="l00634"></a>00634             <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a305497ed8593020624204f9d359743f2">isSigReal</a>(res, &amp;x))     {
<a name="l00635"></a>00635             out = <a class="code" href="boxes_8cpp.html#a8317435afefe21442cf381334d61bf58">boxReal</a>(x);
<a name="l00636"></a>00636             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00637"></a>00637             }
<a name="l00638"></a>00638             <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a75cc925deac1e031e75ae72271dd5995">isSigInt</a>(res, &amp;i))      {
<a name="l00639"></a>00639             out = <a class="code" href="boxes_8cpp.html#add4e510a062bf67762e0ae3ac6112b81">boxInt</a>(i);
<a name="l00640"></a>00640             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00641"></a>00641             }
<a name="l00642"></a>00642         } 
<a name="l00643"></a>00643         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00644"></a>00644     }
<a name="l00645"></a>00645 }
<a name="l00646"></a>00646 
<a name="l00647"></a><a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">00647</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">patternSimplification</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pattern)
<a name="l00648"></a>00648 {   
<a name="l00649"></a>00649     
<a name="l00650"></a>00650     <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a>    n(0);
<a name="l00651"></a>00651     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    v, t1, t2;
<a name="l00652"></a>00652     
<a name="l00653"></a>00653     <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">isBoxNumeric</a>(pattern, v)) {
<a name="l00654"></a>00654         <span class="keywordflow">return</span> v;
<a name="l00655"></a>00655     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#a34cbd25863b5da67208a859cd4e39bb8">isBoxPatternOp</a>(pattern, n, t1, t2)) {
<a name="l00656"></a>00656         <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(n, <a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">patternSimplification</a>(t1), <a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">patternSimplification</a>(t2));
<a name="l00657"></a>00657     } <span class="keywordflow">else</span> {
<a name="l00658"></a>00658         <span class="keywordflow">return</span> pattern;
<a name="l00659"></a>00659     }
<a name="l00660"></a>00660 }
<a name="l00661"></a>00661 
<a name="l00662"></a>00662 
<a name="l00663"></a>00663 
<a name="l00677"></a><a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d">00677</a> <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="eval_8cpp.html#ab36ee6513f6c8a138a444d1efb61535d" title="Eval a block diagram to a double.">eval2double</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00678"></a>00678 {
<a name="l00679"></a>00679     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> diagram = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(exp, visited, localValEnv);
<a name="l00680"></a>00680     <span class="keywordtype">int</span> numInputs, numOutputs;
<a name="l00681"></a>00681     <a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(diagram, &amp;numInputs, &amp;numOutputs);
<a name="l00682"></a>00682     <span class="keywordflow">if</span> ( (numInputs &gt; 0) || (numOutputs != 1) ) {
<a name="l00683"></a>00683         <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a> (<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, <a class="code" href="errormsg_8hh.html#a5e36364965360da7b7cdfc2188e0af84">yylineno</a>, <span class="stringliteral">&quot;not a constant expression of type : (0-&gt;1)&quot;</span>, exp);
<a name="l00684"></a>00684         <span class="keywordflow">return</span> 1;
<a name="l00685"></a>00685     } <span class="keywordflow">else</span> {
<a name="l00686"></a>00686         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lsignals = <a class="code" href="propagate_8cpp.html#a2c94521fac4766648f41758d1be4b089">boxPropagateSig</a>(<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, diagram , <a class="code" href="propagate_8cpp.html#a06328b74db9d4726b9144cf9da9a3a17" title="Fabrique une liste de n entrées.">makeSigInputList</a>(numInputs) );
<a name="l00687"></a>00687         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> val = <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lsignals));
<a name="l00688"></a>00688         <span class="keywordflow">return</span> <a class="code" href="tree_8cpp.html#ad01262fc04f661b162d36b786419a849" title="if t has a node of type float, return it otherwise error">tree2float</a>(val);
<a name="l00689"></a>00689     }
<a name="l00690"></a>00690 }
<a name="l00691"></a>00691 
<a name="l00692"></a>00692 
<a name="l00706"></a><a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4">00706</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> exp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00707"></a>00707 {
<a name="l00708"></a>00708     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> diagram = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(exp, visited, localValEnv);
<a name="l00709"></a>00709     <span class="keywordtype">int</span> numInputs, numOutputs;
<a name="l00710"></a>00710     <a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(diagram, &amp;numInputs, &amp;numOutputs);
<a name="l00711"></a>00711     <span class="keywordflow">if</span> ( (numInputs &gt; 0) || (numOutputs != 1) ) {
<a name="l00712"></a>00712         <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a> (<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, <a class="code" href="errormsg_8hh.html#a5e36364965360da7b7cdfc2188e0af84">yylineno</a>, <span class="stringliteral">&quot;not a constant expression of type : (0-&gt;1)&quot;</span>, exp);
<a name="l00713"></a>00713         <span class="keywordflow">return</span> 1;
<a name="l00714"></a>00714     } <span class="keywordflow">else</span> {
<a name="l00715"></a>00715         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lsignals = <a class="code" href="propagate_8cpp.html#a2c94521fac4766648f41758d1be4b089">boxPropagateSig</a>(<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, diagram , <a class="code" href="propagate_8cpp.html#a06328b74db9d4726b9144cf9da9a3a17" title="Fabrique une liste de n entrées.">makeSigInputList</a>(numInputs) );
<a name="l00716"></a>00716         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> val = <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lsignals));
<a name="l00717"></a>00717         <span class="keywordflow">return</span> <a class="code" href="tree_8cpp.html#a523bce65e2a281fe678f2362496061cf" title="if t has a node of type int, return it otherwise error">tree2int</a>(val);
<a name="l00718"></a>00718     }
<a name="l00719"></a>00719 }
<a name="l00720"></a>00720 
<a name="l00721"></a><a class="code" href="eval_8cpp.html#ae1b5cede7d59af2a39a5f9746a137bad">00721</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#ae1b5cede7d59af2a39a5f9746a137bad">isDigitChar</a>(<span class="keywordtype">char</span> c)
<a name="l00722"></a>00722 {
<a name="l00723"></a>00723     <span class="keywordflow">return</span> (c &gt;= <span class="charliteral">&#39;0&#39;</span>) &amp; (c &lt;= <span class="charliteral">&#39;9&#39;</span>);
<a name="l00724"></a>00724 }
<a name="l00725"></a>00725 
<a name="l00726"></a><a class="code" href="eval_8cpp.html#aef4a1fe7a15ef5ff599a2c16f93dbfe2">00726</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#aef4a1fe7a15ef5ff599a2c16f93dbfe2">isIdentChar</a>(<span class="keywordtype">char</span> c)
<a name="l00727"></a>00727 {
<a name="l00728"></a>00728     <span class="keywordflow">return</span> ((c &gt;= <span class="charliteral">&#39;a&#39;</span>) &amp; (c &lt;= <span class="charliteral">&#39;z&#39;</span>)) || ((c &gt;= <span class="charliteral">&#39;A&#39;</span>) &amp; (c &lt;= <span class="charliteral">&#39;Z&#39;</span>)) || ((c &gt;= <span class="charliteral">&#39;0&#39;</span>) &amp; (c &lt;= <span class="charliteral">&#39;9&#39;</span>)) || (c == <span class="charliteral">&#39;_&#39;</span>);
<a name="l00729"></a>00729 }
<a name="l00730"></a>00730 
<a name="l00731"></a><a class="code" href="eval_8cpp.html#a584131cdbd3c48ec511ea356cd8ad758">00731</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="eval_8cpp.html#a584131cdbd3c48ec511ea356cd8ad758">Formats</a> [] = {<span class="stringliteral">&quot;%d&quot;</span>, <span class="stringliteral">&quot;%1d&quot;</span>, <span class="stringliteral">&quot;%2d&quot;</span>, <span class="stringliteral">&quot;%3d&quot;</span>, <span class="stringliteral">&quot;%4d&quot;</span>};
<a name="l00732"></a>00732 
<a name="l00733"></a><a class="code" href="eval_8cpp.html#ae106abf4929388b29a8830c45815fb09">00733</a> <span class="keyword">static</span> <span class="keywordtype">char</span>* <a class="code" href="eval_8cpp.html#ae106abf4929388b29a8830c45815fb09">writeIdentValue</a>(<span class="keywordtype">char</span>* dst, <span class="keywordtype">int</span> format, <span class="keyword">const</span> <span class="keywordtype">char</span>* ident, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00734"></a>00734 {
<a name="l00735"></a>00735     <span class="keywordtype">int</span> n = <a class="code" href="eval_8cpp.html#a0b41b21215490ad8136097a8289cf2f4" title="Eval a block diagram to an int.">eval2int</a>(<a class="code" href="boxes_8cpp.html#ab32253e24dd40d91b770b381da0d35b1">boxIdent</a>(ident), visited, localValEnv);
<a name="l00736"></a>00736     <span class="keywordtype">int</span> i = <a class="code" href="interval_8hh.html#a2f8edc4561e9744ed4233b205fa7ec32">min</a>(4,<a class="code" href="interval_8hh.html#a1c45761573e6cbc97cfacac78d905016">max</a>(format,0));
<a name="l00737"></a>00737     
<a name="l00738"></a>00738     <span class="keywordflow">return</span> dst + sprintf(dst, Formats[i], n);
<a name="l00739"></a>00739 }
<a name="l00740"></a>00740 
<a name="l00741"></a><a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">00741</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="eval_8cpp.html#a0c7bbcb225a78133217924ac8d09ea60">evalLabel</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* label, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00742"></a>00742 {
<a name="l00743"></a>00743     <span class="keywordtype">char</span>        res[2000];
<a name="l00744"></a>00744     <span class="keywordtype">char</span>        ident[64];
<a name="l00745"></a>00745 
<a name="l00746"></a>00746     <span class="keyword">const</span> <span class="keywordtype">char</span>* src = &amp;label[0];
<a name="l00747"></a>00747     <span class="keywordtype">char</span>*       dst = &amp;res[0];
<a name="l00748"></a>00748     <span class="keywordtype">char</span>*       <span class="keywordtype">id</span>  = &amp;ident[0];
<a name="l00749"></a>00749 
<a name="l00750"></a>00750     <span class="keywordtype">bool</span>        parametric = <span class="keyword">false</span>;
<a name="l00751"></a>00751     <span class="keywordtype">int</span>         state = 0; <span class="keywordtype">int</span> format = 0;
<a name="l00752"></a>00752     <span class="keywordtype">char</span>        c;
<a name="l00753"></a>00753 
<a name="l00754"></a>00754     <span class="keywordflow">while</span> ((c=*src++)) {
<a name="l00755"></a>00755         <span class="keywordflow">if</span> (state == 0) {
<a name="l00756"></a>00756             <span class="comment">// outside ident mode</span>
<a name="l00757"></a>00757             <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;%&#39;</span>) {
<a name="l00758"></a>00758                 <span class="comment">// look ahead for next char</span>
<a name="l00759"></a>00759                 <span class="keywordflow">if</span> (*src == <span class="charliteral">&#39;%&#39;</span>) {
<a name="l00760"></a>00760                     *dst++ = *src++;        <span class="comment">// copy escape char and skip one char</span>
<a name="l00761"></a>00761                 } <span class="keywordflow">else</span> {
<a name="l00762"></a>00762                     state = 1;              <span class="comment">// prepare ident mode</span>
<a name="l00763"></a>00763                     format = 0;
<a name="l00764"></a>00764                     parametric = <span class="keyword">true</span>;
<a name="l00765"></a>00765                     <span class="keywordtype">id</span>  = &amp;ident[0];
<a name="l00766"></a>00766                 }
<a name="l00767"></a>00767             } <span class="keywordflow">else</span> {
<a name="l00768"></a>00768                 *dst++ = c;                 <span class="comment">// copy char</span>
<a name="l00769"></a>00769             }
<a name="l00770"></a>00770         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (state == 1) {
<a name="l00771"></a>00771             <span class="comment">// read the format </span>
<a name="l00772"></a>00772             <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#ae1b5cede7d59af2a39a5f9746a137bad">isDigitChar</a>(c)) {
<a name="l00773"></a>00773                 format = format*10 + (c-<span class="charliteral">&#39;0&#39;</span>);
<a name="l00774"></a>00774             } <span class="keywordflow">else</span> {
<a name="l00775"></a>00775                 state = 2;
<a name="l00776"></a>00776                 --src; <span class="comment">// unread !!!</span>
<a name="l00777"></a>00777             }
<a name="l00778"></a>00778 
<a name="l00779"></a>00779         } <span class="keywordflow">else</span> {
<a name="l00780"></a>00780             
<a name="l00781"></a>00781             <span class="comment">// within ident mode</span>
<a name="l00782"></a>00782             <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#aef4a1fe7a15ef5ff599a2c16f93dbfe2">isIdentChar</a>(c)) {
<a name="l00783"></a>00783                 *<span class="keywordtype">id</span>++ = c;
<a name="l00784"></a>00784             } <span class="keywordflow">else</span> {
<a name="l00785"></a>00785                 *<span class="keywordtype">id</span> = 0;
<a name="l00786"></a>00786                 dst = <a class="code" href="eval_8cpp.html#ae106abf4929388b29a8830c45815fb09">writeIdentValue</a>(dst, format, ident, visited, localValEnv);
<a name="l00787"></a>00787                 state = 0;
<a name="l00788"></a>00788                 src -= 1;
<a name="l00789"></a>00789             }
<a name="l00790"></a>00790         }
<a name="l00791"></a>00791     }
<a name="l00792"></a>00792 
<a name="l00793"></a>00793     <span class="keywordflow">if</span> (state == 2) {
<a name="l00794"></a>00794         *<span class="keywordtype">id</span> = 0;
<a name="l00795"></a>00795         dst = <a class="code" href="eval_8cpp.html#ae106abf4929388b29a8830c45815fb09">writeIdentValue</a>(dst, format, ident, visited, localValEnv);
<a name="l00796"></a>00796     }
<a name="l00797"></a>00797     *dst = 0;
<a name="l00798"></a>00798     <span class="keywordflow">return</span> (parametric) ? strdup(res) : label;
<a name="l00799"></a>00799 }
<a name="l00800"></a>00800 
<a name="l00801"></a>00801 
<a name="l00802"></a>00802 
<a name="l00816"></a><a class="code" href="eval_8cpp.html#ac5442557b2a87fe493033e706efda21f">00816</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#ac5442557b2a87fe493033e706efda21f" title="Iterate a parallel construction.">iteratePar</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00817"></a>00817 {
<a name="l00818"></a>00818     assert (num&gt;0);
<a name="l00819"></a>00819 
<a name="l00820"></a>00820     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(0), localValEnv));
<a name="l00821"></a>00821     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; num; i++) {
<a name="l00822"></a>00822         res = <a class="code" href="boxes_8cpp.html#a9d0633a71eaa42ce8af4decc9e172321">boxPar</a>(res, <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(i), localValEnv)));
<a name="l00823"></a>00823     }
<a name="l00824"></a>00824 
<a name="l00825"></a>00825     <span class="keywordflow">return</span> res;
<a name="l00826"></a>00826 }
<a name="l00827"></a>00827 
<a name="l00828"></a>00828 
<a name="l00829"></a>00829 
<a name="l00842"></a><a class="code" href="eval_8cpp.html#ae97aa34fb590ca644438444f424fce9b">00842</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#ae97aa34fb590ca644438444f424fce9b" title="Iterate a sequential construction.">iterateSeq</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00843"></a>00843 {
<a name="l00844"></a>00844     assert (num&gt;0);
<a name="l00845"></a>00845 
<a name="l00846"></a>00846     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(0), localValEnv));
<a name="l00847"></a>00847 
<a name="l00848"></a>00848     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; num; i++) {
<a name="l00849"></a>00849         res = <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(res, <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(i), localValEnv)));
<a name="l00850"></a>00850     }
<a name="l00851"></a>00851 
<a name="l00852"></a>00852     <span class="keywordflow">return</span> res;
<a name="l00853"></a>00853 }
<a name="l00854"></a>00854 
<a name="l00855"></a>00855 
<a name="l00856"></a>00856 
<a name="l00870"></a><a class="code" href="eval_8cpp.html#a3bf9dcd6b7ee25510038adc4caad8319">00870</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a3bf9dcd6b7ee25510038adc4caad8319" title="Iterate an addition construction.">iterateSum</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00871"></a>00871 {
<a name="l00872"></a>00872     assert (num&gt;0);
<a name="l00873"></a>00873 
<a name="l00874"></a>00874     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(0), localValEnv));
<a name="l00875"></a>00875 
<a name="l00876"></a>00876     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; num; i++) {
<a name="l00877"></a>00877         res = <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="boxes_8cpp.html#a9d0633a71eaa42ce8af4decc9e172321">boxPar</a>(res, <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(i), localValEnv))),<a class="code" href="boxes_8cpp.html#af5b10ed7352e45d75eff6110e04b64a1">boxPrim2</a>(<a class="code" href="signals_8hh.html#ab914de7e6da0eea04636dd51ad35240a">sigAdd</a>)) ;
<a name="l00878"></a>00878     }
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     <span class="keywordflow">return</span> res;
<a name="l00881"></a>00881 }
<a name="l00882"></a>00882 
<a name="l00883"></a>00883 
<a name="l00884"></a>00884 
<a name="l00898"></a><a class="code" href="eval_8cpp.html#a6d5638ac86cc3c168fe1b963a41eebd4">00898</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a6d5638ac86cc3c168fe1b963a41eebd4" title="Iterate a product construction.">iterateProd</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> <a class="code" href="classnum.html">num</a>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l00899"></a>00899 {
<a name="l00900"></a>00900     assert (num&gt;0);
<a name="l00901"></a>00901 
<a name="l00902"></a>00902     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> res = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(0), localValEnv));
<a name="l00903"></a>00903 
<a name="l00904"></a>00904     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; num; i++) {
<a name="l00905"></a>00905         res = <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="boxes_8cpp.html#a9d0633a71eaa42ce8af4decc9e172321">boxPar</a>(res, <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(i), localValEnv))),<a class="code" href="boxes_8cpp.html#af5b10ed7352e45d75eff6110e04b64a1">boxPrim2</a>(<a class="code" href="signals_8hh.html#a333591913e073c3acd6b891b6da85298">sigMul</a>)) ;
<a name="l00906"></a>00906     }
<a name="l00907"></a>00907 
<a name="l00908"></a>00908     <span class="keywordflow">return</span> res;
<a name="l00909"></a>00909 }
<a name="l00910"></a>00910 
<a name="l00919"></a>00919 <span class="preprocessor"> #if 1</span>
<a name="l00920"></a><a class="code" href="eval_8cpp.html#a460a1cdbb416d576196db55d1e89e7ef">00920</a> <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a460a1cdbb416d576196db55d1e89e7ef" title="Compute the sum of outputs of a list of boxes.">boxlistOutputs</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> boxlist, <span class="keywordtype">int</span>* outputs)
<a name="l00921"></a>00921 {
<a name="l00922"></a>00922     <span class="keywordtype">int</span> ins, outs;
<a name="l00923"></a>00923 
<a name="l00924"></a>00924     *outputs = 0;
<a name="l00925"></a>00925     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(boxlist))
<a name="l00926"></a>00926     {
<a name="l00927"></a>00927         <span class="keywordflow">if</span> (<a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(boxlist), &amp;ins, &amp;outs)) {
<a name="l00928"></a>00928             *outputs += outs;
<a name="l00929"></a>00929         } <span class="keywordflow">else</span> {
<a name="l00930"></a>00930             <span class="comment">// arbitrary output arity set to 1</span>
<a name="l00931"></a>00931             <span class="comment">// when can&#39;t be determined</span>
<a name="l00932"></a>00932             *outputs += 1;
<a name="l00933"></a>00933         }
<a name="l00934"></a>00934         boxlist = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(boxlist);
<a name="l00935"></a>00935     }
<a name="l00936"></a>00936     <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(boxlist);
<a name="l00937"></a>00937 }
<a name="l00938"></a>00938 <span class="preprocessor">#else</span>
<a name="l00939"></a>00939 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a460a1cdbb416d576196db55d1e89e7ef" title="Compute the sum of outputs of a list of boxes.">boxlistOutputs</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> boxlist, <span class="keywordtype">int</span>* outputs)
<a name="l00940"></a>00940 {
<a name="l00941"></a>00941     <span class="keywordtype">int</span> ins, outs;
<a name="l00942"></a>00942 
<a name="l00943"></a>00943     *outputs = 0;
<a name="l00944"></a>00944     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(boxlist) &amp;&amp; <a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(boxlist), &amp;ins, &amp;outs)) {
<a name="l00945"></a>00945             *outputs += outs;
<a name="l00946"></a>00946             boxlist = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(boxlist);
<a name="l00947"></a>00947     }
<a name="l00948"></a>00948     <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(boxlist);
<a name="l00949"></a>00949 }
<a name="l00950"></a>00950 <span class="preprocessor">#endif</span>
<a name="l00951"></a>00951 <span class="preprocessor"></span>
<a name="l00955"></a><a class="code" href="eval_8cpp.html#a901e02debbc94b7276ce9410d7b4c277">00955</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a901e02debbc94b7276ce9410d7b4c277" title="repeat n times a wire">nwires</a>(<span class="keywordtype">int</span> n)
<a name="l00956"></a>00956 {
<a name="l00957"></a>00957     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> l = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l00958"></a>00958     <span class="keywordflow">while</span> (n--) { l = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="boxes_8cpp.html#a34d15b5662d2828e5c1ff213bbb91598">boxWire</a>(), l); }
<a name="l00959"></a>00959     <span class="keywordflow">return</span> l;
<a name="l00960"></a>00960 }
<a name="l00961"></a>00961 
<a name="l00962"></a>00962 
<a name="l00974"></a><a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a">00974</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> fun, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg)
<a name="l00975"></a>00975 {
<a name="l00976"></a>00976     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> abstr;
<a name="l00977"></a>00977     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> globalDefEnv;
<a name="l00978"></a>00978     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited;
<a name="l00979"></a>00979     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv;
<a name="l00980"></a>00980     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> envList;
<a name="l00981"></a>00981     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> originalRules;
<a name="l00982"></a>00982     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> revParamList;
<a name="l00983"></a>00983 
<a name="l00984"></a>00984     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> id;
<a name="l00985"></a>00985     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> body;
<a name="l00986"></a>00986     
<a name="l00987"></a>00987     <a class="code" href="structAutomaton.html">Automaton</a>*  automat;
<a name="l00988"></a>00988     <span class="keywordtype">int</span>         state;
<a name="l00989"></a>00989 
<a name="l00990"></a>00990     <a class="code" href="boxes_8hh.html#abc5863a46190002232036f027c5acfdb">prim2</a>   p2;
<a name="l00991"></a>00991 
<a name="l00992"></a>00992     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(larg)) <span class="keywordflow">return</span> fun;
<a name="l00993"></a>00993 
<a name="l00994"></a>00994     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a0f492ef7453000e0b40455ac32bd76d4">isBoxError</a>(fun) || <a class="code" href="boxes_8cpp.html#a0f492ef7453000e0b40455ac32bd76d4">isBoxError</a>(larg)) {
<a name="l00995"></a>00995         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ab4f4d00d6bc173a3c9d20cd7054ffdb7">boxError</a>();
<a name="l00996"></a>00996     }
<a name="l00997"></a>00997 
<a name="l00998"></a>00998     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a23a555bb65c1a6a4af53c7c1f24ff124">isBoxPatternMatcher</a>(fun, automat, state, envList, originalRules, revParamList)) {
<a name="l00999"></a>00999         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>            result;
<a name="l01000"></a>01000         <span class="keywordtype">int</span>             state2;
<a name="l01001"></a>01001         vector&lt;Tree&gt;    envVect;
<a name="l01002"></a>01002         
<a name="l01003"></a>01003         <a class="code" href="eval_8cpp.html#a8f59eee8151ff777c98d0727811de61f">list2vec</a>(envList, envVect);
<a name="l01004"></a>01004         state2 = <a class="code" href="patternmatcher_8cpp.html#a9a0cd806f9df515fe14799df5760021b">apply_pattern_matcher</a>(automat, state, <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg), result, envVect);
<a name="l01005"></a>01005         <span class="keywordflow">if</span> (state2 &gt;= 0 &amp;&amp; <a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(result)) {
<a name="l01006"></a>01006             <span class="comment">// we need to continue the pattern matching</span>
<a name="l01007"></a>01007             <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a>(
<a name="l01008"></a>01008                         <a class="code" href="boxes_8cpp.html#aa155619a2d5daf20b6f652cfdde63876">boxPatternMatcher</a>(automat, state2, <a class="code" href="eval_8cpp.html#a3bb3b3ad867f202d28310ced4b28d8ef">vec2list</a>(envVect), originalRules, <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg),revParamList)),
<a name="l01009"></a>01009                         <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(larg) );
<a name="l01010"></a>01010         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (state2 &lt; 0) {
<a name="l01011"></a>01011             cerr &lt;&lt; <span class="stringliteral">&quot;ERROR : pattern matching failed, no rule of &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<a class="code" href="boxes_8cpp.html#a8bc3b57470ff5814f5f24ed97dff593b">boxCase</a>(originalRules)) 
<a name="l01012"></a>01012                  &lt;&lt; <span class="stringliteral">&quot; matches argument list &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<a class="code" href="list_8cpp.html#a8e15f8d6fcc6cd319059c2e0544145bb">reverse</a>(<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg), revParamList))) &lt;&lt; endl;
<a name="l01013"></a>01013             exit(1);
<a name="l01014"></a>01014         } <span class="keywordflow">else</span> {
<a name="l01015"></a>01015             <span class="comment">// Pattern Matching was succesful</span>
<a name="l01016"></a>01016             <span class="comment">// the result is a closure that we need to evaluate.</span>
<a name="l01017"></a>01017             <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a06b09fa05baf1a2567fb4aae3d1ce544">isClosure</a>(result, body, globalDefEnv, visited, localValEnv)) {
<a name="l01018"></a>01018                 <span class="comment">// why ??? return simplifyPattern(eval(body, nil, localValEnv));</span>
<a name="l01019"></a>01019                 <span class="comment">//return eval(body, nil, localValEnv);</span>
<a name="l01020"></a>01020                 <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, localValEnv), <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(larg));
<a name="l01021"></a>01021             } <span class="keywordflow">else</span> {
<a name="l01022"></a>01022                 cerr &lt;&lt; <span class="stringliteral">&quot;wrong result from pattern matching (not a closure) : &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(result) &lt;&lt; endl;
<a name="l01023"></a>01023                 <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ab4f4d00d6bc173a3c9d20cd7054ffdb7">boxError</a>();
<a name="l01024"></a>01024             }
<a name="l01025"></a>01025         }           
<a name="l01026"></a>01026     }
<a name="l01027"></a>01027     <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a06b09fa05baf1a2567fb4aae3d1ce544">isClosure</a>(fun, abstr, globalDefEnv, visited, localValEnv)) {
<a name="l01028"></a>01028         <span class="comment">// principle : f(a,b,c,...) ==&gt; (a,b,c,...):f</span>
<a name="l01029"></a>01029          <span class="keywordtype">int</span> ins, outs;
<a name="l01030"></a>01030          
<a name="l01031"></a>01031          <span class="comment">// check arity of function</span>
<a name="l01032"></a>01032          <span class="keywordflow">if</span> (!<a class="code" href="boxes_8hh.html#ac5c10eb592a85ecba6d6990f9f78010d" title="Return the type (number of inputs and outputs) of a box or false if undefined.">getBoxType</a>(fun, &amp;ins, &amp;outs)) {
<a name="l01033"></a>01033             <span class="comment">// we can&#39;t determine the input arity of the expression</span>
<a name="l01034"></a>01034             <span class="comment">// hope for the best</span>
<a name="l01035"></a>01035             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a>(larg), fun);
<a name="l01036"></a>01036          }
<a name="l01037"></a>01037  
<a name="l01038"></a>01038          <span class="comment">// check arity of arg list</span>
<a name="l01039"></a>01039          <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#a460a1cdbb416d576196db55d1e89e7ef" title="Compute the sum of outputs of a list of boxes.">boxlistOutputs</a>(larg,&amp;outs)) {
<a name="l01040"></a>01040             <span class="comment">// we don&#39;t know yet the output arity of larg. Therefore we can&#39;t</span>
<a name="l01041"></a>01041             <span class="comment">// do any arity checking nor add _ to reach the required number of arguments</span>
<a name="l01042"></a>01042             <span class="comment">// cerr &lt;&lt; &quot;warning : can&#39;t infere the type of : &quot; &lt;&lt; boxpp(larg) &lt;&lt; endl;</span>
<a name="l01043"></a>01043             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a>(larg), fun);
<a name="l01044"></a>01044          }
<a name="l01045"></a>01045         
<a name="l01046"></a>01046         <span class="keywordflow">if</span> (outs &gt; ins) {
<a name="l01047"></a>01047             cerr &lt;&lt; <span class="stringliteral">&quot;too much arguments : &quot;</span> &lt;&lt; outs &lt;&lt; <span class="stringliteral">&quot;, instead of : &quot;</span> &lt;&lt; ins &lt;&lt; endl;
<a name="l01048"></a>01048             cerr &lt;&lt; <span class="stringliteral">&quot;when applying : &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(fun) &lt;&lt; endl
<a name="l01049"></a>01049                  &lt;&lt; <span class="stringliteral">&quot;           to : &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(larg) &lt;&lt; endl;
<a name="l01050"></a>01050             assert(<span class="keyword">false</span>);
<a name="l01051"></a>01051         }
<a name="l01052"></a>01052         
<a name="l01053"></a>01053         <span class="keywordflow">if</span> ( (outs == 1) &amp;&amp; <a class="code" href="boxes_8cpp.html#a9c79105875b22a5b09a0b6f768375d09">isBoxPrim2</a>(fun, &amp;p2) &amp;&amp; (p2 != <a class="code" href="signals_8cpp.html#aed0831b7a845cd58ab430a42abb7e69c">sigPrefix</a>)) {
<a name="l01054"></a>01054             <span class="comment">// special case : /(3) ==&gt; _,3 : /</span>
<a name="l01055"></a>01055             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg2 = <a class="code" href="list_8cpp.html#af0451cd6205a66bceb0e62f715d59533">concat</a>(<a class="code" href="eval_8cpp.html#a901e02debbc94b7276ce9410d7b4c277" title="repeat n times a wire">nwires</a>(ins-outs), larg);
<a name="l01056"></a>01056             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a>(larg2), fun);
<a name="l01057"></a>01057         } <span class="keywordflow">else</span> {
<a name="l01058"></a>01058             <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg2 = <a class="code" href="list_8cpp.html#af0451cd6205a66bceb0e62f715d59533">concat</a>(larg, <a class="code" href="eval_8cpp.html#a901e02debbc94b7276ce9410d7b4c277" title="repeat n times a wire">nwires</a>(ins-outs));
<a name="l01059"></a>01059             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#ad9b1c09a1b4f662e3ebbbbf1e8f4878f">boxSeq</a>(<a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a>(larg2), fun);
<a name="l01060"></a>01060         }
<a name="l01061"></a>01061     }
<a name="l01062"></a>01062 
<a name="l01063"></a>01063     <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a37fc5c4fbb1931425e6bfe12f637ee87">isBoxEnvironment</a>(abstr)) {
<a name="l01064"></a>01064         <a class="code" href="errormsg_8cpp.html#adea960475d5e6f38eb88824ae0c0d320">evalerrorbox</a>(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, -1, <span class="stringliteral">&quot;an environment can&#39;t be used as a function&quot;</span>, fun);
<a name="l01065"></a>01065         exit(1);
<a name="l01066"></a>01066     }
<a name="l01067"></a>01067 
<a name="l01068"></a>01068     <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#ab0b15f29743df4080b8b1c38e64a2cc1">isBoxAbstr</a>(abstr, <span class="keywordtype">id</span>, body)) {
<a name="l01069"></a>01069         <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a>(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, -1, <span class="stringliteral">&quot;(internal) not an abstraction inside closure&quot;</span>, fun);
<a name="l01070"></a>01070         exit(1);
<a name="l01071"></a>01071     }
<a name="l01072"></a>01072 
<a name="l01073"></a>01073     <span class="comment">// try to synthetise a  name from the function name and the argument name</span>
<a name="l01074"></a>01074     {
<a name="l01075"></a>01075         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> arg = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg), visited, localValEnv);
<a name="l01076"></a>01076         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> narg; <span class="keywordflow">if</span> ( <a class="code" href="eval_8cpp.html#a0f9b3d2672c752d8d3e87904f22e1ebd">isBoxNumeric</a>(arg,narg) ) { arg =  narg; } 
<a name="l01077"></a>01077         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> f = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(body, visited, <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<span class="keywordtype">id</span>, arg, localValEnv));
<a name="l01078"></a>01078 
<a name="l01079"></a>01079         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    fname;
<a name="l01080"></a>01080         <span class="keywordflow">if</span> (<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(fun, fname)) {
<a name="l01081"></a>01081             stringstream s; s &lt;&lt; <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(fname); <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#a80b87fb400c892e011350f61b4033589">gSimpleNames</a>) s &lt;&lt; <span class="stringliteral">&quot;(&quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(arg) &lt;&lt; <span class="stringliteral">&quot;)&quot;</span>;
<a name="l01082"></a>01082             <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(f, s.str());
<a name="l01083"></a>01083         }
<a name="l01084"></a>01084         <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#a071bad7d51b1294eb8dfe30ea1ba354a" title="Apply a function to a list of arguments.">applyList</a>(f, <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(larg));
<a name="l01085"></a>01085     }
<a name="l01086"></a>01086 }
<a name="l01087"></a>01087 
<a name="l01088"></a>01088 
<a name="l01089"></a>01089 
<a name="l01101"></a><a class="code" href="eval_8cpp.html#aa2524d1fe9427038c5a6f17fb9d82ca9">01101</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#aa2524d1fe9427038c5a6f17fb9d82ca9" title="Eval a list of expression in reverse order.">revEvalList</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lexp, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> localValEnv)
<a name="l01102"></a>01102 {
<a name="l01103"></a>01103     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> result = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l01104"></a>01104     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lexp)) {
<a name="l01105"></a>01105         result = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lexp), visited, localValEnv), result);
<a name="l01106"></a>01106         lexp = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(lexp);
<a name="l01107"></a>01107     }
<a name="l01108"></a>01108     <span class="keywordflow">return</span> result;
<a name="l01109"></a>01109 }
<a name="l01110"></a>01110 
<a name="l01111"></a>01111 
<a name="l01112"></a>01112 
<a name="l01119"></a><a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c">01119</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> larg)
<a name="l01120"></a>01120 {
<a name="l01121"></a>01121     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(larg)) {
<a name="l01122"></a>01122         <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a>(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, -1, <span class="stringliteral">&quot;empty list of arguments&quot;</span>, larg);
<a name="l01123"></a>01123         exit(1);
<a name="l01124"></a>01124     }
<a name="l01125"></a>01125     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(larg))) {
<a name="l01126"></a>01126         <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg);
<a name="l01127"></a>01127     }
<a name="l01128"></a>01128     <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a9d0633a71eaa42ce8af4decc9e172321">boxPar</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(larg), <a class="code" href="eval_8cpp.html#afe5428740adf39de538bbc3bf3c7d79c" title="Transform a list of expressions in a parallel construction.">larg2par</a>(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(larg)));
<a name="l01129"></a>01129 }
<a name="l01130"></a>01130 
<a name="l01131"></a>01131 
<a name="l01132"></a>01132 
<a name="l01133"></a>01133 <span class="comment">//-----------------------new environment management----------------------------</span>
<a name="l01134"></a>01134 <span class="comment">//</span>
<a name="l01135"></a>01135 <span class="comment">// The environement is made of layers. Each layer contains a set of definitions</span>
<a name="l01136"></a>01136 <span class="comment">// stored as properties of the layer. Each definition can refers to other</span>
<a name="l01137"></a>01137 <span class="comment">// definitions of the same layer or of subsequent layers. Recursive</span>
<a name="l01138"></a>01138 <span class="comment">// definitions are not allowed. Multiple defintions of the same symbol</span>
<a name="l01139"></a>01139 <span class="comment">// in a layer is allowed but generate a warning when the definition is</span>
<a name="l01140"></a>01140 <span class="comment">// different</span>
<a name="l01141"></a>01141 <span class="comment">//-----------------------------------------------------------------------------</span>
<a name="l01142"></a>01142 
<a name="l01143"></a>01143 
<a name="l01144"></a>01144 
<a name="l01151"></a><a class="code" href="eval_8cpp.html#a4c12b1741c548fc686dca046095fbc6f">01151</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a4c12b1741c548fc686dca046095fbc6f" title="Push a new (unique) empty layer (where multiple definitions can be stored) on top...">pushNewLayer</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01152"></a>01152 {
<a name="l01153"></a>01153     <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="symbol_8hh.html#a377309446e0e86ae663cd6709e02889d" title="Returns a new unique symbol of name strxxx.">unique</a>(<span class="stringliteral">&quot;ENV_LAYER&quot;</span>), lenv);
<a name="l01154"></a>01154 }
<a name="l01155"></a>01155 
<a name="l01156"></a>01156 
<a name="l01164"></a><a class="code" href="eval_8cpp.html#a7f5f4731ffc9c2c137ae52c11df0ab94">01164</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="eval_8cpp.html#a7f5f4731ffc9c2c137ae52c11df0ab94" title="Add a definition (as a property) to the current top level layer.">addLayerDef</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> def, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01165"></a>01165 {
<a name="l01166"></a>01166     <span class="comment">// check for multiple definitions of a symbol in the same layer</span>
<a name="l01167"></a>01167     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> olddef;
<a name="l01168"></a>01168     <span class="keywordflow">if</span> (<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(lenv, <span class="keywordtype">id</span>, olddef)) {
<a name="l01169"></a>01169         <span class="keywordflow">if</span> (def == olddef) {
<a name="l01170"></a>01170             <a class="code" href="errormsg_8cpp.html#a3ab0949ef52e65f87eeaf64e4fc26ccf">evalwarning</a>(<a class="code" href="errormsg_8cpp.html#acf26c50cd21dfe5d71dff434d53e227e">getDefFileProp</a>(<span class="keywordtype">id</span>), <a class="code" href="errormsg_8cpp.html#a3ab477cf5a9b38099d85324b47820d1b">getDefLineProp</a>(<span class="keywordtype">id</span>), <span class="stringliteral">&quot;equivalent re-definitions of&quot;</span>, <span class="keywordtype">id</span>);
<a name="l01171"></a>01171         } <span class="keywordflow">else</span> {
<a name="l01172"></a>01172             fprintf(stderr, <span class="stringliteral">&quot;%s:%d: ERROR: redefinition of symbols are not allowed : &quot;</span>, <a class="code" href="errormsg_8cpp.html#acf26c50cd21dfe5d71dff434d53e227e">getDefFileProp</a>(<span class="keywordtype">id</span>), <a class="code" href="errormsg_8cpp.html#a3ab477cf5a9b38099d85324b47820d1b">getDefLineProp</a>(<span class="keywordtype">id</span>)); 
<a name="l01173"></a>01173             <a class="code" href="list_8cpp.html#a850f2e459a901e0c9908d3a3a54b306e">print</a>(<span class="keywordtype">id</span>,stderr); 
<a name="l01174"></a>01174             fprintf(stderr, <span class="stringliteral">&quot; is already defined in file \&quot;%s\&quot; line %d \n&quot;</span>, <a class="code" href="errormsg_8cpp.html#acf26c50cd21dfe5d71dff434d53e227e">getDefFileProp</a>(<span class="keywordtype">id</span>), <a class="code" href="errormsg_8cpp.html#a3ab477cf5a9b38099d85324b47820d1b">getDefLineProp</a>(<span class="keywordtype">id</span>)); 
<a name="l01175"></a>01175             <a class="code" href="errormsg_8cpp.html#a446dbef8a744dce9d99bab7cf8c7d6d0">gErrorCount</a>++;
<a name="l01176"></a>01176         }
<a name="l01177"></a>01177     }
<a name="l01178"></a>01178     <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(lenv, <span class="keywordtype">id</span>, def);
<a name="l01179"></a>01179 }
<a name="l01180"></a>01180 
<a name="l01181"></a>01181 
<a name="l01189"></a><a class="code" href="names_8hh.html#ad057f174a67a40fd689fc379a5a21c2d">01189</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> def, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01190"></a>01190 {
<a name="l01191"></a>01191     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv2 = <a class="code" href="eval_8cpp.html#a4c12b1741c548fc686dca046095fbc6f" title="Push a new (unique) empty layer (where multiple definitions can be stored) on top...">pushNewLayer</a>(lenv);
<a name="l01192"></a>01192     <a class="code" href="eval_8cpp.html#a7f5f4731ffc9c2c137ae52c11df0ab94" title="Add a definition (as a property) to the current top level layer.">addLayerDef</a>(<span class="keywordtype">id</span>, def, lenv2);
<a name="l01193"></a>01193     <span class="keywordflow">return</span> lenv2;
<a name="l01194"></a>01194 }
<a name="l01195"></a>01195 
<a name="l01196"></a>01196 
<a name="l01204"></a><a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a">01204</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a7665d6a948607fc0b8437099625c429a" title="Push a new layer with multiple definitions creating the appropriate closures.">pushMultiClosureDefs</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> ldefs, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01205"></a>01205 {
<a name="l01206"></a>01206     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv2 = <a class="code" href="eval_8cpp.html#a4c12b1741c548fc686dca046095fbc6f" title="Push a new (unique) empty layer (where multiple definitions can be stored) on top...">pushNewLayer</a>(lenv);
<a name="l01207"></a>01207     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(ldefs)) {
<a name="l01208"></a>01208         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> def = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(ldefs);
<a name="l01209"></a>01209         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span> = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(def);
<a name="l01210"></a>01210         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rhs= <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(def);
<a name="l01211"></a>01211         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> cl = <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(def),<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>,visited,lenv2);
<a name="l01212"></a>01212         stringstream s; s &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<span class="keywordtype">id</span>);
<a name="l01213"></a>01213         <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a345a4cfac5657c40640b503058b300f9">isBoxCase</a>(rhs)) <a class="code" href="names_8cpp.html#a4ae30710c357c86ad325c960b9236797">setDefNameProperty</a>(cl,s.str());
<a name="l01214"></a>01214         <a class="code" href="eval_8cpp.html#a7f5f4731ffc9c2c137ae52c11df0ab94" title="Add a definition (as a property) to the current top level layer.">addLayerDef</a>( <span class="keywordtype">id</span>, cl, lenv2 );
<a name="l01215"></a>01215         ldefs = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(ldefs);
<a name="l01216"></a>01216     }
<a name="l01217"></a>01217     <span class="keywordflow">return</span> lenv2;
<a name="l01218"></a>01218 }
<a name="l01219"></a>01219 
<a name="l01220"></a>01220 
<a name="l01229"></a><a class="code" href="names_8hh.html#adf6ba37a28536372e3be65128c79e615">01229</a> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#adf6ba37a28536372e3be65128c79e615" title="Search the environment for the definition of a symbol ID and return it.">searchIdDef</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; def, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01230"></a>01230 {
<a name="l01231"></a>01231     <span class="comment">// search the environment until a definition is found</span>
<a name="l01232"></a>01232     <span class="comment">// or nil (the empty environment) is reached</span>
<a name="l01233"></a>01233     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lenv) &amp;&amp; !<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(lenv, <span class="keywordtype">id</span>, def)) {
<a name="l01234"></a>01234         lenv = lenv-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0);
<a name="l01235"></a>01235     }
<a name="l01236"></a>01236     <span class="keywordflow">return</span> !<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lenv);
<a name="l01237"></a>01237 }
<a name="l01238"></a>01238 
<a name="l01239"></a>01239 
<a name="l01240"></a>01240 
<a name="l01251"></a><a class="code" href="eval_8cpp.html#a7ffa665e4f7b3e382092983e2022bc3e">01251</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a7ffa665e4f7b3e382092983e2022bc3e" title="Search the environment for the definition of a symbol ID and evaluate it.">evalIdDef</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <span class="keywordtype">id</span>, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> visited, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lenv)
<a name="l01252"></a>01252 {
<a name="l01253"></a>01253     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> def, <a class="code" href="symbol_8hh.html#a8243134fbbd9d924ebbb3f833922e310" title="Returns the name of a symbol.">name</a>;
<a name="l01254"></a>01254 
<a name="l01255"></a>01255     <span class="comment">// search the environment env for a definition of symbol id</span>
<a name="l01256"></a>01256     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lenv) &amp;&amp; !<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(lenv, <span class="keywordtype">id</span>, def)) {
<a name="l01257"></a>01257         lenv = lenv-&gt;<a class="code" href="classCTree.html#a06c1513b23dc7b0d9da9c930c6dc43c5" title="return the ith branch (subtree) of a tree">branch</a>(0);
<a name="l01258"></a>01258     }
<a name="l01259"></a>01259 
<a name="l01260"></a>01260     <span class="comment">// check that the definition exists</span>
<a name="l01261"></a>01261     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lenv)) {
<a name="l01262"></a>01262         <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#a66d9e4214550a34a76936a4ccecea387">gPatternEvalMode</a>) <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a4c923f00afc25e923857fe3c6f3c1ca3">boxPatternVar</a>(<span class="keywordtype">id</span>);
<a name="l01263"></a>01263         cerr &lt;&lt; <span class="stringliteral">&quot;undefined symbol &quot;</span> &lt;&lt; *<span class="keywordtype">id</span> &lt;&lt; endl;
<a name="l01264"></a>01264         <a class="code" href="errormsg_8cpp.html#ac5d774c3bf6fa279bbba90cd94a7d8a9">evalerror</a>(<a class="code" href="errormsg_8cpp.html#acf26c50cd21dfe5d71dff434d53e227e">getDefFileProp</a>(<span class="keywordtype">id</span>), <a class="code" href="errormsg_8cpp.html#a3ab477cf5a9b38099d85324b47820d1b">getDefLineProp</a>(<span class="keywordtype">id</span>), <span class="stringliteral">&quot;undefined symbol &quot;</span>, <span class="keywordtype">id</span>);
<a name="l01265"></a>01265         exit(1);
<a name="l01266"></a>01266 <span class="comment">//      return id;</span>
<a name="l01267"></a>01267     }
<a name="l01268"></a>01268 
<a name="l01269"></a>01269     <span class="comment">// check that it is not a recursive definition</span>
<a name="l01270"></a>01270     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> p = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<span class="keywordtype">id</span>,lenv);
<a name="l01271"></a>01271     <span class="comment">// set the definition name property</span>
<a name="l01272"></a>01272     <span class="keywordflow">if</span> (!<a class="code" href="names_8cpp.html#afa6f89a686c004f84729e2bca7bf2053" title="Indicates the identifier (if any) the expression was a definition of.">getDefNameProperty</a>(def, name)) {
<a name="l01273"></a>01273         <span class="comment">// if the definition has no name use the identifier</span>
<a name="l01274"></a>01274         stringstream s; s &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<span class="keywordtype">id</span>);
<a name="l01275"></a>01275         <span class="comment">//XXXXXX setDefNameProperty(def, s.str());</span>
<a name="l01276"></a>01276     }
<a name="l01277"></a>01277 
<a name="l01278"></a>01278     <span class="comment">// return the evaluated definition</span>
<a name="l01279"></a>01279     <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(def, <a class="code" href="list_8cpp.html#a82cc7a3df71c1e139ce7cf34022ed80d">addElement</a>(p,visited), <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);
<a name="l01280"></a>01280 }
<a name="l01281"></a>01281 
<a name="l01282"></a>01282 
<a name="l01290"></a><a class="code" href="eval_8cpp.html#a941ff6f07c593501956c0e94cb1c8b79">01290</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a941ff6f07c593501956c0e94cb1c8b79" title="Creates a list of n elements.">listn</a> (<span class="keywordtype">int</span> n, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> e)
<a name="l01291"></a>01291 {
<a name="l01292"></a>01292     <span class="keywordflow">return</span> (n&lt;= 0) ? <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a> : <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(e, <a class="code" href="eval_8cpp.html#a941ff6f07c593501956c0e94cb1c8b79" title="Creates a list of n elements.">listn</a>(n-1,e));
<a name="l01293"></a>01293 }
<a name="l01294"></a>01294 
<a name="l01300"></a>01300 <span class="keyword">static</span> <a class="code" href="classNode.html" title="Class Node = (type x (int + double + Sym + void*)).">Node</a> <a class="code" href="eval_8cpp.html#a9471136cb868dd1e6f0c53ae9b3755ce" title="A property to store the pattern matcher corresponding to a set of rules in a specific...">PMPROPERTYNODE</a>(<a class="code" href="symbol_8hh.html#aaa87083235b70d1042e59ae25e0800d8" title="Returns (and creates if new) the symbol of name str.">symbol</a>(<span class="stringliteral">&quot;PMPROPERTY&quot;</span>));
<a name="l01301"></a>01301 
<a name="l01302"></a><a class="code" href="eval_8cpp.html#aa8b4bfd61011ff9131eb72b823e76ff9">01302</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="eval_8cpp.html#aa8b4bfd61011ff9131eb72b823e76ff9">setPMProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pm)
<a name="l01303"></a>01303 {
<a name="l01304"></a>01304     <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(t, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#a9471136cb868dd1e6f0c53ae9b3755ce" title="A property to store the pattern matcher corresponding to a set of rules in a specific...">PMPROPERTYNODE</a>, env), pm);
<a name="l01305"></a>01305 }
<a name="l01306"></a>01306 
<a name="l01307"></a><a class="code" href="eval_8cpp.html#a918fc938392d7e0afd4a96368d476c74">01307</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="eval_8cpp.html#a918fc938392d7e0afd4a96368d476c74">getPMProperty</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>&amp; pm)
<a name="l01308"></a>01308 {
<a name="l01309"></a>01309     <span class="keywordflow">return</span> <a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(t, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="eval_8cpp.html#a9471136cb868dd1e6f0c53ae9b3755ce" title="A property to store the pattern matcher corresponding to a set of rules in a specific...">PMPROPERTYNODE</a>, env), pm);
<a name="l01310"></a>01310 }
<a name="l01311"></a>01311 
<a name="l01321"></a><a class="code" href="eval_8cpp.html#a5cdcbf148322e2141fbda30bc40169ec">01321</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a5cdcbf148322e2141fbda30bc40169ec" title="Eval a case expression containing a list of pattern matching rules.">evalCase</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rules, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env)
<a name="l01322"></a>01322 {
<a name="l01323"></a>01323     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pm;
<a name="l01324"></a>01324     <span class="keywordflow">if</span> (!<a class="code" href="eval_8cpp.html#a918fc938392d7e0afd4a96368d476c74">getPMProperty</a>(rules, env, pm)) {
<a name="l01325"></a>01325         <a class="code" href="structAutomaton.html">Automaton</a>*  a = <a class="code" href="patternmatcher_8cpp.html#a81bb4084b45da5ba7e9bf6f562877543">make_pattern_matcher</a>(<a class="code" href="eval_8cpp.html#af2948c445ab2eb35a4f493b881c7c018" title="Evaluates each rule of the list.">evalRuleList</a>(rules, env));
<a name="l01326"></a>01326         pm = <a class="code" href="boxes_8cpp.html#aa155619a2d5daf20b6f652cfdde63876">boxPatternMatcher</a>(a, 0, <a class="code" href="eval_8cpp.html#a941ff6f07c593501956c0e94cb1c8b79" title="Creates a list of n elements.">listn</a>(<a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(rules), env), rules, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);
<a name="l01327"></a>01327         <a class="code" href="eval_8cpp.html#aa8b4bfd61011ff9131eb72b823e76ff9">setPMProperty</a>(rules, env, pm);
<a name="l01328"></a>01328     }
<a name="l01329"></a>01329     <span class="keywordflow">return</span> pm;
<a name="l01330"></a>01330 }       
<a name="l01331"></a>01331 
<a name="l01332"></a>01332 
<a name="l01336"></a><a class="code" href="eval_8cpp.html#af2948c445ab2eb35a4f493b881c7c018">01336</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#af2948c445ab2eb35a4f493b881c7c018" title="Evaluates each rule of the list.">evalRuleList</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rules, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env)
<a name="l01337"></a>01337 {
<a name="l01338"></a>01338     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(rules)) <span class="keywordflow">return</span> <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l01339"></a>01339     <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="eval_8cpp.html#a8e449962e5f7f4addd0e5a91291d88c2" title="Evaluates the list of patterns and closure the rhs.">evalRule</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(rules), env), <a class="code" href="eval_8cpp.html#af2948c445ab2eb35a4f493b881c7c018" title="Evaluates each rule of the list.">evalRuleList</a>(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(rules), env));
<a name="l01340"></a>01340 }
<a name="l01341"></a>01341 
<a name="l01342"></a>01342 
<a name="l01346"></a><a class="code" href="eval_8cpp.html#a8e449962e5f7f4addd0e5a91291d88c2">01346</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a8e449962e5f7f4addd0e5a91291d88c2" title="Evaluates the list of patterns and closure the rhs.">evalRule</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rule, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env)
<a name="l01347"></a>01347 {
<a name="l01348"></a>01348     <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="eval_8cpp.html#a875de3721ef9aa963b3dd9a19541d94f" title="Evaluates each pattern of the list.">evalPatternList</a>(<a class="code" href="list_8hh.html#a626356b3c8f3e0130d0e043a1dd8547c">left</a>(rule), env), <a class="code" href="list_8hh.html#a098460d0916242eebda50610e2a86e39">right</a>(rule));
<a name="l01349"></a>01349 }
<a name="l01350"></a>01350 
<a name="l01351"></a>01351 
<a name="l01355"></a><a class="code" href="eval_8cpp.html#a875de3721ef9aa963b3dd9a19541d94f">01355</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a875de3721ef9aa963b3dd9a19541d94f" title="Evaluates each pattern of the list.">evalPatternList</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> patterns, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env)
<a name="l01356"></a>01356 {
<a name="l01357"></a>01357     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(patterns)) {
<a name="l01358"></a>01358         <span class="keywordflow">return</span> <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l01359"></a>01359     } <span class="keywordflow">else</span> {
<a name="l01360"></a>01360         <span class="keywordflow">return</span> <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(    <a class="code" href="eval_8cpp.html#acecb528a08d2f78b2eabc7a1468bf03c" title="Evaluates a pattern using a special mode so that free variables are wrapped into...">evalPattern</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(patterns), env), 
<a name="l01361"></a>01361                         <a class="code" href="eval_8cpp.html#a875de3721ef9aa963b3dd9a19541d94f" title="Evaluates each pattern of the list.">evalPatternList</a>(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(patterns), env)  );
<a name="l01362"></a>01362     }
<a name="l01363"></a>01363 }
<a name="l01364"></a>01364 
<a name="l01365"></a>01365 
<a name="l01370"></a><a class="code" href="eval_8cpp.html#acecb528a08d2f78b2eabc7a1468bf03c">01370</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#acecb528a08d2f78b2eabc7a1468bf03c" title="Evaluates a pattern using a special mode so that free variables are wrapped into...">evalPattern</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pattern, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> env)
<a name="l01371"></a>01371 {
<a name="l01372"></a>01372     <span class="keywordtype">bool</span> saveMode = <a class="code" href="eval_8cpp.html#a66d9e4214550a34a76936a4ccecea387">gPatternEvalMode</a>;
<a name="l01373"></a>01373     <a class="code" href="eval_8cpp.html#a66d9e4214550a34a76936a4ccecea387">gPatternEvalMode</a> = <span class="keyword">true</span>;
<a name="l01374"></a>01374     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> p = <a class="code" href="eval_8cpp.html#aaf2a81f44d9e4e6dc257b394f00f28df">eval</a>(pattern, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, env);
<a name="l01375"></a>01375     <a class="code" href="eval_8cpp.html#a66d9e4214550a34a76936a4ccecea387">gPatternEvalMode</a> = saveMode;
<a name="l01376"></a>01376     <span class="keywordflow">return</span> <a class="code" href="eval_8cpp.html#acc9087174c3fdddf927709eb9440c859">patternSimplification</a>(p);
<a name="l01377"></a>01377 }
<a name="l01378"></a>01378 
<a name="l01379"></a>01379 
<a name="l01380"></a><a class="code" href="eval_8cpp.html#a8f59eee8151ff777c98d0727811de61f">01380</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="eval_8cpp.html#a8f59eee8151ff777c98d0727811de61f">list2vec</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> l, vector&lt;Tree&gt;&amp; v)
<a name="l01381"></a>01381 {
<a name="l01382"></a>01382     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(l)) {
<a name="l01383"></a>01383         v.push_back(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(l));
<a name="l01384"></a>01384         l = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(l);
<a name="l01385"></a>01385     }
<a name="l01386"></a>01386 }
<a name="l01387"></a>01387 
<a name="l01388"></a>01388 
<a name="l01389"></a><a class="code" href="eval_8cpp.html#a3bb3b3ad867f202d28310ced4b28d8ef">01389</a> <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="eval_8cpp.html#a3bb3b3ad867f202d28310ced4b28d8ef">vec2list</a>(<span class="keyword">const</span> vector&lt;Tree&gt;&amp; v)
<a name="l01390"></a>01390 {
<a name="l01391"></a>01391     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> l = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l01392"></a>01392     <span class="keywordtype">int</span>  n = v.size();
<a name="l01393"></a>01393     <span class="keywordflow">while</span> (n--) { l = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(v[n],l); }
<a name="l01394"></a>01394     <span class="keywordflow">return</span> l;
<a name="l01395"></a>01395 }
</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>