FAUST compiler  0.9.9.6b8
Functions | Variables
sigtype.cpp File Reference
#include "tree.hh"
#include "sigtype.hh"
#include "property.hh"
Include dependency graph for sigtype.cpp:

Go to the source code of this file.

Functions

ostream & operator<< (ostream &dst, const Type &t)
ostream & operator<< (ostream &dst, const SimpleType &t)
ostream & operator<< (ostream &dst, const TableType &t)
ostream & operator<< (ostream &dst, const TupletType &t)
Type operator| (const Type &t1, const Type &t2)
bool operator== (const Type &t1, const Type &t2)
bool operator<= (const Type &t1, const Type &t2)
Type operator* (const Type &t1, const Type &t2)
SimpleTypeisSimpleType (AudioType *t)
TableTypeisTableType (AudioType *t)
TupletTypeisTupletType (AudioType *t)
Type checkInt (Type t)
 verifie que t est entier
Type checkKonst (Type t)
 verifie que t est constant
Type checkInit (Type t)
 verifie que t est connu a l'initialisation
Type checkIntParam (Type t)
 verifie que t est connu a l'initialisation, constant et entier
Type checkWRTbl (Type tbl, Type wr)
 verifie que wr est compatible avec le contenu de tbl
int checkDelayInterval (Type t)
 Check is a type is appropriate for a delay.
string cType (Type t)
static Tree codeSimpleType (SimpleType *st)
 Code a simple audio type as a tree in order to benefit of memoization.
static Tree codeTableType (TableType *tt)
 Code a table type as a tree in order to benefit of memoization.
static Tree codeTupletType (TupletType *nt)
 Code a tuplet type as a tree in order to benefit of memoization.
Tree codeAudioType (AudioType *t)
 codeAudioType(Type) -> Tree Code an audio type as a tree in order to benefit of memoization The type field (of the coded type) is used to store the audio type
AudioTypemakeSimpleType (int n, int v, int c, int vec, int b, const interval &i)
AudioTypemakeTableType (const Type &ct)
AudioTypemakeTableType (const Type &ct, int n, int v, int c, int vec, int b, const interval &i)
AudioTypemakeTableType (const Type &ct, int n, int v, int c, int vec)
AudioTypemakeTupletType (const vector< Type > &vt)
AudioTypemakeTupletType (const vector< Type > &vt, int n, int v, int c, int vec, int b, const interval &i)

Variables

Type TINT = makeSimpleType(kInt, kKonst, kComp, kVect, kNum, interval())
Type TREAL = makeSimpleType(kReal, kKonst, kComp, kVect, kNum, interval())
Type TKONST = makeSimpleType(kInt, kKonst, kComp, kVect, kNum, interval())
Type TBLOCK = makeSimpleType(kInt, kBlock, kComp, kVect, kNum, interval())
Type TSAMP = makeSimpleType(kInt, kSamp, kComp, kVect, kNum, interval())
Type TCOMP = makeSimpleType(kInt, kKonst, kComp, kVect, kNum, interval())
Type TINIT = makeSimpleType(kInt, kKonst, kInit, kVect, kNum, interval())
Type TEXEC = makeSimpleType(kInt, kKonst, kExec, kVect, kNum, interval())
Type TINPUT = makeSimpleType(kReal, kSamp, kExec, kVect, kNum, interval())
Type TGUI = makeSimpleType(kReal, kBlock,kExec, kVect, kNum, interval())
Type TGUI01 = makeSimpleType(kReal, kBlock,kExec, kVect, kNum, interval(0,1))
Type INT_TGUI = makeSimpleType(kInt, kBlock,kExec, kVect, kNum, interval())
Type TREC = makeSimpleType(kInt, kSamp, kInit, kScal, kNum, interval())
property< AudioType * > MemoizedTypes
Sym SIMPLETYPE = symbol ("SimpleType")
Sym TABLETYPE = symbol ("TableType")
Sym TUPLETTYPE = symbol ("TupletType")

Function Documentation

Check is a type is appropriate for a delay.

Check if the interval of t is appropriate for a delay.

Returns:
-1 if not appropriate, mxd (max delay) if appropriate

Definition at line 327 of file sigtype.cpp.

References interval::hi, interval::lo, and interval::valid.

Referenced by OccMarkup::incOcc().

{
    interval i = t->getInterval();
    if (i.valid && i.lo >= 0) {
        return int(i.hi+0.5);
    } else {
        //cerr << "checkDelayInterval failed for : " << i << endl;
        return -1;
    }
}       

Here is the caller graph for this function:

verifie que t est connu a l'initialisation

Definition at line 297 of file sigtype.cpp.

References kInit.

Referenced by checkIntParam(), infereDocConstantTblType(), infereDocWriteTblType(), and infereSigType().

{
    // verifie que t est connu a l'initialisation
    if (t->computability() > kInit) {
        cerr << "Error : checkInit failed for type " << t << endl;
        exit(1);
    }
    return t;
}   

Here is the caller graph for this function:

Type checkInt ( Type  t)

verifie que t est entier

Definition at line 276 of file sigtype.cpp.

References isSimpleType(), kInt, and AudioType::nature().

Referenced by checkIntParam(), infereDocConstantTblType(), infereDocWriteTblType(), and infereSigType().

{
    // verifie que t est entier
    SimpleType* st = isSimpleType(t);
    if (st == 0 || st->nature() > kInt) {
        cerr << "Error : checkInt failed for type " << t << endl;
        exit(1);
    }
    return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

verifie que t est connu a l'initialisation, constant et entier

Definition at line 307 of file sigtype.cpp.

References checkInit(), checkInt(), and checkKonst().

{
    return checkInit(checkKonst(checkInt(t)));
}

Here is the call graph for this function:

verifie que t est constant

Definition at line 287 of file sigtype.cpp.

References kKonst.

Referenced by checkIntParam(), infereDocConstantTblType(), and infereDocWriteTblType().

{
    // verifie que t est constant
    if (t->variability() > kKonst) {
        cerr << "Error : checkKonst failed for type " << t << endl;
        exit(1);
    }
    return t;
}   

Here is the caller graph for this function:

Type checkWRTbl ( Type  tbl,
Type  wr 
)

verifie que wr est compatible avec le contenu de tbl

Definition at line 312 of file sigtype.cpp.

{
    // verifie que wr est compatible avec le contenu de tbl
    if (wr->nature() > tbl->nature()) {
        cerr << "Error : checkWRTbl failed, the content of  " << tbl << " is incompatible with " << wr << endl;
        exit(1);
    }
    return tbl;
}       

codeAudioType(Type) -> Tree Code an audio type as a tree in order to benefit of memoization The type field (of the coded type) is used to store the audio type

Code an audio type as a tree (memoization)

Definition at line 374 of file sigtype.cpp.

References codeSimpleType(), codeTableType(), codeTupletType(), AudioType::getCode(), isSimpleType(), isTableType(), isTupletType(), and CTree::setType().

Referenced by codeTableType(), codeTupletType(), makeSimpleType(), makeTableType(), and makeTupletType().

{
    SimpleType  *st;
    TableType   *tt;
    TupletType  *nt;

    Tree        r;

    if ((r=t->getCode())) return r;

    if ((st = isSimpleType(t))) {
        r = codeSimpleType(st);
    } else if ((tt = isTableType(t))) {
        r = codeTableType(tt);
    } else if ((nt = isTupletType(t))) {
        r = codeTupletType(nt);
    } else {
        cerr << "ERROR in codeAudioType() : invalide pointer " << t << endl;
        exit(1);
    }

    r->setType(t);
    return r;

}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree codeSimpleType ( SimpleType st) [static]

Code a simple audio type as a tree in order to benefit of memoization.

Definition at line 404 of file sigtype.cpp.

References AudioType::boolean(), AudioType::computability(), AudioType::getInterval(), interval::hi, interval::lo, CTree::make(), AudioType::nature(), tree(), interval::valid, AudioType::variability(), and AudioType::vectorability().

Referenced by codeAudioType().

{
    vector<Tree> elems;
    elems.push_back(tree(st->nature()));
    elems.push_back(tree(st->variability()));
    elems.push_back(tree(st->computability()));
    elems.push_back(tree(st->vectorability()));
    elems.push_back(tree(st->boolean()));

    elems.push_back(tree(st->getInterval().valid));
    elems.push_back(tree(st->getInterval().lo));
    elems.push_back(tree(st->getInterval().hi));

    return CTree::make(SIMPLETYPE, elems);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree codeTableType ( TableType st) [static]

Code a table type as a tree in order to benefit of memoization.

Definition at line 443 of file sigtype.cpp.

References codeAudioType(), TableType::content(), and tree().

Referenced by codeAudioType().

{
    return tree(TABLETYPE, codeAudioType(tt->content()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree codeTupletType ( TupletType st) [static]

Code a tuplet type as a tree in order to benefit of memoization.

Definition at line 504 of file sigtype.cpp.

References TupletType::arity(), codeAudioType(), and CTree::make().

Referenced by codeAudioType().

{
    vector<Tree> elems;
    for (int i=0; i<nt->arity(); i++) {
        elems.push_back(codeAudioType((*nt)[i]));
    }
    return CTree::make(TUPLETTYPE, elems);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string cType ( Type  t)

Definition at line 340 of file sigtype.cpp.

References kInt.

Referenced by ScalarCompiler::generatePrefix().

{
    return (t->nature() == kInt) ? "int" : "float";
}

Here is the caller graph for this function:

Definition at line 267 of file sigtype.cpp.

Referenced by checkInt(), codeAudioType(), infereReadTableType(), infereSigType(), infereWriteTableType(), operator==(), and operator|().

{ return dynamic_cast<SimpleType*>(t); }

Here is the caller graph for this function:

Definition at line 268 of file sigtype.cpp.

Referenced by codeAudioType(), infereReadTableType(), infereWriteTableType(), operator==(), and operator|().

{ return dynamic_cast<TableType*>(t);  }

Here is the caller graph for this function:

Definition at line 269 of file sigtype.cpp.

Referenced by codeAudioType(), infereProjType(), operator==(), and operator|().

{ return dynamic_cast<TupletType*>(t); }

Here is the caller graph for this function:

AudioType* makeSimpleType ( int  n,
int  v,
int  c,
int  vec,
int  b,
const interval i 
)
AudioType* makeTableType ( const Type ct)

Definition at line 448 of file sigtype.cpp.

References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().

Referenced by infereSigType(), infereWriteTableType(), operator|(), TableType::promoteBoolean(), TableType::promoteComputability(), TableType::promoteNature(), TableType::promoteVariability(), and TableType::promoteVectorability().

{
    TableType   prototype(ct);
    Tree        code = codeAudioType(&prototype);

    AudioType*  tt;
    if (MemoizedTypes.get(code, tt)) {
        return tt;
    } else {
        AudioType::gAllocationCount++;
        tt = new TableType(ct);
        MemoizedTypes.set(code, tt);
        tt->setCode(code);
        return tt;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

AudioType* makeTableType ( const Type ct,
int  n,
int  v,
int  c,
int  vec,
int  b,
const interval i 
)

Definition at line 465 of file sigtype.cpp.

References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().

{
    TableType   prototype(ct,n,v,c,vec,b,i);
    Tree        code = codeAudioType(&prototype);

    AudioType*  tt;
    if (MemoizedTypes.get(code, tt)) {
        return tt;
    } else {
        AudioType::gAllocationCount++;
        tt = new TableType(ct);
        MemoizedTypes.set(code, tt);
        tt->setCode(code);
        return tt;
    }
}

Here is the call graph for this function:

AudioType* makeTableType ( const Type ct,
int  n,
int  v,
int  c,
int  vec 
)

Definition at line 482 of file sigtype.cpp.

References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().

{
    TableType   prototype(ct,n,v,c,vec);
    Tree        code = codeAudioType(&prototype);

    AudioType*  tt;
    if (MemoizedTypes.get(code, tt)) {
        return tt;
    } else {
        AudioType::gAllocationCount++;
        tt = new TableType(ct);
        MemoizedTypes.set(code, tt);
        tt->setCode(code);
        return tt;
    }
}

Here is the call graph for this function:

AudioType* makeTupletType ( const vector< Type > &  vt)

Definition at line 513 of file sigtype.cpp.

References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().

{
    TupletType  prototype(vt);
    Tree        code = codeAudioType(&prototype);

    AudioType*  t;
    if (MemoizedTypes.get(code, t)) {
        return t;
    } else {
        AudioType::gAllocationCount++;
        t = new TupletType(vt);
        MemoizedTypes.set(code, t);
        t->setCode(code);
        return t;
    }

}

Here is the call graph for this function:

AudioType* makeTupletType ( const vector< Type > &  vt,
int  n,
int  v,
int  c,
int  vec,
int  b,
const interval i 
)

Definition at line 531 of file sigtype.cpp.

References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().

{
    TupletType  prototype(vt,n,v,c,vec,b,i);
    Tree        code = codeAudioType(&prototype);

    AudioType*  t;
    if (MemoizedTypes.get(code, t)) {
        return t;
    } else {
        AudioType::gAllocationCount++;
        t = new TupletType(vt,n,v,c,vec,b,i);
        MemoizedTypes.set(code, t);
        t->setCode(code);
        return t;
    }

}

Here is the call graph for this function:

Type operator* ( const Type t1,
const Type t2 
)

Definition at line 241 of file sigtype.cpp.

References TupletType::arity().

{
    vector<Type>    v;
    
    TupletType* nt1 = dynamic_cast<TupletType*>((AudioType*)t1);
    TupletType* nt2 = dynamic_cast<TupletType*>((AudioType*)t2);
    
    if (nt1) {
        for (int i=0; i<nt1->arity(); i++) {
            v.push_back((*nt1)[i]);
        }
    } else {
        v.push_back(t1);
    }
    
    if (nt2) {
        for (int i=0; i<nt2->arity(); i++) {
            v.push_back((*nt2)[i]);
        }
    } else {
        v.push_back(t2);
    }
    return new TupletType(v);   
}

Here is the call graph for this function:

ostream& operator<< ( ostream &  dst,
const Type t 
)

Definition at line 46 of file sigtype.cpp.

{ return  t->print(dst);}
ostream& operator<< ( ostream &  dst,
const SimpleType t 
)

Definition at line 48 of file sigtype.cpp.

References SimpleType::print().

{ return  t.print(dst); }

Here is the call graph for this function:

ostream& operator<< ( ostream &  dst,
const TableType t 
)

Definition at line 50 of file sigtype.cpp.

References TableType::print().

{ return  t.print(dst); }

Here is the call graph for this function:

ostream& operator<< ( ostream &  dst,
const TupletType t 
)

Definition at line 52 of file sigtype.cpp.

References TupletType::print().

{ return  t.print(dst); }

Here is the call graph for this function:

bool operator<= ( const Type t1,
const Type t2 
)

Definition at line 234 of file sigtype.cpp.

{
    return (t1|t2) == t2;
}
bool operator== ( const Type t1,
const Type t2 
)

Definition at line 201 of file sigtype.cpp.

References TupletType::arity(), AudioType::boolean(), AudioType::computability(), TableType::content(), AudioType::getInterval(), interval::hi, isSimpleType(), isTableType(), isTupletType(), interval::lo, AudioType::nature(), interval::valid, AudioType::variability(), and AudioType::vectorability().

{
    SimpleType  *st1, *st2;
    TableType   *tt1, *tt2;
    TupletType  *nt1, *nt2;

    if (t1->variability() != t2->variability())     return false;
    if (t1->computability() != t2->computability()) return false;
    
    if ( (st1 = isSimpleType(t1)) && (st2 = isSimpleType(t2)) )
        return     (st1->nature() == st2->nature())
                && (st1->variability() == st2->variability())
                && (st1->computability() == st2->computability())
                && (st1->vectorability() == st2->vectorability())
                && (st1->boolean() == st2->boolean())
                && (st1->getInterval().lo == st2->getInterval().lo)
                && (st1->getInterval().hi == st2->getInterval().hi)
                && (st1->getInterval().valid == st2->getInterval().valid);
    if ( (tt1 = isTableType(t1)) && (tt2 = isTableType(t2)) )
        return tt1->content()== tt2->content();
    if ( (nt1 = isTupletType(t1)) && (nt2 = isTupletType(t2)) ) {
        int a1 = nt1->arity();
        int a2 = nt2->arity();
        if (a1 == a2) {
            for (int i=0; i<a1; i++)  { if ((*nt1)[i] != (*nt2)[i]) return false; }
            return true;
        } else {
            return false;
        }
    }
    return false;
}

Here is the call graph for this function:

Type operator| ( const Type t1,
const Type t2 
)

Definition at line 166 of file sigtype.cpp.

References TupletType::arity(), AudioType::boolean(), AudioType::computability(), TableType::content(), AudioType::getInterval(), isSimpleType(), isTableType(), isTupletType(), makeSimpleType(), makeTableType(), min(), AudioType::nature(), reunion(), AudioType::variability(), and AudioType::vectorability().

{
    SimpleType  *st1, *st2;
    TableType   *tt1, *tt2;
    TupletType  *nt1, *nt2;
    
    if ( (st1 = isSimpleType(t1)) && (st2 = isSimpleType(t2)) ) {
        
        return makeSimpleType(  st1->nature()|st2->nature(),
                    st1->variability()|st2->variability(),
                    st1->computability()|st2->computability(),
                    st1->vectorability()|st2->vectorability(),
                    st1->boolean()|st2->boolean(),
                    reunion(st1->getInterval(), st2->getInterval())
                    );
        
    } else if ( (tt1 = isTableType(t1)) && (tt2 = isTableType(t2)) ) {
        
        return makeTableType( tt1->content() | tt2->content() );
        
    } else if ( (nt1 = isTupletType(t1)) && (nt2 = isTupletType(t2)) ) {
        
        vector<Type> v;
        int n = min(nt1->arity(), nt2->arity());
        for (int i=0; i<n; i++) { v.push_back( (*nt1)[i] | (*nt2)[i]); }
        return new TupletType( v );
        
    } else {
        
        cerr << "Error : trying to combine incompatible types, " << t1 << " and " << t2 << endl;
        exit(1);
        return 0;
    }
}

Here is the call graph for this function:


Variable Documentation

Definition at line 158 of file sigtype.cpp.

Definition at line 356 of file sigtype.cpp.

Sym SIMPLETYPE = symbol ("SimpleType")

Definition at line 359 of file sigtype.cpp.

Sym TABLETYPE = symbol ("TableType")

Definition at line 360 of file sigtype.cpp.

Definition at line 146 of file sigtype.cpp.

Definition at line 149 of file sigtype.cpp.

Definition at line 151 of file sigtype.cpp.

Definition at line 156 of file sigtype.cpp.

Referenced by infereSigType().

Definition at line 157 of file sigtype.cpp.

Referenced by infereSigType().

Definition at line 150 of file sigtype.cpp.

Definition at line 155 of file sigtype.cpp.

Referenced by infereSigType().

Definition at line 142 of file sigtype.cpp.

Definition at line 145 of file sigtype.cpp.

Definition at line 143 of file sigtype.cpp.

Definition at line 163 of file sigtype.cpp.

Referenced by initialRecType().

Definition at line 147 of file sigtype.cpp.

Sym TUPLETTYPE = symbol ("TupletType")

Definition at line 361 of file sigtype.cpp.