示例#1
0
bool operator== ( const Type& t1, const Type& t2)
{
	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;
}
示例#2
0
Type operator| ( const Type& t1, const Type& t2)
{
	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 {

	    stringstream error;
        error << "Error : trying to combine incompatible types, " << t1 << " and " << t2 << endl;
        throw faustexception(error.str());
        
	}
}
示例#3
0
/**
 * 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
 */
Tree codeAudioType(AudioType* t)
{
    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 {
        stringstream error;
        error << "ERROR in codeAudioType() : invalide pointer " << t << endl;
        throw faustexception(error.str());
    }

    r->setType(t);
    return r;
}
示例#4
0
void printSigType (Tree tp)
{
	Tree t0;
	int 	n, v, c;
	
	if (isTableType(tp, t0)) {
		printf("table-of "); 
		printSigType(t0);
	} else if (isSigType(tp, &n, &v, &c)) {
		putchar("NR"[n]);
		putchar("KB S"[v]);
		putchar("CI X"[c]);
		//printf(" {%d,%d,%d} ", n, v, c);
	} else {
		printf("unknown");
	}
}