An ExpressionProgram is a linear sequence of Operations for evaluating an expression.
More...
#include <ExpressionProgram.h>
An ExpressionProgram is a linear sequence of Operations for evaluating an expression.
The evaluation is done with a stack. The arguments to each Operation are first taken off the stack in order, then it is evaluated and the result is pushed back onto the stack. At the end, the stack contains a single value, which is the value of the expression.
An ExpressionProgram is created by calling createProgram() on a ParsedExpression.
◆ ExpressionProgram() [1/3]
| PLMD::ExpressionProgram::ExpressionProgram |
( |
| ) |
|
◆ ExpressionProgram() [2/3]
| PLMD::ExpressionProgram::ExpressionProgram |
( |
const ExpressionProgram & | program | ) |
|
◆ ~ExpressionProgram()
| PLMD::ExpressionProgram::~ExpressionProgram |
( |
| ) |
|
◆ ExpressionProgram() [3/3]
| PLMD::ExpressionProgram::ExpressionProgram |
( |
const ParsedExpression & | expression | ) |
|
|
private |
◆ buildProgram()
◆ evaluate() [1/2]
| double PLMD::ExpressionProgram::evaluate |
( |
| ) |
const |
Evaluate the expression.
If the expression involves any variables, this method will throw an exception.
◆ evaluate() [2/2]
| double PLMD::ExpressionProgram::evaluate |
( |
const std::map< std::string, double > & | variables | ) |
const |
Evaluate the expression.
- Parameters
-
| variables | a map specifying the values of all variables that appear in the expression. If any variable appears in the expression but is not included in this map, an exception will be thrown. |
◆ getNumOperations()
| int PLMD::ExpressionProgram::getNumOperations |
( |
| ) |
const |
Get the number of Operations that make up this program.
◆ getOperation()
| const Operation & PLMD::ExpressionProgram::getOperation |
( |
int | index | ) |
const |
◆ getStackSize()
| int PLMD::ExpressionProgram::getStackSize |
( |
| ) |
const |
Get the size of the stack needed to execute this program.
This is the largest number of elements present on the stack at any point during evaluation.
◆ operator=()
◆ setOperation()
| void PLMD::ExpressionProgram::setOperation |
( |
int | index, |
|
|
Operation * | operation ) |
Change an Operation in this program.
The Operation must have been allocated on the heap with the "new" operator. The ExpressionProgram assumes ownership of it and will delete it when it is no longer needed.
◆ ParsedExpression
| friend class ParsedExpression |
|
friend |
◆ maxArgs
| int PLMD::lepton::ExpressionProgram::maxArgs |
|
private |
◆ operations
| std::vector<Operation*> PLMD::lepton::ExpressionProgram::operations |
|
private |
◆ stackSize
| int PLMD::lepton::ExpressionProgram::stackSize |
|
private |
The documentation for this class was generated from the following files: