The Sparta Modeling Framework
|
Expression container/builder. Contains a single ExpressionNode representing the root of an expression tree. This is the object on which the parser operates to build an expression incrementally through basic operators. More...
#include <Expression.hpp>
Public Member Functions | |
Expression ()=default | |
Constructs an expression containing no content. | |
Expression (const Expression &rhp) | |
Copy Constructor. | |
Expression (Expression &&rhp) | |
Move Constructor. | |
Expression (const std::string &expression, TreeNode *context) | |
Construct with string expression. | |
Expression (const std::string &expression, TreeNode *context, const StatisticPairs &report_si) | |
Construct with string expression. | |
Expression (const std::string &expression, TreeNode *context, std::vector< const TreeNode * > &already_used) | |
Construct with string expression. | |
Expression (ExpressionNode *item) | |
Blind content constructor. | |
Expression (double d) | |
Constant construction. | |
Expression (operation_t type, ExpressionNode *op1, ExpressionNode *op2=nullptr, ExpressionNode *op3=nullptr) | |
Operation construction. | |
Expression (const TreeNode *n, std::vector< const TreeNode * > &used) | |
Stat/Counter/Parameter construction. | |
template<typename RetT , typename ArgT > | |
Expression (const std::string &name, RetT(*fxn)(ArgT), const Expression &a) | |
Unary function construction. | |
template<typename RetT , typename ArgT > | |
Expression (const std::string &name, std::function< RetT(ArgT)> &, const Expression &a) | |
Unary function construction. | |
template<typename RetT , typename ArgT > | |
Expression (const std::string &name, RetT(*fxn)(ArgT, ArgT), const Expression &a, const Expression &b) | |
Binary function construction. | |
template<typename RetT > | |
Expression (const std::string &name, const RetT &functor, const Expression &a, const Expression &b) | |
Binary function construction. | |
template<typename RetT , typename ArgT > | |
Expression (const std::string &name, RetT(*fxn)(ArgT, ArgT, ArgT), const Expression &a, const Expression &b, const Expression &c) | |
Ternary function construction. | |
virtual | ~Expression () |
Virtual destructor. | |
Expression & | operator= (const Expression &rhp) |
Assignment operator. Clones the content of rhp and discards current expression content. | |
Expression & | operator= (Expression &&rhp) |
Assignment operator with move. Moves content of rhp and discards current expression content. | |
ExpressionNode * | cloneContent () const |
Makes a clone of the content of this expression. | |
uint32_t | getStats (std::vector< const StatisticInstance * > &results) const |
Gets the statistics present in this expression. | |
bool | hasContent () const |
Does this expression have content. | |
template<typename RetT , typename ArgT > | |
Expression | ufunc (const std::string &name, RetT(*fxn)(ArgT), const Expression &a) const |
Construct a unary function having the given name and function. | |
template<typename RetT , typename ArgT > | |
Expression | ufunc (const std::string &name, std::function< RetT(ArgT)> &, const Expression &a) const |
Construct a unary function having the given name and functor. | |
template<typename RetT , typename ArgT > | |
Expression | bfunc (const std::string &name, RetT(*fxn)(ArgT, ArgT), const Expression &a, const Expression &b) const |
Construct a binary function having the given name and function. | |
template<typename RetT > | |
Expression | bfunc (const std::string &name, const RetT &functor, const Expression &a, const Expression &b) const |
Construct a binary function having the given name and functor. | |
template<typename RetT , typename ArgT > | |
Expression | tfunc (const std::string &name, RetT(*fxn)(ArgT, ArgT, ArgT), const Expression &a, const Expression &b, const Expression &c) const |
Construct a ternary function having the given name and function. | |
Expression & | operator= (double d) |
Construct a constant node. | |
Expression | operator+ () const |
Return this expression with no effect. | |
Expression | operator- () const |
Return this expression with a negation inserted. | |
Expression | operator+ (const Expression &rhp) const |
Return a new expression of: *this + rhp. | |
Expression | operator- (const Expression &rhp) const |
Return a new expression of: *this - rhp. | |
Expression | operator* (const Expression &rhp) const |
Return a new expression of: *this * rhp. | |
Expression | operator/ (const Expression &rhp) const |
Return a new expression of: *this / rhp. | |
Expression & | operator+= (const Expression &rhp) |
Return this expression with a node adding rhp. | |
Expression & | operator-= (const Expression &rhp) |
Return this expression with a node subtracting rhp. | |
Expression & | operator*= (const Expression &rhp) |
Return this expression with a node multiplying by rhp. | |
Expression & | operator/= (const Expression &rhp) |
Return this expression with a node dividing by rhp. | |
double | evaluate () const |
Compute value of this operate in simulation for the current computation window. | |
void | start () |
Notify every item in this expression to start a new computation window. | |
void | end () |
Notify every item in this expression to end the current computation window. | |
void | dump (std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const |
Write the content of this entire expression to an ostream. | |
bool | supportsCompression () const |
std::string | stringize (bool show_range=true, bool resolve_subexprs=true) const |
Return a string representing this expression including any TreeNode dependencies. | |
const Clock * | getClock () |
Gets the clock associated with the content of this expression. This is done by finding all TreeNodes on which the Expression depends. | |
void | getClocks (std::vector< const Clock * > &clocks) const |
Gets all clocks associated with this Expression. | |
Expression container/builder. Contains a single ExpressionNode representing the root of an expression tree. This is the object on which the parser operates to build an expression incrementally through basic operators.
Expressions have an inherit computation window built in (like StatisticDef). This means that when the expression is created, any counter or stat-def referenced is treated as if it was 0 at that point. When the expression is later evaluated, the delta for those counters or stat-defs is used. This can be avoided simply by evaluating with evaluateAbsolute (generally not recommended)
If expressions created during different simulation states are joined together, then they may see different windows. This is intentional so that comparisons can be made between different simulation time windows in a single expression (most users will not need to do this). This issue can be avoided by manually calling start()
Definition at line 67 of file Expression.hpp.
|
inline |
Copy Constructor.
Definition at line 86 of file Expression.hpp.
|
inline |
Move Constructor.
Definition at line 98 of file Expression.hpp.
sparta::statistics::expression::Expression::Expression | ( | const std::string & | expression, |
TreeNode * | context | ||
) |
Construct with string expression.
expr | String containing an arithmetic expression |
context | TreeNode from which variables in the expression will be searched for. Must not be nullptr |
sparta::statistics::expression::Expression::Expression | ( | const std::string & | expression, |
TreeNode * | context, | ||
const StatisticPairs & | report_si | ||
) |
Construct with string expression.
expr | String containing an arithmetic expression |
context | TreeNode from which variables in the expression |
report_si | Previously defined StatisticInstances in the report |
sparta::statistics::expression::Expression::Expression | ( | const std::string & | expression, |
TreeNode * | context, | ||
std::vector< const TreeNode * > & | already_used | ||
) |
Construct with string expression.
expr | String containing an arithmetic expression |
context | Optional TreeNode from which variables in the expression will be searched for. Must not be nullptr |
already_used | TreeNodes already in an expression containing this expression |
|
inline |
Blind content constructor.
item | Expression item to contain. Takes ownership |
Definition at line 139 of file Expression.hpp.
|
inline |
Constant construction.
Definition at line 572 of file Expression.hpp.
|
inline |
Operation construction.
Definition at line 578 of file Expression.hpp.
sparta::statistics::expression::Expression::Expression | ( | const TreeNode * | n, |
std::vector< const TreeNode * > & | used | ||
) |
Stat/Counter/Parameter construction.
[in] | n | Node to use (StatisticDef, Parameter, or Counter variant) |
[in] | used | Vector of nodes already used higher up in an enclosing expression (for preventing cycles). Use a dummy object if there is no chance of cyclic expressions |
|
inline |
Unary function construction.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
Definition at line 588 of file Expression.hpp.
|
inline |
Unary function construction.
RetT | Return type of functor. Must be convertable to double |
ArgT | Argument type of functor. |
Definition at line 597 of file Expression.hpp.
|
inline |
Binary function construction.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
Definition at line 606 of file Expression.hpp.
|
inline |
Binary function construction.
RetT | Return type of functor. Must be convertable to double |
ArgT | Argument type of functor. |
Definition at line 616 of file Expression.hpp.
|
inline |
Ternary function construction.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
Definition at line 624 of file Expression.hpp.
|
inline |
Construct a binary function having the given name and functor.
RetT | Return type of functor. Must be convertable to double |
ArgT | Argument type of functor. |
name | Name of the function (e.g. fabs) |
fxn | Functor to invoke to compute the value. Must not be null |
a | Operand 1 of the binary function |
b | Operand 2 of the binary function |
Definition at line 664 of file Expression.hpp.
|
inline |
Construct a binary function having the given name and function.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
name | Name of the function (e.g. fabs) |
fxn | Function pointer to invoke to compute the value. Must not be nullptr |
a | Operand 1 of the binary function |
b | Operand 2 of the binary function |
Definition at line 654 of file Expression.hpp.
|
inline |
Makes a clone of the content of this expression.
SpartaException | if this node has null content |
Definition at line 266 of file Expression.hpp.
|
inline |
Write the content of this entire expression to an ostream.
o | Ostream to write to |
show_range | Should the range be shown in any subexpression nodes. |
resolve_subexprs | Should any referenced statistic defs be expanded to their full expressions so that this becomes an expression containing only counters. |
Definition at line 482 of file Expression.hpp.
|
inline |
Notify every item in this expression to end the current computation window.
Definition at line 466 of file Expression.hpp.
|
inline |
Compute value of this operate in simulation for the current computation window.
Definition at line 437 of file Expression.hpp.
|
inline |
Gets the clock associated with the content of this expression. This is done by finding all TreeNodes on which the Expression depends.
Definition at line 523 of file Expression.hpp.
|
inline |
Gets all clocks associated with this Expression.
clocks | Vector of clocks to which all clocks contained in this Expression will be added. Does not clear this vector. |
Definition at line 545 of file Expression.hpp.
|
inline |
Gets the statistics present in this expression.
results | Vector of pointers to StatisticInstances. All statistics within this class will be appended to the results vector. These pointers are valid until this expression is modified or deleted |
Definition at line 280 of file Expression.hpp.
|
inline |
Does this expression have content.
Definition at line 289 of file Expression.hpp.
|
inline |
Return a new expression of: *this * rhp.
Definition at line 725 of file Expression.hpp.
|
inline |
Return this expression with a node multiplying by rhp.
Definition at line 768 of file Expression.hpp.
|
inline |
Return this expression with no effect.
Definition at line 689 of file Expression.hpp.
|
inline |
Return a new expression of: *this + rhp.
Definition at line 705 of file Expression.hpp.
|
inline |
Return this expression with a node adding rhp.
Definition at line 745 of file Expression.hpp.
|
inline |
Return this expression with a negation inserted.
Definition at line 697 of file Expression.hpp.
|
inline |
Return a new expression of: *this - rhp.
Definition at line 715 of file Expression.hpp.
|
inline |
Return this expression with a node subtracting rhp.
Definition at line 756 of file Expression.hpp.
|
inline |
Return a new expression of: *this / rhp.
Definition at line 735 of file Expression.hpp.
|
inline |
Return this expression with a node dividing by rhp.
Definition at line 779 of file Expression.hpp.
|
inline |
Assignment operator. Clones the content of rhp and discards current expression content.
rhp | Expression to copy content from |
Definition at line 238 of file Expression.hpp.
|
inline |
Construct a constant node.
Definition at line 682 of file Expression.hpp.
|
inline |
Assignment operator with move. Moves content of rhp and discards current expression content.
rhp | Expression to move content from |
Definition at line 254 of file Expression.hpp.
|
inline |
Notify every item in this expression to start a new computation window.
Definition at line 453 of file Expression.hpp.
|
inline |
Return a string representing this expression including any TreeNode dependencies.
show_range | See dump |
resolve_subexprs | See dump |
Definition at line 508 of file Expression.hpp.
|
inline |
Definition at line 492 of file Expression.hpp.
|
inline |
Construct a ternary function having the given name and function.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
name | Name of the function (e.g. fabs) |
fxn | Function pointer to invoke to compute the value. Must not be nullptr |
a | Operand 1 of the binary function |
b | Operand 2 of the binary function |
c | Operand 3 of the binary function |
Definition at line 672 of file Expression.hpp.
|
inline |
Construct a unary function having the given name and function.
RetT | Return type of function pointer. Must be convertable to double |
ArgT | Argument type of function pointer. |
name | Name of the function (e.g. fabs) |
fxn | Function pointer to invoke to compute the value. Must not be nullptr |
a | Operand of the unary function |
Definition at line 635 of file Expression.hpp.
|
inline |
Construct a unary function having the given name and functor.
RetT | Return type of functor. Must be convertable to double |
ArgT | Argument type of functor. |
name | Name of the function (e.g. fabs) |
fxn | Functor to invoke to compute the value. Must not be null |
a | Operand of the unary function |
Definition at line 645 of file Expression.hpp.