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.
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.
void setSigNickname (Tree t, const string &id)
 Set the nickname property of a signal.
bool getSigNickname (Tree t, Tree &id)
 Get the nickname property of a signal.
bool searchIdDef (Tree id, Tree &def, Tree lenv)
 Search the environment for the definition of a symbol ID and return it.
Tree pushValueDef (Tree id, Tree def, Tree lenv)
 Push a new layer and add a single definition.
Tree simplifyPattern (Tree pattern)
 Simplify a block-diagram pattern by computing its numerical sub-expressions.

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:
t the expression
id reference 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(), eval(), evalIdDef(), generateDiagramSchema(), generateInputSlotSchema(), generateInsideSchema(), generateOutputSlotSchema(), legalFileName(), mapGetEqName(), real_a2sb(), and writeSchemaFile().

00086 {
00087     //cerr << "getDefNameProperty of : " << t << endl;
00088     return getProperty(t, DEFNAMEPROPERTY, id);
00089 }

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

00123 {
00124     bool r = getProperty(t, NICKNAMEPROPERTY, id);
00125     return r;
00126 }

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:
id the symbol id to be defined
def the definition to be binded to the symbol id
lenv the environment where to push the layer and add the definition
Returns:
the new environment

Definition at line 64 of file environment.cpp.

References addLayerDef(), and pushNewLayer().

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

00065 {
00066     Tree lenv2 = pushNewLayer(lenv);
00067     addLayerDef(id, def, lenv2);
00068     return lenv2;
00069 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool searchIdDef ( Tree  id,
Tree def,
Tree  lenv 
)

Search the environment for the definition of a symbol ID and return it.

Parameters:
id the symbol ID to search
def where to store the definition if any
lenv the environment
Returns:
true if a definition was found

Definition at line 104 of file environment.cpp.

References CTree::branch(), getProperty(), and isNil().

Referenced by apply_pattern_matcher().

00105 {
00106     // search the environment until a definition is found
00107     // or nil (the empty environment) is reached
00108     while (!isNil(lenv) && !getProperty(lenv, id, def)) {
00109         lenv = lenv->branch(0);
00110     }
00111     return !isNil(lenv);
00112 }

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

00061 {
00062     //cerr << "setDefNameProperty : " << name << " FOR " << t << "#" << boxpp(t) << endl;
00063     int     n = name.size();
00064     int     m = (gMaxNameSize>1023) ? 1023 : gMaxNameSize;
00065     if (n > m) {
00066         // the name is too long we reduce it to 2/3 of maxsize
00067         char    buf[1024];
00068         int i = 0;
00069         // copy first third
00070         for (; i < m/3; i++) { buf[i] = name[i]; }
00071         // add ...
00072         buf[i++] = '.';
00073         buf[i++] = '.';
00074         buf[i++] = '.';
00075         // copy last third
00076         for (int c = n-m/3; c<n; c++, i++) { buf[i] = name[c]; }
00077         buf[i] = 0;
00078         setProperty(t, DEFNAMEPROPERTY, tree(buf));
00079     } else {
00080         setProperty(t, DEFNAMEPROPERTY, tree(name.c_str()));
00081     }
00082 
00083 }

Here is the call graph for this function:

void setDefNameProperty ( Tree  t,
Tree  id 
)

Definition at line 54 of file names.cpp.

References setProperty().

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

00055 {
00056     //cerr << "setDefNameProperty : " << *id << " FOR " << t << "#" << boxpp(t) << endl;
00057     setProperty(t, DEFNAMEPROPERTY, id);
00058 }

Here is the call graph for this function:

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

00135 {
00136     assert(isList(lsig));
00137     
00138     if (isNil(tl(lsig))) {
00139         setSigNickname(hd(lsig), nickname);
00140     } else {
00141         int     i=0;
00142         while (!isNil(lsig)) {
00143             setSigNickname(hd(lsig), subst("$0_$1", nickname, T(++i)));
00144             lsig = tl(lsig);
00145         }
00146     }
00147 }

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

00109 {
00110     Tree    s,d;
00111     if (isSigFixDelay(t,s,d) && isZero(d)) {
00112         setProperty(s, NICKNAMEPROPERTY, tree(id));
00113     } else {
00114         setProperty(t, NICKNAMEPROPERTY, tree(id));
00115     }
00116 }

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:
pattern an evaluated block-diagram
Returns:
a simplified pattern

Definition at line 623 of file eval.cpp.

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

Referenced by apply_pattern_matcher_internal().

00624 {
00625     Tree num;
00626     if (!getNumericProperty(value,num)) {
00627         if (!isBoxNumeric(value,num)) {
00628             num = value;
00629         }
00630         setNumericProperty(value,num);
00631     }
00632     return num;
00633 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated on Thu Jul 15 16:15:43 2010 for FAUST compiler by  doxygen 1.6.3