FAUST compiler  0.9.9.6b8
Macros | Functions | Variables
tree.cpp File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "tree.hh"
#include <fstream>
#include <cstdlib>
Include dependency graph for tree.cpp:

Go to the source code of this file.

Macros

#define ERROR(s, t)   { error(s,t); exit(1); }
 

Functions

static void error (const char *s, Tree t)
 
int tree2int (Tree t)
 if t has a node of type int, return it otherwise error More...
 
double tree2float (Tree t)
 if t has a node of type float, return it otherwise error More...
 
double tree2double (Tree t)
 if t has a node of type float, return it otherwise error More...
 
const char * tree2str (Tree t)
 if t has a node of type symbol, return its name otherwise error More...
 
void * tree2ptr (Tree t)
 if t has a node of type ptr, return it otherwise error More...
 
bool isTree (const Tree &t, const Node &n)
 
bool isTree (const Tree &t, const Node &n, Tree &a)
 
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b)
 
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c)
 
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c, Tree &d)
 
bool isTree (const Tree &t, const Node &n, Tree &a, Tree &b, Tree &c, Tree &d, Tree &e)
 
void * getUserData (Tree t)
 if t has a node of type symbol, return the associated user data More...
 

Variables

Tabber TABBER (1)
 
Sym PROCESS = symbol("process")
 

Macro Definition Documentation

#define ERROR (   s,
 
)    { error(s,t); exit(1); }

Definition at line 96 of file tree.cpp.

Referenced by tree2double(), tree2float(), tree2int(), tree2ptr(), and tree2str().

Function Documentation

static void error ( const char *  s,
Tree  t 
)
static

Definition at line 90 of file tree.cpp.

91 {
92  //fprintf(stderr, "ERROR : %s (%p)\n", s, t);
93  cerr << "ERROR : " << s << " : " << *t << endl;
94 }
void* getUserData ( Tree  t)

if t has a node of type symbol, return the associated user data

Definition at line 372 of file tree.cpp.

References getUserData(), isSym(), and CTree::node().

Referenced by getUserData().

373 {
374  Sym s;
375  if (isSym(t->node(), &s)) {
376  return getUserData(s);
377  } else {
378  return 0;
379  }
380 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
void * getUserData(Tree t)
if t has a node of type symbol, return the associated user data
Definition: tree.cpp:372
bool isSym(const Node &n)
Definition: node.hh:199
Symbols are unique objects with a name stored in a hash table.
Definition: symbol.hh:53

Here is the call graph for this function:

Here is the caller graph for this function:

bool isTree ( const Tree t,
const Node n 
)

Definition at line 305 of file tree.cpp.

References CTree::node().

Referenced by isBoxAbstr(), isBoxAccess(), isBoxAppl(), isBoxButton(), isBoxCase(), isBoxCheckbox(), isBoxComponent(), isBoxCut(), isBoxEnvironment(), isBoxError(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxIdent(), isBoxInputs(), isBoxIPar(), isBoxIProd(), isBoxISeq(), isBoxISum(), isBoxLibrary(), isBoxMerge(), isBoxModifLocalDef(), isBoxNumEntry(), isBoxOutputs(), isBoxPar(), isBoxPatternMatcher(), isBoxPatternVar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWaveform(), isBoxWire(), isBoxWithLocalDef(), isClosure(), isDocDgm(), isDocEqn(), isDocLst(), isDocMtd(), isDocNtc(), isDocTxt(), isImportFile(), isPathCurrent(), isPathParent(), isPathRoot(), isProj(), isRec(), isRef(), isSigAttach(), isSigBinOp(), isSigButton(), isSigCheckbox(), isSigDelay1(), isSigDocAccessTbl(), isSigDocConstantTbl(), isSigDocWriteTbl(), isSigFConst(), isSigFFun(), isSigFixDelay(), isSigFloatCast(), isSigFVar(), isSigGen(), isSigHBargraph(), isSigHSlider(), isSigInput(), isSigIntCast(), isSigIota(), isSigNumEntry(), isSigOutput(), isSigPrefix(), isSigRDTbl(), isSigSelect2(), isSigSelect3(), isSigTable(), isSigTuple(), isSigTupleAccess(), isSigVBargraph(), isSigVSlider(), isSigWaveform(), isSigWRTbl(), isUiFolder(), and isUiWidget().

306 {
307  return (t->node() == n);
308 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a 
)

Definition at line 310 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

311 {
312  if ((t->node() == n) && (t->arity() == 1)) {
313  a=t->branch(0);
314  return true;
315  } else {
316  return false;
317  }
318 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b 
)

Definition at line 320 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

321 {
322  if ((t->node() == n) && (t->arity() == 2)) {
323  a=t->branch(0);
324  b=t->branch(1);
325  return true;
326  } else {
327  return false;
328  }
329 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c 
)

Definition at line 331 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

332 {
333  if ((t->node() == n) && (t->arity() == 3)) {
334  a=t->branch(0);
335  b=t->branch(1);
336  c=t->branch(2);
337  return true;
338  } else {
339  return false;
340  }
341 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c,
Tree d 
)

Definition at line 343 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

344 {
345  if ((t->node() == n) && (t->arity() == 4)) {
346  a=t->branch(0);
347  b=t->branch(1);
348  c=t->branch(2);
349  d=t->branch(3);
350  return true;
351  } else {
352  return false;
353  }
354 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

bool isTree ( const Tree t,
const Node n,
Tree a,
Tree b,
Tree c,
Tree d,
Tree e 
)

Definition at line 356 of file tree.cpp.

References CTree::arity(), CTree::branch(), and CTree::node().

357 {
358  if ((t->node() == n) && (t->arity() == 5)) {
359  a=t->branch(0);
360  b=t->branch(1);
361  c=t->branch(2);
362  d=t->branch(3);
363  e=t->branch(4);
364  return true;
365  } else {
366  return false;
367  }
368 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
int arity() const
return the number of branches (subtrees) of a tree
Definition: tree.hh:144
Tree branch(int i) const
return the ith branch (subtree) of a tree
Definition: tree.hh:145

Here is the call graph for this function:

double tree2double ( Tree  t)

if t has a node of type float, return it otherwise error

Definition at line 262 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by Description::addWidget().

263 {
264  double x;
265  int i;
266 
267  if (isInt(t->node(), &i)) {
268  x = double(i);
269  } else if (isDouble(t->node(), &x)) {
270  //nothing to do
271  } else {
272  ERROR("the node of the tree is not a float nor an int", t);
273  }
274  return double(x);
275 }
#define ERROR(s, t)
Definition: tree.cpp:96
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isDouble(const Node &n)
Definition: node.hh:143
bool isInt(const Node &n)
Definition: node.hh:126

Here is the call graph for this function:

Here is the caller graph for this function:

double tree2float ( Tree  t)

if t has a node of type float, return it otherwise error

Definition at line 246 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by eval2double(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generateVSlider(), Compiler::generateWidgetCode(), Compiler::generateWidgetMacro(), infereSigType(), infereWaveformType(), and DocCompiler::prepareIntervallicUI().

247 {
248  double x;
249  int i;
250 
251  if (isInt(t->node(), &i)) {
252  x = double(i);
253  } else if (isDouble(t->node(), &x)) {
254  //nothing to do
255  } else {
256  ERROR("the node of the tree is not a float nor an int", t);
257  }
258  return x;
259 }
#define ERROR(s, t)
Definition: tree.cpp:96
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isDouble(const Node &n)
Definition: node.hh:143
bool isInt(const Node &n)
Definition: node.hh:126

Here is the call graph for this function:

Here is the caller graph for this function:

int tree2int ( Tree  t)

if t has a node of type int, return it otherwise error

Definition at line 230 of file tree.cpp.

References ERROR, isDouble(), isInt(), and CTree::node().

Referenced by Description::addGroup(), annotate(), boxComplexity(), eval2int(), ffargtype(), ffrestype(), Compiler::generateUserInterfaceTree(), getRecursivness(), getSigOrder(), infereFConstType(), infereFVarType(), isBoxPatternMatcher(), and boxpp::print().

231 {
232  double x;
233  int i;
234 
235  if (isInt(t->node(), &i)) {
236  // nothing to do
237  } else if (isDouble(t->node(), &x)) {
238  i = int(x);
239  } else {
240  ERROR("the node of the tree is not an int nor a float", t);
241  }
242  return i;
243 }
#define ERROR(s, t)
Definition: tree.cpp:96
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isDouble(const Node &n)
Definition: node.hh:143
bool isInt(const Node &n)
Definition: node.hh:126

Here is the call graph for this function:

Here is the caller graph for this function:

void* tree2ptr ( Tree  t)

if t has a node of type ptr, return it otherwise error

Definition at line 288 of file tree.cpp.

References ERROR, isPointer(), and CTree::node().

Referenced by getColorProperty(), OccMarkup::getOcc(), and isBoxPatternMatcher().

289 {
290  void* x;
291  if (! isPointer(t->node(), &x)) {
292  ERROR("the node of the tree is not a pointer", t);
293  }
294  return x;
295 }
#define ERROR(s, t)
Definition: tree.cpp:96
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isPointer(const Node &n)
Definition: node.hh:216

Here is the call graph for this function:

Here is the caller graph for this function:

const char* tree2str ( Tree  t)

if t has a node of type symbol, return its name otherwise error

Definition at line 278 of file tree.cpp.

References ERROR, isSym(), name(), and CTree::node().

Referenced by Description::addGroup(), Description::addWidget(), applyList(), DocCompiler::compileLateq(), declareAutoDoc(), declareMetadata(), SourceReader::expandrec(), extractName(), ffincfile(), fflibfile(), ffname(), ScalarCompiler::generateCode(), DocCompiler::generateCode(), generateDiagramSchema(), generateInputSlotSchema(), generateInsideSchema(), Compiler::generateMacroInterfaceTree(), generateOutputSlotSchema(), Compiler::generateUserInterfaceTree(), Compiler::generateWidgetCode(), Compiler::generateWidgetMacro(), DocCompiler::getUIDir(), DocCompiler::getUIDocInfos(), legalFileName(), main(), mapGetEqName(), ppsig::print(), boxpp::print(), printDocMetadata(), realeval(), tree2quotedstr(), and writeSchemaFile().

279 {
280  Sym s;
281  if (!isSym(t->node(), &s)) {
282  ERROR("the node of the tree is not a symbol", t);
283  }
284  return name(s);
285 }
#define ERROR(s, t)
Definition: tree.cpp:96
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isSym(const Node &n)
Definition: node.hh:199
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
Symbols are unique objects with a name stored in a hash table.
Definition: symbol.hh:53

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Sym PROCESS = symbol("process")

Definition at line 144 of file tree.cpp.

Tabber TABBER

Definition at line 87 of file tree.cpp.

Referenced by annotationStatistics(), getSigType(), setSigType(), T(), and traced_simplification().