1 /************************************************************************
2 ************************************************************************
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
24 #ifndef _DOC_COMPILE_SCAL_
25 #define _DOC_COMPILE_SCAL_
32 #include "sigtyperules.hh"
33 #include "occurences.hh"
34 #include "property.hh"
38 #include "doc_Text.hh"
39 #include "description.hh"
42 ///////////////////////////////////////////////////////////////////////
44 * Compile a list of FAUST signals into a list of LaTeX formulas.
46 ///////////////////////////////////////////////////////////////////////
52 property<string> fCompileProperty;
53 property<string> fVectorProperty;
56 Description* fDescription;
58 static map<string, int> fIDCounters;
61 int fPriority; ///< math priority context
66 DocCompiler (int numInputs, int numOutputs)
68 fLateq(new Lateq(numInputs, numOutputs)),
73 DocCompiler ( Lateq* k, int priority)
83 Lateq* compileLateq (Tree L, Lateq* compiledEqn);
84 Tree annotate(Tree L0);
86 Lateq* getLateq() { return (Lateq*)fLateq; }
87 void setDescription(Description* descr) { fDescription= descr; }
88 Description* getDescription() { return fDescription; }
93 string CS (Tree sig, int priority);
94 string generateCode (Tree sig, int priority);
95 string generateCacheCode(Tree sig, const string& exp) ;
96 string generateVariableStore(Tree sig, const string& exp);
98 string getFreshID (const string& prefix);
100 bool getCompiledExpression(Tree sig, string& name);
101 string setCompiledExpression(Tree sig, const string& name);
103 void setVectorNameProperty(Tree sig, const string& vecname);
104 bool getVectorNameProperty(Tree sig, string& vecname);
106 int getSharingCount(Tree t);
107 void setSharingCount(Tree t, int count);
108 void sharingAnalysis(Tree t);
109 void sharingAnnotation(int vctxt, Tree t);
111 bool isShortEnough(string& s, unsigned int max);
114 /* Code generation. */
116 string generateXtended (Tree sig, int priority);
117 string generateFixDelay (Tree sig, Tree arg, Tree size, int priority);
118 string generatePrefix (Tree sig, Tree x, Tree e, int priority);
119 string generateIota (Tree sig, Tree arg);
120 string generateBinOp (Tree sig, int opcode, Tree arg1, Tree arg2, int priority);
122 string generateFFun (Tree sig, Tree ff, Tree largs, int priority);
124 string generateInput (Tree sig, const string& idx);
125 string generateOutput (Tree sig, const string& idx, const string& arg1);
127 // string generateDocReadOnlyTbl (Tree sig, Tree size, Tree content, Tree ridx);
128 // string generateDocReadWriteTbl (Tree sig, Tree size, Tree content, Tree widx, Tree wsig, Tree ridx);
129 string generateDocConstantTbl (Tree sig, Tree size, Tree content);
130 string generateDocWriteTbl (Tree sig, Tree size, Tree content, Tree widx, Tree wsig);
131 string generateDocAccessTbl (Tree sig, Tree tbl, Tree ridx);
133 string generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2, int priority);
134 string generateSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3, int priority);
136 string generateRecProj (Tree sig, Tree exp, int i, int priority);
137 void generateRec (Tree sig, Tree var, Tree le, int priority);
139 string generateIntCast (Tree sig, Tree x, int priority);
140 string generateFloatCast (Tree sig, Tree x, int priority);
142 string generateButton (Tree sig, Tree label);
143 string generateCheckbox (Tree sig, Tree label);
144 string generateVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step);
145 string generateHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step);
146 string generateNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step);
148 string generateVBargraph (Tree sig, Tree label, Tree min, Tree max, const string& exp);
149 string generateHBargraph (Tree sig, Tree label, Tree min, Tree max, const string& exp);
150 string generateAttach (Tree sig, Tree x, Tree y, int priority);
152 string generateNumber(Tree sig, const string& exp);
153 string generateFConst (Tree sig, const string& file, const string& name);
154 string generateFVar (Tree sig, const string& file, const string& name);
156 string generateDelayVec(Tree sig, const string& exp, const string& ctype, const string& vname, int mxd);
157 string generateDelayVecNoTemp(Tree sig, const string& exp, const string& ctype, const string& vname, int mxd);
158 void generateDelayLine(const string& ctype, const string& vname, int mxd, const string& exp);
160 void getTypedNames(Type t, const string& prefix, string& ctype, string& vname);
161 void printGCCall(Tree sig, const string& calledFunction);
164 /* Managment of user interface elements. */
166 void getUIDocInfos(Tree path, string& label, string& unit);
167 string getUIDir (Tree pathname);
168 string prepareBinaryUI(const string& name, Tree pathname);
169 string prepareIntervallicUI(const string& name, Tree path, Tree tcur, Tree tmin, Tree tmax);