|
FAUST compiler
0.9.9.6b8
|
00001 #ifndef _BOXES_ 00002 #define _BOXES_ 00003 00004 /************************************************************************ 00005 ************************************************************************ 00006 FAUST compiler 00007 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00008 --------------------------------------------------------------------- 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00022 ************************************************************************ 00023 ************************************************************************/ 00024 00025 00026 00027 /***************************************************************************** 00028 ****************************************************************************** 00029 FAUST BOX ALGEBRA 00030 Y. Orlarey, (c) Grame 2002 00031 ------------------------------------------------------------------------------ 00032 box ::= i | f | p0 | p1 | p3 00033 | _ | ! | a:b | a<:b | a,b | a:>b | a~b 00034 00035 History : 00036 --------- 00037 2002-06-06 : First version 00038 00039 ****************************************************************************** 00040 *****************************************************************************/ 00041 00042 #include "tlib.hh" 00043 #include "signals.hh" 00044 00045 struct Automaton; 00046 00047 /***************************************************************************** 00048 ****************************************************************************** 00049 00050 The Box Language 00051 00052 ****************************************************************************** 00053 *****************************************************************************/ 00054 00055 00056 /***************************************************************************** 00057 Identifiers 00058 *****************************************************************************/ 00059 00060 Tree boxIdent(const char* name); 00061 bool isBoxIdent(Tree t); 00062 bool isBoxIdent(Tree t, const char** name); 00063 00064 00065 /***************************************************************************** 00066 Numbers 00067 *****************************************************************************/ 00068 00069 Tree boxInt(int n); 00070 Tree boxReal(double n); 00071 00072 bool isBoxInt(Tree t); 00073 bool isBoxReal(Tree t); 00074 00075 bool isBoxInt(Tree t, int* i); 00076 bool isBoxReal(Tree t, double* r); 00077 00078 00079 /***************************************************************************** 00080 Wire and Cut 00081 *****************************************************************************/ 00082 00083 Tree boxWire(); 00084 Tree boxCut(); 00085 00086 bool isBoxWire(Tree t); 00087 bool isBoxCut(Tree t); 00088 00089 00090 /***************************************************************************** 00091 Symbolic Boxes with symbolic slots 00092 *****************************************************************************/ 00093 00094 Tree boxSlot(int id); 00095 Tree boxSymbolic(Tree slot, Tree body); 00096 00097 bool isBoxSlot(Tree t); 00098 bool isBoxSymbolic(Tree t); 00099 00100 bool isBoxSlot(Tree t, int* id); 00101 bool isBoxSymbolic(Tree t, Tree& slot, Tree& body); 00102 00103 00104 /***************************************************************************** 00105 Composition of Boxes 00106 *****************************************************************************/ 00107 00108 Tree boxSeq (Tree x, Tree y); 00109 Tree boxPar (Tree x, Tree y); 00110 Tree boxRec (Tree x, Tree y); 00111 Tree boxSplit (Tree x, Tree y); 00112 Tree boxMerge (Tree x, Tree y); 00113 00114 bool isBoxSeq (Tree t, Tree& x, Tree& y); 00115 bool isBoxPar (Tree t, Tree& x, Tree& y); 00116 bool isBoxRec (Tree t, Tree& x, Tree& y); 00117 bool isBoxSplit (Tree t, Tree& x, Tree& y); 00118 bool isBoxMerge (Tree t, Tree& x, Tree& y); 00119 00120 /***************************************************************************** 00121 Algorithmic Composition of Boxes 00122 *****************************************************************************/ 00123 00124 Tree boxIPar(Tree x, Tree y, Tree z); 00125 Tree boxISeq(Tree x, Tree y, Tree z); 00126 Tree boxISum(Tree x, Tree y, Tree z); 00127 Tree boxIProd(Tree x, Tree y, Tree z); 00128 00129 bool isBoxIPar(Tree t, Tree& x, Tree& y, Tree& z); 00130 bool isBoxISeq(Tree t, Tree& x, Tree& y, Tree& z); 00131 bool isBoxISum(Tree t, Tree& x, Tree& y, Tree& z); 00132 bool isBoxIProd(Tree t, Tree& x, Tree& y, Tree& z); 00133 00134 00135 /***************************************************************************** 00136 Lambda-Calculus of Boxes 00137 *****************************************************************************/ 00138 00139 Tree buildBoxAbstr (Tree x, Tree y); 00140 Tree buildBoxAppl (Tree x, Tree y); 00141 00142 Tree boxAbstr (Tree x, Tree y); 00143 Tree boxAppl (Tree x, Tree y); 00144 00145 bool isBoxAbstr (Tree t); 00146 bool isBoxAppl (Tree t); 00147 00148 bool isBoxAbstr (Tree t, Tree& x, Tree& y); 00149 bool isBoxAppl (Tree t, Tree& x, Tree& y); 00150 00151 Tree closure (Tree abstr, Tree genv, Tree vis, Tree lenv); 00152 00153 bool isClosure (Tree t, Tree& abstr, Tree& genv, Tree& vis, Tree& lenv); 00154 00155 // for foo(x,y).faa expressions 00156 Tree boxAccess (Tree exp, Tree id); 00157 bool isBoxAccess(Tree t, Tree& exp, Tree& id); 00158 00159 00160 /***************************************************************************** 00161 Boxes with local definitions 00162 *****************************************************************************/ 00163 00164 Tree boxWithLocalDef (Tree body, Tree ldef); 00165 bool isBoxWithLocalDef (Tree t, Tree& body, Tree& ldef); 00166 00167 00168 /***************************************************************************** 00169 Modification of local definitions 00170 *****************************************************************************/ 00171 00172 Tree boxModifLocalDef (Tree body, Tree ldef); 00173 bool isBoxModifLocalDef (Tree t, Tree& body, Tree& ldef); 00174 00175 00176 /***************************************************************************** 00177 Error Boxe 00178 *****************************************************************************/ 00179 00180 Tree boxError(); 00181 bool isBoxError(Tree t); 00182 00183 /***************************************************************************** 00184 Primitive Boxes (n -> 1) 00185 *****************************************************************************/ 00186 00187 typedef Tree (*prim0)(); 00188 typedef Tree (*prim1)(Tree x); 00189 typedef Tree (*prim2)(Tree x, Tree y); 00190 typedef Tree (*prim3)(Tree x, Tree y, Tree z); 00191 typedef Tree (*prim4)(Tree w, Tree x, Tree y, Tree z); 00192 typedef Tree (*prim5)(Tree v, Tree w, Tree x, Tree y, Tree z); 00193 00194 Tree boxPrim0 (prim0 foo); 00195 Tree boxPrim1 (prim1 foo); 00196 Tree boxPrim2 (prim2 foo); 00197 Tree boxPrim3 (prim3 foo); 00198 Tree boxPrim4 (prim4 foo); 00199 Tree boxPrim5 (prim5 foo); 00200 00201 bool isBoxPrim0 (Tree s); 00202 bool isBoxPrim1 (Tree s); 00203 bool isBoxPrim2 (Tree s); 00204 bool isBoxPrim3 (Tree s); 00205 bool isBoxPrim4 (Tree s); 00206 bool isBoxPrim5 (Tree s); 00207 00208 bool isBoxPrim0 (Tree s, prim0* p); 00209 bool isBoxPrim1 (Tree s, prim1* p); 00210 bool isBoxPrim2 (Tree s, prim2* p); 00211 bool isBoxPrim3 (Tree s, prim3* p); 00212 bool isBoxPrim4 (Tree s, prim4* p); 00213 bool isBoxPrim5 (Tree s, prim5* p); 00214 00215 00216 /***************************************************************************** 00217 Foreign Functions 00218 *****************************************************************************/ 00219 00220 Tree boxFFun (Tree ff); 00221 bool isBoxFFun (Tree s); 00222 bool isBoxFFun (Tree s, Tree& ff); 00223 00224 00225 Tree boxFConst (Tree type, Tree name, Tree file); 00226 bool isBoxFConst (Tree s); 00227 bool isBoxFConst (Tree s, Tree& type, Tree& name, Tree& file); 00228 00229 00230 Tree boxFVar (Tree type, Tree name, Tree file); 00231 bool isBoxFVar (Tree s); 00232 bool isBoxFVar (Tree s, Tree& type, Tree& name, Tree& file); 00233 00234 00235 /***************************************************************************** 00236 Modules 00237 *****************************************************************************/ 00238 00239 Tree boxEnvironment(); 00240 bool isBoxEnvironment (Tree s); 00241 00242 Tree boxComponent (Tree filename); 00243 bool isBoxComponent (Tree s, Tree& filename); 00244 00245 Tree boxLibrary (Tree filename); 00246 bool isBoxLibrary (Tree s, Tree& filename); 00247 00248 Tree importFile(Tree filename); 00249 bool isImportFile(Tree s, Tree& filename); 00250 00251 00252 /***************************************************************************** 00253 User Interface Elements 00254 *****************************************************************************/ 00255 00256 Tree boxButton (Tree label); 00257 bool isBoxButton (Tree s); 00258 bool isBoxButton (Tree s, Tree& label); 00259 00260 Tree boxCheckbox (Tree label); 00261 bool isBoxCheckbox (Tree s); 00262 bool isBoxCheckbox (Tree s, Tree& label); 00263 00264 Tree boxVSlider (Tree label, Tree cur, Tree min, Tree max, Tree step); 00265 bool isBoxVSlider (Tree s); 00266 bool isBoxVSlider (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step); 00267 00268 Tree boxHSlider (Tree label, Tree cur, Tree min, Tree max, Tree step); 00269 bool isBoxHSlider (Tree s); 00270 bool isBoxHSlider (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step); 00271 00272 Tree boxNumEntry (Tree label, Tree cur, Tree min, Tree max, Tree step); 00273 bool isBoxNumEntry (Tree s); 00274 bool isBoxNumEntry (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step); 00275 00276 Tree boxVGroup (Tree label, Tree x); 00277 bool isBoxVGroup (Tree s); 00278 bool isBoxVGroup (Tree s, Tree& label, Tree& x); 00279 00280 Tree boxHGroup (Tree label, Tree x); 00281 bool isBoxHGroup (Tree s); 00282 bool isBoxHGroup (Tree s, Tree& label, Tree& x); 00283 00284 Tree boxTGroup (Tree label, Tree x); 00285 bool isBoxTGroup (Tree s); 00286 bool isBoxTGroup (Tree s, Tree& label, Tree& x); 00287 00288 // GUI outputs 00289 Tree boxVBargraph (Tree label, Tree min, Tree max); 00290 bool isBoxVBargraph (Tree s); 00291 bool isBoxVBargraph (Tree s, Tree& label, Tree& min, Tree& max); 00292 00293 Tree boxHBargraph (Tree label, Tree min, Tree max); 00294 bool isBoxHBargraph (Tree s); 00295 bool isBoxHBargraph (Tree s, Tree& label, Tree& min, Tree& max); 00296 00297 00298 /***************************************************************************** 00299 case (pattern matching) 00300 *****************************************************************************/ 00301 Tree boxCase (Tree rules); 00302 bool isBoxCase (Tree s); 00303 bool isBoxCase (Tree s, Tree& rules); 00304 00305 Tree boxPatternMatcher (Automaton* a, int state, Tree env, Tree origRules, Tree revParamList); 00306 bool isBoxPatternMatcher (Tree s); 00307 bool isBoxPatternMatcher (Tree s, Automaton*& a, int& state, Tree& env, Tree& origRules, Tree& revParamList); 00308 00309 // wrap an id into a pattern variable 00310 Tree boxPatternVar (Tree id); 00311 bool isBoxPatternVar(Tree s, Tree& id); 00312 00313 00314 /***************************************************************************** 00315 ****************************************************************************** 00316 00317 Box Algorithms 00318 00319 ****************************************************************************** 00320 *****************************************************************************/ 00321 00322 // return the number of input 00323 bool getBoxType (Tree box, int* inum, int* onum); 00324 00325 00326 #endif
1.8.0