sigtype.hh File Reference

#include <vector>
#include <string>
#include <iostream>
#include "smartpointer.hh"
#include "interval.hh"
Include dependency graph for sigtype.hh:
This graph shows which files directly or indirectly include this file:

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< AudioTypeType

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.
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)
SimpleTypeisSimpleType (AudioType *t)
TableTypeisTableType (AudioType *t)
TupletTypeisTupletType (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)

Variables

Type TINT
Type TREAL
Type TKONST
Type TBLOCK
Type TSAMP
Type TCOMP
Type TINIT
Type TEXEC
Type TINPUT
Type TGUI
Type INT_TGUI
Type TREC

Typedef Documentation

typedef P<AudioType> Type

Definition at line 71 of file sigtype.hh.


Enumeration Type Documentation

anonymous enum
Enumerator:
kInt 
kReal 

Definition at line 53 of file sigtype.hh.

00053 { kInt = 0, kReal = 1 };                           

anonymous enum
Enumerator:
kNum 
kBool 

Definition at line 54 of file sigtype.hh.

00054 { kNum = 0 , kBool = 1};                           

anonymous enum
Enumerator:
kKonst 
kBlock 
kSamp 

Definition at line 55 of file sigtype.hh.

00055 { kKonst = 0, kBlock = 1, kSamp = 3 };             

anonymous enum
Enumerator:
kComp 
kInit 
kExec 

Definition at line 56 of file sigtype.hh.

00056 { kComp = 0, kInit = 1, kExec = 3 };               

anonymous enum
Enumerator:
kVect 
kScal 
kTrueScal 

Definition at line 57 of file sigtype.hh.

00057 { kVect = 0, kScal = 1, kTrueScal = 3/*, kIndex = 4*/};


Function Documentation

Type boolCast ( Type  t  )  [inline]

Definition at line 250 of file sigtype.hh.

References kBool.

00250 { return new SimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), kBool, t->getInterval()); }

Type castInterval ( Type  t,
const interval i 
) [inline]

Definition at line 256 of file sigtype.hh.

Referenced by TanPrim::infereSigType(), SqrtPrim::infereSigType(), SinPrim::infereSigType(), infereSigType(), RintPrim::infereSigType(), RemainderPrim::infereSigType(), PowPrim::infereSigType(), MinPrim::infereSigType(), MaxPrim::infereSigType(), LogPrim::infereSigType(), Log10Prim::infereSigType(), and CosPrim::infereSigType().

00257 { 
00258     return new SimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), t->boolean(), i); 
00259 }

Here is the caller graph for this function:

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.

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

Definition at line 279 of file sigtype.cpp.

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

Referenced by OccMarkup::incOcc().

00280 {
00281     interval i = t->getInterval();
00282     if (i.valid && i.lo >= 0) {
00283         return int(i.hi+0.5);
00284     } else {
00285         //cerr << "checkDelayInterval failed for : " << i << endl;
00286         return -1;
00287     }
00288 }       

Here is the caller graph for this function:

Type checkInit ( Type  t  ) 

verifie que t est connu a l'initialisation

Definition at line 249 of file sigtype.cpp.

References kInit.

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

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

Here is the caller graph for this function:

Type checkInt ( Type  t  ) 

verifie que t est entier

Definition at line 228 of file sigtype.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

Type checkIntParam ( Type  t  ) 

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

Definition at line 259 of file sigtype.cpp.

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

00260 {
00261     return checkInit(checkKonst(checkInt(t)));
00262 }

Here is the call graph for this function:

Type checkKonst ( Type  t  ) 

verifie que t est constant

Definition at line 239 of file sigtype.cpp.

References kKonst.

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

00240 {
00241     // verifie que t est constant
00242     if (t->variability() > kKonst) {
00243         cerr << "Error : checkKonst failed for type " << t << endl;
00244         exit(1);
00245     }
00246     return t;
00247 }   

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 264 of file sigtype.cpp.

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

string cType ( Type  t  ) 

Definition at line 292 of file sigtype.cpp.

References kInt.

Referenced by ScalarCompiler::generatePrefix(), ScalarCompiler::generateSelect2(), and ScalarCompiler::generateSelect3().

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

Here is the caller graph for this function:

Type floatCast ( Type  t  )  [inline]
Type intCast ( Type  t  )  [inline]

Definition at line 247 of file sigtype.hh.

References kInt.

Referenced by infereSigType().

00247 { return new SimpleType(kInt, t->variability(), t->computability(), t->vectorability(), t->boolean(), t->getInterval()); }

Here is the caller graph for this function:

SimpleType* isSimpleType ( AudioType t  ) 

Definition at line 219 of file sigtype.cpp.

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

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

Here is the caller graph for this function:

TableType* isTableType ( AudioType t  ) 

Definition at line 220 of file sigtype.cpp.

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

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

Here is the caller graph for this function:

TupletType* isTupletType ( AudioType t  ) 

Definition at line 221 of file sigtype.cpp.

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

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

Here is the caller graph for this function:

int mergeboolean ( const vector< Type > &  v  )  [inline]

Return the booleanity of a vector of types.

Definition at line 179 of file sigtype.hh.

00180 {
00181     int r = 0;
00182     for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->boolean();
00183     return r;
00184 }

int mergecomputability ( const vector< Type > &  v  )  [inline]

Return the computability of a vector of types.

Definition at line 155 of file sigtype.hh.

00156 {
00157     int r = 0;
00158     for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->computability(); 
00159     return r;
00160 }

interval mergeinterval ( const vector< Type > &  v  )  [inline]

Return the interval of a vector of types.

Definition at line 191 of file sigtype.hh.

References interval::hi, interval::lo, max(), min(), and interval::valid.

00192 {
00193     if (v.size()==0) {
00194         return interval();
00195     } else {
00196         double lo=0, hi=0;
00197         for (unsigned int i = 0; i < v.size(); i++) {
00198             interval r = v[i]->getInterval();
00199             if (!r.valid) return r;
00200             if (i==0) { 
00201                 lo = r.lo;
00202                 hi = r.hi;
00203             } else {
00204                 lo = min(lo,r.lo);
00205                 hi = max(hi,r.hi);
00206             }
00207         }
00208         return interval(lo, hi);
00209     }
00210 }

Here is the call graph for this function:

int mergenature ( const vector< Type > &  v  )  [inline]

Return the nature of a vector of types.

Definition at line 131 of file sigtype.hh.

00132 {
00133     int r = 0;
00134     for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->nature(); 
00135     return r;
00136 }

int mergevariability ( const vector< Type > &  v  )  [inline]

Return the variability of a vector of types.

Definition at line 143 of file sigtype.hh.

00144 {
00145     int r = 0;
00146     for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->variability(); 
00147     return r;
00148 }

int mergevectorability ( const vector< Type > &  v  )  [inline]

Return the vectorability of a vector of types.

Definition at line 167 of file sigtype.hh.

00168 {
00169     int r = 0;
00170     for (unsigned int i = 0; i < v.size(); i++) r |= v[i]->vectorability();
00171     return r;
00172 }

Type numCast ( Type  t  )  [inline]

Definition at line 251 of file sigtype.hh.

References kNum.

00251 { return new SimpleType(t->nature(), t->variability(), t->computability(), t->vectorability(), kNum, t->getInterval()); }

bool operator!= ( const Type t1,
const Type t2 
) [inline]

Definition at line 398 of file sigtype.hh.

00398 { return !(t1==t2); }

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

Definition at line 193 of file sigtype.cpp.

References TupletType::arity().

00194 {
00195     vector<Type>    v;
00196     
00197     TupletType* nt1 = dynamic_cast<TupletType*>((AudioType*)t1);
00198     TupletType* nt2 = dynamic_cast<TupletType*>((AudioType*)t2);
00199     
00200     if (nt1) {
00201         for (int i=0; i<nt1->arity(); i++) {
00202             v.push_back((*nt1)[i]);
00203         }
00204     } else {
00205         v.push_back(t1);
00206     }
00207     
00208     if (nt2) {
00209         for (int i=0; i<nt2->arity(); i++) {
00210             v.push_back((*nt2)[i]);
00211         }
00212     } else {
00213         v.push_back(t2);
00214     }
00215     return new TupletType(v);   
00216 }

Here is the call graph for this function:

bool operator< ( const Type t1,
const Type t2 
) [inline]

Definition at line 399 of file sigtype.hh.

00399 { return t1<=t2 && t1!=t2; }

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

Definition at line 40 of file sigtype.cpp.

References TupletType::print().

00040 { return  t.print(dst); }

Here is the call graph for this function:

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

Definition at line 38 of file sigtype.cpp.

References TableType::print().

00038 { return  t.print(dst); }

Here is the call graph for this function:

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

Definition at line 34 of file sigtype.cpp.

00034 { return  t->print(dst);}

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

Definition at line 36 of file sigtype.cpp.

References SimpleType::print().

00036 { return  t.print(dst); }

Here is the call graph for this function:

ostream& operator<< ( ostream &  s,
const AudioType n 
) [inline]

Definition at line 125 of file sigtype.hh.

References AudioType::print().

00125 { return n.print(s); }

Here is the call graph for this function:

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

Definition at line 186 of file sigtype.cpp.

00187 {
00188     return (t1|t2) == t2;
00189 }

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

Definition at line 162 of file sigtype.cpp.

References TupletType::arity(), AudioType::boolean(), TableType::content(), isSimpleType(), isTableType(), isTupletType(), AudioType::nature(), and AudioType::vectorability().

00163 {
00164     SimpleType  *st1, *st2;
00165     TableType   *tt1, *tt2;
00166     TupletType  *nt1, *nt2;
00167 
00168     if (t1->variability() != t2->variability())     return false;
00169     if (t1->computability() != t2->computability()) return false;
00170     
00171     if ( (st1 = isSimpleType(t1)) && (st2 = isSimpleType(t2)) ) return (st1->nature() == st2->nature())&&(st1->vectorability() == st2->vectorability())&&(st1->boolean() == st2->boolean());
00172     if ( (tt1 = isTableType(t1)) && (tt2 = isTableType(t2)) )   return tt1->content()== tt2->content(); 
00173     if ( (nt1 = isTupletType(t1)) && (nt2 = isTupletType(t2)) ) {
00174         int a1 = nt1->arity();
00175         int a2 = nt2->arity();
00176         if (a1 == a2) {
00177             for (int i=0; i<a1; i++)  { if ((*nt1)[i] != (*nt2)[i]) return false; }
00178             return true;
00179         } else {
00180             return false;
00181         }
00182     }
00183     return false;
00184 }

Here is the call graph for this function:

bool operator> ( const Type t1,
const Type t2 
) [inline]

Definition at line 400 of file sigtype.hh.

00400 { return t2<t1;     }

bool operator>= ( const Type t1,
const Type t2 
) [inline]

Definition at line 401 of file sigtype.hh.

00401 { return t2<=t1; }

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

achanger

Definition at line 127 of file sigtype.cpp.

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

00128 {
00129     SimpleType  *st1, *st2;
00130     TableType   *tt1, *tt2;
00131     TupletType  *nt1, *nt2;
00132     
00133     if ( (st1 = isSimpleType(t1)) && (st2 = isSimpleType(t2)) ) {
00134         
00135         return new SimpleType(  st1->nature()|st2->nature(),
00136                     st1->variability()|st2->variability(),
00137                     st1->computability()|st2->computability(),
00138                     st1->vectorability()|st2->vectorability(),
00139                     st1->boolean()|st2->boolean(),
00140                     interval() 
00141                     );
00142         
00143     } else if ( (tt1 = isTableType(t1)) && (tt2 = isTableType(t2)) ) {
00144         
00145         return new TableType( tt1->content() | tt2->content() );
00146         
00147     } else if ( (nt1 = isTupletType(t1)) && (nt2 = isTupletType(t2)) ) {
00148         
00149         vector<Type> v;
00150         int n = min(nt1->arity(), nt2->arity());
00151         for (int i=0; i<n; i++) { v.push_back( (*nt1)[i] | (*nt2)[i]); }
00152         return new TupletType( v );
00153         
00154     } else {
00155         
00156         cerr << "Error : trying to combine incompatible types, " << t1 << " and " << t2 << endl;
00157         exit(1);
00158         return 0;
00159     }
00160 }

Here is the call graph for this function:

Type sampCast ( Type  t  )  [inline]

Definition at line 249 of file sigtype.hh.

References kSamp.

Referenced by infereSigType().

00249 { return new SimpleType(t->nature(), kSamp, t->computability(), t->vectorability(), t->boolean(), t->getInterval()); }

Here is the caller graph for this function:

Type scalCast ( Type  t  )  [inline]

Definition at line 253 of file sigtype.hh.

References kScal.

00253 { return new SimpleType(t->nature(), t->variability(), t->computability(), kScal, t->boolean(), t->getInterval()); }

Type table ( const Type t  ) 
Type truescalCast ( Type  t  )  [inline]

Definition at line 254 of file sigtype.hh.

References kTrueScal.

00254 { return new SimpleType(t->nature(), t->variability(), t->computability(), kTrueScal, t->boolean(), t->getInterval()); }

Type vecCast ( Type  t  )  [inline]

Definition at line 252 of file sigtype.hh.

References kVect.

Referenced by infereProjType().

00252 { return new SimpleType(t->nature(), t->variability(), t->computability(), kVect, t->boolean(), t->getInterval()); }

Here is the caller graph for this function:


Variable Documentation

Definition at line 122 of file sigtype.cpp.

Definition at line 111 of file sigtype.cpp.

Definition at line 114 of file sigtype.cpp.

Definition at line 116 of file sigtype.cpp.

Definition at line 121 of file sigtype.cpp.

Referenced by infereSigType().

Definition at line 115 of file sigtype.cpp.

Definition at line 120 of file sigtype.cpp.

Definition at line 107 of file sigtype.cpp.

Definition at line 110 of file sigtype.cpp.

Definition at line 108 of file sigtype.cpp.

Definition at line 124 of file sigtype.cpp.

Referenced by initialRecType().

Definition at line 112 of file sigtype.cpp.

Generated on Thu Apr 29 00:00:14 2010 for FAUST compiler by  doxygen 1.6.3