FAUST compiler  0.9.9.6b8
doc_compile.hh
Go to the documentation of this file.
1 /************************************************************************
2  ************************************************************************
3  FAUST compiler
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.
10 
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.
15 
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  ************************************************************************/
21 
22 
23 
24 #ifndef _DOC_COMPILE_SCAL_
25 #define _DOC_COMPILE_SCAL_
26 
27 
28 #include <string>
29 #include <list>
30 #include <map>
31 
32 #include "sigtyperules.hh"
33 #include "occurences.hh"
34 #include "property.hh"
35 #include "signals.hh"
36 #include "lateq.hh"
37 #include "Text.hh"
38 #include "doc_Text.hh"
39 #include "description.hh"
40 
41 
43 
46 
49 {
50  protected:
51 
54 
57 
58  static map<string, int> fIDCounters;
61  int fPriority;
62 
63 
64  public:
65 
66  DocCompiler (int numInputs, int numOutputs)
67  :
68  fLateq(new Lateq(numInputs, numOutputs)),
69  fDescription(0),
70  fPriority(0)
71  {}
72 
73  DocCompiler ( Lateq* k, int priority)
74  :
75  fLateq(k),
76  fDescription(0),
77  fPriority(priority)
78  {}
79 
81  {}
82 
83  Lateq* compileLateq (Tree L, Lateq* compiledEqn);
84  Tree annotate(Tree L0);
85 
86  Lateq* getLateq() { return (Lateq*)fLateq; }
87  void setDescription(Description* descr) { fDescription= descr; }
89 
90 
91  protected:
92 
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);
97 
98  string getFreshID (const string& prefix);
99 
100  bool getCompiledExpression(Tree sig, string& name);
101  string setCompiledExpression(Tree sig, const string& name);
102 
103  void setVectorNameProperty(Tree sig, const string& vecname);
104  bool getVectorNameProperty(Tree sig, string& vecname);
105 
106  int getSharingCount(Tree t);
107  void setSharingCount(Tree t, int count);
108  void sharingAnalysis(Tree t);
109  void sharingAnnotation(int vctxt, Tree t);
110 
111  bool isShortEnough(string& s, unsigned int max);
112 
113 
114  /* Code generation. */
115 
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);
121 
122  string generateFFun (Tree sig, Tree ff, Tree largs, int priority);
123 
124  string generateInput (Tree sig, const string& idx);
125  string generateOutput (Tree sig, const string& idx, const string& arg1);
126 
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);
132 
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);
135 
136  string generateRecProj (Tree sig, Tree exp, int i, int priority);
137  void generateRec (Tree sig, Tree var, Tree le, int priority);
138 
139  string generateIntCast (Tree sig, Tree x, int priority);
140  string generateFloatCast (Tree sig, Tree x, int priority);
141 
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);
147 
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);
151 
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);
155 
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);
159 
160  void getTypedNames(Type t, const string& prefix, string& ctype, string& vname);
161  void printGCCall(Tree sig, const string& calledFunction);
162 
163 
164  /* Managment of user interface elements. */
165 
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);
170 };
171 
172 #endif
string generateAttach(Tree sig, Tree x, Tree y, int priority)
void sharingAnalysis(Tree t)
Definition: doc_sharing.cpp:96
string prepareIntervallicUI(const string &name, Tree path, Tree tcur, Tree tmin, Tree tmax)
Prepare "intervallic" user interface elements (sliders, nentry).
string generateDelayVec(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism.
string CS(Tree sig, int priority)
Compile a signal.
string generateCacheCode(Tree sig, const string &exp)
string generateIntCast(Tree sig, Tree x, int priority)
string setCompiledExpression(Tree sig, const string &name)
Set the string of a compiled expression is already compiled.
string prepareBinaryUI(const string &name, Tree pathname)
Prepare binary user interface elements (button, checkbox).
void generateDelayLine(const string &ctype, const string &vname, int mxd, const string &exp)
Generate code for the delay mecchanism without using temporary variables.
string generateFVar(Tree sig, const string &file, const string &name)
DocCompiler(int numInputs, int numOutputs)
Definition: doc_compile.hh:66
string generateSelect2(Tree sig, Tree sel, Tree s1, Tree s2, int priority)
Generate a select2 code.
string generateButton(Tree sig, Tree label)
string generateXtended(Tree sig, int priority)
retrieve the type annotation of sig
string generateDocConstantTbl(Tree sig, Tree size, Tree content)
Generate the equation of a constant table (its content is time constant).
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Description * fDescription
Definition: doc_compile.hh:56
Definition: lateq.hh:56
void setVectorNameProperty(Tree sig, const string &vecname)
Set the vector name property of a signal, the name of the vector used to store the previous values of...
string generateRecProj(Tree sig, Tree exp, int i, int priority)
Generate code for a projection of a group of mutually recursive definitions.
int fPriority
math priority context
Definition: doc_compile.hh:61
Lateq * compileLateq(Tree L, Lateq *compiledEqn)
string generateCode(Tree sig, int priority)
Main code generator dispatch.
OccMarkup fOccMarkup
Definition: doc_compile.hh:60
double max(double x, double y)
Definition: interval.hh:60
string generateDocWriteTbl(Tree sig, Tree size, Tree content, Tree widx, Tree wsig)
Generate the equation of a write table, which content is time dependent.
DocCompiler(Lateq *k, int priority)
Definition: doc_compile.hh:73
void sharingAnnotation(int vctxt, Tree t)
Tree annotate(Tree L0)
Definition: doc_compile.cpp:88
property< string > fVectorProperty
Definition: doc_compile.hh:53
string generateSelect3(Tree sig, Tree sel, Tree s1, Tree s2, Tree s3, int priority)
Generate a select3 code.
string generateDocAccessTbl(Tree sig, Tree tbl, Tree ridx)
Generate the equation of a write table, which content is time dependent.
string generateFConst(Tree sig, const string &file, const string &name)
string generateCheckbox(Tree sig, Tree label)
string generateVBargraph(Tree sig, Tree label, Tree min, Tree max, const string &exp)
string generateNumEntry(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateBinOp(Tree sig, int opcode, Tree arg1, Tree arg2, int priority)
string generateIota(Tree sig, Tree arg)
Generate a "iota" time function, n-cyclical.
void getUIDocInfos(Tree path, string &label, string &unit)
Get information on a user interface element for documentation.
Lateq * fLateq
Definition: doc_compile.hh:55
void printGCCall(Tree sig, const string &calledFunction)
Print calling information of generateCode, for debug purposes.
Tree fSharingKey
Definition: doc_compile.hh:59
bool isShortEnough(string &s, unsigned int max)
string generateDelayVecNoTemp(Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
Generate code for the delay mecchanism without using temporary variables.
void setSharingCount(Tree t, int count)
Definition: doc_sharing.cpp:81
string generatePrefix(Tree sig, Tree x, Tree e, int priority)
Generate LaTeX code for "prefix", a 1­sample-delay explicitely initialized.
string generateFFun(Tree sig, Tree ff, Tree largs, int priority)
string generateHBargraph(Tree sig, Tree label, Tree min, Tree max, const string &exp)
Occurences Markup of a root tree.
Definition: occurences.hh:32
string getUIDir(Tree pathname)
Get the directory of a user interface element.
Lateq * getLateq()
Definition: doc_compile.hh:86
void setDescription(Description *descr)
Definition: doc_compile.hh:87
string generateInput(Tree sig, const string &idx)
bool getVectorNameProperty(Tree sig, string &vecname)
Get the vector name property of a signal, the name of the vector used to store the previous values of...
void getTypedNames(Type t, const string &prefix, string &ctype, string &vname)
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
void generateRec(Tree sig, Tree var, Tree le, int priority)
Generate code for a group of mutually recursive definitions.
Compile a list of FAUST signals into a list of LaTeX formulas.
Definition: doc_compile.hh:48
int getSharingCount(Tree t)
Definition: doc_sharing.cpp:66
string generateFloatCast(Tree sig, Tree x, int priority)
Don't generate float cast !
static map< string, int > fIDCounters
Definition: doc_compile.hh:58
string generateVSlider(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateNumber(Tree sig, const string &exp)
string generateOutput(Tree sig, const string &idx, const string &arg1)
Unused for the moment !
Description * getDescription()
Definition: doc_compile.hh:88
bool getCompiledExpression(Tree sig, string &name)
Test if a signal is already compiled.
string generateFixDelay(Tree sig, Tree arg, Tree size, int priority)
Generate code for accessing a delayed signal.
API to the typing system of signals.
string generateVariableStore(Tree sig, const string &exp)
double min(double x, double y)
Definition: interval.hh:59
string getFreshID(const string &prefix)
Definition: doc_compile.cpp:72
string generateHSlider(Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
property< string > fCompileProperty
Definition: doc_compile.hh:52