|
FAUST compiler
0.9.9.6b8
|
00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 ************************************************************************ 00020 ************************************************************************/ 00029 // construction des representations graphiques 00030 00031 00032 #include <ostream> 00033 #include "xtended.hh" 00034 #include "boxcomplexity.h" 00035 00036 using namespace std; 00037 00041 Tree BCOMPLEXITY = tree ("BCOMPLEXITY"); 00042 00043 static int computeBoxComplexity (Tree box); 00044 00056 int boxComplexity (Tree box) 00057 { 00058 Tree prop = box->getProperty(BCOMPLEXITY); 00059 00060 if (prop) { 00061 return tree2int(prop); 00062 00063 } else { 00064 int v = computeBoxComplexity(box); 00065 box->setProperty(BCOMPLEXITY,tree(v)); 00066 return v; 00067 } 00068 } 00069 00073 #define BC boxComplexity 00074 00075 00087 int computeBoxComplexity (Tree box) 00088 { 00089 int i; 00090 double r; 00091 prim0 p0; 00092 prim1 p1; 00093 prim2 p2; 00094 prim3 p3; 00095 prim4 p4; 00096 prim5 p5; 00097 00098 Tree t1, t2, ff, label, cur, min, max, step, type, name, file; 00099 00100 xtended* xt = (xtended*) getUserData(box); 00101 00102 00103 // simple elements 00104 if (xt) return 1; 00105 else if (isBoxInt(box, &i)) return 1; 00106 else if (isBoxReal(box, &r)) return 1; 00107 00108 else if (isBoxCut(box)) return 0; 00109 else if (isBoxWire(box)) return 0; 00110 00111 else if (isBoxPrim0(box, &p0)) return 1; 00112 else if (isBoxPrim1(box, &p1)) return 1; 00113 else if (isBoxPrim2(box, &p2)) return 1; 00114 else if (isBoxPrim3(box, &p3)) return 1; 00115 else if (isBoxPrim4(box, &p4)) return 1; 00116 else if (isBoxPrim5(box, &p5)) return 1; 00117 00118 // foreign elements 00119 else if (isBoxFFun(box, ff)) return 1; 00120 else if (isBoxFConst(box, type, name, file)) 00121 return 1; 00122 else if (isBoxFVar(box, type, name, file)) 00123 return 1; 00124 // slots and symbolic boxes 00125 else if (isBoxSlot(box, &i)) return 1; 00126 else if (isBoxSymbolic(box,t1,t2)) return 1 + BC(t2); 00127 00128 // block diagram binary operator 00129 else if (isBoxSeq(box, t1, t2)) return BC(t1) + BC(t2); 00130 else if (isBoxSplit(box, t1, t2)) return BC(t1) + BC(t2); 00131 else if (isBoxMerge(box, t1, t2)) return BC(t1) + BC(t2); 00132 else if (isBoxPar(box, t1, t2)) return BC(t1) + BC(t2); 00133 else if (isBoxRec(box, t1, t2)) return BC(t1) + BC(t2); 00134 00135 // user interface widgets 00136 else if (isBoxButton(box, label)) return 1; 00137 else if (isBoxCheckbox(box, label)) return 1; 00138 else if (isBoxVSlider(box, label, cur, min, max, step)) return 1; 00139 else if (isBoxHSlider(box, label, cur, min, max, step)) return 1; 00140 else if (isBoxHBargraph(box, label, min, max)) return 1; 00141 else if (isBoxVBargraph(box, label, min, max)) return 1; 00142 else if (isBoxNumEntry(box, label, cur, min, max, step))return 1; 00143 00144 // user interface groups 00145 else if (isBoxVGroup(box, label, t1)) return BC(t1); 00146 else if (isBoxHGroup(box, label, t1)) return BC(t1); 00147 else if (isBoxTGroup(box, label, t1)) return BC(t1); 00148 00149 //a completer 00150 else { 00151 //fout << tree2str(box); 00152 cerr << "ERROR in boxComplexity : not an evaluated box [[ " << *box << " ]]"; 00153 exit(-1); 00154 } 00155 00156 return -1; 00157 }
1.8.0