<!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: boxtype.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 Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>boxtype.cpp</h1><a href="boxtype_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>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="comment">/*****************************************************************************</span> <a name="l00025"></a>00025 <span class="comment">******************************************************************************</span> <a name="l00026"></a>00026 <span class="comment"> </span> <a name="l00027"></a>00027 <span class="comment"> Box Type System</span> <a name="l00028"></a>00028 <span class="comment"> </span> <a name="l00029"></a>00029 <span class="comment">******************************************************************************</span> <a name="l00030"></a>00030 <span class="comment">*****************************************************************************/</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <a name="l00042"></a>00042 <span class="preprocessor">#include <stdio.h></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <string.h></span> <a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="boxes_8hh.html">boxes.hh</a>"</span> <a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="ppbox_8hh.html">ppbox.hh</a>"</span> <a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="prim2_8hh.html">prim2.hh</a>"</span> <a name="l00047"></a>00047 <span class="preprocessor">#include "<a class="code" href="xtended_8hh.html">xtended.hh</a>"</span> <a name="l00048"></a>00048 <a name="l00049"></a>00049 <a name="l00050"></a><a class="code" href="boxtype_8cpp.html#a8112d401cbebb0271a59c1519be875be">00050</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="boxtype_8cpp.html#a8112d401cbebb0271a59c1519be875be">BOXTYPEPROP</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">"boxTypeProp"</span>)); <a name="l00051"></a>00051 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="boxtype_8cpp.html#ae159e6baa8401e374f0f42182725fd46" title="Infere the type (number of inputs and outputs) of a box.">infereBoxType</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, <span class="keywordtype">int</span>* inum, <span class="keywordtype">int</span>* onum); <a name="l00052"></a>00052 <a name="l00053"></a>00053 <a name="l00054"></a>00054 <a name="l00063"></a><a class="code" href="boxtype_8cpp.html#ac5c10eb592a85ecba6d6990f9f78010d">00063</a> <span class="keywordtype">bool</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="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> box, <span class="keywordtype">int</span>* inum, <span class="keywordtype">int</span>* onum) <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <a 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 name="l00066"></a>00066 <span class="keywordflow">if</span> (<a class="code" href="list_8cpp.html#a665745948013d012bb123e9577c094bd">getProperty</a>(box, BOXTYPEPROP, t)) { <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(t)) { <a name="l00069"></a>00069 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00070"></a>00070 } <span class="keywordflow">else</span> { <a name="l00071"></a>00071 *inum = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(t)-><a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>().<a class="code" href="classNode.html#a0ac89402d0e51d19bed062529a375efe">getInt</a>(); <a name="l00072"></a>00072 *onum = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(t)-><a class="code" href="classCTree.html#a8de786fec095c8304b9ffa7c1c316237" title="return the content of the tree">node</a>().<a class="code" href="classNode.html#a0ac89402d0e51d19bed062529a375efe">getInt</a>(); <a name="l00073"></a>00073 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00074"></a>00074 } <a name="l00075"></a>00075 <a name="l00076"></a>00076 } <span class="keywordflow">else</span> { <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="keywordflow">if</span> (<a class="code" href="boxtype_8cpp.html#ae159e6baa8401e374f0f42182725fd46" title="Infere the type (number of inputs and outputs) of a box.">infereBoxType</a>(box, inum, onum)) { <a name="l00079"></a>00079 <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(box, BOXTYPEPROP, <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(*inum), <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(*onum))); <a name="l00080"></a>00080 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00081"></a>00081 } <span class="keywordflow">else</span> { <a name="l00082"></a>00082 <a class="code" href="list_8cpp.html#a5ead5a3e91af18d8f94e0974990a3c5a">setProperty</a>(box, BOXTYPEPROP, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>); <a name="l00083"></a>00083 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00084"></a>00084 } <a name="l00085"></a>00085 } <a name="l00086"></a>00086 } <a name="l00087"></a>00087 <a name="l00088"></a>00088 <a name="l00089"></a>00089 <a name="l00097"></a><a class="code" href="boxtype_8cpp.html#ae159e6baa8401e374f0f42182725fd46">00097</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="boxtype_8cpp.html#ae159e6baa8401e374f0f42182725fd46" title="Infere the type (number of inputs and outputs) of a box.">infereBoxType</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, <span class="keywordtype">int</span>* inum, <span class="keywordtype">int</span>* onum) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 <a 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, b, ff, l, <a class="code" href="structAutomaton.html#a12b5aa75d9587716b139bc41fbb5d695">s</a>; <a name="l00100"></a>00100 <span class="comment">//Tree abstr, genv, vis, lenv;</span> <a name="l00101"></a>00101 <a name="l00102"></a>00102 <a class="code" href="classxtended.html">xtended</a>* p = (<a class="code" href="classxtended.html">xtended</a>*) <a class="code" href="symbol_8hh.html#a603fcb6c07eacf2688c2a8470637d0ff" title="Returns user data.">getUserData</a>(t); <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">if</span> (p) { *inum = p-><a class="code" href="classxtended.html#ad709963a78f1b630e44ff518134487b5">arity</a>(); *onum = 1; } <a name="l00105"></a>00105 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a7904414896442fcfa0947156b6563d52">isBoxInt</a>(t)) { *inum = 0; *onum = 1; } <a name="l00106"></a>00106 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a292a68d93ea73f703bc880cca4d01bc2">isBoxReal</a>(t)) { *inum = 0; *onum = 1; } <a name="l00107"></a>00107 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ac32713127f8c8c3cb26e28a31580b257">isBoxWire</a>(t)) { *inum = 1; *onum = 1; } <a name="l00108"></a>00108 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#acf54df78e7e909644907619a03b3f695">isBoxCut</a>(t)) { *inum = 1; *onum = 0; } <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#af4b23a35faec0884c4591ff92576c3d4">isBoxSlot</a>(t)) { *inum = 0; *onum = 1; } <a name="l00111"></a>00111 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ab73899d732fd2181be3d72f28c11ab3d">isBoxSymbolic</a>(t,s,b)) { <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>(b, inum, onum)) <span class="keywordflow">return</span> <span class="keyword">false</span>; *inum += 1; } <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#af6596889fd117b00a85ca9ee837f2988">isBoxPrim0</a>(t)) { *inum = 0; *onum = 1; } <a name="l00114"></a>00114 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a261369dc82c96fbfa1978859ca4cf2e3">isBoxPrim1</a>(t)) { *inum = 1; *onum = 1; } <a name="l00115"></a>00115 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a9c79105875b22a5b09a0b6f768375d09">isBoxPrim2</a>(t)) { *inum = 2; *onum = 1; } <a name="l00116"></a>00116 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a826142cbc8a1a762612f22273303794e">isBoxPrim3</a>(t)) { *inum = 3; *onum = 1; } <a name="l00117"></a>00117 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a5cae175b6153210d76c153feb2af908c">isBoxPrim4</a>(t)) { *inum = 4; *onum = 1; } <a name="l00118"></a>00118 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aba4a65a9f30e78759da0796c55b13e8e">isBoxPrim5</a>(t)) { *inum = 5; *onum = 1; } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a70f7ab7aecc722355d6096ca89a7658f">isBoxFFun</a>(t,ff)) { *inum = <a class="code" href="prim2_8cpp.html#af82147adb6d445cb8f8878f6dcedba64">ffarity</a>(ff); *onum = 1; } <a name="l00121"></a>00121 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a8744a0451eacde8e56290b3fd74bc0b1">isBoxFConst</a>(t)) { *inum = 0; *onum = 1; } <a name="l00122"></a>00122 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aed6793582932079092255c2643b45f91">isBoxFVar</a>(t)) { *inum = 0; *onum = 1; } <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a83b021a73e7c4af2535efcfe0832c690">isBoxButton</a>(t)) { *inum = 0; *onum = 1; } <a name="l00125"></a>00125 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a635dcccb574f9a9c911b89a756126473">isBoxCheckbox</a>(t)) { *inum = 0; *onum = 1; } <a name="l00126"></a>00126 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a4bf55c2d9a65d986d0d19da98d14db16">isBoxVSlider</a>(t)) { *inum = 0; *onum = 1; } <a name="l00127"></a>00127 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#adf3ec537a021d2a50ddc8e029d540451">isBoxHSlider</a>(t)) { *inum = 0; *onum = 1; } <a name="l00128"></a>00128 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aa135a488b7d54dcce1249f5761ab014a">isBoxNumEntry</a>(t)) { *inum = 0; *onum = 1; } <a name="l00129"></a>00129 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a5643302db2568cf9eaa48fd6f7d336a9">isBoxVGroup</a>(t,l,a)){ <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, inum, onum)) <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00130"></a>00130 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a1b73cc14722de085e72c0a008fa56af3">isBoxHGroup</a>(t,l,a)){ <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, inum, onum)) <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00131"></a>00131 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a3e76d86869cc8b1df759a4bcb972cf2d">isBoxTGroup</a>(t,l,a)){ <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, inum, onum)) <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00132"></a>00132 <a name="l00133"></a>00133 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a1f17c731544a73f907993681b57e7461">isBoxVBargraph</a>(t)) { *inum = 1; *onum = 1; } <a name="l00134"></a>00134 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#aa34cc27fbf6e04a6825ba4461af2a9e0">isBoxHBargraph</a>(t)) { *inum = 1; *onum = 1; } <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#ad7c79f7a1c0aa3109ab0548e59194d48">isBoxSeq</a>(t, a, b)) { <a name="l00137"></a>00137 <a name="l00138"></a>00138 <span class="keywordtype">int</span> u,v,x,y; <a name="l00139"></a>00139 <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, &u, &v)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00140"></a>00140 <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>(b, &x, &y)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keywordflow">if</span> (v != x) { <a name="l00143"></a>00143 cerr << <span class="stringliteral">"Error in sequential composition (A:B)"</span> << endl <a name="l00144"></a>00144 << <span class="stringliteral">"The number of outputs ("</span> << v << <span class="stringliteral">") of A = "</span> << <a class="code" href="classboxpp.html">boxpp</a>(a) << endl <a name="l00145"></a>00145 << <span class="stringliteral">"must be equal to the number of inputs ("</span> << x << <span class="stringliteral">") of B : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(b) << endl; <a name="l00146"></a>00146 exit(1); <a name="l00147"></a>00147 } <span class="keywordflow">else</span> { <a name="l00148"></a>00148 *inum = u; *onum = y; <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <a name="l00151"></a>00151 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a8a24d365092cfdabb32218ab8e446dc6">isBoxPar</a>(t, a, b)) { <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordtype">int</span> u,v,x,y; <a name="l00154"></a>00154 <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, &u, &v)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00155"></a>00155 <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>(b, &x, &y)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00156"></a>00156 <a name="l00157"></a>00157 *inum = u+x; *onum = v+y; <a name="l00158"></a>00158 <a name="l00159"></a>00159 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a654a2a97bdc734448e669899976bdbd0">isBoxSplit</a>(t, a, b)) { <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="keywordtype">int</span> u,v,x,y; <a name="l00162"></a>00162 <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, &u, &v)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00163"></a>00163 <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>(b, &x, &y)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00164"></a>00164 <a name="l00165"></a>00165 <span class="keywordflow">if</span> (v == 0) { <a name="l00166"></a>00166 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00167"></a>00167 << <span class="stringliteral">"The first expression : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(a) << <span class="stringliteral">" has no outputs"</span> << endl; <a name="l00168"></a>00168 exit(1); <a name="l00169"></a>00169 } <a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="keywordflow">if</span> (x == 0) { <a name="l00172"></a>00172 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00173"></a>00173 << <span class="stringliteral">"The second expression : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(b) << <span class="stringliteral">" has no inputs"</span> << endl; <a name="l00174"></a>00174 exit(1); <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="keywordflow">if</span> (x % v != 0) { <a name="l00178"></a>00178 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00179"></a>00179 << <span class="stringliteral">"The number of outputs "</span> << v <a name="l00180"></a>00180 << <span class="stringliteral">" of the first expression should be a divisor of the number of inputs "</span> << x <a name="l00181"></a>00181 << <span class="stringliteral">" of the second expression"</span> << endl; <a name="l00182"></a>00182 exit(1); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00185"></a>00185 *inum = u; *onum = y; <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#a7b7d0ce5bacf1a799517f7b50dfe7a3e">isBoxMerge</a>(t, a, b)) { <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="keywordtype">int</span> u,v,x,y; <a name="l00190"></a>00190 <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, &u, &v)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00191"></a>00191 <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>(b, &x, &y)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keywordflow">if</span> (v == 0) { <a name="l00194"></a>00194 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00195"></a>00195 << <span class="stringliteral">"The first expression : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(a) << <span class="stringliteral">" has no outputs"</span> << endl; <a name="l00196"></a>00196 exit(1); <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="keywordflow">if</span> (x == 0) { <a name="l00200"></a>00200 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00201"></a>00201 << <span class="stringliteral">"The second expression : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(b) << <span class="stringliteral">" has no inputs"</span> << endl; <a name="l00202"></a>00202 exit(1); <a name="l00203"></a>00203 } <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="keywordflow">if</span> (v % x != 0) { <a name="l00206"></a>00206 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl <a name="l00207"></a>00207 << <span class="stringliteral">"The number of outputs "</span> << v <a name="l00208"></a>00208 << <span class="stringliteral">" of the first expression should be a multiple of the number of inputs "</span> << x <a name="l00209"></a>00209 << <span class="stringliteral">" of the second expression"</span> << endl; <a name="l00210"></a>00210 exit(1); <a name="l00211"></a>00211 } <a name="l00212"></a>00212 <a name="l00213"></a>00213 *inum = u; *onum = y; <a name="l00214"></a>00214 <a name="l00215"></a>00215 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a97de4dc9680e2d0820a5d1d18255fa35">isBoxRec</a>(t, a, b)) { <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keywordtype">int</span> u,v,x,y; <a name="l00218"></a>00218 <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, &u, &v)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00219"></a>00219 <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>(b, &x, &y)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00220"></a>00220 <span class="keywordflow">if</span> ( (x > v) | (y > u) ) { <a name="l00221"></a>00221 cerr << <span class="stringliteral">"Connection error in : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl; <a name="l00222"></a>00222 <span class="keywordflow">if</span> (x > v) cerr << <span class="stringliteral">"The number of outputs "</span> << v <a name="l00223"></a>00223 << <span class="stringliteral">" of the first expression should be greater or equal \n to the number of inputs "</span> << x <a name="l00224"></a>00224 << <span class="stringliteral">" of the second exepression"</span> << endl; <a name="l00225"></a>00225 <span class="keywordflow">if</span> (y > u) cerr << <span class="stringliteral">"The number of inputs "</span> << u <a name="l00226"></a>00226 << <span class="stringliteral">" of the first expression should be greater or equal \n to the number of outputs "</span> << y <a name="l00227"></a>00227 << <span class="stringliteral">" of the second exepression"</span> << endl; <a name="l00228"></a>00228 exit(1); <a name="l00229"></a>00229 } <a name="l00230"></a>00230 *inum = <a class="code" href="interval_8hh.html#a1c45761573e6cbc97cfacac78d905016">max</a>(0,u-y); *onum = v; <a name="l00231"></a>00231 <a name="l00232"></a>00232 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a37fc5c4fbb1931425e6bfe12f637ee87">isBoxEnvironment</a>(t)) { <a name="l00233"></a>00233 cerr << <span class="stringliteral">"An environment is not a block-diagram : "</span> << <a class="code" href="classboxpp.html">boxpp</a>(t) << endl; <a name="l00234"></a>00234 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00235"></a>00235 } <span class="keywordflow">else</span> { <a name="l00236"></a>00236 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00237"></a>00237 } <a name="l00238"></a>00238 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00239"></a>00239 } <a name="l00240"></a>00240 <a name="l00241"></a>00241 <a name="l00242"></a>00242 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:58 2010 for FAUST compiler by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>