eval.cpp File Reference

Implementation of the Block diagram evaluator. More...

#include "eval.hh"
#include <stdio.h>
#include "errormsg.hh"
#include "ppbox.hh"
#include "simplify.hh"
#include "propagate.hh"
#include "patternmatcher.hh"
#include "signals.hh"
#include "xtended.hh"
#include "loopDetector.hh"
#include "property.hh"
#include "names.hh"
#include <assert.h>
Include dependency graph for eval.cpp:

Go to the source code of this file.

Functions

Tree evalprocess (Tree eqlist)
 Eval "process" from a list of definitions.
void setEvalProperty (Tree box, Tree env, Tree value)
 set the type annotation of sig
bool getEvalProperty (Tree box, Tree env, Tree &value)
 retrieve the value of box in the environment env
Tree simplifyPattern (Tree value)
 Simplify a block-diagram pattern by computing its numerical sub-expressions.
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 for the definition of a symbol ID and return it.

Variables

property< TreegSymbolicBoxProperty
 Transform unused (unapplied) closures into symbolic boxes.

Detailed Description

Implementation of the Block diagram evaluator.

Interface for names propagation.

A strict lambda-calculus evaluator for block diagram expressions.

Definition in file eval.cpp.


Function Documentation

Tree evalprocess ( Tree  eqlist  ) 

Eval "process" from a list of definitions.

Eval the definition of 'process'.

Strict evaluation of a block diagram expression by applying beta reduction.

Parameters:
eqlist a list of faust defintions forming the the global environment
Returns:
the process block diagram in normal form

Definition at line 102 of file eval.cpp.

00103 {
00104     return a2sb(eval(boxIdent("process"), nil, pushMultiClosureDefs(eqlist, nil, nil)));
00105 }

bool getEvalProperty ( Tree  box,
Tree  env,
Tree value 
)

retrieve the value of box in the environment env

Parameters:
box the expression we want to retrieve the value
env the lexical environment
value the returned value if any
Returns:
true if a value already exist

Definition at line 273 of file eval.cpp.

00274 {
00275     return getProperty(box, tree(EVALPROPERTY,env), value);
00276 }

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 1189 of file eval.cpp.

01190 {
01191     Tree lenv2 = pushNewLayer(lenv);
01192     addLayerDef(id, def, lenv2);
01193     return lenv2;
01194 }

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 1229 of file eval.cpp.

References CTree::branch().

01230 {
01231     // search the environment until a definition is found
01232     // or nil (the empty environment) is reached
01233     while (!isNil(lenv) && !getProperty(lenv, id, def)) {
01234         lenv = lenv->branch(0);
01235     }
01236     return !isNil(lenv);
01237 }

Here is the call graph for this function:

void setEvalProperty ( Tree  box,
Tree  env,
Tree  value 
)

set the type annotation of sig

Parameters:
sig the signal we want to type
t the type of the signal

Definition at line 259 of file eval.cpp.

00260 {
00261     //cerr << "setSigType(" << *sig << ", " << t << ")" << endl;
00262     setProperty(box, tree(EVALPROPERTY,env), value);
00263 }

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 605 of file eval.cpp.

00606 {
00607     Tree num;
00608     if (!getNumericProperty(value,num)) {
00609         if (!isBoxNumeric(value,num)) {
00610             num = value;
00611         }
00612         setNumericProperty(value,num);
00613     }
00614     return num;
00615 }


Variable Documentation

Transform unused (unapplied) closures into symbolic boxes.

Parameters:
exp the expression to transform
Returns:
an expression where abstractions have been replaced by symbolic boxes

Definition at line 127 of file eval.cpp.

Generated by  doxygen 1.6.2-20100208