DocCompiler Class Reference

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

#include <doc_compile.hh>

Collaboration diagram for DocCompiler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Lateq * compileLateq (Tree L, Lateq *compiledEqn)

Protected Member Functions

string CS (Tree sig, int priority)
 Compile a signal.
string generateCode (Tree sig, int priority)
 Main code generator dispatch.
string generateVariableStore (Tree sig, const string &exp)
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.
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 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 generateFloatCast (Tree sig, Tree x, int priority)
 Don't generate float cast !
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 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

int fPriority
 math priority context

Detailed Description

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

Definition at line 48 of file doc_compile.hh.


Member Function Documentation

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

< Dynamic field !

Definition at line 105 of file doc_compile.cpp.

References CS().

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:

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(), generateBinOp(), generateCode(), generateDocAccessTbl(), generateDocConstantTbl(), generateDocWriteTbl(), generateFixDelay(), generateFloatCast(), 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::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().

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::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(), generateBinOp(), generateDocAccessTbl(), generateDocConstantTbl(), generateDocWriteTbl(), generateFixDelay(), generateFloatCast(), generateIota(), generateOutput(), generatePrefix(), generateRecProj(), generateSelect2(), generateSelect3(), generateXtended(), getUserData(), name(), and printGCCall().

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

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:

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

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

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

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::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(), and getVectorNameProperty().

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

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::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 CS(), and getVectorNameProperty().

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:

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 getVectorNameProperty(), and setVectorNameProperty().

Referenced by 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::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(), and getUserData().

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.

Referenced by CS().

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

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.

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 }

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.

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 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.

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

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

Here is the caller graph for this function:

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

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:

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

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:

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.

Referenced by CS().

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

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.

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

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

Here is the caller graph for this function:


The documentation for this class was generated from the following files:

Generated on 1 Feb 2010 for FAUST compiler by  doxygen 1.6.1