|
FAUST compiler
0.9.9.6b8
|
#include "tlib.hh"

Go to the source code of this file.
Functions | |
| Tree | pushValueDef (Tree id, Tree def, Tree lenv) |
| Push a new layer and add a single definition. | |
| bool | searchIdDef (Tree id, Tree &def, Tree lenv) |
| Search the environment (until first barrier) for the definition of a symbol ID and return it. | |
| Tree | pushMultiClosureDefs (Tree ldefs, Tree visited, Tree lenv) |
| Push a new layer with multiple definitions creating the appropriate closures. | |
| Tree | copyEnvReplaceDefs (Tree anEnv, Tree ldefs, Tree visited, Tree curEnv) |
| Create a new environment by copying an existing one and replacing some definitions. | |
| bool | isEnvBarrier (Tree t) |
| Test if the environment is a barrier (or nil) so that searchIdDef will know where to stop when searching an environment. | |
| Tree | pushEnvBarrier (Tree lenv) |
Create a new environment by copying an existing one and replacing some definitions.
| xenv | existing environment we will copy |
| ldefs | list of pairs (symbol id x definition) that will replace old definitions |
| visited | set of visited symbols (used for recursive definition detection) |
| lenv | the current environment to evaluate the definitions |
Definition at line 169 of file environment.cpp.
References CTree::branch(), closure(), CTree::exportProperties(), hd(), isBoxCase(), isNil(), nil, pushNewLayer(), setDefNameProperty(), setProperty(), tl(), and updateClosures().
Referenced by realeval().
{
vector<Tree> ids, clos;
Tree copyEnv;
anEnv->exportProperties(ids, clos); // get the definitions of the environment
copyEnv = pushNewLayer(anEnv->branch(0)); // create new environment with same stack
updateClosures(clos, anEnv, copyEnv); // update the closures replacing oldEnv with newEnv
for (unsigned int i=0; i < clos.size(); i++) { // transfers the updated definitions to the new environment
setProperty(copyEnv, ids[i], clos[i]);
}
while (!isNil(ldefs)) { // replace the old definitions with the new ones
Tree def = hd(ldefs);
Tree id = hd(def);
Tree rhs= tl(def);
Tree cl = closure(rhs,nil,visited,curEnv);
stringstream s; s << boxpp(id);
if (!isBoxCase(rhs)) setDefNameProperty(cl,s.str());
setProperty(copyEnv, id, cl);
ldefs = tl(ldefs);
}
return copyEnv;
}


| bool isEnvBarrier | ( | Tree | lenv | ) |
Test if the environment is a barrier (or nil) so that searchIdDef will know where to stop when searching an environment.
| lenv | the environment to test |
Definition at line 56 of file environment.cpp.
References isNil(), and CTree::node().
Referenced by searchIdDef().


| Tree pushEnvBarrier | ( | Tree | lenv | ) |
Definition at line 43 of file environment.cpp.
References tree().
Referenced by evalCase().


| Tree pushMultiClosureDefs | ( | Tree | ldefs, |
| Tree | visited, | ||
| Tree | lenv | ||
| ) |
Push a new layer with multiple definitions creating the appropriate closures.
| ldefs | list of pairs (symbol id x definition) to be binded to the symbol id |
| visited | set of visited symbols (used for recursive definition detection) |
| lenv | the environment where to push the layer and add all the definitions |
Definition at line 109 of file environment.cpp.
References addLayerDef(), closure(), hd(), isBoxCase(), isNil(), nil, pushNewLayer(), setDefNameProperty(), and tl().
Referenced by evaldocexpr(), evalprocess(), and realeval().
{
Tree lenv2 = pushNewLayer(lenv);
while (!isNil(ldefs)) {
Tree def = hd(ldefs);
Tree id = hd(def);
Tree rhs= tl(def);
Tree cl = closure(tl(def),nil,visited,lenv2);
stringstream s; s << boxpp(id);
if (!isBoxCase(rhs)) setDefNameProperty(cl,s.str());
addLayerDef( id, cl, lenv2 );
ldefs = tl(ldefs);
}
return lenv2;
}


| Tree pushValueDef | ( | Tree | id, |
| Tree | def, | ||
| Tree | lenv | ||
| ) |
Push a new layer and add a single definition.
| 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 |
Definition at line 94 of file environment.cpp.
{
Tree lenv2 = pushNewLayer(lenv);
addLayerDef(id, def, lenv2);
return lenv2;
}
| bool searchIdDef | ( | Tree | id, |
| Tree & | def, | ||
| Tree | lenv | ||
| ) |
Search the environment (until first barrier) for the definition of a symbol ID and return it.
Used by the pattern matcher.
| id | the symbol ID to search |
| def | where to store the definition if any |
| lenv | the environment |
Definition at line 135 of file environment.cpp.
References CTree::branch(), getProperty(), and isEnvBarrier().
Referenced by apply_pattern_matcher().
{
// search the environment until a definition is found
// or a barrier (or nil) is reached
while (!isEnvBarrier(lenv) && !getProperty(lenv, id, def)) {
lenv = lenv->branch(0);
}
return !isEnvBarrier(lenv);
}


1.8.0