DocCompiler Class Reference

Compile a list of FAUST signals into a list of LaTeX formulas. More...

#include <doc_compile.hh>

Collaboration diagram for DocCompiler:
[legend]

List of all members.

Public Member Functions

 DocCompiler (int numInputs, int numOutputs)
 DocCompiler (Lateq *k, int priority)
 ~DocCompiler ()
LateqcompileLateq (Tree L, Lateq *compiledEqn)
Tree annotate (Tree L0)
LateqgetLateq ()
void setDescription (Description *descr)
DescriptiongetDescription ()

Protected Member Functions

string CS (Tree sig, int priority)
 Compile a signal.
string generateCode (Tree sig, int priority)
 Main code generator dispatch.
string generateCacheCode (Tree sig, const string &exp)
string generateVariableStore (Tree sig, const string &exp)
string getFreshID (const string &prefix)
bool getCompiledExpression (Tree sig, string &name)
 Test if a signal is already compiled.
string setCompiledExpression (Tree sig, const string &name)
 Set the string of a compiled expression is already compiled.
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 the signal to implement a delay.
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 the signal to implement a delay.
int getSharingCount (Tree t)
void setSharingCount (Tree t, int count)
void sharingAnalysis (Tree t)
void sharingAnnotation (int vctxt, Tree t)
bool isShortEnough (string &s, unsigned int max)
string generateXtended (Tree sig, int priority)
 retrieve the type annotation of sig
string generateFixDelay (Tree sig, Tree arg, Tree size, int priority)
 Generate code for accessing a delayed signal.
string generatePrefix (Tree sig, Tree x, Tree e, int priority)
 Generate LaTeX code for "prefix", a 1­sample-delay explicitely initialized.
string generateIota (Tree sig, Tree arg)
 Generate a "iota" time function, n-cyclical.
string generateBinOp (Tree sig, int opcode, Tree arg1, Tree arg2, int priority)
 Generate binary operations, managing priority parenthesis.
string generateFFun (Tree sig, Tree ff, Tree largs, int priority)
string generateInput (Tree sig, const string &idx)
string generateOutput (Tree sig, const string &idx, const string &arg1)
 Unused for the moment !
string generateDocConstantTbl (Tree sig, Tree size, Tree content)
 Generate the equation of a constant table (its content is time constant).
string generateDocWriteTbl (Tree sig, Tree size, Tree content, Tree widx, Tree wsig)
 Generate the equation of a write table, which content is time dependent.
string generateDocAccessTbl (Tree sig, Tree tbl, Tree ridx)
 Generate the equation of a write table, which content is time dependent.
string generateSelect2 (Tree sig, Tree sel, Tree s1, Tree s2, int priority)
 Generate a select2 code.
string generateSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3, int priority)
 Generate a select3 code.
string generateRecProj (Tree sig, Tree exp, int i, int priority)
 Generate code for a projection of a group of mutually recursive definitions.
void generateRec (Tree sig, Tree var, Tree le, int priority)
 Generate code for a group of mutually recursive definitions.
string generateIntCast (Tree sig, Tree x, int priority)
string generateFloatCast (Tree sig, Tree x, int priority)
 Don't generate float cast !
string generateButton (Tree sig, Tree label)
string generateCheckbox (Tree sig, Tree label)
string generateVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step)
string generateVBargraph (Tree sig, Tree label, Tree min, Tree max, const string &exp)
string generateHBargraph (Tree sig, Tree label, Tree min, Tree max, const string &exp)
string generateAttach (Tree sig, Tree x, Tree y, int priority)
string generateNumber (Tree sig, const string &exp)
string generateFConst (Tree sig, const string &file, const string &name)
string generateFVar (Tree sig, const string &file, const string &name)
string generateDelayVec (Tree sig, const string &exp, const string &ctype, const string &vname, int mxd)
 Generate code for the delay mecchanism.
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 generateDelayLine (const string &ctype, const string &vname, int mxd, const string &exp)
 Generate code for the delay mecchanism without using temporary variables.
void getTypedNames (Type t, const string &prefix, string &ctype, string &vname)
void printGCCall (Tree sig, const string &calledFunction)
 Print calling information of generateCode, for debug purposes.
void getUIDocInfos (Tree path, string &label, string &unit)
 Get information on a user interface element for documentation.
string getUIDir (Tree pathname)
 Get the directory of a user interface element.
string prepareBinaryUI (const string &name, Tree pathname)
 Prepare binary user interface elements (button, checkbox).
string prepareIntervallicUI (const string &name, Tree path, Tree tcur, Tree tmin, Tree tmax)
 Prepare "intervallic" user interface elements (sliders, nentry).

Protected Attributes

property< string > fCompileProperty
property< string > fVectorProperty
LateqfLateq
DescriptionfDescription
Tree fSharingKey
OccMarkup fOccMarkup
int fPriority
 math priority context

Static Protected Attributes

static map< string, int > fIDCounters

Detailed Description

Compile a list of FAUST signals into a list of LaTeX formulas.

Definition at line 48 of file doc_compile.hh.


Constructor & Destructor Documentation

DocCompiler::DocCompiler ( int  numInputs,
int  numOutputs 
) [inline]

Definition at line 66 of file doc_compile.hh.

00068     :
00069     fLateq(new Lateq(numInputs, numOutputs)),
00070     fDescription(0), 
00071     fPriority(0)
    {}

DocCompiler::DocCompiler ( Lateq k,
int  priority 
) [inline]

Definition at line 73 of file doc_compile.hh.

00074     : 
00075     fLateq(k),
00076     fDescription(0), 
00077     fPriority(priority)
00078     {}

DocCompiler::~DocCompiler (  )  [inline]

Definition at line 80 of file doc_compile.hh.

00081     {}


Member Function Documentation

Tree DocCompiler::annotate ( Tree  L0  ) 

Definition at line 91 of file doc_compile.cpp.

References fOccMarkup, OccMarkup::mark(), recursivnessAnnotation(), sharingAnalysis(), and typeAnnotation().

Referenced by annotateSuperList().

00092 {
00093     recursivnessAnnotation(LS);     // Annotate LS with recursivness information
00094     typeAnnotation(LS);             // Annotate LS with type information
00095     sharingAnalysis(LS);            // annotate LS with sharing count
00096     fOccMarkup.mark(LS);            // annotate LS with occurences analysis
00097 
00098     return LS;
00099 }

Here is the call graph for this function:

Here is the caller graph for this function:

Lateq * DocCompiler::compileLateq ( Tree  L,
Lateq compiledEqn 
)

< Dynamic field !

Definition at line 105 of file doc_compile.cpp.

References Lateq::addOutputSigFormula(), CS(), docT(), fLateq, gDocNoticeFlagMap, getFreshID(), getSigNickname(), hd(), isList(), Lateq::outputs(), subst(), tl(), and tree2str().

Referenced by mapCompileDocEqnSigs().

00106 {
00107     //cerr << "Documentator : compileLateq : L = "; printSignal(L, stdout, 0); cerr << endl;
00108     
00109     fLateq = compiledEqn; 
00110     int priority = 0;
00111     
00112     for (int i = 0; isList(L); L = tl(L), i++) {
00113         Tree sig = hd(L);
00114         Tree id;
00115         if(getSigNickname(sig, id)) {
00116             //cerr << "Documentator : compileLateq : NICKNAMEPROPERTY = " << tree2str(id) << endl;
00117             fLateq->addOutputSigFormula(subst("$0(t) = $1", tree2str(id), CS(sig, priority), docT(i))); 
00118         } else {
00119             //cerr << "Documentator : compileLateq : NO NICKNAMEPROPERTY" << endl;
00120             if (fLateq->outputs() == 1) {
00121                 fLateq->addOutputSigFormula(subst("y(t) = $0", CS(sig, priority))); 
00122                 gDocNoticeFlagMap["outputsig"] = true;
00123             } else {
00124                 fLateq->addOutputSigFormula(subst("$0(t) = $1", getFreshID("y"), CS(sig, priority)));   
00125                 gDocNoticeFlagMap["outputsigs"] = true;
00126             }
00127         }
00128     }
00129     return fLateq;
00130 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::CS ( Tree  sig,
int  priority 
) [protected]

Compile a signal.

Parameters:
sig the signal expression to compile.
Returns:
the C code translation of sig as a string

Definition at line 168 of file doc_compile.cpp.

References generateCode(), getCompiledExpression(), and setCompiledExpression().

Referenced by compileLateq(), generateAttach(), generateBinOp(), generateCode(), generateDocAccessTbl(), generateDocConstantTbl(), generateDocWriteTbl(), generateFFun(), generateFixDelay(), generateFloatCast(), generateIntCast(), generatePrefix(), generateRec(), generateSelect2(), generateSelect3(), and generateXtended().

00169 {
00170     string      code;
00171 
00172     if (!getCompiledExpression(sig, code)) { // not compiled yet.
00173         code = generateCode(sig, priority);
00174         setCompiledExpression(sig, code);
00175     }
00176     return code;
00177 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateAttach ( Tree  sig,
Tree  x,
Tree  y,
int  priority 
) [protected]

Definition at line 721 of file doc_compile.cpp.

References CS(), generateCacheCode(), getVectorNameProperty(), and setVectorNameProperty().

Referenced by generateCode().

00722 {
00723     string vname;
00724     string exp;
00725     
00726     CS(y, priority);
00727     exp = CS(x, priority);
00728     
00729     if(getVectorNameProperty(x, vname)) {
00730         setVectorNameProperty(sig, vname);
00731     }
00732 
00733     return generateCacheCode(sig, exp);
00734 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateBinOp ( Tree  sig,
int  opcode,
Tree  arg1,
Tree  arg2,
int  priority 
) [protected]

Generate binary operations, managing priority parenthesis.

Parameters:
sig The signal expression to treat.
opcode The operation code, as described in gBinOpLateqTable.
arg1 The first operand.
arg2 The second operand.
priority The priority of the environment of the expression.
Returns:
<string> The LaTeX code translation of the signal, cached.
Remarks:
The case of LaTeX frac{}{} is special.
Todo:
Handle integer arithmetics, by testing arguments type, and printing dedicated operators (, , , ).

Definition at line 398 of file doc_compile.cpp.

References CS(), BinOp::fName, BinOp::fPriority, gBinOpLateqTable, gDocNoticeFlagMap, generateCacheCode(), getSigType(), kAdd, kDiv, kInt, kMul, kSub, and subst().

Referenced by generateCode().

00399 {
00400     string s;
00401     int thisPriority = gBinOpLateqTable[opcode]->fPriority;
00402     
00403     /* Priority parenthesis handling. */
00404     string lpar = "";
00405     string rpar = "";
00406     if (thisPriority < priority) {
00407         lpar = " \\left(";
00408         rpar = "\\right) ";
00409     }
00410     
00411     Type t1 = getSigType(arg1);
00412     Type t2 = getSigType(arg2);
00413     bool intOpDetected = false;
00414     if ( (t1->nature() == kInt) && (t2->nature() == kInt) ) {
00415         intOpDetected = true;
00416     }
00417     
00418     string op;
00419     if(!intOpDetected) {
00420         op = gBinOpLateqTable[opcode]->fName;
00421     } else {
00422         switch (opcode) {
00423             case kAdd:
00424                 op = "\\oplus";
00425                 gDocNoticeFlagMap["intplus"] = true;
00426                 break;
00427             case kSub:
00428                 op = "\\ominus";
00429                 gDocNoticeFlagMap["intminus"] = true;
00430                 break;
00431             case kMul:
00432                 op = "\\odot";
00433                 gDocNoticeFlagMap["intmult"] = true;
00434                 break;
00435             case kDiv:
00436                 op = "\\oslash";
00437                 gDocNoticeFlagMap["intdiv"] = true;
00438                 break;
00439             default:
00440                 op = gBinOpLateqTable[opcode]->fName;
00441                 break;
00442         }
00443     }
00444     
00445     /* LaTeX frac{}{} handling VS general case. */
00446     if ( (opcode == kDiv) && (!intOpDetected) ) { 
00447         s = subst("$0\\frac{$1}{$2}$3", lpar, CS(arg1, 0), CS(arg2, 0), rpar);
00448     } else {
00449         s = subst("$0$1 $2 $3$4", lpar, CS(arg1, thisPriority), op, CS(arg2, thisPriority), rpar);
00450     }
00451     
00452     if (opcode == kMul) {
00453         gDocNoticeFlagMap["cdot"] = true;
00454     }
00455     
00456     return generateCacheCode(sig, s);
00457 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateButton ( Tree  sig,
Tree  label 
) [protected]

Definition at line 638 of file doc_compile.cpp.

References Lateq::addUISigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getUIDir(), and prepareBinaryUI().

Referenced by generateCode().

00639 {
00640     string vname = getFreshID("{u_b}");
00641     string varname = vname + "(t)";
00642     fLateq->addUISigFormula(getUIDir(path), prepareBinaryUI(varname, path));
00643     gDocNoticeFlagMap["buttonsigs"] = true;
00644     return generateCacheCode(sig, varname);
00645 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateCacheCode ( Tree  sig,
const string &  exp 
) [protected]

Definition at line 521 of file doc_compile.cpp.

References fOccMarkup, gDocNoticeFlagMap, generateDelayVec(), generateVariableStore(), getCompiledExpression(), Occurences::getMaxDelay(), getSharingCount(), getSigType(), getTypedNames(), getVectorNameProperty(), isVerySimpleFormula(), and OccMarkup::retrieve().

Referenced by generateAttach(), generateBinOp(), generateButton(), generateCheckbox(), generateDocAccessTbl(), generateFloatCast(), generateFVar(), generateHBargraph(), generateHSlider(), generateInput(), generateIntCast(), generateNumEntry(), generatePrefix(), generateVBargraph(), generateVSlider(), and generateXtended().

00522 {
00523     //cerr << "!! entering generateCacheCode with sig=\"" << ppsig(sig) << "\"" << endl;    
00524     
00525     string      vname, ctype, code, vectorname;
00526     
00527     int         sharing = getSharingCount(sig);
00528     Occurences* o = fOccMarkup.retrieve(sig);
00529     
00530     // check reentrance
00531     if (getCompiledExpression(sig, code)) {
00532         //cerr << "!! generateCacheCode called a true getCompiledExpression" << endl;
00533         return code;
00534     }
00535     
00536     // check for expression occuring in delays
00537     if (o->getMaxDelay()>0) {
00538         if (getVectorNameProperty(sig, vectorname)) {
00539             return exp;
00540         }
00541         getTypedNames(getSigType(sig), "r", ctype, vname);
00542         gDocNoticeFlagMap["recursigs"] = true;
00543         //cerr << "- r : generateCacheCode : vame=\"" << vname << "\", for sig=\"" << ppsig(sig) << "\"" << endl;
00544         if (sharing>1) {
00545             //cerr << "      generateCacheCode calls generateDelayVec(generateVariableStore) on vame=\"" << vname << "\"" << endl;            
00546             return generateDelayVec(sig, generateVariableStore(sig,exp), ctype, vname, o->getMaxDelay());
00547         } else {
00548             //cerr << "      generateCacheCode calls generateDelayVec(exp) on vame=\"" << vname << "\"" << endl;            
00549             return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
00550         }
00551     } 
00552     else if (sharing == 1 || getVectorNameProperty(sig, vectorname) || isVerySimpleFormula(sig)) {
00553         //cerr << "! generateCacheCode : sharing == 1 : return \"" << exp << "\"" << endl;
00554         return exp;
00555     } 
00556     else if (sharing > 1) {
00557         //cerr << "! generateCacheCode : sharing > 1 : return \"" << exp << "\"" << endl;
00558         return generateVariableStore(sig, exp);
00559     } 
00560     else {
00561         cerr << "Error in sharing count (" << sharing << ") for " << *sig << endl;
00562         exit(1);
00563     }
00564     
00565     return "Error in generateCacheCode";
00566 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateCheckbox ( Tree  sig,
Tree  label 
) [protected]

Definition at line 647 of file doc_compile.cpp.

References Lateq::addUISigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getUIDir(), and prepareBinaryUI().

Referenced by generateCode().

00648 {
00649     string vname = getFreshID("{u_c}");
00650     string varname = vname + "(t)";
00651     fLateq->addUISigFormula(getUIDir(path), prepareBinaryUI(varname, path));
00652     gDocNoticeFlagMap["checkboxsigs"] = true;
00653     return generateCacheCode(sig, varname);
00654 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateCode ( Tree  sig,
int  priority 
) [protected]

Main code generator dispatch.

According to the type of the input signal, generateCode calls the appropriate generator with appropriate arguments.

Parameters:
sig The signal expression to compile.
priority The environment priority of the expression.
Returns:
<string> The LaTeX code translation of the signal.

Definition at line 196 of file doc_compile.cpp.

References CS(), docT(), generateAttach(), generateBinOp(), generateButton(), generateCheckbox(), generateDocAccessTbl(), generateDocConstantTbl(), generateDocWriteTbl(), generateFConst(), generateFFun(), generateFixDelay(), generateFloatCast(), generateFVar(), generateHSlider(), generateInput(), generateIntCast(), generateIota(), generateNumber(), generateNumEntry(), generateOutput(), generatePrefix(), generateRecProj(), generateSelect2(), generateSelect3(), generateVSlider(), generateXtended(), getUserData(), isProj(), isSigAttach(), isSigBinOp(), isSigButton(), isSigCheckbox(), isSigDocAccessTbl(), isSigDocConstantTbl(), isSigDocWriteTbl(), isSigFConst(), isSigFFun(), isSigFixDelay(), isSigFloatCast(), isSigFVar(), isSigHBargraph(), isSigHSlider(), isSigInput(), isSigInt(), isSigIntCast(), isSigIota(), isSigNumEntry(), isSigOutput(), isSigPrefix(), isSigReal(), isSigSelect2(), isSigSelect3(), isSigVBargraph(), isSigVSlider(), name(), printGCCall(), and tree2str().

Referenced by CS().

00197 {
00198     int     i;
00199     double  r;
00200     Tree    c, sel, x, y, z, u, label, ff, largs, type, name, file;
00201     
00202     if ( getUserData(sig) )                         { printGCCall(sig,"generateXtended");   return generateXtended  (sig, priority);        }
00203     else if ( isSigInt(sig, &i) )                   { printGCCall(sig,"generateNumber");    return generateNumber   (sig, docT(i));         }
00204     else if ( isSigReal(sig, &r) )                  { printGCCall(sig,"generateNumber");    return generateNumber   (sig, docT(r));         }
00205     else if ( isSigInput(sig, &i) )                 { printGCCall(sig,"generateInput");     return generateInput    (sig, docT(i+1));       }
00206     else if ( isSigOutput(sig, &i, x) )             { printGCCall(sig,"generateOutput");    return generateOutput   (sig, docT(i+1), CS(x, priority));  }
00207     
00208     else if ( isSigFixDelay(sig, x, y) )            { printGCCall(sig,"generateFixDelay");  return generateFixDelay (sig, x, y, priority);  }
00209     else if ( isSigPrefix(sig, x, y) )              { printGCCall(sig,"generatePrefix");    return generatePrefix   (sig, x, y, priority);  }
00210     else if ( isSigIota(sig, x) )                   { printGCCall(sig,"generateIota");      return generateIota     (sig, x);               }
00211     
00212     else if ( isSigBinOp(sig, &i, x, y) )           { printGCCall(sig,"generateBinOp");     return generateBinOp    (sig, i, x, y, priority);       }
00213     else if ( isSigFFun(sig, ff, largs) )           { printGCCall(sig,"generateFFun");      return generateFFun     (sig, ff, largs, priority);     }
00214     else if ( isSigFConst(sig, type, name, file) )  { printGCCall(sig,"generateFConst");    return generateFConst   (sig, tree2str(file), tree2str(name)); }
00215     else if ( isSigFVar(sig, type, name, file) )    { printGCCall(sig,"generateFVar");      return generateFVar     (sig, tree2str(file), tree2str(name)); }
00216     
00217     // new special tables for documentation purposes
00218 
00219     else if ( isSigDocConstantTbl(sig, x, y) )      { printGCCall(sig,"generateDocConstantTbl");    return generateDocConstantTbl (sig, x, y);  }
00220     else if ( isSigDocWriteTbl(sig,x,y,z,u) )       { printGCCall(sig,"generateDocWriteTbl");       return generateDocWriteTbl (sig, x, y, z, u); }
00221     else if ( isSigDocAccessTbl(sig, x, y) )        { printGCCall(sig, "generateDocAccessTbl");     return generateDocAccessTbl(sig, x, y); }
00222 
00223 
00224     else if ( isSigSelect2(sig, sel, x, y) )        { printGCCall(sig,"generateSelect2");   return generateSelect2  (sig, sel, x, y, priority);     }
00225     else if ( isSigSelect3(sig, sel, x, y, z) )     { printGCCall(sig,"generateSelect3");   return generateSelect3  (sig, sel, x, y, z, priority);  }
00226     
00227     else if ( isProj(sig, &i, x) )                  { printGCCall(sig,"generateRecProj");   return generateRecProj  (sig, x, i, priority);  }
00228     
00229     else if ( isSigIntCast(sig, x) )                { printGCCall(sig,"generateIntCast");   return generateIntCast  (sig, x, priority);     }
00230     else if ( isSigFloatCast(sig, x) )              { printGCCall(sig,"generateFloatCast"); return generateFloatCast(sig, x, priority);     }
00231     
00232     else if ( isSigButton(sig, label) )             { printGCCall(sig,"generateButton");    return generateButton   (sig, label);           }
00233     else if ( isSigCheckbox(sig, label) )           { printGCCall(sig,"generateCheckbox");  return generateCheckbox (sig, label);           }
00234     else if ( isSigVSlider(sig, label,c,x,y,z) )    { printGCCall(sig,"generateVSlider");   return generateVSlider  (sig, label, c,x,y,z);  }
00235     else if ( isSigHSlider(sig, label,c,x,y,z) )    { printGCCall(sig,"generateHSlider");   return generateHSlider  (sig, label, c,x,y,z);  }
00236     else if ( isSigNumEntry(sig, label,c,x,y,z) )   { printGCCall(sig,"generateNumEntry");  return generateNumEntry (sig, label, c,x,y,z);  }
00237     
00238     else if ( isSigVBargraph(sig, label,x,y,z) )    { printGCCall(sig,"generateVBargraph"); return CS(z, priority);}//generateVBargraph     (sig, label, x, y, CS(z, priority)); }
00239     else if ( isSigHBargraph(sig, label,x,y,z) )    { printGCCall(sig,"generateHBargraph"); return CS(z, priority);}//generateHBargraph     (sig, label, x, y, CS(z, priority)); }
00240     else if ( isSigAttach(sig, x, y) )              { printGCCall(sig,"generateAttach");    return generateAttach   (sig, x, y, priority); }
00241     
00242     else {
00243         cerr << "Error in d signal, unrecognized signal : " << *sig << endl;
00244         exit(1);
00245     }
00246     assert(0);
00247     return "error in generate code";
00248 }

Here is the caller graph for this function:

void DocCompiler::generateDelayLine ( const string &  ctype,
const string &  vname,
int  mxd,
const string &  exp 
) [protected]

Generate code for the delay mecchanism without using temporary variables.

Definition at line 1205 of file doc_compile.cpp.

References Lateq::addRecurSigFormula(), fLateq, and subst().

Referenced by generateRec().

01206 {
01207     //assert(mxd > 0);
01208     if (mxd == 0) {
01209         fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
01210     } else {
01211         fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
01212     }
01213 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateDelayVec ( Tree  sig,
const string &  exp,
const string &  ctype,
const string &  vname,
int  mxd 
) [protected]

Generate code for the delay mecchanism.

The generated code depend of the maximum delay attached to exp and the "less temporaries" switch

Definition at line 1169 of file doc_compile.cpp.

References generateDelayVecNoTemp(), getSigType(), and kSamp.

Referenced by generateCacheCode(), generateFConst(), generateFVar(), and generateNumber().

01170 {
01171     string s = generateDelayVecNoTemp(sig, exp, ctype, vname, mxd);
01172     if (getSigType(sig)->variability() < kSamp) {
01173         return exp;
01174     } else {
01175         return s;
01176     }
01177 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateDelayVecNoTemp ( Tree  sig,
const string &  exp,
const string &  ctype,
const string &  vname,
int  mxd 
) [protected]

Generate code for the delay mecchanism without using temporary variables.

Definition at line 1183 of file doc_compile.cpp.

References Lateq::addRecurSigFormula(), fLateq, getVectorNameProperty(), setVectorNameProperty(), and subst().

Referenced by generateDelayVec().

01184 {
01185     assert(mxd > 0);
01186 
01187     //cerr << "  entering generateDelayVecNoTemp" << endl;
01188     
01189     string vectorname;
01190 
01191     // if generateVariableStore has already tagged sig, no definition is needed.
01192     if(getVectorNameProperty(sig, vectorname)) { 
01193         return subst("$0(t)", vectorname);
01194     } else {
01195         fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
01196         setVectorNameProperty(sig, vname);
01197         return subst("$0(t)", vname);
01198     }
01199 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateDocAccessTbl ( Tree  sig,
Tree  tbl,
Tree  ridx 
) [protected]

Generate the equation of a write table, which content is time dependent.

It is basically a signal of vectors.

Definition at line 854 of file doc_compile.cpp.

References CS(), generateCacheCode(), and subst().

Referenced by generateCode().

00855 {
00856     // the compilation of a table always returns its name
00857     string  vname = CS(tbl, 0);
00858     string result = subst("$0[$1]", vname, CS(ridx,0) );
00859 
00860     return generateCacheCode(sig, result);
00861 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateDocConstantTbl ( Tree  sig,
Tree  size,
Tree  isig 
) [protected]

Generate the equation of a constant table (its content is time constant).

Returns the name of the table

Definition at line 749 of file doc_compile.cpp.

References Lateq::addRDTblSigFormula(), CS(), fLateq, gDocNoticeFlagMap, getSigType(), getTypedNames(), isSigInt(), subst(), and T().

Referenced by generateCode().

00750 {   
00751     string  vname, ctype;
00752     string  init = CS(isig,0);
00753 
00754     int     n;
00755     if (!isSigInt(size, &n)) {
00756         cerr << "error in DocCompiler::generateDocConstantTbl() : "
00757              << *size
00758              << " is not an integer expression and can't be used as a table size' "
00759              << endl;
00760     }
00761 
00762     // allocate a name v_i for the table
00763     getTypedNames(getSigType(isig), "v", ctype, vname);
00764     
00765     // add a comment on tables in the notice
00766         gDocNoticeFlagMap["tablesigs"] = true;
00767     
00768     // add equation v[t] = isig(t)
00769         fLateq->addRDTblSigFormula(subst("$0[t] = $1 \\condition{when $$t \\in [0,$2]$$} ", vname, init, T(n-1)));
00770     
00771     // note that the name of the table can never be used outside an sigDocTableAccess
00772     return vname;
00773 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateDocWriteTbl ( Tree  sig,
Tree  size,
Tree  isig,
Tree  widx,
Tree  wsig 
) [protected]

Generate the equation of a write table, which content is time dependent.

It is basically a signal of vectors.

Definition at line 814 of file doc_compile.cpp.

References Lateq::addRWTblSigFormula(), CS(), fLateq, gDocNoticeFlagMap, getSigType(), getTypedNames(), isSigInt(), replaceTimeBy(), subst(), and T().

Referenced by generateCode().

00815 {
00816     string  vname, ctype;
00817     string  init = CS(isig,0);
00818     int     n;
00819     if (!isSigInt(size, &n)) {
00820         cerr << "error in DocCompiler::generateDocWriteTbl() : "
00821              << *size
00822              << " is not an integer expression and can't be used as a table size' "
00823              << endl;
00824     }
00825 
00826 
00827     // allocate a name w_i for the table
00828     getTypedNames(getSigType(isig), "w", ctype, vname);
00829 
00830     // add a comment on tables in the notice
00831     gDocNoticeFlagMap["tablesigs"] = true;
00832 
00833     // describe the table equation
00834     string ltqRWTableDef;
00835     ltqRWTableDef += subst("$0(t)[i] = \n", vname);
00836     ltqRWTableDef += "\\left\\{\\begin{array}{ll}\n";
00837     ltqRWTableDef += subst("$0 & \\mbox{if \\,} t < 0 \\mbox{\\, and \\,}  i \\in [0,$1] \\\\\n",   replaceTimeBy(init,'i'), T(n-1));
00838     ltqRWTableDef += subst("$0 & \\mbox{if \\,} i = $1 \\\\\n", CS(wsig,0), CS(widx,0));
00839     ltqRWTableDef += subst("$0(t\\!-\\!1)[i] & \\mbox{otherwise} \\\\\n", vname);
00840     ltqRWTableDef += "\\end{array}\\right.";
00841         
00842     // add the table equation
00843         fLateq->addRWTblSigFormula(ltqRWTableDef); //w(t) = initsig(t)
00844     
00845     // note that the name of the table can never be used outside an sigDocTableAccess
00846     return vname;
00847 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateFConst ( Tree  sig,
const string &  file,
const string &  name 
) [protected]

Definition at line 298 of file doc_compile.cpp.

References fOccMarkup, gDocNoticeFlagMap, generateDelayVec(), Occurences::getMaxDelay(), getSigType(), getTypedNames(), and OccMarkup::retrieve().

Referenced by generateCode().

00299 {
00300     string      ctype, vname;
00301     Occurences* o = fOccMarkup.retrieve(sig);
00302 
00303     if (o->getMaxDelay()>0) {
00304         getTypedNames(getSigType(sig), "r", ctype, vname);
00305         gDocNoticeFlagMap["recursigs"] = true;
00306         //cerr << "- r : generateFConst : \"" << vname << "\"" << endl;            
00307         generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
00308     }
00309     
00310     if (exp == "fSamplingFreq") {
00311         gDocNoticeFlagMap["fsamp"] = true;
00312         return "f_S";
00313     }
00314     
00315     return "\\mathrm{"+exp+"}";
00316 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateFFun ( Tree  sig,
Tree  ff,
Tree  largs,
int  priority 
) [protected]

Definition at line 464 of file doc_compile.cpp.

References CS(), ffarity(), ffname(), gDocNoticeFlagMap, and nth().

Referenced by generateCode().

00465 {
00466     string code = ffname(ff);
00467     code += '(';
00468     string sep = "";
00469     for (int i = 0; i< ffarity(ff); i++) {
00470         code += sep;
00471         code += CS(nth(largs, i), priority);
00472         sep = ", ";
00473     }
00474     code += ')';
00475     
00476     gDocNoticeFlagMap["foreignfun"] = true;
00477 
00478     return "\\mathrm{ff"+code+"}";
00479 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateFixDelay ( Tree  sig,
Tree  exp,
Tree  delay,
int  priority 
) [protected]

Generate code for accessing a delayed signal.

The generated code depend of the maximum delay attached to exp and the gLessTempSwitch.

Todo:
Priorités à revoir pour le parenthésage (associativité de - et /), avec gBinOpLateqTable dans binop.cpp.

Definition at line 1143 of file doc_compile.cpp.

References CS(), getVectorNameProperty(), isSigInt(), and subst().

Referenced by generateCode().

01144 {
01145     int d;
01146     string vecname;
01147     
01148     CS(exp, 0); // ensure exp is compiled to have a vector name
01149     
01150     if (! getVectorNameProperty(exp, vecname)) {
01151         cerr << "No vector name for : " << ppsig(exp) << endl;
01152         assert(0);
01153     }
01154     
01155     if (isSigInt(delay, &d) && (d == 0)) {
01156         //cerr << "@ generateFixDelay : d = " << d << endl;
01157         return subst("$0(t)", vecname);
01158     } else {
01159         //cerr << "@ generateFixDelay : d = " << d << endl;
01160         return subst("$0(t\\!-\\!$1)", vecname, CS(delay, 7));
01161     }
01162 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateFloatCast ( Tree  sig,
Tree  x,
int  priority 
) [protected]

Don't generate float cast !

It is just a kind of redirection. Calling generateCacheCode ensures to create a new variable name if the input signal expression is shared.

Definition at line 628 of file doc_compile.cpp.

References CS(), generateCacheCode(), and subst().

Referenced by generateCode().

00629 {
00630     return generateCacheCode(sig, subst("$0", CS(x, priority)));
00631 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateFVar ( Tree  sig,
const string &  file,
const string &  name 
) [protected]

Definition at line 323 of file doc_compile.cpp.

References fOccMarkup, gDocNoticeFlagMap, generateCacheCode(), generateDelayVec(), Occurences::getMaxDelay(), getSigType(), getTypedNames(), OccMarkup::retrieve(), and setVectorNameProperty().

Referenced by generateCode().

00324 {
00325     string      ctype, vname;
00326     Occurences* o = fOccMarkup.retrieve(sig);
00327 
00328     if (o->getMaxDelay()>0) {
00329         getTypedNames(getSigType(sig), "r", ctype, vname);
00330         gDocNoticeFlagMap["recursigs"] = true;
00331         //cerr << "- r : generateFVar : \"" << vname << "\"" << endl;            
00332         setVectorNameProperty(sig, vname);
00333         generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
00334     }
00335     return generateCacheCode(sig, exp);
00336 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateHBargraph ( Tree  sig,
Tree  label,
Tree  min,
Tree  max,
const string &  exp 
) [protected]

Definition at line 701 of file doc_compile.cpp.

References generateCacheCode(), getFreshID(), getSigType(), kBlock, kKonst, and kSamp.

00702 {
00703     string varname = getFreshID("{u_g}");
00704 
00705     Type t = getSigType(sig);
00706     switch (t->variability()) {
00707 
00708         case kKonst :
00709             break;
00710 
00711         case kBlock :
00712             break;
00713 
00714         case kSamp :
00715             break;
00716     }
00717     return generateCacheCode(sig, varname);
00718 }

Here is the call graph for this function:

string DocCompiler::generateHSlider ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
) [protected]

Definition at line 664 of file doc_compile.cpp.

References Lateq::addUISigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getUIDir(), and prepareIntervallicUI().

Referenced by generateCode().

00665 {
00666     string varname = getFreshID("{u_s}") + "(t)";
00667     fLateq->addUISigFormula(getUIDir(path), prepareIntervallicUI(varname, path, cur, min, max));
00668     gDocNoticeFlagMap["slidersigs"] = true;
00669     return generateCacheCode(sig, varname);
00670 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateInput ( Tree  sig,
const string &  idx 
) [protected]

Definition at line 344 of file doc_compile.cpp.

References Lateq::addInputSigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), Lateq::inputs(), setVectorNameProperty(), and subst().

Referenced by generateCode().

00345 {
00346     if (fLateq->inputs() == 1) {
00347         setVectorNameProperty(sig, "x");
00348         fLateq->addInputSigFormula("x(t)"); 
00349         gDocNoticeFlagMap["inputsig"] = true;
00350         return generateCacheCode(sig, "x(t)");
00351     } else {
00352         setVectorNameProperty(sig, subst("x_{$0}", idx));
00353         fLateq->addInputSigFormula(subst("x_{$0}(t)", idx));
00354         gDocNoticeFlagMap["inputsigs"] = true;
00355         return generateCacheCode(sig, subst("x_{$0}(t)", idx));
00356     }
00357 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateIntCast ( Tree  sig,
Tree  x,
int  priority 
) [protected]

Definition at line 613 of file doc_compile.cpp.

References CS(), gDocNoticeFlagMap, generateCacheCode(), and subst().

Referenced by generateCode().

00614 {
00615     gDocNoticeFlagMap["intcast"] = true;
00616              
00617     return generateCacheCode(sig, subst("\\mathrm{int}\\left($0\\right)", CS(x, 0)));
00618 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateIota ( Tree  sig,
Tree  arg 
) [protected]

Generate a "iota" time function, n-cyclical.

Definition at line 987 of file doc_compile.cpp.

References docT(), isSigInt(), and subst().

Referenced by generateCode().

00988 {
00989     int size;
00990     if (!isSigInt(n, &size)) { fprintf(stderr, "error in generateIota\n"); exit(1); }
00991     //cout << "iota !" << endl;
00992     return subst(" t \\bmod{$0} ", docT(size));
00993 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateNumber ( Tree  sig,
const string &  exp 
) [protected]

Definition at line 278 of file doc_compile.cpp.

References fOccMarkup, gDocNoticeFlagMap, generateDelayVec(), Occurences::getMaxDelay(), getSigType(), getTypedNames(), and OccMarkup::retrieve().

Referenced by generateCode().

00279 {
00280     string      ctype, vname;
00281     Occurences* o = fOccMarkup.retrieve(sig);
00282 
00283     // check for number occuring in delays
00284     if (o->getMaxDelay()>0) {
00285         getTypedNames(getSigType(sig), "r", ctype, vname);
00286         gDocNoticeFlagMap["recursigs"] = true;
00287         //cerr << "- r : generateNumber : \"" << vname << "\"" << endl;            
00288         generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
00289     }
00290     return exp;
00291 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateNumEntry ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
) [protected]

Definition at line 672 of file doc_compile.cpp.

References Lateq::addUISigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getUIDir(), and prepareIntervallicUI().

Referenced by generateCode().

00673 {
00674     string varname = getFreshID("{u_n}") + "(t)";       
00675     fLateq->addUISigFormula(getUIDir(path), prepareIntervallicUI(varname, path, cur, min, max));
00676     gDocNoticeFlagMap["nentrysigs"] = true;
00677     return generateCacheCode(sig, varname);
00678 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateOutput ( Tree  sig,
const string &  idx,
const string &  arg1 
) [protected]

Unused for the moment !

Definition at line 361 of file doc_compile.cpp.

References Lateq::addOutputSigFormula(), fLateq, gDocNoticeFlagMap, Lateq::outputs(), and subst().

Referenced by generateCode().

00362 {
00363     string dst;
00364     
00365     if (fLateq->outputs() == 1) {
00366         dst = subst("y(t)", idx);
00367         gDocNoticeFlagMap["outputsig"] = true;
00368     } else {
00369         dst = subst("y_{$0}(t)", idx);
00370         gDocNoticeFlagMap["outputsigs"] = true;
00371     }
00372     
00373     fLateq->addOutputSigFormula(subst("$0 = $1", dst, arg));
00374     return dst;
00375 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generatePrefix ( Tree  sig,
Tree  x,
Tree  e,
int  priority 
) [protected]

Generate LaTeX code for "prefix", a 1­sample-delay explicitely initialized.

Parameters:
sig The signal expression to treat.
x The initial value for the delay line.
e The value for the delay line, after initialization.
priority The priority of the environment of the expression.
Returns:
<string> The LaTeX code translation of the signal, cached.

Definition at line 954 of file doc_compile.cpp.

References Lateq::addPrefixSigFormula(), CS(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getVectorNameProperty(), and subst().

Referenced by generateCode().

00955 {
00956     string var  = getFreshID("m");
00957     string exp0 = CS(x, priority);
00958     string exp1 = CS(e, priority); // ensure exp1 is compiled to have a vector name
00959     string vecname;
00960 
00961     if (! getVectorNameProperty(e, vecname)) {
00962         cerr << "No vector name for : " << ppsig(e) << endl;
00963         assert(0);
00964     }
00965     
00966     string ltqPrefixDef;
00967     ltqPrefixDef += subst("$0(t) = \n", var);
00968     ltqPrefixDef += "\\left\\{\\begin{array}{ll}\n";
00969     ltqPrefixDef += subst("$0 & \\mbox{, when \\,} t = 0\\\\\n", exp0);
00970     ltqPrefixDef += subst("$0 & \\mbox{, when \\,} t > 0\n", subst("$0(t\\!-\\!1)", vecname));
00971     ltqPrefixDef += "\\end{array}\\right.";
00972     
00973     fLateq->addPrefixSigFormula(ltqPrefixDef);
00974     gDocNoticeFlagMap["prefixsigs"] = true;
00975     
00976     return generateCacheCode(sig, subst("$0(t)", var));
00977 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::generateRec ( Tree  sig,
Tree  var,
Tree  le,
int  priority 
) [protected]

Generate code for a group of mutually recursive definitions.

Definition at line 902 of file doc_compile.cpp.

References CS(), fOccMarkup, gDocNoticeFlagMap, generateDelayLine(), Occurences::getMaxDelay(), getSigType(), getTypedNames(), len(), nth(), OccMarkup::retrieve(), setVectorNameProperty(), and sigProj().

Referenced by generateRecProj().

00903 {
00904     int             N = len(le);
00905 
00906     vector<bool>    used(N);
00907     vector<int>     delay(N);
00908     vector<string>  vname(N);
00909     vector<string>  ctype(N);
00910 
00911     // prepare each element of a recursive definition
00912     for (int i=0; i<N; i++) {
00913         Tree    e = sigProj(i,sig);     // recreate each recursive definition
00914         if (fOccMarkup.retrieve(e)) {
00915             // this projection is used
00916             used[i] = true;
00917             //cerr << "generateRec : used[" << i << "] = true" << endl;            
00918             getTypedNames(getSigType(e), "r", ctype[i],  vname[i]);
00919             gDocNoticeFlagMap["recursigs"] = true;
00920             //cerr << "- r : generateRec setVectorNameProperty : \"" << vname[i] << "\"" << endl;
00921             setVectorNameProperty(e, vname[i]);
00922             delay[i] = fOccMarkup.retrieve(e)->getMaxDelay();
00923         } else {
00924             // this projection is not used therefore
00925             // we should not generate code for it
00926             used[i] = false;
00927             //cerr << "generateRec : used[" << i << "] = false" << endl;
00928         }
00929     }
00930 
00931     // generate delayline for each element of a recursive definition
00932     for (int i=0; i<N; i++) {
00933         if (used[i]) {
00934             generateDelayLine(ctype[i], vname[i], delay[i], CS(nth(le,i), priority));
00935         }
00936     }
00937 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateRecProj ( Tree  sig,
Tree  exp,
int  i,
int  priority 
) [protected]

Generate code for a projection of a group of mutually recursive definitions.

Definition at line 878 of file doc_compile.cpp.

References generateRec(), getVectorNameProperty(), isRec(), and subst().

Referenced by generateCode().

00879 {
00880     string  vname;
00881     Tree    var, le;
00882     
00883     //cerr << "*** generateRecProj sig : \"" << ppsig(sig) << "\"" << endl;            
00884 
00885     if ( ! getVectorNameProperty(sig, vname)) {
00886         assert(isRec(r, var, le));
00887         //cerr << "    generateRecProj has NOT YET a vname : " << endl;            
00888         //cerr << "--> generateRecProj calls generateRec on \"" << ppsig(sig) << "\"" << endl;            
00889         generateRec(r, var, le, priority);
00890         assert(getVectorNameProperty(sig, vname));
00891         //cerr << "<-- generateRecProj vname : \"" << subst("$0(t)", vname) << "\"" << endl;            
00892     } else {
00893         //cerr << "(generateRecProj has already a vname : \"" << subst("$0(t)", vname) << "\")" << endl;            
00894     }
00895     return subst("$0(t)", vname);
00896 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateSelect2 ( Tree  sig,
Tree  sel,
Tree  s1,
Tree  s2,
int  priority 
) [protected]

Generate a select2 code.

Definition at line 1003 of file doc_compile.cpp.

References Lateq::addSelectSigFormula(), CS(), fLateq, gDocNoticeFlagMap, getFreshID(), setVectorNameProperty(), and subst().

Referenced by generateCode().

01004 {
01005     string var  = getFreshID("q");
01006     string expsel = CS(sel, 0);
01007     string exps1 = CS(s1, 0);
01008     string exps2 = CS(s2, 0);
01009     
01010     string ltqSelDef;
01011     ltqSelDef += subst("$0(t) = \n", var);
01012     ltqSelDef += "\\left\\{\\begin{array}{ll}\n";
01013     ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 0\\\\\n", exps1, expsel);
01014     ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 1\n", exps2, expsel);
01015     ltqSelDef += "\\end{array}\\right.";
01016     
01017     fLateq->addSelectSigFormula(ltqSelDef);
01018     gDocNoticeFlagMap["selectionsigs"] = true;
01019     
01020     //return generateCacheCode(sig, subst("$0(t)", var));
01021     setVectorNameProperty(sig, var);
01022     return subst("$0(t)", var);
01023 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateSelect3 ( Tree  sig,
Tree  sel,
Tree  s1,
Tree  s2,
Tree  s3,
int  priority 
) [protected]

Generate a select3 code.

Definition at line 1029 of file doc_compile.cpp.

References Lateq::addSelectSigFormula(), CS(), fLateq, gDocNoticeFlagMap, generateVariableStore(), getFreshID(), setVectorNameProperty(), and subst().

Referenced by generateCode().

01030 {
01031     string var  = getFreshID("q");
01032     string expsel = CS(sel, 0);
01033     string exps1 = CS(s1, 0);
01034     string exps2 = CS(s2, 0);
01035     string exps3 = CS(s3, 0);
01036     
01037     string ltqSelDef;
01038     ltqSelDef += subst("$0(t) = \n", var);
01039     ltqSelDef += "\\left\\{\\begin{array}{ll}\n";
01040     ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 0\\\\\n", generateVariableStore(s1, exps1), expsel);
01041     ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 1\\\\\n", generateVariableStore(s2, exps2), expsel);
01042     ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 2\n", generateVariableStore(s3, exps3), expsel);
01043     ltqSelDef += "\\end{array}\\right.";
01044     
01045     fLateq->addSelectSigFormula(ltqSelDef);
01046     gDocNoticeFlagMap["selectionsigs"] = true;
01047     
01048     //return generateCacheCode(sig, subst("$0(t)", var));
01049     setVectorNameProperty(sig, var);
01050     return subst("$0(t)", var);
01051 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateVariableStore ( Tree  sig,
const string &  exp 
) [protected]

< "k" for constants.

< "p" for "parameter".

Definition at line 569 of file doc_compile.cpp.

References Lateq::addConstSigFormula(), Lateq::addParamSigFormula(), Lateq::addStoreSigFormula(), fLateq, gDocNoticeFlagMap, getSigType(), getTypedNames(), getVectorNameProperty(), kBlock, kKonst, kSamp, setVectorNameProperty(), and subst().

Referenced by generateCacheCode(), and generateSelect3().

00570 {
00571     string      vname, ctype;
00572     Type        t = getSigType(sig);
00573     
00574     switch (t->variability()) {
00575             
00576         case kKonst :
00577             getTypedNames(t, "k", ctype, vname); 
00578             fLateq->addConstSigFormula(subst("$0 = $1", vname, exp));
00579             gDocNoticeFlagMap["constsigs"] = true;
00580             return vname;
00581             
00582         case kBlock :
00583             getTypedNames(t, "p", ctype, vname); 
00584             fLateq->addParamSigFormula(subst("$0(t) = $1", vname, exp));
00585             gDocNoticeFlagMap["paramsigs"] = true;
00586             setVectorNameProperty(sig, vname);
00587             return subst("$0(t)", vname);
00588             
00589         case kSamp :
00590             if(getVectorNameProperty(sig, vname)) {
00591                 return subst("$0(t)", vname);
00592             } else {
00593                 getTypedNames(t, "s", ctype, vname);
00594                 //cerr << "- generateVariableStore : \"" << subst("$0(t) = $1", vname, exp) << "\"" << endl;
00595                 fLateq->addStoreSigFormula(subst("$0(t) = $1", vname, exp));
00596                 gDocNoticeFlagMap["storedsigs"] = true;
00597                 setVectorNameProperty(sig, vname);
00598                 return subst("$0(t)", vname);
00599             }
00600             
00601         default:
00602             assert(0);
00603             return "";
00604     }
00605 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateVBargraph ( Tree  sig,
Tree  label,
Tree  min,
Tree  max,
const string &  exp 
) [protected]

Definition at line 681 of file doc_compile.cpp.

References generateCacheCode(), getFreshID(), getSigType(), kBlock, kKonst, and kSamp.

00682 {
00683     string varname = getFreshID("{u_g}");
00684 
00685     Type t = getSigType(sig);
00686     switch (t->variability()) {
00687 
00688         case kKonst :
00689             break;
00690 
00691         case kBlock :
00692             break;
00693 
00694         case kSamp :
00695             break;
00696     }
00697     return generateCacheCode(sig, varname);
00698 }

Here is the call graph for this function:

string DocCompiler::generateVSlider ( Tree  sig,
Tree  label,
Tree  cur,
Tree  min,
Tree  max,
Tree  step 
) [protected]

Definition at line 656 of file doc_compile.cpp.

References Lateq::addUISigFormula(), fLateq, gDocNoticeFlagMap, generateCacheCode(), getFreshID(), getUIDir(), and prepareIntervallicUI().

Referenced by generateCode().

00657 {
00658     string varname = getFreshID("{u_s}") + "(t)";
00659     fLateq->addUISigFormula(getUIDir(path), prepareIntervallicUI(varname, path, cur, min, max));
00660     gDocNoticeFlagMap["slidersigs"] = true;
00661     return generateCacheCode(sig, varname);
00662 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::generateXtended ( Tree  sig,
int  priority 
) [protected]

retrieve the type annotation of sig

Parameters:
sig the signal we want to know the type

Definition at line 1058 of file doc_compile.cpp.

References CTree::arity(), CTree::branch(), CS(), fLateq, generateCacheCode(), xtended::generateLateq(), getSigType(), getUserData(), and xtended::needCache().

Referenced by generateCode().

01059 {
01060     xtended*        p = (xtended*) getUserData(sig);
01061     vector<string>  args;
01062     vector<Type>    types;
01063 
01064     for (int i=0; i<sig->arity(); i++) {
01065         args.push_back(CS(sig->branch(i), 0));
01066         types.push_back(getSigType(sig->branch(i)));
01067     }
01068 
01069     if (p->needCache()) {
01070         //cerr << "!! generateXtended : <needCache> : calls generateCacheCode(sig, p->generateLateq(fLateq, args, types))" << endl;
01071         return generateCacheCode(sig, p->generateLateq(fLateq, args, types));
01072     } else {
01073         //cerr << "!! generateXtended : <do not needCache> : calls p->generateLateq(fLateq, args, types)" << endl;
01074         return p->generateLateq(fLateq, args, types);
01075     }
01076 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool DocCompiler::getCompiledExpression ( Tree  sig,
string &  cexp 
) [protected]

Test if a signal is already compiled.

Parameters:
sig the signal expression to compile.
name the string representing the compiled expression.
Returns:
true is already compiled

Definition at line 144 of file doc_compile.cpp.

References fCompileProperty.

Referenced by CS(), and generateCacheCode().

00145 {
00146     return fCompileProperty.get(sig, cexp);
00147 }

Here is the caller graph for this function:

Description* DocCompiler::getDescription (  )  [inline]

Definition at line 88 of file doc_compile.hh.

References fDescription.

00088 { return fDescription; }

string DocCompiler::getFreshID ( const string &  prefix  )  [protected]

Definition at line 75 of file doc_compile.cpp.

References docT(), fIDCounters, and subst().

Referenced by compileLateq(), generateButton(), generateCheckbox(), generateHBargraph(), generateHSlider(), generateNumEntry(), generatePrefix(), generateSelect2(), generateSelect3(), generateVBargraph(), generateVSlider(), and getTypedNames().

00076 {
00077     if (fIDCounters.find(prefix) == fIDCounters.end()) {
00078         fIDCounters[prefix] = 1;
00079     }
00080     int n = fIDCounters[prefix];
00081     fIDCounters[prefix] = n+1;
00082     
00083     return subst("$0_{$1}", prefix, docT(n));
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

Lateq* DocCompiler::getLateq (  )  [inline]

Definition at line 86 of file doc_compile.hh.

References fLateq.

00086 { return (Lateq*)fLateq; }

int DocCompiler::getSharingCount ( Tree  t  )  [protected]

Definition at line 66 of file doc_sharing.cpp.

References fSharingKey, Node::getInt(), getProperty(), and CTree::node().

Referenced by generateCacheCode(), and sharingAnnotation().

00068 {
00069     //cerr << "getSharingCount of : " << *sig << " = ";
00070     Tree c;
00071     if (getProperty(sig, fSharingKey, c)) {
00072         //cerr << c->node().getInt() << endl;
00073         return c->node().getInt();
00074     } else {
00075         //cerr << 0 << endl;
00076         return 0;
00077     }
00078 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::getTypedNames ( Type  t,
const string &  prefix,
string &  ctype,
string &  vname 
) [protected]

Definition at line 486 of file doc_compile.cpp.

References getFreshID(), ifloat(), kInt, and subst().

Referenced by generateCacheCode(), generateDocConstantTbl(), generateDocWriteTbl(), generateFConst(), generateFVar(), generateNumber(), generateRec(), and generateVariableStore().

00487 {
00488     if (t->nature() == kInt) {
00489         ctype = "int"; vname = subst("$0", getFreshID(prefix));
00490     } else {
00491         ctype = ifloat(); vname = subst("$0", getFreshID(prefix));
00492     }
00493 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::getUIDir ( Tree  pathname  )  [protected]

Get the directory of a user interface element.

Convert the input reversed path tree into a string. The name of the UI is stripped (the head of the path tree), the rest of the tree is a list of pointed pairs, where the names are contained by the tail of these pointed pairs. Metadatas (begining by '[') are stripped.

Parameters:
[in] pathname The path tree to convert.
Returns:
<string> A directory-like string.

Definition at line 1235 of file doc_compile.cpp.

References hd(), isNil(), reverse(), tl(), and tree2str().

Referenced by generateButton(), generateCheckbox(), generateHSlider(), generateNumEntry(), and generateVSlider().

01236 {   
01237     //cerr << "Documentator : getUIDir : print(pathname, stdout) = "; print(pathname, stdout); cerr << endl;
01238     string s;
01239     Tree dir = reverse(tl(pathname));
01240     while (!isNil(dir)) { 
01241         string tmp = tree2str(tl(hd(dir)));
01242         if ( (tmp[0] != '[') && (!tmp.empty()) ) {
01243             s += tmp + '/';
01244         }
01245         dir = tl(dir);
01246     }
01247     return s;
01248 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::getUIDocInfos ( Tree  path,
string &  label,
string &  unit 
) [protected]

Get information on a user interface element for documentation.

Parameters:
[in] path The UI full pathname to parse.
[out] label The place to store the UI name.
[out] unit The place to store the UI unit.

Definition at line 1319 of file doc_compile.cpp.

References extractMetadata(), hd(), and tree2str().

Referenced by prepareBinaryUI(), and prepareIntervallicUI().

01320 {
01321     label = "";
01322     unit = "";
01323     
01324     map<string, set<string> >   metadata;
01325     extractMetadata(tree2str(hd(path)), label, metadata);
01326     
01327     set<string> myunits = metadata["unit"];
01328 //  for (set<string>::iterator i = myunits.begin(); i != myunits.end(); i++) {
01329 //      cerr << "Documentator : getUIDocInfos : metadata[\"unit\"] = " << *i << endl;
01330 //  }
01331     for (map<string, set<string> >::iterator i = metadata.begin(); i != metadata.end(); i++) {
01332         const string& key = i->first;
01333         const set<string>& values = i->second;
01334         for (set<string>::iterator j = values.begin(); j != values.end(); j++) {
01335             if(key == "unit") unit += *j;
01336         }
01337     }
01338 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool DocCompiler::getVectorNameProperty ( Tree  sig,
string &  vecname 
) [protected]

Get the vector name property of a signal, the name of the vector used to store the previous values of the signal to implement a delay.

Parameters:
sig the signal expression.
vecname the string where to store the vector name.
Returns:
true if the signal has this property, false otherwise

Definition at line 1108 of file doc_compile.cpp.

References fVectorProperty.

Referenced by generateAttach(), generateCacheCode(), generateDelayVecNoTemp(), generateFixDelay(), generatePrefix(), generateRecProj(), and generateVariableStore().

01109 {
01110     return fVectorProperty.get(sig, vecname);
01111 }

Here is the caller graph for this function:

bool DocCompiler::isShortEnough ( string &  s,
unsigned int  max 
) [protected]

Definition at line 863 of file doc_compile.cpp.

00864 {   
00865     return (s.length() <= max);
00866 }

string DocCompiler::prepareBinaryUI ( const string &  name,
Tree  path 
) [protected]

Prepare binary user interface elements (button, checkbox).

  • Format a LaTeX output string as a supertabular row with 5 columns : "\begin{supertabular}{rllll}".
    See also:
    Lateq::printHierarchy
  • The UI range is only a set of two values : {0, 1}.
  • The UI current value is automatically 0.
Parameters:
[in] name The LaTeX name of the UI signal (eg. "{u_b}_{i}(t)").
[in] path The path tree to parse.
Returns:
<string> The LaTeX output string.

Definition at line 1263 of file doc_compile.cpp.

References gDocMathStringMap, and getUIDocInfos().

Referenced by generateButton(), and generateCheckbox().

01264 {   
01265     string label, unit;
01266     getUIDocInfos(path, label, unit);
01267     string s = "";
01268     label = (label.size()>0) ? ("\\textsf{\""+label+"\"} :") : "";
01269     unit = (unit.size()>0) ? ("\\,\\mathrm{"+unit+"}") : "";
01270     s += label;
01271     s += " & $" + name + "$";
01272     s += " & $\\in$ & $\\left\\{\\,0" + unit + ", 1" + unit +"\\,\\right\\}$";
01273     s += " & $(\\mbox{" + gDocMathStringMap["defaultvalue"] + "} = 0" + unit + ")$\\\\";
01274     return s;
01275 }

Here is the call graph for this function:

Here is the caller graph for this function:

string DocCompiler::prepareIntervallicUI ( const string &  name,
Tree  path,
Tree  tcur,
Tree  tmin,
Tree  tmax 
) [protected]

Prepare "intervallic" user interface elements (sliders, nentry).

  • Format a LaTeX output string as a supertabular row with 5 columns : "\begin{supertabular}{rllll}".
    See also:
    Lateq::printHierarchy
  • The UI range is an bounded interval : [tmin, tmax].
  • The UI current value is tcur.
Parameters:
[in] name The LaTeX name of the UI signal (eg. "{u_s}_{i}(t)").
[in] path The path tree to parse.
[in] tcur The current UI value tree to convert.
[in] tmin The minimum UI value tree to convert.
[in] tmax The maximum UI value tree to convert.
Returns:
<string> The LaTeX output string.

Definition at line 1293 of file doc_compile.cpp.

References docT(), gDocMathStringMap, getUIDocInfos(), max(), min(), and tree2float().

Referenced by generateHSlider(), generateNumEntry(), and generateVSlider().

01294 {   
01295     string label, unit, cur, min, max;
01296     getUIDocInfos(path, label, unit);
01297     cur = docT(tree2float(tcur));
01298     min = docT(tree2float(tmin));
01299     max = docT(tree2float(tmax));
01300     
01301     string s = "";
01302     label = (label.size()>0) ? ("\\textsf{\""+label+"\"} :") : "";
01303     unit = (unit.size()>0) ? ("\\,\\mathrm{"+unit+"}") : "";
01304     s += label;
01305     s += " & $" + name + "$";
01306     s += " & $\\in$ & $\\left[\\," + min + unit + ", " + max + unit +"\\,\\right]$";
01307     s += " & $(\\mbox{" + gDocMathStringMap["defaultvalue"] + "} = " + cur + unit + ")$\\\\";
01308     return s;
01309 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::printGCCall ( Tree  sig,
const string &  calledFunction 
) [protected]

Print calling information of generateCode, for debug purposes.

Remarks:
To turn printing on, turn the 'printCalls' boolean to true.

Definition at line 257 of file doc_compile.cpp.

Referenced by generateCode().

00258 {
00259     bool printCalls = false;
00260     bool maskSigs   = false;
00261     
00262     if(printCalls) {
00263         cerr << "  -> generateCode calls " << calledFunction;
00264         if(maskSigs) {
00265             cerr << endl;
00266         } else {
00267             cerr << " on " << ppsig(sig) << endl;
00268         }
00269     }
00270 }

Here is the caller graph for this function:

string DocCompiler::setCompiledExpression ( Tree  sig,
const string &  cexp 
) [protected]

Set the string of a compiled expression is already compiled.

Parameters:
sig the signal expression to compile.
cexp the string representing the compiled expression.
Returns:
the cexp (for commodity)

Definition at line 156 of file doc_compile.cpp.

References fCompileProperty.

Referenced by CS().

00157 {
00158     fCompileProperty.set(sig, cexp);
00159     return cexp;
00160 }

Here is the caller graph for this function:

void DocCompiler::setDescription ( Description descr  )  [inline]

Definition at line 87 of file doc_compile.hh.

References fDescription.

00087 { fDescription= descr; }

void DocCompiler::setSharingCount ( Tree  t,
int  count 
) [protected]

Definition at line 81 of file doc_sharing.cpp.

References fSharingKey, setProperty(), and tree().

Referenced by sharingAnnotation().

00083 {
00084     //cerr << "setSharingCount of : " << *sig << " <- " << count << endl;
00085     setProperty(sig, fSharingKey, tree(count));
00086 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::setVectorNameProperty ( Tree  sig,
const string &  vecname 
) [protected]

Set the vector name property of a signal, the name of the vector used to store the previous values of the signal to implement a delay.

Parameters:
sig the signal expression.
vecname the string representing the vector name.
Returns:
true is already compiled

Definition at line 1094 of file doc_compile.cpp.

References fVectorProperty.

Referenced by generateAttach(), generateDelayVecNoTemp(), generateFVar(), generateInput(), generateRec(), generateSelect2(), generateSelect3(), and generateVariableStore().

01095 {
01096     fVectorProperty.set(sig, vecname);
01097 }

Here is the caller graph for this function:

void DocCompiler::sharingAnalysis ( Tree  t  )  [protected]

Definition at line 96 of file doc_sharing.cpp.

References fSharingKey, hd(), isList(), kSamp, sharingAnnotation(), shprkey(), and tl().

Referenced by annotate().

00098 {
00099     fSharingKey = shprkey(t);
00100     if (isList(t)) {
00101         while (isList(t)) {
00102             sharingAnnotation(kSamp, hd(t));
00103             t = tl(t);
00104         }
00105     } else {
00106         sharingAnnotation(kSamp, t);
00107     }
00108 }

Here is the call graph for this function:

Here is the caller graph for this function:

void DocCompiler::sharingAnnotation ( int  vctxt,
Tree  t 
) [protected]

Definition at line 117 of file doc_sharing.cpp.

References getSharingCount(), getSigType(), getSubSignals(), isSigGen(), and setSharingCount().

Referenced by sharingAnalysis().

00119 {
00120     //cerr << "START sharing annotation of " << *sig << endl;
00121     int count = getSharingCount(sig);
00122 
00123     if (count > 0) {
00124         // it is not our first visit
00125         setSharingCount(sig, count+1);
00126 
00127     } else {
00128         // it is our first visit,
00129         int v = getSigType(sig)->variability();
00130 
00131         // check "time sharing" cases
00132         if (v < vctxt) {
00133             setSharingCount(sig, 2);    // time sharing occurence : slower expression in faster context
00134         } else {
00135             setSharingCount(sig, 1);    // regular occurence
00136         }
00137 
00138         // Annotate the sub signals
00139         vector<Tree> subsig;
00140         int n = getSubSignals(sig, subsig);
00141         if (n>0 && ! isSigGen(sig)) {
00142             for (int i=0; i<n; i++) sharingAnnotation(v, subsig[i]);
00143         }
00144     }
00145     //cerr << "END sharing annotation of " << *sig << endl;
00146 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 52 of file doc_compile.hh.

Referenced by getCompiledExpression(), and setCompiledExpression().

Definition at line 56 of file doc_compile.hh.

Referenced by getDescription(), and setDescription().

map< string, int > DocCompiler::fIDCounters [static, protected]

Definition at line 58 of file doc_compile.hh.

Referenced by getFreshID().

Lateq* DocCompiler::fLateq [protected]
int DocCompiler::fPriority [protected]

math priority context

Definition at line 61 of file doc_compile.hh.

Definition at line 59 of file doc_compile.hh.

Referenced by getSharingCount(), setSharingCount(), and sharingAnalysis().

Definition at line 53 of file doc_compile.hh.

Referenced by getVectorNameProperty(), and setVectorNameProperty().


The documentation for this class was generated from the following files:
Generated on Wed Apr 28 23:46:04 2010 for FAUST compiler by  doxygen 1.6.3