|
FAUST compiler
0.9.9.6b8
|
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 "compatibility.hh"#include <assert.h>
Go to the source code of this file.
Macros | |
| #define | TRACE |
Functions | |
| static Tree | a2sb (Tree exp) |
| static Tree | eval (Tree exp, Tree visited, Tree localValEnv) |
| static Tree | realeval (Tree exp, Tree visited, Tree localValEnv) |
| Eval a block diagram expression. More... | |
| static Tree | revEvalList (Tree lexp, Tree visited, Tree localValEnv) |
| Eval a list of expression in reverse order. More... | |
| static Tree | applyList (Tree fun, Tree larg) |
| Apply a function to a list of arguments. More... | |
| static Tree | iteratePar (Tree id, int num, Tree body, Tree visited, Tree localValEnv) |
| Iterate a parallel construction. More... | |
| static Tree | iterateSeq (Tree id, int num, Tree body, Tree visited, Tree localValEnv) |
| Iterate a sequential construction. More... | |
| static Tree | iterateSum (Tree id, int num, Tree body, Tree visited, Tree localValEnv) |
| Iterate an addition construction. More... | |
| static Tree | iterateProd (Tree id, int num, Tree body, Tree visited, Tree localValEnv) |
| Iterate a product construction. More... | |
| static Tree | larg2par (Tree larg) |
| Transform a list of expressions in a parallel construction. More... | |
| static int | eval2int (Tree exp, Tree visited, Tree localValEnv) |
| Eval a block diagram to an int. More... | |
| static double | eval2double (Tree exp, Tree visited, Tree localValEnv) |
| Eval a block diagram to a double. More... | |
| static const char * | evalLabel (const char *src, Tree visited, Tree localValEnv) |
| evallabel replace "...%2i..." occurences in label with value of i More... | |
| static Tree | evalIdDef (Tree id, Tree visited, Tree lenv) |
| Search the environment for the definition of a symbol ID and evaluate it. More... | |
| static Tree | evalCase (Tree rules, Tree env) |
| Eval a case expression containing a list of pattern matching rules. More... | |
| static Tree | evalRuleList (Tree rules, Tree env) |
| Evaluates each rule of the list. More... | |
| static Tree | evalRule (Tree rule, Tree env) |
| Evaluates the list of patterns and closure the rhs. More... | |
| static Tree | evalPatternList (Tree patterns, Tree env) |
| Evaluates each pattern of the list. More... | |
| static Tree | evalPattern (Tree pattern, Tree env) |
| Evaluates a pattern and simplify it to numerical value if possible. More... | |
| static Tree | patternSimplification (Tree pattern) |
| static bool | isBoxNumeric (Tree in, Tree &out) |
| static Tree | vec2list (const vector< Tree > &v) |
| static void | list2vec (Tree l, vector< Tree > &v) |
| static Tree | listn (int n, Tree e) |
| Creates a list of n elements. More... | |
| static Tree | boxSimplification (Tree box) |
| boxSimplification(box) : simplify a block-diagram by replacing expressions denoting a constant number by this number. More... | |
| Tree | evalprocess (Tree eqlist) |
| Eval "process" from a list of definitions. More... | |
| Tree | evaldocexpr (Tree docexpr, Tree eqlist) |
| static Tree | real_a2sb (Tree exp) |
| static bool | autoName (Tree exp, Tree &id) |
| bool | getArgName (Tree t, Tree &id) |
| void | setEvalProperty (Tree box, Tree env, Tree value) |
| set the value of box in the environment env More... | |
| bool | getEvalProperty (Tree box, Tree env, Tree &value) |
| retrieve the value of box in the environment env More... | |
| static bool | isBoxPatternOp (Tree box, Node &n, Tree &t1, Tree &t2) |
| void | setNumericProperty (Tree t, Tree num) |
| bool | getNumericProperty (Tree t, Tree &num) |
| Tree | simplifyPattern (Tree value) |
| Simplify a block-diagram pattern by computing its numerical sub-expressions. More... | |
| static bool | isDigitChar (char c) |
| static bool | isIdentChar (char c) |
| static void | writeIdentValue (std::string &dst, const std::string &format, const std::string &ident, Tree visited, Tree localValEnv) |
| static bool | boxlistOutputs (Tree boxlist, int *outputs) |
| Compute the sum of outputs of a list of boxes. More... | |
| static Tree | nwires (int n) |
| repeat n times a wire More... | |
| static void | setPMProperty (Tree t, Tree env, Tree pm) |
| static bool | getPMProperty (Tree t, Tree env, Tree &pm) |
| static Tree | numericBoxSimplification (Tree box) |
| Try to do a numeric simplification of a block-diagram. More... | |
| static Tree | insideBoxSimplification (Tree box) |
| Simplify inside a block-diagram : S[A*B] => S[A]*S[B]. More... | |
Variables | |
| SourceReader | gReader |
| int | gMaxNameSize |
| bool | gSimpleNames |
| bool | gSimplifyDiagrams |
| property< Tree > | gSymbolicBoxProperty |
| Transform unused (unapplied) closures into symbolic boxes. More... | |
| static int | gBoxSlotNumber = 0 |
| counter for unique slot number More... | |
| static loopDetector | LD (1024, 512) |
| Eval a block diagram expression. More... | |
| static Node | EVALPROPERTY (symbol("EvalProperty")) |
| Tree | NUMERICPROPERTY = tree(symbol("NUMERICPROPERTY")) |
| const char * | Formats [] = {"%d", "%1d", "%2d", "%3d", "%4d"} |
| static Node | PMPROPERTYNODE (symbol("PMPROPERTY")) |
| A property to store the pattern matcher corresponding to a set of rules in a specific environement. More... | |
| static property< Tree > | SimplifiedBoxProperty |
Implementation of the Block diagram evaluator.
Interface for names propagation.
A strict lambda-calculus evaluator for block diagram expressions.
Definition in file eval.cpp.
Definition at line 135 of file eval.cpp.
References property< Tree >::get(), getDefNameProperty(), real_a2sb(), property< Tree >::set(), and setDefNameProperty().
Referenced by applyList(), boxlistOutputs(), eval2double(), eval2int(), evaldocexpr(), evalprocess(), isBoxNumeric(), real_a2sb(), and realeval().


Apply a function to a list of arguments.
Apply a function F to a list of arguments (a,b,c,...). F can be either a closure over an abstraction, or a pattern matcher. If it is not the case then we have : F(a,b,c,...) ==> (a,b,c,...):F
| fun | the function to apply |
| larg | the list of arguments |
Definition at line 1003 of file eval.cpp.
References a2sb(), apply_pattern_matcher(), boxCase(), boxError(), boxlistOutputs(), boxPatternMatcher(), boxSeq(), concat(), cons(), eval(), evalerror(), evalerrorbox(), getBoxType(), getDefNameProperty(), getUserData(), gSimpleNames, hd(), isBoxAbstr(), isBoxEnvironment(), isBoxError(), isBoxNumeric(), isBoxPatternMatcher(), isBoxPrim2(), isClosure(), isNil(), larg2par(), list2vec(), nil, nwires(), pushValueDef(), reverse(), setDefNameProperty(), sigPrefix(), tl(), tree2str(), vec2list(), and yyfilename.
Referenced by real_a2sb(), and realeval().


Definition at line 226 of file eval.cpp.
References tree().
Referenced by getArgName().


|
static |
Compute the sum of outputs of a list of boxes.
The sum is valid if all the boxes have a valid boxType
| boxlist | the list of boxes |
| outputs | sum of outputs of the boxes |
Definition at line 948 of file eval.cpp.
References a2sb(), getBoxType(), hd(), isNil(), and tl().
Referenced by applyList().


boxSimplification(box) : simplify a block-diagram by replacing expressions denoting a constant number by this number.
Definition at line 1347 of file eval.cpp.
References property< Tree >::get(), getDefNameProperty(), name(), numericBoxSimplification(), property< Tree >::set(), and setDefNameProperty().
Referenced by evalprocess(), and insideBoxSimplification().


Definition at line 280 of file eval.cpp.
References cons(), loopDetector::detect(), getDefNameProperty(), getEvalProperty(), LD, realeval(), setDefNameProperty(), and setEvalProperty().
Referenced by applyList(), eval2double(), eval2int(), evaldocexpr(), evalIdDef(), evalPattern(), evalprocess(), iteratePar(), iterateProd(), iterateSeq(), iterateSum(), real_a2sb(), realeval(), and revEvalList().


Eval a block diagram to a double.
Eval a block diagram that represent a double constant. This function first eval a block diagram to its normal form, then check it represent a numerical value (a block diagram of type : 0->1) then do a symbolic propagation and try to convert the resulting signal to a double.
| exp | the expression to evaluate |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 689 of file eval.cpp.
References a2sb(), boxPropagateSig(), eval(), evalerror(), getBoxType(), hd(), makeSigInputList(), nil, simplify(), tree2float(), yyfilename, and yylineno.
Referenced by realeval().


Eval a block diagram to an int.
Eval a block diagram that represent an integer constant. This function first eval a block diagram to its normal form, then check it represent a numerical value (a block diagram of type : 0->1) then do a symbolic propagation and try to convert the resulting signal to an int.
| exp | the expression to evaluate |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 718 of file eval.cpp.
References a2sb(), boxPropagateSig(), eval(), evalerror(), getBoxType(), hd(), makeSigInputList(), nil, simplify(), tree2int(), yyfilename, and yylineno.
Referenced by realeval(), and writeIdentValue().


Eval a case expression containing a list of pattern matching rules.
Creates a boxPatternMatcher containing a pm autamaton a state and a list of environments.
| rules | the list of rules |
| env | the environment uused to evaluate the patterns and closure the rhs |
Definition at line 1257 of file eval.cpp.
References boxPatternMatcher(), evalRuleList(), getPMProperty(), len(), listn(), make_pattern_matcher(), nil, pushEnvBarrier(), and setPMProperty().
Referenced by realeval().


Definition at line 114 of file eval.cpp.
References a2sb(), eval(), nil, and pushMultiClosureDefs().
Referenced by mapEvalDocEqn(), and printDocDgm().


Search the environment for the definition of a symbol ID and evaluate it.
Detects recursive definitions using a set of visited IDxENV. Associates the symbol as a definition name property of the definition.
| id | the symbol ID t-o search |
| visited | set of visited symbols (used for recursive definition detection) |
| lenv | the environment where to search |
Definition at line 1188 of file eval.cpp.
References addElement(), CTree::branch(), cons(), eval(), evalerror(), getDefFileProp(), getDefLineProp(), getDefNameProperty(), getProperty(), isNil(), name(), and nil.
Referenced by realeval().


evallabel replace "...%2i..." occurences in label with value of i
Definition at line 760 of file eval.cpp.
References isDigitChar(), isIdentChar(), and writeIdentValue().
Referenced by realeval().


Evaluates a pattern and simplify it to numerical value if possible.
Definition at line 1308 of file eval.cpp.
References eval(), nil, and patternSimplification().
Referenced by evalPatternList().


Evaluates each pattern of the list.
Definition at line 1293 of file eval.cpp.
References cons(), evalPattern(), hd(), isNil(), nil, and tl().
Referenced by evalRule().


Eval "process" from a list of definitions.
Eval the definition of 'process'.
Strict evaluation of a block diagram expression by applying beta reduction.
| eqlist | a list of faust defintions forming the the global environment |
Definition at line 100 of file eval.cpp.
References a2sb(), boxIdent(), boxSimplification(), eval(), gSimplifyDiagrams, nil, and pushMultiClosureDefs().
Referenced by main().


Evaluates the list of patterns and closure the rhs.
Definition at line 1283 of file eval.cpp.
References cons(), evalPatternList(), left(), and right().
Referenced by evalRuleList().


Evaluates each rule of the list.
Definition at line 1272 of file eval.cpp.
References cons(), evalRule(), hd(), isNil(), nil, and tl().
Referenced by evalCase().


Definition at line 233 of file eval.cpp.
References autoName().

retrieve the value of box in the environment env
| box | the expression we want to retrieve the value |
| env | the lexical environment |
| value | the returned value if any |
Definition at line 274 of file eval.cpp.
References EVALPROPERTY, getProperty(), and tree().
Referenced by eval().


Definition at line 604 of file eval.cpp.
References getProperty().
Referenced by simplifyPattern().


Definition at line 1243 of file eval.cpp.
References getProperty(), PMPROPERTYNODE, and tree().
Referenced by evalCase().


Simplify inside a block-diagram : S[A*B] => S[A]*S[B].
Definition at line 1413 of file eval.cpp.
References boxHGroup(), boxMerge(), boxPar(), boxRec(), boxSeq(), boxSimplification(), boxSplit(), boxSymbolic(), boxTGroup(), boxVGroup(), getUserData(), isBoxButton(), isBoxCheckbox(), isBoxCut(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxInt(), isBoxMerge(), isBoxNumEntry(), isBoxPar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWire(), max(), min(), and name().
Referenced by numericBoxSimplification().


Definition at line 630 of file eval.cpp.
References a2sb(), boxInt(), boxPropagateSig(), boxReal(), getBoxType(), hd(), isBoxInt(), isBoxReal(), isSigInt(), isSigReal(), makeSigInputList(), nil, and simplify().
Referenced by applyList(), patternSimplification(), and simplifyPattern().


Definition at line 581 of file eval.cpp.
References isBoxMerge(), isBoxPar(), isBoxRec(), isBoxSeq(), isBoxSplit(), and CTree::node().
Referenced by patternSimplification().


|
static |
Definition at line 733 of file eval.cpp.
Referenced by evalLabel().

|
static |
Definition at line 738 of file eval.cpp.
Referenced by evalLabel().

Iterate a parallel construction.
Iterate a parallel construction such that : par(i,10,E) –> E(i<-0),(E(i<-1),...,E(i<-9))
| id | the formal parameter of the iteration |
| num | the number of iterartions |
| body | the body expression of the iteration |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 845 of file eval.cpp.
References boxPar(), eval(), pushValueDef(), and tree().
Referenced by realeval().


Iterate a product construction.
Iterate a product construction such that : par(i,10,E) –> E(i<-0)*E(i<-1)*...*E(i<-9)
| id | the formal parameter of the iteration |
| num | the number of iterartions |
| body | the body expression of the iteration |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 926 of file eval.cpp.
References boxPar(), boxPrim2(), boxSeq(), eval(), pushValueDef(), sigMul(), and tree().
Referenced by realeval().


Iterate a sequential construction.
Iterate a sequential construction such that : seq(i,10,E) –> E(i<-0):(E(i<-1):...:E(i<-9))
| id | the formal parameter of the iteration |
| num | the number of iterartions |
| body | the body expression of the iteration |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
Definition at line 871 of file eval.cpp.
References boxSeq(), eval(), pushValueDef(), and tree().
Referenced by realeval().


Iterate an addition construction.
Iterate an addition construction such that : par(i,10,E) –> E(i<-0)+E(i<-1)+...+E(i<-9)
| id | the formal parameter of the iteration |
| num | the number of iterartions |
| body | the body expression of the iteration |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 898 of file eval.cpp.
References boxPar(), boxPrim2(), boxSeq(), eval(), pushValueDef(), sigAdd(), and tree().
Referenced by realeval().


Transform a list of expressions in a parallel construction.
| larg | list of expressions |
Definition at line 1163 of file eval.cpp.
References boxPar(), evalerror(), hd(), isNil(), tl(), and yyfilename.
Referenced by applyList().


Creates a list of n elements.
| n | number of elements |
| e | element to be repeated |
Definition at line 1226 of file eval.cpp.
Referenced by evalCase().


Try to do a numeric simplification of a block-diagram.
Definition at line 1372 of file eval.cpp.
References boxInt(), boxPropagateSig(), boxReal(), getBoxType(), hd(), insideBoxSimplification(), isBoxInt(), isBoxReal(), isSigInt(), isSigReal(), makeSigInputList(), nil, and simplify().
Referenced by boxSimplification().


|
static |
repeat n times a wire
Definition at line 984 of file eval.cpp.
References boxWire(), cons(), and nil.
Referenced by applyList().


Definition at line 659 of file eval.cpp.
References isBoxNumeric(), isBoxPatternOp(), and tree().
Referenced by evalPattern().


Definition at line 154 of file eval.cpp.
References a2sb(), applyList(), CTree::arity(), boxSlot(), boxSymbolic(), CTree::branch(), cons(), eval(), evalerror(), gBoxSlotNumber, getDefNameProperty(), isBoxAbstr(), isBoxEnvironment(), isBoxIdent(), isBoxPatternMatcher(), isBoxWaveform(), isClosure(), CTree::make(), name(), nil, CTree::node(), pushValueDef(), setDefNameProperty(), and yyfilename.
Referenced by a2sb().


Eval a block diagram expression.
Strict evaluation of a block diagram expression by applying beta reduction.
| exp | the expression to evaluate |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 308 of file eval.cpp.
References a2sb(), applyList(), boxButton(), boxCheckbox(), boxEnvironment(), boxHBargraph(), boxHGroup(), boxHSlider(), boxIdent(), boxInt(), boxMerge(), boxNumEntry(), boxPar(), boxRec(), boxSeq(), boxSplit(), boxTGroup(), boxVBargraph(), boxVGroup(), boxVSlider(), closure(), copyEnvReplaceDefs(), eval(), eval2double(), eval2int(), evalCase(), evalerror(), evalIdDef(), evalLabel(), SourceReader::expandlist(), getBoxType(), getDefFileProp(), getDefLineProp(), SourceReader::getlist(), getUserData(), isBoxAbstr(), isBoxAccess(), isBoxAppl(), isBoxButton(), isBoxCase(), isBoxCheckbox(), isBoxComponent(), isBoxCut(), isBoxEnvironment(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxIdent(), isBoxInputs(), isBoxInt(), isBoxIPar(), isBoxIProd(), isBoxISeq(), isBoxISum(), isBoxLibrary(), isBoxMerge(), isBoxModifLocalDef(), isBoxNumEntry(), isBoxOutputs(), isBoxPar(), isBoxPatternMatcher(), isBoxPatternVar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWaveform(), isBoxWire(), isBoxWithLocalDef(), isClosure(), iteratePar(), iterateProd(), iterateSeq(), iterateSum(), nil, pushMultiClosureDefs(), revEvalList(), setDefNameProperty(), setUnion(), tree(), and tree2str().
Referenced by eval().

Eval a list of expression in reverse order.
Eval a list of expressions returning the list of results in reverse order.
| lexp | list of expressions to evaluate |
| globalDefEnv | the global environment |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Definition at line 1141 of file eval.cpp.
References cons(), eval(), hd(), isNil(), nil, and tl().
Referenced by realeval().


set the value of box in the environment env
| box | the block diagram we have evaluated |
| env | the evaluation environment |
| value | the evaluated block diagram |
Definition at line 261 of file eval.cpp.
References EVALPROPERTY, setProperty(), and tree().
Referenced by eval().


Definition at line 599 of file eval.cpp.
References setProperty().
Referenced by simplifyPattern().


Definition at line 1238 of file eval.cpp.
References PMPROPERTYNODE, setProperty(), and tree().
Referenced by evalCase().


Simplify a block-diagram pattern by computing its numerical sub-expressions.
| pattern | an evaluated block-diagram |
Definition at line 617 of file eval.cpp.
References getNumericProperty(), isBoxNumeric(), and setNumericProperty().
Referenced by apply_pattern_matcher_internal().


Definition at line 1324 of file eval.cpp.
Referenced by applyList().


|
static |
Definition at line 745 of file eval.cpp.
References boxIdent(), eval2int(), max(), and min().
Referenced by evalLabel().


Referenced by getEvalProperty(), and setEvalProperty().
|
static |
| SourceReader gReader |
| bool gSimpleNames |
Definition at line 128 of file main.cpp.
Referenced by applyList(), and process_cmdline().
| bool gSimplifyDiagrams |
Definition at line 129 of file main.cpp.
Referenced by evalprocess(), and process_cmdline().
|
static |
Eval a block diagram expression.
Wrap the realeval function in order to propagate the name property
| exp | the expression to evaluate |
| visited | list of visited definition to detect recursive definitions |
| localValEnv | the local environment |
Referenced by eval().
A property to store the pattern matcher corresponding to a set of rules in a specific environement.
Referenced by getPMProperty(), and setPMProperty().
1.8.7