FAUST compiler  0.9.9.6b8
Functions
names.hh File Reference

Interface for names management. More...

#include "tlib.hh"
#include "propagate.hh"
#include <string>
Include dependency graph for names.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool getDefNameProperty (Tree t, Tree &id)
 Indicates the identifier (if any) the expression was a definition of. More...
 
void setDefNameProperty (Tree t, Tree id)
 
void setDefNameProperty (Tree t, const string &name)
 
void setSigListNickName (Tree lsig, const string &nickname)
 set the nickname property of a list of signals. More...
 
void setSigNickname (Tree t, const string &id)
 Set the nickname property of a signal. More...
 
bool getSigNickname (Tree t, Tree &id)
 Get the nickname property of a signal. More...
 
Tree pushValueDef (Tree id, Tree def, Tree lenv)
 Push a new layer and add a single definition. More...
 
Tree simplifyPattern (Tree pattern)
 Simplify a block-diagram pattern by computing its numerical sub-expressions. More...
 

Detailed Description

Interface for names management.

Definition in file names.hh.

Function Documentation

bool getDefNameProperty ( Tree  t,
Tree id 
)

Indicates the identifier (if any) the expression was a definition of.

Parameters
tthe expression
idreference to the identifier
Returns
true if the expression t was a definition of id

Definition at line 85 of file names.cpp.

References getProperty().

Referenced by a2sb(), applyList(), boxSimplification(), eval(), evalIdDef(), generateDiagramSchema(), generateInputSlotSchema(), generateInsideSchema(), generateOutputSlotSchema(), legalFileName(), mapGetEqName(), real_a2sb(), and writeSchemaFile().

86 {
87  //cerr << "getDefNameProperty of : " << t << endl;
88  return getProperty(t, DEFNAMEPROPERTY, id);
89 }
Tree DEFNAMEPROPERTY
Definition name property : a property to keep track of the definition name of an expression.
Definition: names.cpp:52
bool getProperty(Tree t, Tree key, Tree &val)
Definition: list.cpp:423

Here is the call graph for this function:

Here is the caller graph for this function:

bool getSigNickname ( Tree  t,
Tree id 
)

Get the nickname property of a signal.

Definition at line 122 of file names.cpp.

References getProperty().

Referenced by DocCompiler::compileLateq().

123 {
124  bool r = getProperty(t, NICKNAMEPROPERTY, id);
125  return r;
126 }
Tree NICKNAMEPROPERTY
Definition: names.cpp:102
bool getProperty(Tree t, Tree key, Tree &val)
Definition: list.cpp:423

Here is the call graph for this function:

Here is the caller graph for this function:

Tree pushValueDef ( Tree  id,
Tree  def,
Tree  lenv 
)

Push a new layer and add a single definition.

Parameters
idthe symbol id to be defined
defthe definition to be binded to the symbol id
lenvthe environment where to push the layer and add the definition
Returns
the new environment

Definition at line 94 of file environment.cpp.

References addLayerDef(), and pushNewLayer().

Referenced by apply_pattern_matcher(), applyList(), iteratePar(), iterateProd(), iterateSeq(), iterateSum(), and real_a2sb().

95 {
96  Tree lenv2 = pushNewLayer(lenv);
97  addLayerDef(id, def, lenv2);
98  return lenv2;
99 }
static void addLayerDef(Tree id, Tree def, Tree lenv)
Add a definition (as a property) to the current top level layer.
Definition: environment.cpp:69
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static Tree pushNewLayer(Tree lenv)
Push a new (unique) empty layer (where multiple definitions can be stored) on top of an existing envi...
Definition: environment.cpp:26

Here is the call graph for this function:

Here is the caller graph for this function:

void setDefNameProperty ( Tree  t,
Tree  id 
)

Definition at line 54 of file names.cpp.

References setProperty().

Referenced by a2sb(), applyList(), boxSimplification(), copyEnvReplaceDefs(), eval(), pushMultiClosureDefs(), real_a2sb(), and realeval().

55 {
56  //cerr << "setDefNameProperty : " << *id << " FOR " << t << "#" << boxpp(t) << endl;
58 }
Tree DEFNAMEPROPERTY
Definition name property : a property to keep track of the definition name of an expression.
Definition: names.cpp:52
void setProperty(Tree t, Tree key, Tree val)
Definition: list.cpp:418

Here is the call graph for this function:

Here is the caller graph for this function:

void setDefNameProperty ( Tree  t,
const string &  name 
)

Definition at line 60 of file names.cpp.

References gMaxNameSize, setProperty(), and tree().

61 {
62  //cerr << "setDefNameProperty : " << name << " FOR " << t << "#" << boxpp(t) << endl;
63  int n = (int)name.size();
64  int m = (gMaxNameSize>1023) ? 1023 : gMaxNameSize;
65  if (n > m) {
66  // the name is too long we reduce it to 2/3 of maxsize
67  char buf[1024];
68  int i = 0;
69  // copy first third
70  for (; i < m/3; i++) { buf[i] = name[i]; }
71  // add ...
72  buf[i++] = '.';
73  buf[i++] = '.';
74  buf[i++] = '.';
75  // copy last third
76  for (int c = n-m/3; c<n; c++, i++) { buf[i] = name[c]; }
77  buf[i] = 0;
79  } else {
80  setProperty(t, DEFNAMEPROPERTY, tree(name.c_str()));
81  }
82 
83 }
Tree DEFNAMEPROPERTY
Definition name property : a property to keep track of the definition name of an expression.
Definition: names.cpp:52
int gMaxNameSize
Definition: main.cpp:127
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
Tree tree(const Node &n)
Definition: tree.hh:186
void setProperty(Tree t, Tree key, Tree val)
Definition: list.cpp:418

Here is the call graph for this function:

void setSigListNickName ( Tree  lsig,
const string &  nickname 
)

set the nickname property of a list of signals.

If the list contains more than one signal, adds an index to the nickname

Definition at line 134 of file names.cpp.

References hd(), isList(), isNil(), setSigNickname(), subst(), T(), and tl().

135 {
136  assert(isList(lsig));
137 
138  if (isNil(tl(lsig))) {
139  setSigNickname(hd(lsig), nickname);
140  } else {
141  int i=0;
142  while (!isNil(lsig)) {
143  setSigNickname(hd(lsig), subst("$0_$1", nickname, T(++i)));
144  lsig = tl(lsig);
145  }
146  }
147 }
Tree hd(Tree l)
Definition: list.hh:133
bool isNil(Tree l)
Definition: list.hh:137
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
bool isList(Tree l)
Definition: list.hh:138
string T(char *c)
Definition: Text.cpp:158
void setSigNickname(Tree t, const string &id)
Set the nickname property of a signal.
Definition: names.cpp:108
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

void setSigNickname ( Tree  t,
const string &  id 
)

Set the nickname property of a signal.

Definition at line 108 of file names.cpp.

References isSigFixDelay(), isZero(), setProperty(), and tree().

Referenced by setSigListNickName().

109 {
110  Tree s,d;
111  if (isSigFixDelay(t,s,d) && isZero(d)) {
113  } else {
115  }
116 }
bool isZero(Tree a)
Definition: signals.hh:188
Tree NICKNAMEPROPERTY
Definition: names.cpp:102
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigFixDelay(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:62
Tree tree(const Node &n)
Definition: tree.hh:186
void setProperty(Tree t, Tree key, Tree val)
Definition: list.cpp:418

Here is the call graph for this function:

Here is the caller graph for this function:

Tree simplifyPattern ( Tree  value)

Simplify a block-diagram pattern by computing its numerical sub-expressions.

Parameters
patternan evaluated block-diagram
Returns
a simplified pattern

Definition at line 617 of file eval.cpp.

References getNumericProperty(), isBoxNumeric(), and setNumericProperty().

Referenced by apply_pattern_matcher_internal().

618 {
619  Tree num;
620  if (!getNumericProperty(value,num)) {
621  if (!isBoxNumeric(value,num)) {
622  num = value;
623  }
624  setNumericProperty(value,num);
625  }
626  return num;
627 }
static bool isBoxNumeric(Tree in, Tree &out)
Definition: eval.cpp:630
Definition: num.hh:58
void setNumericProperty(Tree t, Tree num)
Definition: eval.cpp:599
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool getNumericProperty(Tree t, Tree &num)
Definition: eval.cpp:604

Here is the call graph for this function:

Here is the caller graph for this function: