|
FAUST compiler
0.9.9.6b8
|
#include <vector>#include <string>#include <iostream>#include "tree.hh"#include "smartpointer.hh"#include "interval.hh"

Go to the source code of this file.
Classes | |
| class | AudioType |
| The Root class for all audio data types. More... | |
| class | SimpleType |
| The type of a simple numeric audio signal. More... | |
| class | TableType |
| The type of a table of audio data. More... | |
| class | TupletType |
| The type of a tuplet of data. More... | |
Typedefs | |
| typedef P< AudioType > | Type |
Enumerations | |
| enum | { kInt = 0, kReal = 1 } |
| enum | { kNum = 0, kBool = 1 } |
| enum | { kKonst = 0, kBlock = 1, kSamp = 3 } |
| enum | { kComp = 0, kInit = 1, kExec = 3 } |
| enum | { kVect = 0, kScal = 1, kTrueScal = 3 } |
Functions | |
| ostream & | operator<< (ostream &s, const AudioType &n) |
| int | mergenature (const vector< Type > &v) |
| Return the nature of a vector of types. | |
| int | mergevariability (const vector< Type > &v) |
| Return the variability of a vector of types. | |
| int | mergecomputability (const vector< Type > &v) |
| Return the computability of a vector of types. | |
| int | mergevectorability (const vector< Type > &v) |
| Return the vectorability of a vector of types. | |
| int | mergeboolean (const vector< Type > &v) |
| Return the booleanity of a vector of types. | |
| interval | mergeinterval (const vector< Type > &v) |
| Return the interval of a vector of types. | |
| AudioType * | makeSimpleType (int n, int v, int c, int vec, int b, const interval &i) |
| AudioType * | makeTableType (const Type &ct) |
| AudioType * | makeTableType (const Type &ct, int n, int v, int c, int vec) |
| AudioType * | makeTableType (const Type &ct, int n, int v, int c, int vec, int b, const interval &i) |
| AudioType * | makeTupletType (const vector< Type > &vt) |
| AudioType * | makeTupletType (const vector< Type > &vt, int n, int v, int c, int vec, int b, const interval &i) |
| Type | intCast (Type t) |
| Type | floatCast (Type t) |
| Type | sampCast (Type t) |
| Type | boolCast (Type t) |
| Type | numCast (Type t) |
| Type | vecCast (Type t) |
| Type | scalCast (Type t) |
| Type | truescalCast (Type t) |
| Type | castInterval (Type t, const interval &i) |
| Type | table (const Type &t) |
| Type | operator| (const Type &t1, const Type &t2) |
| Type | operator* (const Type &t1, const Type &t2) |
| bool | operator== (const Type &t1, const Type &t2) |
| bool | operator<= (const Type &t1, const Type &t2) |
| bool | operator!= (const Type &t1, const Type &t2) |
| bool | operator< (const Type &t1, const Type &t2) |
| bool | operator> (const Type &t1, const Type &t2) |
| bool | operator>= (const Type &t1, const Type &t2) |
| SimpleType * | isSimpleType (AudioType *t) |
| TableType * | isTableType (AudioType *t) |
| TupletType * | isTupletType (AudioType *t) |
| ostream & | operator<< (ostream &dst, const SimpleType &t) |
| ostream & | operator<< (ostream &dst, const Type &t) |
| ostream & | operator<< (ostream &dst, const TableType &t) |
| ostream & | operator<< (ostream &dst, const TupletType &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 if the interval of t is appropriate for a delay. | |
| string | cType (Type t) |
| Tree | codeAudioType (AudioType *t) |
| Code an audio type as a tree (memoization) | |
Variables | |
| Type | TINT |
| Type | TREAL |
| Type | TKONST |
| Type | TBLOCK |
| Type | TSAMP |
| Type | TCOMP |
| Type | TINIT |
| Type | TEXEC |
| Type | TINPUT |
| Type | TGUI |
| Type | TGUI01 |
| Type | INT_TGUI |
| Type | TREC |
Definition at line 72 of file sigtype.hh.
| anonymous enum |
| anonymous enum |
| anonymous enum |
Definition at line 56 of file sigtype.hh.
| anonymous enum |
Definition at line 57 of file sigtype.hh.
| anonymous enum |
Definition at line 58 of file sigtype.hh.
Definition at line 272 of file sigtype.hh.
References kBool, and makeSimpleType().
{ return makeSimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), kBool, t->getInterval()); }

| Type castInterval | ( | Type | t, |
| const interval & | i | ||
| ) | [inline] |
Definition at line 278 of file sigtype.hh.
References makeSimpleType().
Referenced by CosPrim::infereSigType(), LogPrim::infereSigType(), SinPrim::infereSigType(), PowPrim::infereSigType(), TanPrim::infereSigType(), SqrtPrim::infereSigType(), AbsPrim::infereSigType(), Log10Prim::infereSigType(), RemainderPrim::infereSigType(), MinPrim::infereSigType(), MaxPrim::infereSigType(), RintPrim::infereSigType(), and infereSigType().
{
return makeSimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), t->boolean(), i);
}


| int checkDelayInterval | ( | Type | t | ) |
Check if the interval of t is appropriate for a delay.
Check if the interval of t is appropriate for a delay.
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;
}
}

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;
}

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;
}


| Type checkIntParam | ( | Type | t | ) |
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)));
}

| Type checkKonst | ( | Type | t | ) |
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;
}

| 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;
}
| Tree codeAudioType | ( | AudioType * | t | ) |
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;
}


Definition at line 340 of file sigtype.cpp.
References kInt.
Referenced by ScalarCompiler::generatePrefix().
{
return (t->nature() == kInt) ? "int" : "float";
}

Definition at line 270 of file sigtype.hh.
References kReal, and makeSimpleType().
Referenced by AcosPrim::infereSigType(), TanPrim::infereSigType(), AsinPrim::infereSigType(), SinPrim::infereSigType(), AtanPrim::infereSigType(), FloorPrim::infereSigType(), FmodPrim::infereSigType(), CeilPrim::infereSigType(), LogPrim::infereSigType(), Atan2Prim::infereSigType(), CosPrim::infereSigType(), ExpPrim::infereSigType(), Log10Prim::infereSigType(), RemainderPrim::infereSigType(), SqrtPrim::infereSigType(), RintPrim::infereSigType(), and infereSigType().
{ return makeSimpleType(kReal, t->variability(), t->computability(), t->vectorability(), t->boolean(), t->getInterval()); }


Definition at line 269 of file sigtype.hh.
References kInt, and makeSimpleType().
Referenced by infereSigType().
{ return makeSimpleType(kInt, t->variability(), t->computability(), t->vectorability(), t->boolean(), t->getInterval()); }


| SimpleType* isSimpleType | ( | AudioType * | t | ) |
Definition at line 267 of file sigtype.cpp.
Referenced by checkInt(), codeAudioType(), infereReadTableType(), infereSigType(), infereWriteTableType(), operator==(), and operator|().
{ return dynamic_cast<SimpleType*>(t); }

| TableType* isTableType | ( | AudioType * | t | ) |
Definition at line 268 of file sigtype.cpp.
Referenced by codeAudioType(), infereReadTableType(), infereWriteTableType(), operator==(), and operator|().
{ return dynamic_cast<TableType*>(t); }

| TupletType* isTupletType | ( | AudioType * | t | ) |
Definition at line 269 of file sigtype.cpp.
Referenced by codeAudioType(), infereProjType(), operator==(), and operator|().
{ return dynamic_cast<TupletType*>(t); }

| AudioType* makeSimpleType | ( | int | n, |
| int | v, | ||
| int | c, | ||
| int | vec, | ||
| int | b, | ||
| const interval & | i | ||
| ) |
Definition at line 421 of file sigtype.cpp.
References codeAudioType(), AudioType::gAllocationCount, property< P >::get(), property< P >::set(), and AudioType::setCode().
Referenced by boolCast(), castInterval(), floatCast(), infereFConstType(), infereFFType(), infereFVarType(), infereSigType(), intCast(), numCast(), operator|(), SimpleType::promoteBoolean(), SimpleType::promoteComputability(), SimpleType::promoteNature(), SimpleType::promoteVariability(), SimpleType::promoteVectorability(), sampCast(), scalCast(), truescalCast(), and vecCast().
{
SimpleType prototype(n,v,c,vec,b,i);
Tree code = codeAudioType(&prototype);
AudioType* t;
if (MemoizedTypes.get(code, t)) {
return t;
} else {
AudioType::gAllocationCount++;
t = new SimpleType(n,v,c,vec,b,i);
MemoizedTypes.set(code, t);
t->setCode(code);
return t;
}
}


| 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;
}
}


| 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;
}
}

| 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;
}
}

| 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;
}
}

| 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;
}
}

| int mergeboolean | ( | const vector< Type > & | v | ) | [inline] |
Return the booleanity of a vector of types.
Definition at line 187 of file sigtype.hh.
{
int r = 0;
for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->boolean();
return r;
}
| int mergecomputability | ( | const vector< Type > & | v | ) | [inline] |
Return the computability of a vector of types.
Definition at line 163 of file sigtype.hh.
{
int r = 0;
for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->computability();
return r;
}
| interval mergeinterval | ( | const vector< Type > & | v | ) | [inline] |
Return the interval of a vector of types.
Definition at line 199 of file sigtype.hh.
References interval::hi, interval::lo, max(), min(), and interval::valid.
{
if (v.size()==0) {
return interval();
} else {
double lo=0, hi=0;
for (unsigned int i = 0; i < v.size(); i++) {
interval r = v[i]->getInterval();
if (!r.valid) return r;
if (i==0) {
lo = r.lo;
hi = r.hi;
} else {
lo = min(lo,r.lo);
hi = max(hi,r.hi);
}
}
return interval(lo, hi);
}
}

| int mergenature | ( | const vector< Type > & | v | ) | [inline] |
Return the nature of a vector of types.
Definition at line 139 of file sigtype.hh.
{
int r = 0;
for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->nature();
return r;
}
| int mergevariability | ( | const vector< Type > & | v | ) | [inline] |
Return the variability of a vector of types.
Definition at line 151 of file sigtype.hh.
{
int r = 0;
for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->variability();
return r;
}
| int mergevectorability | ( | const vector< Type > & | v | ) | [inline] |
Return the vectorability of a vector of types.
Definition at line 175 of file sigtype.hh.
{
int r = 0;
for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->vectorability();
return r;
}
Definition at line 273 of file sigtype.hh.
References kNum, and makeSimpleType().
{ return makeSimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), kNum, t->getInterval()); }

Definition at line 419 of file sigtype.hh.
{ return !(t1==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);
}

Definition at line 420 of file sigtype.hh.
{ return t1<=t2 && t1!=t2; }
| ostream& operator<< | ( | ostream & | s, |
| const AudioType & | n | ||
| ) | [inline] |
Definition at line 133 of file sigtype.hh.
References AudioType::print().
{ return n.print(s); }

| ostream& operator<< | ( | ostream & | dst, |
| const SimpleType & | t | ||
| ) |
Definition at line 48 of file sigtype.cpp.
References SimpleType::print().
{ return t.print(dst); }

| ostream& operator<< | ( | ostream & | dst, |
| const Type & | t | ||
| ) |
Definition at line 46 of file sigtype.cpp.
{ return t->print(dst);}
| ostream& operator<< | ( | ostream & | dst, |
| const TableType & | t | ||
| ) |
Definition at line 50 of file sigtype.cpp.
References TableType::print().
{ return t.print(dst); }

| ostream& operator<< | ( | ostream & | dst, |
| const TupletType & | t | ||
| ) |
Definition at line 52 of file sigtype.cpp.
References TupletType::print().
{ return t.print(dst); }

Definition at line 234 of file sigtype.cpp.
{
return (t1|t2) == 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;
}

Definition at line 421 of file sigtype.hh.
{ return t2<t1; }
Definition at line 422 of file sigtype.hh.
{ return t2<=t1; }
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;
}
}

Definition at line 271 of file sigtype.hh.
References kSamp, and makeSimpleType().
Referenced by infereSigType().
{ return makeSimpleType(t->nature(), kSamp, t->computability(), t->vectorability(), t->boolean(), t->getInterval()); }


Definition at line 275 of file sigtype.hh.
References kScal, and makeSimpleType().
{ return makeSimpleType(t->nature(), t->variability(), t->computability(), kScal, t->boolean(), t->getInterval()); }

| Type truescalCast | ( | Type | t | ) | [inline] |
Definition at line 276 of file sigtype.hh.
References kTrueScal, and makeSimpleType().
{ return makeSimpleType(t->nature(), t->variability(), t->computability(), kTrueScal, t->boolean(), t->getInterval()); }

Definition at line 274 of file sigtype.hh.
References kVect, and makeSimpleType().
Referenced by infereProjType().
{ return makeSimpleType(t->nature(), t->variability(), t->computability(), kVect, t->boolean(), t->getInterval()); }


Definition at line 158 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.
1.8.0