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 722 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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                 gDocNoticeFlagMap["intcast"] = true; // "$normalize(int(i/j))$" in the notice.
00439                 break;
00440             default:
00441                 op = gBinOpLateqTable[opcode]->fName;
00442                 break;
00443         }
00444     }
00445     
00446     /* LaTeX frac{}{} handling VS general case. */
00447     if ( (opcode == kDiv) && (!intOpDetected) ) { 
00448         s = subst("$0\\frac{$1}{$2}$3", lpar, CS(arg1, 0), CS(arg2, 0), rpar);
00449     } else {
00450         s = subst("$0$1 $2 $3$4", lpar, CS(arg1, thisPriority), op, CS(arg2, thisPriority), rpar);
00451     }
00452     
00453 //  if (opcode == kMul) {
00454 //      gDocNoticeFlagMap["cdot"] = true;
00455 //  }
00456     
00457     return generateCacheCode(sig, s);
00458 }

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 639 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 522 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().

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

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 648 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 1206 of file doc_compile.cpp.

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

Referenced by generateRec().

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

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 1170 of file doc_compile.cpp.

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

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

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

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 1184 of file doc_compile.cpp.

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

Referenced by generateDelayVec().

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

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 855 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 750 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 815 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 465 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 1144 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 629 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 702 of file doc_compile.cpp.

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

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

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 665 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 614 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 988 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 673 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 955 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 903 of file doc_compile.cpp.

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

Referenced by generateRecProj().

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

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 879 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 1004 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 1030 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 570 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().

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

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 682 of file doc_compile.cpp.

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

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

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 657 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 1059 of file doc_compile.cpp.

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

Referenced by generateCode().

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

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 487 of file doc_compile.cpp.

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

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

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

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 1236 of file doc_compile.cpp.

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

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

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

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 1320 of file doc_compile.cpp.

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

Referenced by prepareBinaryUI(), and prepareIntervallicUI().

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

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 1109 of file doc_compile.cpp.

References fVectorProperty.

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

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

Here is the caller graph for this function:

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

Definition at line 864 of file doc_compile.cpp.

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

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 3 columns : "\begin{supertabular}{lll}".
    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 1264 of file doc_compile.cpp.

References gDocMathStringMap, and getUIDocInfos().

Referenced by generateButton(), and generateCheckbox().

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

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 3 columns : "\begin{supertabular}{lll}".
    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 1294 of file doc_compile.cpp.

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

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

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

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 1095 of file doc_compile.cpp.

References fVectorProperty.

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

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

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 Thu Jul 15 15:47:31 2010 for FAUST compiler by  doxygen 1.6.3