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().

00273 {
00274     if (isList(l)) {
00275         if (e < hd(l)) {
00276             return cons(e,l);
00277         } else if (e == hd(l)) {
00278             return l;
00279         } else {
00280             return cons(hd(l), addElement(e,tl(l)));
00281         }
00282     } else {
00283         return cons(e,nil);
00284     }
00285 }

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().

00217 {
00218     return rconcat(reverse(l), q);
00219 }

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 
)

Definition at line 423 of file list.cpp.

References CTree::getProperty().

Referenced by addLayerDef(), annotate(), evalIdDef(), getBoxType(), getColorProperty(), Occurrences::getCount(), getDefFileProp(), getDefLineProp(), getDefNameProperty(), getEvalProperty(), getInferredType(), getNumericProperty(), getPMProperty(), getRecursivness(), ScalarCompiler::getSharingCount(), DocCompiler::getSharingCount(), getSigNickname(), getSigOrder(), privatisation(), searchIdDef(), shcount(), sigMap(), sigMapRename(), subst(), and tmap().

00424 {
00425     CTree* pl = t->getProperty(key);
00426     if (pl) {
00427         val = pl;
00428         return true;
00429     } else {
00430         return false;
00431     }
00432 }

Here is the call graph for this function:

Here is the caller graph for this function:

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(), collectDocEqns(), DocCompiler::compileLateq(), VectorCompiler::compileMultiSignal(), SchedulerCompiler::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(), initialRecType(), isBoxNumeric(), isCons(), isElement(), isInEnv(), larg2par(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), position(), Compiler::prepareUserInterfaceTree(), envpp::print(), boxpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), remElement(), removeKey(), replace(), replaceBoxNumeric(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), standardArgList(), updateKey(), and fullvisitor::visitList().

00133 { 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().

00263 {
00264     while (isList(l)) {
00265         if (hd(l) == e) return true;
00266         if (hd(l) > e) return false;
00267         l = tl(l);
00268     }
00269     return false;
00270 }

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().

00170 { 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(), DocCompiler::generateRec(), ScalarCompiler::generateRec(), make_pattern_matcher(), makeDefinition(), and Symbol::Symbol().

00199 {
00200     int     n = 0;
00201     while (isList(l)) { l = tl(l); n++; }
00202     return n;
00203 }

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.

Referenced by list1().

00126 { 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().

00127 { 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().

00128 { 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(), and tl().

00308 {
00309     Tree s = nil;
00310     while (isList(l)) {
00311         s = addElement(hd(l),s);
00312         l = tl(l);
00313     }
00314     return s;
00315 }

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().

00129 { 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().

00130 { 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().

00248 {
00249     return reverse(rmap(f,l));
00250 }

Here is the call graph for this function:

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

Definition at line 221 of file list.cpp.

References cons(), and nth().

00222 {
00223     Tree    r = nil;
00224     int     c = j;
00225     while (c>i) r = cons( nth(l,--c), r);
00226     return r;
00227 }

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(), and tl().

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

00183 {
00184     while (isList(l)) {
00185         if (i == 0)  return hd(l);
00186         l = tl(l);
00187         i--;
00188     }
00189     return nil;
00190 }

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(), printSignal(), and searchEnv().

00155 {
00156     int i; double f; Sym s; void* p;
00157     
00158     if (printlist(t, out))      return;
00159     
00160     Node n = t->node();
00161          if (isInt(n, &i))      fprintf (out, "%d", i);
00162     else if (isDouble(n, &f))   fprintf (out, "%f", f);
00163     else if (isSym(n, &s))      fprintf (out, "%s", name(s));
00164     else if (isPointer(n, &p))  fprintf (out, "#%p", p);
00165     
00166     int k = t->arity();
00167     if (k > 0) {
00168         char sep = '[';
00169         for (int i=0; i<k; i++) {
00170             fputc(sep, out); sep = ',';
00171             print(t->branch(i), out);
00172         }
00173         fputc(']', out);
00174     } 
00175 }

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().

00352 {
00353     return cons (cons(key,val), env);
00354 }

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().

00211 {
00212     while (isList(l)) { q = cons(hd(l),q); l = tl(l); }
00213     return q;
00214 }

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(), remElement(), and tl().

Referenced by remElement().

00288 {
00289     if (isList(l)) {
00290         if (e < hd(l)) {
00291             return l;
00292         } else if (e == hd(l)) {
00293             return tl(l);
00294         } else {
00295             return cons(hd(l), remElement(e,tl(l)));
00296         }
00297     } else {
00298         return nil;
00299     }
00300 }

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.

00435 {
00436     exit(1); // fonction not implemented
00437 }

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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Tree reverse ( Tree  l  ) 

Definition at line 240 of file list.cpp.

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

Referenced by applyList(), collectDocEqns(), concat(), ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generateVBargraph(), ScalarCompiler::generateVSlider(), DocCompiler::getUIDir(), lmap(), make_pattern_matcher(), printdoccontent(), and printPatternError().

00241 {
00242     Tree r = nil;
00243     while (isList(l)) { r = cons(hd(l),r); l = tl(l); }
00244     return r;
00245 }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree reverseall ( Tree  l  ) 

Definition at line 252 of file list.cpp.

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

Referenced by reverseall().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Tree right ( Tree  t  )  [inline]

Definition at line 171 of file list.hh.

References CTree::branch().

Referenced by Description::addGroup(), evalRule(), findKey(), Compiler::generateMacroInterfaceElements(), Compiler::generateMacroInterfaceTree(), Compiler::generateUserInterfaceElements(), Compiler::generateUserInterfaceTree(), Compiler::prepareUserInterfaceTree(), and printRule().

00171 { return t->branch(1); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool searchEnv ( Tree  key,
Tree v,
Tree  env 
)

Definition at line 356 of file list.cpp.

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

00357 {
00358     while (isList(env)) {
00359         if (hd(hd(env)) == key) {
00360             v = tl(hd(env));
00361             return true;
00362         }
00363         env = tl(env);
00364     }
00365     return false;
00366 }

Here is the call 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().

00337 {
00338     if (isNil(A))       return A;
00339     if (isNil(B))       return A;
00340     if (hd(A) == hd(B)) return setDifference(tl(A),tl(B));
00341     if (hd(A) < hd(B))  return cons(hd(A), setDifference(tl(A),B));
00342     /* (hd(A) > hd(B)*/ return setDifference(A,tl(B));
00343 }

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 setIntersection().

00328 {
00329     if (isNil(A))       return A;
00330     if (isNil(B))       return B;
00331     if (hd(A) == hd(B)) return cons(hd(A), setIntersection(tl(A),tl(B)));
00332     if (hd(A) < hd(B))  return setIntersection(tl(A),B);
00333     /* (hd(A) > hd(B)*/ return setIntersection(A,tl(B));
00334 }

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 realeval(), and setUnion().

00318 {
00319     if (isNil(A))       return B;
00320     if (isNil(B))       return A;
00321     
00322     if (hd(A) == hd(B)) return cons(hd(A), setUnion(tl(A),tl(B)));
00323     if (hd(A) < hd(B))  return cons(hd(A), setUnion(tl(A),B));
00324     /* hd(A) > hd(B) */ return cons(hd(B), setUnion(A,tl(B)));
00325 }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree singleton ( Tree  l  ) 

Definition at line 302 of file list.cpp.

References list1().

00303 {
00304     return list1(e);
00305 }

Here is the call 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().

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

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(), collectDocEqns(), DocCompiler::compileLateq(), VectorCompiler::compileMultiSignal(), SchedulerCompiler::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(), isInEnv(), larg2par(), len(), list2set(), list2vec(), makeDefinition(), makeSubFolderChain(), OccMarkup::mark(), normalizePath(), nth(), position(), Compiler::prepareUserInterfaceTree(), envpp::print(), boxpp::print(), printdoccontent(), ppsig::printlabel(), ppsig::printlist(), printlist(), printRule(), printSignal(), pushMultiClosureDefs(), putSubFolder(), rconcat(), remElement(), removeKey(), replace(), reverse(), revEvalList(), rmap(), searchEnv(), setDifference(), setIntersection(), setSigListNickName(), setUnion(), ScalarCompiler::sharingAnalysis(), DocCompiler::sharingAnalysis(), standardArgList(), updateKey(), and fullvisitor::visitList().

00134 { 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(), CTree::node(), setProperty(), tmap(), and tree().

Referenced by tmap().

00446 {   
00447     //printf("start tmap\n");
00448     Tree p; 
00449     
00450     if (getProperty(t, key, p)) {
00451         
00452         return (isNil(p)) ? t : p;  // truc pour eviter les boucles
00453         
00454     } else {
00455         
00456         Tree r1=nil;
00457         switch (t->arity()) {
00458             
00459             case 0 : 
00460                 r1 = t; 
00461                 break;
00462             case 1 : 
00463                 r1 = tree(t->node(), tmap(key,f,t->branch(0))); 
00464                 break;
00465             case 2 : 
00466                 r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1))); 
00467                 break;
00468             case 3 : 
00469                 r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
00470                                            tmap(key,f,t->branch(2))); 
00471                 break;
00472             case 4 : 
00473                 r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
00474                                            tmap(key,f,t->branch(2)), tmap(key,f,t->branch(3))); 
00475                 break;
00476         }
00477         Tree r2 = f(r1);
00478         if (r2 == t) {
00479             setProperty(t, key, nil);
00480         } else {
00481             setProperty(t, key, r2);
00482         }
00483         return r2;
00484     }
00485 }

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.

Generated on Tue Aug 10 08:04:14 2010 for FAUST compiler by  doxygen 1.6.3