FAUST compiler  0.9.9.6b8
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
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

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

    :
    fLateq(new Lateq(numInputs, numOutputs)),
    fDescription(0), 
    fPriority(0)
    {}
DocCompiler::DocCompiler ( Lateq k,
int  priority 
) [inline]

Definition at line 73 of file doc_compile.hh.

    : 
    fLateq(k),
    fDescription(0), 
    fPriority(priority)
    {}

Definition at line 80 of file doc_compile.hh.

    {}

Member Function Documentation

Definition at line 88 of file doc_compile.cpp.

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

Referenced by annotateSuperList().

{
    recursivnessAnnotation(LS);     // Annotate LS with recursivness information
    typeAnnotation(LS);             // Annotate LS with type information
    sharingAnalysis(LS);            // annotate LS with sharing count
    fOccMarkup.mark(LS);            // annotate LS with occurences analysis

    return LS;
}

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

{
    //cerr << "Documentator : compileLateq : L = "; printSignal(L, stdout, 0); cerr << endl;
    
    fLateq = compiledEqn; 
    int priority = 0;
    
    for (int i = 0; isList(L); L = tl(L), i++) {
        Tree sig = hd(L);
        Tree id;
        if(getSigNickname(sig, id)) {
            //cerr << "Documentator : compileLateq : NICKNAMEPROPERTY = " << tree2str(id) << endl;
            fLateq->addOutputSigFormula(subst("$0(t) = $1", tree2str(id), CS(sig, priority), docT(i))); 
        } else {
            //cerr << "Documentator : compileLateq : NO NICKNAMEPROPERTY" << endl;
            if (fLateq->outputs() == 1) {
                fLateq->addOutputSigFormula(subst("y(t) = $0", CS(sig, priority))); 
                gDocNoticeFlagMap["outputsig"] = true;
            } else {
                fLateq->addOutputSigFormula(subst("$0(t) = $1", getFreshID("y"), CS(sig, priority)));   
                gDocNoticeFlagMap["outputsigs"] = true;
            }
        }
    }
    return fLateq;
}

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:
sigthe signal expression to compile.
Returns:
the C code translation of sig as a string

Definition at line 165 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().

{
    string      code;

    if (!getCompiledExpression(sig, code)) { // not compiled yet.
        code = generateCode(sig, priority);
        setCompiledExpression(sig, code);
    }
    return code;
}

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

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

Referenced by generateCode().

{
    string vname;
    string exp;
    
    CS(y, priority);
    exp = CS(x, priority);
    
    if(getVectorNameProperty(x, vname)) {
        setVectorNameProperty(sig, vname);
    }

    return generateCacheCode(sig, exp);
}

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]

Definition at line 405 of file doc_compile.cpp.

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

Referenced by generateCode().

{
    string s;
    int thisPriority = gBinOpLateqTable[opcode]->fPriority;
    
    /* Priority parenthesis handling. */
    string lpar = "";
    string rpar = "";
    if ( (thisPriority < priority) || ((thisPriority == priority) && !associative(opcode)) ) {
        // (a+b)*c or (a/b)/c need parenthesis
        lpar = " \\left(";
        rpar = "\\right) ";
    }
    
    Type t1 = getCertifiedSigType(arg1);
    Type t2 = getCertifiedSigType(arg2);
    bool intOpDetected = false;
    if ( (t1->nature() == kInt) && (t2->nature() == kInt) ) {
        intOpDetected = true;
    }
    
    string op;
    if(!intOpDetected) {
        op = gBinOpLateqTable[opcode]->fName;
    } else {
        switch (opcode) {
            case kAdd:
                op = "\\oplus";
                gDocNoticeFlagMap["intplus"] = true;
                break;
            case kSub:
                op = "\\ominus";
                gDocNoticeFlagMap["intminus"] = true;
                break;
            case kMul:
                op = "\\odot";
                gDocNoticeFlagMap["intmult"] = true;
                break;
            case kDiv:
                op = "\\oslash";
                gDocNoticeFlagMap["intdiv"] = true;
                gDocNoticeFlagMap["intcast"] = true; // "$normalize(int(i/j))$" in the notice.
                break;
            default:
                op = gBinOpLateqTable[opcode]->fName;
                break;
        }
    }
    
    /* LaTeX frac{}{} handling VS general case. */
    if ( (opcode == kDiv) && (!intOpDetected) ) { 
        s = subst("$0\\frac{$1}{$2}$3", lpar, CS(arg1, 0), CS(arg2, 0), rpar);
    } else {
        s = subst("$0$1 $2 $3$4", lpar, CS(arg1, thisPriority), op, CS(arg2, thisPriority), rpar);
    }
    
//  if (opcode == kMul) {
//      gDocNoticeFlagMap["cdot"] = true;
//  }
    
    return generateCacheCode(sig, s);
}

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

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

Referenced by generateCode().

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

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

References fOccMarkup, gDocNoticeFlagMap, generateDelayVec(), generateVariableStore(), getCertifiedSigType(), getCompiledExpression(), Occurences::getMaxDelay(), getSharingCount(), 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().

{
    //cerr << "!! entering generateCacheCode with sig=\"" << ppsig(sig) << "\"" << endl;    
    
    string      vname, ctype, code, vectorname;
    
    int         sharing = getSharingCount(sig);
    Occurences* o = fOccMarkup.retrieve(sig);
    
    // check reentrance
    if (getCompiledExpression(sig, code)) {
        //cerr << "!! generateCacheCode called a true getCompiledExpression" << endl;
        return code;
    }
    
    // check for expression occuring in delays
    if (o->getMaxDelay()>0) {
        if (getVectorNameProperty(sig, vectorname)) {
            return exp;
        }
        getTypedNames(getCertifiedSigType(sig), "r", ctype, vname);
        gDocNoticeFlagMap["recursigs"] = true;
        //cerr << "- r : generateCacheCode : vame=\"" << vname << "\", for sig=\"" << ppsig(sig) << "\"" << endl;
        if (sharing>1) {
            //cerr << "      generateCacheCode calls generateDelayVec(generateVariableStore) on vame=\"" << vname << "\"" << endl;            
            return generateDelayVec(sig, generateVariableStore(sig,exp), ctype, vname, o->getMaxDelay());
        } else {
            //cerr << "      generateCacheCode calls generateDelayVec(exp) on vame=\"" << vname << "\"" << endl;            
            return generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
        }
    } 
    else if (sharing == 1 || getVectorNameProperty(sig, vectorname) || isVerySimpleFormula(sig)) {
        //cerr << "! generateCacheCode : sharing == 1 : return \"" << exp << "\"" << endl;
        return exp;
    } 
    else if (sharing > 1) {
        //cerr << "! generateCacheCode : sharing > 1 : return \"" << exp << "\"" << endl;
        return generateVariableStore(sig, exp);
    } 
    else {
        cerr << "Error in sharing count (" << sharing << ") for " << *sig << endl;
        exit(1);
    }
    
    return "Error in generateCacheCode";
}

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

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

Referenced by generateCode().

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

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:
sigThe signal expression to compile.
priorityThe environment priority of the expression.
Returns:
<string> The LaTeX code translation of the signal.

Definition at line 193 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().

{
    int     i;
    double  r;
    Tree    c, sel, x, y, z, u, label, ff, largs, type, name, file;
    
    if ( getUserData(sig) )                         { printGCCall(sig,"generateXtended");   return generateXtended  (sig, priority);        }
    else if ( isSigInt(sig, &i) )                   { printGCCall(sig,"generateNumber");    return generateNumber   (sig, docT(i));         }
    else if ( isSigReal(sig, &r) )                  { printGCCall(sig,"generateNumber");    return generateNumber   (sig, docT(r));         }
    else if ( isSigInput(sig, &i) )                 { printGCCall(sig,"generateInput");     return generateInput    (sig, docT(i+1));       }
    else if ( isSigOutput(sig, &i, x) )             { printGCCall(sig,"generateOutput");    return generateOutput   (sig, docT(i+1), CS(x, priority));  }
    
    else if ( isSigFixDelay(sig, x, y) )            { printGCCall(sig,"generateFixDelay");  return generateFixDelay (sig, x, y, priority);  }
    else if ( isSigPrefix(sig, x, y) )              { printGCCall(sig,"generatePrefix");    return generatePrefix   (sig, x, y, priority);  }
    else if ( isSigIota(sig, x) )                   { printGCCall(sig,"generateIota");      return generateIota     (sig, x);               }
    
    else if ( isSigBinOp(sig, &i, x, y) )           { printGCCall(sig,"generateBinOp");     return generateBinOp    (sig, i, x, y, priority);       }
    else if ( isSigFFun(sig, ff, largs) )           { printGCCall(sig,"generateFFun");      return generateFFun     (sig, ff, largs, priority);     }
    else if ( isSigFConst(sig, type, name, file) )  { printGCCall(sig,"generateFConst");    return generateFConst   (sig, tree2str(file), tree2str(name)); }
    else if ( isSigFVar(sig, type, name, file) )    { printGCCall(sig,"generateFVar");      return generateFVar     (sig, tree2str(file), tree2str(name)); }
    
    // new special tables for documentation purposes

    else if ( isSigDocConstantTbl(sig, x, y) )      { printGCCall(sig,"generateDocConstantTbl");    return generateDocConstantTbl (sig, x, y);  }
    else if ( isSigDocWriteTbl(sig,x,y,z,u) )       { printGCCall(sig,"generateDocWriteTbl");       return generateDocWriteTbl (sig, x, y, z, u); }
    else if ( isSigDocAccessTbl(sig, x, y) )        { printGCCall(sig, "generateDocAccessTbl");     return generateDocAccessTbl(sig, x, y); }


    else if ( isSigSelect2(sig, sel, x, y) )        { printGCCall(sig,"generateSelect2");   return generateSelect2  (sig, sel, x, y, priority);     }
    else if ( isSigSelect3(sig, sel, x, y, z) )     { printGCCall(sig,"generateSelect3");   return generateSelect3  (sig, sel, x, y, z, priority);  }
    
    else if ( isProj(sig, &i, x) )                  { printGCCall(sig,"generateRecProj");   return generateRecProj  (sig, x, i, priority);  }
    
    else if ( isSigIntCast(sig, x) )                { printGCCall(sig,"generateIntCast");   return generateIntCast  (sig, x, priority);     }
    else if ( isSigFloatCast(sig, x) )              { printGCCall(sig,"generateFloatCast"); return generateFloatCast(sig, x, priority);     }
    
    else if ( isSigButton(sig, label) )             { printGCCall(sig,"generateButton");    return generateButton   (sig, label);           }
    else if ( isSigCheckbox(sig, label) )           { printGCCall(sig,"generateCheckbox");  return generateCheckbox (sig, label);           }
    else if ( isSigVSlider(sig, label,c,x,y,z) )    { printGCCall(sig,"generateVSlider");   return generateVSlider  (sig, label, c,x,y,z);  }
    else if ( isSigHSlider(sig, label,c,x,y,z) )    { printGCCall(sig,"generateHSlider");   return generateHSlider  (sig, label, c,x,y,z);  }
    else if ( isSigNumEntry(sig, label,c,x,y,z) )   { printGCCall(sig,"generateNumEntry");  return generateNumEntry (sig, label, c,x,y,z);  }
    
    else if ( isSigVBargraph(sig, label,x,y,z) )    { printGCCall(sig,"generateVBargraph"); return CS(z, priority);}//generateVBargraph     (sig, label, x, y, CS(z, priority)); }
    else if ( isSigHBargraph(sig, label,x,y,z) )    { printGCCall(sig,"generateHBargraph"); return CS(z, priority);}//generateHBargraph     (sig, label, x, y, CS(z, priority)); }
    else if ( isSigAttach(sig, x, y) )              { printGCCall(sig,"generateAttach");    return generateAttach   (sig, x, y, priority); }
    
    else {
        cerr << "Error in d signal, unrecognized signal : " << *sig << endl;
        exit(1);
    }
    assert(0);
    return "error in generate code";
}

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

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

Referenced by generateRec().

{
    //assert(mxd > 0);
    if (mxd == 0) {
        fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
    } else {
        fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
    }
}

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

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

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

{
    string s = generateDelayVecNoTemp(sig, exp, ctype, vname, mxd);
    if (getCertifiedSigType(sig)->variability() < kSamp) {
        return exp;
    } else {
        return s;
    }
}

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

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

Referenced by generateDelayVec().

{
    assert(mxd > 0);

    //cerr << "  entering generateDelayVecNoTemp" << endl;
    
    string vectorname;

    // if generateVariableStore has already tagged sig, no definition is needed.
    if(getVectorNameProperty(sig, vectorname)) { 
        return subst("$0(t)", vectorname);
    } else {
        fLateq->addRecurSigFormula(subst("$0(t) = $1", vname, exp));
        setVectorNameProperty(sig, vname);
        return subst("$0(t)", vname);
    }
}

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

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

Referenced by generateCode().

{
    // the compilation of a table always returns its name
    string  vname = CS(tbl, 0);
    string result = subst("$0[$1]", vname, CS(ridx,0) );

    return generateCacheCode(sig, result);
}

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

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

Referenced by generateCode().

{   
    string  vname, ctype;
    string  init = CS(isig,0);

    int     n;
    if (!isSigInt(size, &n)) {
        cerr << "error in DocCompiler::generateDocConstantTbl() : "
             << *size
             << " is not an integer expression and can't be used as a table size' "
             << endl;
    }

    // allocate a name v_i for the table
    getTypedNames(getCertifiedSigType(isig), "v", ctype, vname);
    
    // add a comment on tables in the notice
        gDocNoticeFlagMap["tablesigs"] = true;
    
    // add equation v[t] = isig(t)
        fLateq->addRDTblSigFormula(subst("$0[t] = $1 \\condition{when $$t \\in [0,$2]$$} ", vname, init, T(n-1)));
    
    // note that the name of the table can never be used outside an sigDocTableAccess
    return vname;
}

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

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

Referenced by generateCode().

{
    string  vname, ctype;
    string  init = CS(isig,0);
    int     n;
    if (!isSigInt(size, &n)) {
        cerr << "error in DocCompiler::generateDocWriteTbl() : "
             << *size
             << " is not an integer expression and can't be used as a table size' "
             << endl;
    }


    // allocate a name w_i for the table
    getTypedNames(getCertifiedSigType(isig), "w", ctype, vname);

    // add a comment on tables in the notice
    gDocNoticeFlagMap["tablesigs"] = true;

    // describe the table equation
    string ltqRWTableDef;
    ltqRWTableDef += subst("$0(t)[i] = \n", vname);
    ltqRWTableDef += "\\left\\{\\begin{array}{ll}\n";
    ltqRWTableDef += subst("$0 & \\mbox{if \\,} t < 0 \\mbox{\\, and \\,}  i \\in [0,$1] \\\\\n",   replaceTimeBy(init,'i'), T(n-1));
    ltqRWTableDef += subst("$0 & \\mbox{if \\,} i = $1 \\\\\n", CS(wsig,0), CS(widx,0));
    ltqRWTableDef += subst("$0(t\\!-\\!1)[i] & \\mbox{otherwise} \\\\\n", vname);
    ltqRWTableDef += "\\end{array}\\right.";
        
    // add the table equation
        fLateq->addRWTblSigFormula(ltqRWTableDef); //w(t) = initsig(t)
    
    // note that the name of the table can never be used outside an sigDocTableAccess
    return vname;
}

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

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

Referenced by generateCode().

{
    string      ctype, vname;
    Occurences* o = fOccMarkup.retrieve(sig);

    if (o->getMaxDelay()>0) {
        getTypedNames(getCertifiedSigType(sig), "r", ctype, vname);
        gDocNoticeFlagMap["recursigs"] = true;
        //cerr << "- r : generateFConst : \"" << vname << "\"" << endl;            
        generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
    }
    
    if (exp == "fSamplingFreq") {
        //gDocNoticeFlagMap["fsamp"] = true;
        return "f_S";
    }
    
    return "\\mathrm{"+exp+"}";
}

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

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

Referenced by generateCode().

{
    string code = ffname(ff);
    code += '(';
    string sep = "";
    for (int i = 0; i< ffarity(ff); i++) {
        code += sep;
        code += CS(nth(largs, i), priority);
        sep = ", ";
    }
    code += ')';
    
    gDocNoticeFlagMap["foreignfun"] = true;

    return "\\mathrm{ff"+code+"}";
}

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

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

Referenced by generateCode().

{
    int d;
    string vecname;
    
    CS(exp, 0); // ensure exp is compiled to have a vector name
    
    if (! getVectorNameProperty(exp, vecname)) {
        cerr << "No vector name for : " << ppsig(exp) << endl;
        assert(0);
    }
    
    if (isSigInt(delay, &d) && (d == 0)) {
        //cerr << "@ generateFixDelay : d = " << d << endl;
        return subst("$0(t)", vecname);
    } else {
        //cerr << "@ generateFixDelay : d = " << d << endl;
        return subst("$0(t\\!-\\!$1)", vecname, CS(delay, 7));
    }
}

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

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

Referenced by generateCode().

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

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

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

Referenced by generateCode().

{
    string      ctype, vname;
    Occurences* o = fOccMarkup.retrieve(sig);

    if (o->getMaxDelay()>0) {
        getTypedNames(getCertifiedSigType(sig), "r", ctype, vname);
        gDocNoticeFlagMap["recursigs"] = true;
        //cerr << "- r : generateFVar : \"" << vname << "\"" << endl;            
        setVectorNameProperty(sig, vname);
        generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
    }
    return generateCacheCode(sig, exp);
}

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

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

{
    string varname = getFreshID("{u_g}");

    Type t = getCertifiedSigType(sig);
    switch (t->variability()) {

        case kKonst :
            break;

        case kBlock :
            break;

        case kSamp :
            break;
    }
    return generateCacheCode(sig, varname);
}

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

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

Referenced by generateCode().

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

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

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

Referenced by generateCode().

{
    if (fLateq->inputs() == 1) {
        setVectorNameProperty(sig, "x");
        fLateq->addInputSigFormula("x(t)"); 
        gDocNoticeFlagMap["inputsig"] = true;
        return generateCacheCode(sig, "x(t)");
    } else {
        setVectorNameProperty(sig, subst("x_{$0}", idx));
        fLateq->addInputSigFormula(subst("x_{$0}(t)", idx));
        gDocNoticeFlagMap["inputsigs"] = true;
        return generateCacheCode(sig, subst("x_{$0}(t)", idx));
    }
}

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

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

Referenced by generateCode().

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

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

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

Referenced by generateCode().

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

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

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

Referenced by generateCode().

{
    string      ctype, vname;
    Occurences* o = fOccMarkup.retrieve(sig);

    // check for number occuring in delays
    if (o->getMaxDelay()>0) {
        getTypedNames(getCertifiedSigType(sig), "r", ctype, vname);
        gDocNoticeFlagMap["recursigs"] = true;
        //cerr << "- r : generateNumber : \"" << vname << "\"" << endl;            
        generateDelayVec(sig, exp, ctype, vname, o->getMaxDelay());
    }
    return exp;
}

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

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

Referenced by generateCode().

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

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

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

Referenced by generateCode().

{
    string dst;
    
    if (fLateq->outputs() == 1) {
        dst = subst("y(t)", idx);
        gDocNoticeFlagMap["outputsig"] = true;
    } else {
        dst = subst("y_{$0}(t)", idx);
        gDocNoticeFlagMap["outputsigs"] = true;
    }
    
    fLateq->addOutputSigFormula(subst("$0 = $1", dst, arg));
    return dst;
}

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:
sigThe signal expression to treat.
xThe initial value for the delay line.
eThe value for the delay line, after initialization.
priorityThe priority of the environment of the expression.
Returns:
<string> The LaTeX code translation of the signal, cached.

Definition at line 963 of file doc_compile.cpp.

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

Referenced by generateCode().

{
    string var  = getFreshID("m");
    string exp0 = CS(x, priority);
    string exp1 = CS(e, priority); // ensure exp1 is compiled to have a vector name
    string vecname;

    if (! getVectorNameProperty(e, vecname)) {
        cerr << "No vector name for : " << ppsig(e) << endl;
        assert(0);
    }
    
    string ltqPrefixDef;
    ltqPrefixDef += subst("$0(t) = \n", var);
    ltqPrefixDef += "\\left\\{\\begin{array}{ll}\n";
    ltqPrefixDef += subst("$0 & \\mbox{, when \\,} t = 0\\\\\n", exp0);
    ltqPrefixDef += subst("$0 & \\mbox{, when \\,} t > 0\n", subst("$0(t\\!-\\!1)", vecname));
    ltqPrefixDef += "\\end{array}\\right.";
    
    fLateq->addPrefixSigFormula(ltqPrefixDef);
    gDocNoticeFlagMap["prefixsigs"] = true;
    
    return generateCacheCode(sig, subst("$0(t)", var));
}

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

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

Referenced by generateRecProj().

{
    int             N = len(le);

    vector<bool>    used(N);
    vector<int>     delay(N);
    vector<string>  vname(N);
    vector<string>  ctype(N);

    // prepare each element of a recursive definition
    for (int i=0; i<N; i++) {
        Tree    e = sigProj(i,sig);     // recreate each recursive definition
        if (fOccMarkup.retrieve(e)) {
            // this projection is used
            used[i] = true;
            //cerr << "generateRec : used[" << i << "] = true" << endl;            
            getTypedNames(getCertifiedSigType(e), "r", ctype[i],  vname[i]);
            gDocNoticeFlagMap["recursigs"] = true;
            //cerr << "- r : generateRec setVectorNameProperty : \"" << vname[i] << "\"" << endl;
            setVectorNameProperty(e, vname[i]);
            delay[i] = fOccMarkup.retrieve(e)->getMaxDelay();
        } else {
            // this projection is not used therefore
            // we should not generate code for it
            used[i] = false;
            //cerr << "generateRec : used[" << i << "] = false" << endl;
        }
    }

    // generate delayline for each element of a recursive definition
    for (int i=0; i<N; i++) {
        if (used[i]) {
            generateDelayLine(ctype[i], vname[i], delay[i], CS(nth(le,i), priority));
        }
    }
}

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

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

Referenced by generateCode().

{
    string  vname;
    Tree    var, le;
    
    //cerr << "*** generateRecProj sig : \"" << ppsig(sig) << "\"" << endl;            

    if ( ! getVectorNameProperty(sig, vname)) {
        assert(isRec(r, var, le));
        //cerr << "    generateRecProj has NOT YET a vname : " << endl;            
        //cerr << "--> generateRecProj calls generateRec on \"" << ppsig(sig) << "\"" << endl;            
        generateRec(r, var, le, priority);
        assert(getVectorNameProperty(sig, vname));
        //cerr << "<-- generateRecProj vname : \"" << subst("$0(t)", vname) << "\"" << endl;            
    } else {
        //cerr << "(generateRecProj has already a vname : \"" << subst("$0(t)", vname) << "\")" << endl;            
    }
    return subst("$0(t)", vname);
}

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

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

Referenced by generateCode().

{
    string var  = getFreshID("q");
    string expsel = CS(sel, 0);
    string exps1 = CS(s1, 0);
    string exps2 = CS(s2, 0);
    
    string ltqSelDef;
    ltqSelDef += subst("$0(t) = \n", var);
    ltqSelDef += "\\left\\{\\begin{array}{ll}\n";
    ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 0\\\\\n", exps1, expsel);
    ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 1\n", exps2, expsel);
    ltqSelDef += "\\end{array}\\right.";
    
    fLateq->addSelectSigFormula(ltqSelDef);
    gDocNoticeFlagMap["selectionsigs"] = true;
    
    //return generateCacheCode(sig, subst("$0(t)", var));
    setVectorNameProperty(sig, var);
    return subst("$0(t)", var);
}

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

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

Referenced by generateCode().

{
    string var  = getFreshID("q");
    string expsel = CS(sel, 0);
    string exps1 = CS(s1, 0);
    string exps2 = CS(s2, 0);
    string exps3 = CS(s3, 0);
    
    string ltqSelDef;
    ltqSelDef += subst("$0(t) = \n", var);
    ltqSelDef += "\\left\\{\\begin{array}{ll}\n";
    ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 0\\\\\n", generateVariableStore(s1, exps1), expsel);
    ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 1\\\\\n", generateVariableStore(s2, exps2), expsel);
    ltqSelDef += subst("$0 & \\mbox{if \\,} $1 = 2\n", generateVariableStore(s3, exps3), expsel);
    ltqSelDef += "\\end{array}\\right.";
    
    fLateq->addSelectSigFormula(ltqSelDef);
    gDocNoticeFlagMap["selectionsigs"] = true;
    
    //return generateCacheCode(sig, subst("$0(t)", var));
    setVectorNameProperty(sig, var);
    return subst("$0(t)", var);
}

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

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

Referenced by generateCacheCode(), and generateSelect3().

{
    string      vname, ctype;
    Type        t = getCertifiedSigType(sig);
    
    switch (t->variability()) {
            
        case kKonst :
            getTypedNames(t, "k", ctype, vname); 
            fLateq->addConstSigFormula(subst("$0 = $1", vname, exp));
            gDocNoticeFlagMap["constsigs"] = true;
            return vname;
            
        case kBlock :
            getTypedNames(t, "p", ctype, vname); 
            fLateq->addParamSigFormula(subst("$0(t) = $1", vname, exp));
            gDocNoticeFlagMap["paramsigs"] = true;
            setVectorNameProperty(sig, vname);
            return subst("$0(t)", vname);
            
        case kSamp :
            if(getVectorNameProperty(sig, vname)) {
                return subst("$0(t)", vname);
            } else {
                getTypedNames(t, "s", ctype, vname);
                //cerr << "- generateVariableStore : \"" << subst("$0(t) = $1", vname, exp) << "\"" << endl;
                fLateq->addStoreSigFormula(subst("$0(t) = $1", vname, exp));
                gDocNoticeFlagMap["storedsigs"] = true;
                setVectorNameProperty(sig, vname);
                return subst("$0(t)", vname);
            }
            
        default:
            assert(0);
            return "";
    }
}

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

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

{
    string varname = getFreshID("{u_g}");

    Type t = getCertifiedSigType(sig);
    switch (t->variability()) {

        case kKonst :
            break;

        case kBlock :
            break;

        case kSamp :
            break;
    }
    return generateCacheCode(sig, varname);
}

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

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

Referenced by generateCode().

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

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:
sigthe signal we want to know the type

Definition at line 1067 of file doc_compile.cpp.

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

Referenced by generateCode().

{
    xtended*        p = (xtended*) getUserData(sig);
    vector<string>  args;
    vector<Type>    types;

    for (int i=0; i<sig->arity(); i++) {
        args.push_back(CS(sig->branch(i), 0));
        types.push_back(getCertifiedSigType(sig->branch(i)));
    }

    if (p->needCache()) {
        //cerr << "!! generateXtended : <needCache> : calls generateCacheCode(sig, p->generateLateq(fLateq, args, types))" << endl;
        return generateCacheCode(sig, p->generateLateq(fLateq, args, types));
    } else {
        //cerr << "!! generateXtended : <do not needCache> : calls p->generateLateq(fLateq, args, types)" << endl;
        return p->generateLateq(fLateq, args, types);
    }
}

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:
sigthe signal expression to compile.
namethe string representing the compiled expression.
Returns:
true is already compiled

Definition at line 141 of file doc_compile.cpp.

References fCompileProperty, and property< P >::get().

Referenced by CS(), and generateCacheCode().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 88 of file doc_compile.hh.

References fDescription.

{ return fDescription; }
string DocCompiler::getFreshID ( const string &  prefix) [protected]

Definition at line 72 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().

{
    if (fIDCounters.find(prefix) == fIDCounters.end()) {
        fIDCounters[prefix] = 1;
    }
    int n = fIDCounters[prefix];
    fIDCounters[prefix] = n+1;
    
    return subst("$0_{$1}", prefix, docT(n));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 86 of file doc_compile.hh.

References fLateq.

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

{
    //cerr << "getSharingCount of : " << *sig << " = ";
    Tree c;
    if (getProperty(sig, fSharingKey, c)) {
        //cerr << c->node().getInt() << endl;
        return c->node().getInt();
    } else {
        //cerr << 0 << endl;
        return 0;
    }
}

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

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

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

{
    if (t->nature() == kInt) {
        ctype = "int"; vname = subst("$0", getFreshID(prefix));
    } else {
        ctype = ifloat(); vname = subst("$0", getFreshID(prefix));
    }
}

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]pathnameThe path tree to convert.
Returns:
<string> A directory-like string.

Definition at line 1244 of file doc_compile.cpp.

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

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

{   
    //cerr << "Documentator : getUIDir : print(pathname, stdout) = "; print(pathname, stdout); cerr << endl;
    string s;
    Tree dir = reverse(tl(pathname));
    while (!isNil(dir)) { 
        string tmp = tree2str(tl(hd(dir)));
        if ( (tmp[0] != '[') && (!tmp.empty()) ) {
            s += tmp + '/';
        }
        dir = tl(dir);
    }
    return s;
}

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]pathThe UI full pathname to parse.
[out]labelThe place to store the UI name.
[out]unitThe place to store the UI unit.

Definition at line 1328 of file doc_compile.cpp.

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

Referenced by prepareBinaryUI(), and prepareIntervallicUI().

{
    label = "";
    unit = "";
    
    map<string, set<string> >   metadata;
    extractMetadata(tree2str(hd(path)), label, metadata);
    
    set<string> myunits = metadata["unit"];
//  for (set<string>::iterator i = myunits.begin(); i != myunits.end(); i++) {
//      cerr << "Documentator : getUIDocInfos : metadata[\"unit\"] = " << *i << endl;
//  }
    for (map<string, set<string> >::iterator i = metadata.begin(); i != metadata.end(); i++) {
        const string& key = i->first;
        const set<string>& values = i->second;
        for (set<string>::const_iterator j = values.begin(); j != values.end(); j++) {
            if(key == "unit") unit += *j;
        }
    }
}

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:
sigthe signal expression.
vecnamethe string where to store the vector name.
Returns:
true if the signal has this property, false otherwise

Definition at line 1117 of file doc_compile.cpp.

References fVectorProperty, and property< P >::get().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 872 of file doc_compile.cpp.

References max().

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

Here is the call 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 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]nameThe LaTeX name of the UI signal (eg. "{u_b}_{i}(t)").
[in]pathThe path tree to parse.
Returns:
<string> The LaTeX output string.

Definition at line 1272 of file doc_compile.cpp.

References gDocMathStringMap, and getUIDocInfos().

Referenced by generateButton(), and generateCheckbox().

{   
    string label, unit;
    getUIDocInfos(path, label, unit);
    string s = "";
    label = (label.size()>0) ? ("\\textsf{\""+label+"\"} ") : "";
    unit = (unit.size()>0) ? ("\\ ("+unit+")") : "";
    s += label + unit;
    s += " & $" + name + "$";
    s += " $\\in$ $\\left\\{\\,0, 1\\,\\right\\}$";
    s += " & $(\\mbox{" + gDocMathStringMap["defaultvalue"] + "} = 0)$\\\\";
    return s;
}

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]nameThe LaTeX name of the UI signal (eg. "{u_s}_{i}(t)").
[in]pathThe path tree to parse.
[in]tcurThe current UI value tree to convert.
[in]tminThe minimum UI value tree to convert.
[in]tmaxThe maximum UI value tree to convert.
Returns:
<string> The LaTeX output string.

Definition at line 1302 of file doc_compile.cpp.

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

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

{   
    string label, unit, cur, min, max;
    getUIDocInfos(path, label, unit);
    cur = docT(tree2float(tcur));
    min = docT(tree2float(tmin));
    max = docT(tree2float(tmax));
    
    string s = "";
    label = (label.size()>0) ? ("\\textsf{\""+label+"\"} ") : "";
    unit = (unit.size()>0) ? ("\\ ("+unit+")") : "";
    s += label + unit;
    s += " & $" + name + "$";
    s += " $\\in$ $\\left[\\," + min + ", " + max + "\\,\\right]$";
    s += " & $(\\mbox{" + gDocMathStringMap["defaultvalue"] + "} = " + cur + ")$\\\\";
    return s;
}

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

Referenced by generateCode().

{
    bool printCalls = false;
    bool maskSigs   = false;
    
    if(printCalls) {
        cerr << "  -> generateCode calls " << calledFunction;
        if(maskSigs) {
            cerr << endl;
        } else {
            cerr << " on " << ppsig(sig) << endl;
        }
    }
}

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:
sigthe signal expression to compile.
cexpthe string representing the compiled expression.
Returns:
the cexp (for commodity)

Definition at line 153 of file doc_compile.cpp.

References fCompileProperty, and property< P >::set().

Referenced by CS().

{
    fCompileProperty.set(sig, cexp);
    return cexp;
}

Here is the call graph for this function:

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.

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

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

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:
sigthe signal expression.
vecnamethe string representing the vector name.
Returns:
true is already compiled

Definition at line 1103 of file doc_compile.cpp.

References fVectorProperty, and property< P >::set().

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

{
    fVectorProperty.set(sig, vecname);
}

Here is the call graph for this function:

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

{
    fSharingKey = shprkey(t);
    if (isList(t)) {
        while (isList(t)) {
            sharingAnnotation(kSamp, hd(t));
            t = tl(t);
        }
    } else {
        sharingAnnotation(kSamp, t);
    }
}

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 getCertifiedSigType(), getSharingCount(), getSubSignals(), isSigGen(), and setSharingCount().

Referenced by sharingAnalysis().

{
    //cerr << "START sharing annotation of " << *sig << endl;
    int count = getSharingCount(sig);

    if (count > 0) {
        // it is not our first visit
        setSharingCount(sig, count+1);

    } else {
        // it is our first visit,
        int v = getCertifiedSigType(sig)->variability();

        // check "time sharing" cases
        if (v < vctxt) {
            setSharingCount(sig, 2);    // time sharing occurence : slower expression in faster context
        } else {
            setSharingCount(sig, 1);    // regular occurence
        }

        // Annotate the sub signals
        vector<Tree> subsig;
        int n = getSubSignals(sig, subsig);
        if (n>0 && ! isSigGen(sig)) {
            for (int i=0; i<n; i++) sharingAnnotation(v, subsig[i]);
        }
    }
    //cerr << "END sharing annotation of " << *sig << endl;
}

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: