FAUST compiler  0.9.9.6b8
Defines | Functions | Variables
boxcomplexity.cpp File Reference

Implement complexity computation for box diagrams. More...

#include <ostream>
#include "xtended.hh"
#include "boxcomplexity.h"
Include dependency graph for boxcomplexity.cpp:

Go to the source code of this file.

Defines

#define BC   boxComplexity
 internal shortcut to simplify computeBoxComplexity code

Functions

static int computeBoxComplexity (Tree box)
 Compute the complexity of a box expression.
int boxComplexity (Tree box)
 Return the complexity propety of a box expression tree.

Variables

Tree BCOMPLEXITY = tree ("BCOMPLEXITY")
 property Key used to store box complexity

Detailed Description

Implement complexity computation for box diagrams.

Definition in file boxcomplexity.cpp.


Define Documentation

#define BC   boxComplexity

internal shortcut to simplify computeBoxComplexity code

Definition at line 73 of file boxcomplexity.cpp.

Referenced by computeBoxComplexity().


Function Documentation

int boxComplexity ( Tree  box)

Return the complexity propety of a box expression tree.

Return the complexity propety of a box expression tree. If no complexity property exist, it is created an computeBoxComplexity is called do to the job.

Parameters:
boxan evaluated box expression tree
Returns:
the complexity of box
See also:
computeBoxComplexity

Definition at line 56 of file boxcomplexity.cpp.

References BCOMPLEXITY, computeBoxComplexity(), CTree::getProperty(), CTree::setProperty(), tree(), and tree2int().

Referenced by drawSchema(), and generateDiagramSchema().

{
    Tree prop = box->getProperty(BCOMPLEXITY);
    
    if (prop) {
        return tree2int(prop);
        
    } else {
        int v = computeBoxComplexity(box);
        box->setProperty(BCOMPLEXITY,tree(v));
        return v;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int computeBoxComplexity ( Tree  box) [static]

Compute the complexity of a box expression.

Compute the complexity of a box expression tree according to the complexity of its subexpressions. Basically it counts the number of boxes to be drawn. The box-diagram expression is supposed to be evaluated. It will exit with an error if it is not the case.

Parameters:
boxan evaluated box expression tree
Returns:
the complexity of box

Definition at line 87 of file boxcomplexity.cpp.

References BC, getUserData(), isBoxButton(), isBoxCheckbox(), isBoxCut(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxInt(), isBoxMerge(), isBoxNumEntry(), isBoxPar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWire(), max(), min(), and name().

Referenced by boxComplexity().

{
    int     i;
    double  r;
    prim0   p0;
    prim1   p1;
    prim2   p2;
    prim3   p3;
    prim4   p4;
    prim5   p5;

    Tree    t1, t2, ff, label, cur, min, max, step, type, name, file;
    
    xtended* xt = (xtended*) getUserData(box);

    
    // simple elements 
         if (xt)                        return 1;
    else if (isBoxInt(box, &i))         return 1; 
    else if (isBoxReal(box, &r))        return 1; 

    else if (isBoxCut(box))             return 0; 
    else if (isBoxWire(box))            return 0; 
     
    else if (isBoxPrim0(box, &p0))      return 1;  
    else if (isBoxPrim1(box, &p1))      return 1;  
    else if (isBoxPrim2(box, &p2))      return 1;  
    else if (isBoxPrim3(box, &p3))      return 1;  
    else if (isBoxPrim4(box, &p4))      return 1;  
    else if (isBoxPrim5(box, &p5))      return 1; 
    
    // foreign elements 
    else if (isBoxFFun(box, ff))        return 1; 
    else if (isBoxFConst(box, type, name, file))        
                                        return 1; 
    else if (isBoxFVar(box, type, name, file))        
                                        return 1; 
    // slots and symbolic boxes
    else if (isBoxSlot(box, &i))        return 1;
    else if (isBoxSymbolic(box,t1,t2))  return 1 + BC(t2);
    
    // block diagram binary operator 
    else if (isBoxSeq(box, t1, t2))     return BC(t1) + BC(t2);
    else if (isBoxSplit(box, t1, t2))   return BC(t1) + BC(t2);
    else if (isBoxMerge(box, t1, t2))   return BC(t1) + BC(t2);
    else if (isBoxPar(box, t1, t2))     return BC(t1) + BC(t2);
    else if (isBoxRec(box, t1, t2))     return BC(t1) + BC(t2);
    
    // user interface widgets
    else if (isBoxButton(box, label))                       return 1;  
    else if (isBoxCheckbox(box, label))                     return 1;  
    else if (isBoxVSlider(box, label, cur, min, max, step)) return 1;
    else if (isBoxHSlider(box, label, cur, min, max, step)) return 1;
    else if (isBoxHBargraph(box, label, min, max))          return 1;
    else if (isBoxVBargraph(box, label, min, max))          return 1;
    else if (isBoxNumEntry(box, label, cur, min, max, step))return 1;
    
    // user interface groups
    else if (isBoxVGroup(box, label, t1))   return BC(t1);
    else if (isBoxHGroup(box, label, t1))   return BC(t1);
    else if (isBoxTGroup(box, label, t1))   return BC(t1);

    //a completer
    else {
        //fout << tree2str(box);
        cerr << "ERROR in boxComplexity : not an evaluated box [[  " << *box << " ]]";
        exit(-1);
    }

    return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Tree BCOMPLEXITY = tree ("BCOMPLEXITY")

property Key used to store box complexity

Definition at line 41 of file boxcomplexity.cpp.

Referenced by boxComplexity().