FAUST compiler  0.9.9.6b8
Typedefs | Functions | Variables
list.hh File Reference
#include "symbol.hh"
#include "tree.hh"
#include <stdio.h>
Include dependency graph for list.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef Tree(* tfun )(Tree)

Functions

void print (Tree t, FILE *out=stdout)
Tree cons (Tree a, Tree b)
Tree list0 ()
Tree list1 (Tree a)
Tree list2 (Tree a, Tree b)
Tree list3 (Tree a, Tree b, Tree c)
Tree list4 (Tree a, Tree b, Tree c, Tree d)
Tree hd (Tree l)
Tree tl (Tree l)
bool isNil (Tree l)
bool isList (Tree l)
Tree nth (Tree l, int i)
Tree replace (Tree l, int i, Tree e)
int len (Tree l)
Tree reverse (Tree l)
Tree reverseall (Tree l)
Tree rconcat (Tree l1, Tree l2)
Tree concat (Tree l1, Tree l2)
Tree lrange (Tree l, int i, int j)
Tree lmap (tfun f, Tree l)
bool isElement (Tree e, Tree l)
Tree addElement (Tree e, Tree l1)
Tree remElement (Tree e, Tree l1)
Tree singleton (Tree l)
Tree list2set (Tree l)
Tree setUnion (Tree l1, Tree l2)
Tree setIntersection (Tree l1, Tree l2)
Tree setDifference (Tree l1, Tree l2)
Tree left (Tree t)
Tree right (Tree t)
Tree pushEnv (Tree key, Tree val, Tree env=nil)
bool searchEnv (Tree key, Tree &v, Tree env)
void setProperty (Tree t, Tree key, Tree val)
bool getProperty (Tree t, Tree key, Tree &val)
void remProperty (Tree t, Tree key)
Tree tmap (Tree k, tfun f, Tree t)
Tree substitute (Tree t, Tree id, Tree val)

Variables

Sym CONS
Sym NIL
Tree nil

Typedef Documentation

typedef Tree(* tfun)(Tree)

Definition at line 118 of file list.hh.


Function Documentation

Tree addElement ( Tree  e,
Tree  l1 
)

Definition at line 272 of file list.cpp.

References addElement(), cons(), hd(), isList(), and tl().

Referenced by addElement(), evalIdDef(), list2set(), and ppsig::printrec().

{
    if (isList(l)) {
        if (e < hd(l)) {
            return cons(e,l);
        } else if (e == hd(l)) {
            return l;
        } else {
            return cons(hd(l), addElement(e,tl(l)));
        }
    } else {
        return cons(e,nil);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree concat ( Tree  l1,
Tree  l2 
)

Definition at line 216 of file list.cpp.

References rconcat(), and reverse().

Referenced by applyList(), and sigCartesianProd().

{
    return rconcat(reverse(l), q);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree cons ( Tree  a,
Tree  b 
) [inline]
bool getProperty ( Tree  t,
Tree  key,
Tree val 
)
Tree hd ( Tree  l) [inline]

Definition at line 133 of file list.hh.

References CTree::branch().

Referenced by addElement(), Description::addGroup(), addKey(), applyList(), boxlistOutputs(), buildBoxAbstr(), checkRulelist(), Klass::closeLoop(), collectDocEqns(), DocCompiler::compileLateq(), SchedulerCompiler::compileMultiSignal(), VectorCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), concatPath(), copyEnvReplaceDefs(), eval2double(), eval2int(), evalPatternList(), evalRuleList(), SourceReader::expandrec(), ffrestype(), findKey(), formatDefinitions(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), Compiler::generateMacroInterfaceElements(), ScalarCompiler::generateNumEntry(), Compiler::generateUserInterfaceElements(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), getBoxType(), getDefFileProp(), getSubSignals(), DocCompiler::getUIDir(), DocCompiler::getUIDocInfos(), infereFFType(), infereSigOrder(), infereSigType(), isBoxNumeric(), isCons(), isElement(), larg2par(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), numericBoxSimplification(), position(), prepareRule(), Compiler::prepareUserInterfaceTree(), boxpp::print(), envpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), recdraw(), remElement(), removeKey(), replace(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), sigToGraph(), standardArgList(), typeAnnotation(), updateKey(), and fullvisitor::visitList().

{ return l->branch(0); }

Here is the call graph for this function:

bool isElement ( Tree  e,
Tree  l 
)

Definition at line 262 of file list.cpp.

References hd(), isList(), and tl().

{
    while (isList(l)) {
        if (hd(l) == e) return true;
        if (hd(l) > e) return false;
        l = tl(l);
    }
    return false;
}

Here is the call graph for this function:

bool isList ( Tree  l) [inline]
bool isNil ( Tree  l) [inline]
Tree left ( Tree  t) [inline]

Definition at line 170 of file list.hh.

References CTree::branch().

Referenced by Description::addGroup(), addKey(), evalRule(), findKey(), Compiler::generateUserInterfaceTree(), printRule(), removeKey(), and updateKey().

{ return t->branch(0); }

Here is the call graph for this function:

Here is the caller graph for this function:

int len ( Tree  l)

Definition at line 198 of file list.cpp.

References isList(), and tl().

Referenced by checkRulelist(), evalCase(), ffarity(), ScalarCompiler::generateRec(), DocCompiler::generateRec(), make_pattern_matcher(), makeDefinition(), Symbol::Symbol(), symlistVisit(), and typeAnnotation().

{
    int     n = 0;
    while (isList(l)) { l = tl(l); n++; }
    return n;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list0 ( ) [inline]

Definition at line 126 of file list.hh.

References nil.

Referenced by list1().

{ return nil; }

Here is the caller graph for this function:

Tree list1 ( Tree  a) [inline]

Definition at line 127 of file list.hh.

References cons(), and list0().

Referenced by list2(), sigCartesianProd(), and singleton().

{ return cons (a, list0()); }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list2 ( Tree  a,
Tree  b 
) [inline]

Definition at line 128 of file list.hh.

References cons(), and list1().

Referenced by list3().

{ return cons (a, list1(b)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list2set ( Tree  l)

Definition at line 307 of file list.cpp.

References addElement(), hd(), isList(), nil, and tl().

{
    Tree s = nil;
    while (isList(l)) {
        s = addElement(hd(l),s);
        l = tl(l);
    }
    return s;
}

Here is the call graph for this function:

Tree list3 ( Tree  a,
Tree  b,
Tree  c 
) [inline]

Definition at line 129 of file list.hh.

References cons(), and list2().

Referenced by list4().

{ return cons (a, list2(b, c)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree list4 ( Tree  a,
Tree  b,
Tree  c,
Tree  d 
) [inline]

Definition at line 130 of file list.hh.

References cons(), and list3().

Referenced by boxHSlider(), boxNumEntry(), boxVSlider(), sigHSlider(), sigNumEntry(), and sigVSlider().

{ return cons (a, list3(b, c, d)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree lmap ( tfun  f,
Tree  l 
)

Definition at line 247 of file list.cpp.

References reverse(), and rmap().

Referenced by preparePattern(), prepareRule(), and prepareRules().

{
    return reverse(rmap(f,l));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree lrange ( Tree  l,
int  i,
int  j 
)

Definition at line 221 of file list.cpp.

References cons(), nil, and nth().

{
    Tree    r = nil;
    int     c = j;
    while (c>i) r = cons( nth(l,--c), r);
    return r;
}

Here is the call graph for this function:

Tree nth ( Tree  l,
int  i 
)

Definition at line 182 of file list.cpp.

References hd(), isList(), nil, and tl().

Referenced by ffargtype(), ffname(), ScalarCompiler::generateFFun(), DocCompiler::generateFFun(), ScalarCompiler::generateRec(), DocCompiler::generateRec(), isBoxHSlider(), isBoxNumEntry(), isBoxVSlider(), isSigHSlider(), isSigNumEntry(), isSigVSlider(), lrange(), and symlistVisit().

{
    while (isList(l)) {
        if (i == 0)  return hd(l);
        l = tl(l);
        i--;
    }
    return nil;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print ( Tree  t,
FILE *  out = stdout 
)

Definition at line 154 of file list.cpp.

References CTree::arity(), CTree::branch(), isDouble(), isInt(), isPointer(), isSym(), name(), CTree::node(), print(), and printlist().

Referenced by addLayerDef(), evalerror(), evalremark(), evalwarning(), ScalarCompiler::generateCode(), generateInsideSchema(), infereSigOrder(), infereSigType(), print(), printlist(), and printSignal().

{
    int i; double f; Sym s; void* p;
    
    if (printlist(t, out))      return;
    
    Node n = t->node();
         if (isInt(n, &i))      fprintf (out, "%d", i);
    else if (isDouble(n, &f))   fprintf (out, "%f", f);
    else if (isSym(n, &s))      fprintf (out, "%s", name(s));
    else if (isPointer(n, &p))  fprintf (out, "#%p", p);
    
    int k = t->arity();
    if (k > 0) {
        char sep = '[';
        for (int i=0; i<k; i++) {
            fputc(sep, out); sep = ',';
            print(t->branch(i), out);
        }
        fputc(']', out);
    } 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree pushEnv ( Tree  key,
Tree  val,
Tree  env = nil 
)

Definition at line 351 of file list.cpp.

References cons().

Referenced by propagate(), and sigMapRename().

{
    return cons (cons(key,val), env);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree rconcat ( Tree  l1,
Tree  l2 
)

Definition at line 210 of file list.cpp.

References cons(), hd(), isList(), and tl().

Referenced by concat().

{
    while (isList(l)) { q = cons(hd(l),q); l = tl(l); }
    return q;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree remElement ( Tree  e,
Tree  l1 
)

Definition at line 287 of file list.cpp.

References cons(), hd(), isList(), nil, remElement(), and tl().

Referenced by remElement().

{
    if (isList(l)) {
        if (e < hd(l)) {
            return l;
        } else if (e == hd(l)) {
            return tl(l);
        } else {
            return cons(hd(l), remElement(e,tl(l)));
        }
    } else {
        return nil;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void remProperty ( Tree  t,
Tree  key 
)

Definition at line 434 of file list.cpp.

{
    exit(1); // fonction not implemented
}
Tree replace ( Tree  l,
int  i,
Tree  e 
)

Definition at line 192 of file list.cpp.

References cons(), hd(), replace(), and tl().

Referenced by replace().

{
    return (i==0) ? cons(e,tl(l)) : cons( hd(l), replace(tl(l),i-1,e) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree reverse ( Tree  l)

Definition at line 252 of file list.cpp.

References isList(), reverseall(), and rmap().

Referenced by reverseall().

{
    return isList(l) ? rmap(reverseall, l) : l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree right ( Tree  t) [inline]
bool searchEnv ( Tree  key,
Tree v,
Tree  env 
)

Definition at line 356 of file list.cpp.

References hd(), isList(), and tl().

Referenced by propagate(), and sigMapRename().

{
    while (isList(env)) {
        if (hd(hd(env)) == key) {
            v = tl(hd(env));
            return true;
        }
        env = tl(env);
    }
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree setDifference ( Tree  l1,
Tree  l2 
)

Definition at line 336 of file list.cpp.

References cons(), hd(), isNil(), setDifference(), and tl().

Referenced by setDifference().

{
    if (isNil(A))       return A;
    if (isNil(B))       return A;
    if (hd(A) == hd(B)) return setDifference(tl(A),tl(B));
    if (hd(A) < hd(B))  return cons(hd(A), setDifference(tl(A),B));
    /* (hd(A) > hd(B)*/ return setDifference(A,tl(B));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree setIntersection ( Tree  l1,
Tree  l2 
)

Definition at line 327 of file list.cpp.

References cons(), hd(), isNil(), setIntersection(), and tl().

Referenced by Loop::hasRecDependencyIn(), and setIntersection().

{
    if (isNil(A))       return A;
    if (isNil(B))       return B;
    if (hd(A) == hd(B)) return cons(hd(A), setIntersection(tl(A),tl(B)));
    if (hd(A) < hd(B))  return setIntersection(tl(A),B);
    /* (hd(A) > hd(B)*/ return setIntersection(A,tl(B));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setProperty ( Tree  t,
Tree  key,
Tree  val 
)
Tree setUnion ( Tree  l1,
Tree  l2 
)

Definition at line 317 of file list.cpp.

References cons(), hd(), isNil(), setUnion(), and tl().

Referenced by Loop::absorb(), realeval(), setUnion(), and symlistVisit().

{
    if (isNil(A))       return B;
    if (isNil(B))       return A;
    
    if (hd(A) == hd(B)) return cons(hd(A), setUnion(tl(A),tl(B)));
    if (hd(A) < hd(B))  return cons(hd(A), setUnion(tl(A),B));
    /* hd(A) > hd(B) */ return cons(hd(B), setUnion(A,tl(B)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 302 of file list.cpp.

References list1().

Referenced by VectorCompiler::generateLoopCode(), and symlistVisit().

{
    return list1(e);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree substitute ( Tree  t,
Tree  id,
Tree  val 
)

Definition at line 559 of file list.cpp.

References subst(), and substkey().

Referenced by calcDeBruijn2Sym(), and calcsubstitute().

{
    return subst (t, substkey(t,id,val), id, val);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Tree tl ( Tree  l) [inline]

Definition at line 134 of file list.hh.

References CTree::branch().

Referenced by addElement(), Description::addGroup(), addKey(), applyList(), boxlistOutputs(), buildBoxAbstr(), checkRulelist(), Klass::closeLoop(), collectDocEqns(), DocCompiler::compileLateq(), SchedulerCompiler::compileMultiSignal(), VectorCompiler::compileMultiSignal(), ScalarCompiler::compileMultiSignal(), concatPath(), copyEnvReplaceDefs(), VectorCompiler::CS(), decorateSchema::draw(), evalPatternList(), evalRuleList(), SourceReader::expandrec(), findKey(), formatDefinitions(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), Compiler::generateMacroInterfaceElements(), ScalarCompiler::generateNumEntry(), Compiler::generateUserInterfaceElements(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), getBoxType(), getDefLineProp(), getSubSignals(), DocCompiler::getUIDir(), infereFFType(), infereSigOrder(), infereSigType(), initialRecType(), isBefore(), isCons(), isElement(), larg2par(), len(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), position(), prepareRule(), Compiler::prepareUserInterfaceTree(), boxpp::print(), envpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), recdraw(), remElement(), removeKey(), replace(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), sigToGraph(), standardArgList(), typeAnnotation(), updateKey(), and fullvisitor::visitList().

{ return l->branch(1); }

Here is the call graph for this function:

Tree tmap ( Tree  k,
tfun  f,
Tree  t 
)

Definition at line 445 of file list.cpp.

References CTree::arity(), CTree::branch(), getProperty(), isNil(), nil, CTree::node(), setProperty(), tmap(), and tree().

Referenced by tmap().

{   
    //printf("start tmap\n");
    Tree p; 
    
    if (getProperty(t, key, p)) {
        
        return (isNil(p)) ? t : p;  // truc pour eviter les boucles
        
    } else {
        
        Tree r1=nil;
        switch (t->arity()) {
            
            case 0 : 
                r1 = t; 
                break;
            case 1 : 
                r1 = tree(t->node(), tmap(key,f,t->branch(0))); 
                break;
            case 2 : 
                r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1))); 
                break;
            case 3 : 
                r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
                                           tmap(key,f,t->branch(2))); 
                break;
            case 4 : 
                r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
                                           tmap(key,f,t->branch(2)), tmap(key,f,t->branch(3))); 
                break;
        }
        Tree r2 = f(r1);
        if (r2 == t) {
            setProperty(t, key, nil);
        } else {
            setProperty(t, key, r2);
        }
        return r2;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 112 of file list.cpp.

Definition at line 113 of file list.cpp.