00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00029
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 float 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
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
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
00125 else if (isBoxSlot(box, &i)) return 1;
00126 else if (isBoxSymbolic(box,t1,t2)) return 1 + BC(t2);
00127
00128
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
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
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
00150 else {
00151
00152 cerr << "ERROR in boxComplexity : not an evaluated box [[ " << *box << " ]]";
00153 exit(-1);
00154 }
00155
00156 return -1;
00157 }