FAUST compiler  0.9.9.6b8
Defines | Functions | Variables
tree.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "tree.hh"
#include <fstream>
#include <cstdlib>
Include dependency graph for tree.cpp:

Go to the source code of this file.

Defines

#define ERROR(s, t)   { error(s,t); exit(1); }

Functions

static void error (const char *s, Tree t)
int tree2int (Tree t)
 if t has a node of type int, return it otherwise error
double tree2float (Tree t)
 if t has a node of type float, return it otherwise error
double tree2double (Tree t)
 if t has a node of type float, return it otherwise error
const char * tree2str (Tree t)
 if t has a node of type symbol, return its name otherwise error
void * tree2ptr (Tree t)
 if t has a node of type ptr, return it otherwise error
bool isTree (const Tree &t, const Node &n)
bool isTree (const Tree &t, const Node &n, Tree &a)
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b)
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c)
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c, Tree &d)
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c, Tree &d, Tree &e)
void * getUserData (Tree t)
 if t has a node of type symbol, return the associated user data

Variables

Tabber TABBER (1)
Sym PROCESS = symbol("process")

Define Documentation

#define ERROR (   s,
 
)    { error(s,t); exit(1); }

Definition at line 96 of file tree.cpp.

Referenced by tree2double(), tree2float(), tree2int(), tree2ptr(), and tree2str().


Function Documentation

static void error ( const char *  s,
Tree  t 
) [static]

Definition at line 90 of file tree.cpp.

{
    //fprintf(stderr, "ERROR : %s (%p)\n", s, t);
    cerr << "ERROR : " << s << " : " << *t << endl;
}
void* getUserData ( Tree  t)

if t has a node of type symbol, return the associated user data

Definition at line 372 of file tree.cpp.

References getUserData(), isSym(), and CTree::node().

{
    Sym s;
    if (isSym(t->node(), &s)) {
        return getUserData(s);
    } else {
        return 0;
    }
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n 
)

Definition at line 305 of file tree.cpp.

References CTree::node().

Referenced by isBoxAbstr(), isBoxAccess(), isBoxAppl(), isBoxButton(), isBoxCase(), isBoxCheckbox(), isBoxComponent(), isBoxCut(), isBoxEnvironment(), isBoxError(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxIdent(), isBoxIPar(), isBoxIProd(), isBoxISeq(), isBoxISum(), isBoxLibrary(), isBoxMerge(), isBoxModifLocalDef(), isBoxNumEntry(), isBoxPar(), isBoxPatternMatcher(), isBoxPatternVar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWire(), isBoxWithLocalDef(), isClosure(), isDocDgm(), isDocEqn(), isDocLst(), isDocMtd(), isDocNtc(), isDocTxt(), isImportFile(), isPathCurrent(), isPathParent(), isPathRoot(), isProj(), isRec(), isRef(), isSigAttach(), isSigBinOp(), isSigButton(), isSigCheckbox(), isSigDelay1(), isSigDocAccessTbl(), isSigDocConstantTbl(), isSigDocWriteTbl(), isSigFConst(), isSigFFun(), isSigFixDelay(), isSigFloatCast(), isSigFVar(), isSigGen(), isSigHBargraph(), isSigHSlider(), isSigInput(), isSigIntCast(), isSigIota(), isSigNumEntry(), isSigOutput(), isSigPrefix(), isSigRDTbl(), isSigSelect2(), isSigSelect3(), isSigTable(), isSigTuple(), isSigTupleAccess(), isSigVBargraph(), isSigVSlider(), isSigWRTbl(), isUiFolder(), and isUiWidget().

{ 
    return (t->node() == n);
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a 
)

Definition at line 310 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

{ 
    if ((t->node() == n) && (t->arity() == 1)) { 
        a=t->branch(0); 
        return true; 
    } else {
        return false;
    }
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b 
)

Definition at line 320 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

{ 
    if ((t->node() == n) && (t->arity() == 2)) { 
        a=t->branch(0); 
        b=t->branch(1); 
        return true; 
    } else {
        return false;
    }
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c 
)

Definition at line 331 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

{ 
    if ((t->node() == n) && (t->arity() == 3)) { 
        a=t->branch(0); 
        b=t->branch(1); 
        c=t->branch(2); 
        return true; 
    } else {
        return false;
    }
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c,
Tree d 
)

Definition at line 343 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

{ 
    if ((t->node() == n) && (t->arity() == 4)) { 
        a=t->branch(0); 
        b=t->branch(1); 
        c=t->branch(2); 
        d=t->branch(3); 
        return true; 
    } else {
        return false;
    }
}

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c,
Tree d,
Tree e 
)

Definition at line 356 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

{ 
    if ((t->node() == n) && (t->arity() == 5)) { 
        a=t->branch(0); 
        b=t->branch(1); 
        c=t->branch(2); 
        d=t->branch(3); 
        e=t->branch(4); 
        return true; 
    } else {
        return false;
    }
}

Here is the call graph for this function:

double tree2double ( Tree  t)

if t has a node of type float, return it otherwise error

Definition at line 262 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by Description::addWidget().

{
    double   x;
    int     i;

    if (isInt(t->node(), &i)) {
        x = double(i);
    } else if (isDouble(t->node(), &x)) {
        //nothing to do
    } else {
        ERROR("the node of the tree is not a float nor an int", t);
    }
    return double(x);
}   

Here is the call graph for this function:

Here is the caller graph for this function:

double tree2float ( Tree  t)

if t has a node of type float, return it otherwise error

Definition at line 246 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by eval2double(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generateVSlider(), Compiler::generateWidgetCode(), Compiler::generateWidgetMacro(), infereSigType(), and DocCompiler::prepareIntervallicUI().

{
    double   x;
    int     i;

    if (isInt(t->node(), &i)) {
        x = double(i);
    } else if (isDouble(t->node(), &x)) {
        //nothing to do
    } else {
        ERROR("the node of the tree is not a float nor an int", t);
    }
    return x;
}   

Here is the call graph for this function:

Here is the caller graph for this function:

int tree2int ( Tree  t)

if t has a node of type int, return it otherwise error

Definition at line 230 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by Description::addGroup(), annotate(), boxComplexity(), eval2int(), ffargtype(), ffrestype(), Compiler::generateUserInterfaceTree(), getRecursivness(), getSigOrder(), infereFConstType(), infereFVarType(), and isBoxPatternMatcher().

{
    double  x;
    int     i;

    if (isInt(t->node(), &i)) {
        // nothing to do
    } else if (isDouble(t->node(), &x)) {
        i = int(x);
    } else {
        ERROR("the node of the tree is not an int nor a float", t);
    }
    return i;
}   

Here is the call graph for this function:

Here is the caller graph for this function:

void* tree2ptr ( Tree  t)

if t has a node of type ptr, return it otherwise error

Definition at line 288 of file tree.cpp.

References ERROR, isPointer(), and CTree::node().

Referenced by getColorProperty(), OccMarkup::getOcc(), and isBoxPatternMatcher().

{
    void*   x;
    if (! isPointer(t->node(), &x)) {
        ERROR("the node of the tree is not a pointer", t);
    }
    return x;
}   

Here is the call graph for this function:

Here is the caller graph for this function:

const char* tree2str ( Tree  t)

Variable Documentation

Sym PROCESS = symbol("process")

Definition at line 144 of file tree.cpp.

Definition at line 87 of file tree.cpp.

Referenced by annotationStatistics(), getSigType(), setSigType(), T(), and traced_simplification().