OpcUaCanOpen
CANopen OPC-UA server
|
Bytecode implementation of the Math Parser. More...
#include <muParserBytecode.h>
Public Member Functions | |
ParserByteCode () | |
Bytecode default constructor. More... | |
ParserByteCode (const ParserByteCode &a_ByteCode) | |
Copy constructor. More... | |
ParserByteCode & | operator= (const ParserByteCode &a_ByteCode) |
Assignment operator. More... | |
void | Assign (const ParserByteCode &a_ByteCode) |
Copy state of another object to this. More... | |
void | AddVar (value_type *a_pVar) |
Add a Variable pointer to bytecode. More... | |
void | AddVal (value_type a_fVal) |
Add a Variable pointer to bytecode. More... | |
void | AddOp (ECmdCode a_Oprt) |
Add an operator identifier to bytecode. More... | |
void | AddIfElse (ECmdCode a_Oprt) |
void | AddAssignOp (value_type *a_pVar) |
Add an assignment operator. More... | |
void | AddFun (generic_fun_type a_pFun, int a_iArgc) |
Add function to bytecode. More... | |
void | AddBulkFun (generic_fun_type a_pFun, int a_iArgc) |
Add a bulk function to bytecode. More... | |
void | AddStrFun (generic_fun_type a_pFun, int a_iArgc, int a_iIdx) |
Add Strung function entry to the parser bytecode. More... | |
void | EnableOptimizer (bool bStat) |
void | Finalize () |
Add end marker to bytecode. More... | |
void | clear () |
Delete the bytecode. More... | |
std::size_t | GetMaxStackSize () const |
std::size_t | GetSize () const |
Returns the number of entries in the bytecode. More... | |
const SToken * | GetBase () const |
void | AsciiDump () |
Dump bytecode (for debugging only!). More... | |
Private Types | |
typedef ParserToken< value_type, string_type > | token_type |
Token type for internal use only. More... | |
typedef std::vector< SToken > | rpn_type |
Token vector for storing the RPN. More... | |
Private Member Functions | |
void | ConstantFolding (ECmdCode a_Oprt) |
Private Attributes | |
unsigned | m_iStackPos |
Position in the Calculation array. More... | |
std::size_t | m_iMaxStackSize |
Maximum size needed for the stack. More... | |
rpn_type | m_vRPN |
The actual rpn storage. More... | |
bool | m_bEnableOptimizer |
Bytecode implementation of the Math Parser.
The bytecode contains the formula converted to revers polish notation stored in a continious memory area. Associated with this data are operator codes, variable pointers, constant values and function pointers. Those are necessary in order to calculate the result. All those data items will be casted to the underlying datatype of the bytecode.
Definition at line 87 of file muParserBytecode.h.
|
private |
Token vector for storing the RPN.
Definition at line 95 of file muParserBytecode.h.
|
private |
Token type for internal use only.
Definition at line 92 of file muParserBytecode.h.
mu::ParserByteCode::ParserByteCode | ( | ) |
Bytecode default constructor.
Definition at line 46 of file muParserBytecode.cpp.
mu::ParserByteCode::ParserByteCode | ( | const ParserByteCode & | a_ByteCode | ) |
Copy constructor.
Implemented in Terms of Assign(const ParserByteCode &a_ByteCode)
Definition at line 60 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddAssignOp | ( | value_type * | a_pVar | ) |
Add an assignment operator.
Operator entries in byte code consist of:
Definition at line 345 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddBulkFun | ( | generic_fun_type | a_pFun, |
int | a_iArgc | ||
) |
Add a bulk function to bytecode.
a_iArgc | Number of arguments, negative numbers indicate multiarg functions. |
a_pFun | Pointer to function callback. |
Definition at line 387 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddFun | ( | generic_fun_type | a_pFun, |
int | a_iArgc | ||
) |
Add function to bytecode.
a_iArgc | Number of arguments, negative numbers indicate multiarg functions. |
a_pFun | Pointer to function callback. |
Definition at line 361 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddIfElse | ( | ECmdCode | a_Oprt | ) |
Definition at line 327 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddOp | ( | ECmdCode | a_Oprt | ) |
Add an operator identifier to bytecode.
Operator entries in byte code consist of:
Definition at line 194 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddStrFun | ( | generic_fun_type | a_pFun, |
int | a_iArgc, | ||
int | a_iIdx | ||
) |
Add Strung function entry to the parser bytecode.
nothrow | A string function entry consists of the stack position of the return value, followed by a cmSTRFUNC code, the function pointer and an index into the string buffer maintained by the parser. |
Definition at line 407 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddVal | ( | value_type | a_fVal | ) |
Add a Variable pointer to bytecode.
Value entries in byte code consist of:
a_pVal | Value to be added. |
nothrow |
Definition at line 130 of file muParserBytecode.cpp.
void mu::ParserByteCode::AddVar | ( | value_type * | a_pVar | ) |
Add a Variable pointer to bytecode.
a_pVar | Pointer to be added. |
nothrow |
Definition at line 103 of file muParserBytecode.cpp.
void mu::ParserByteCode::AsciiDump | ( | ) |
Dump bytecode (for debugging only!).
Definition at line 501 of file muParserBytecode.cpp.
void mu::ParserByteCode::Assign | ( | const ParserByteCode & | a_ByteCode | ) |
Copy state of another object to this.
nowthrow |
Definition at line 87 of file muParserBytecode.cpp.
void mu::ParserByteCode::clear | ( | ) |
Delete the bytecode.
nothrow | The name of this function is a violation of my own coding guidelines but this way it's more in line with the STL functions thus more intuitive. |
Definition at line 492 of file muParserBytecode.cpp.
|
private |
Definition at line 145 of file muParserBytecode.cpp.
void mu::ParserByteCode::EnableOptimizer | ( | bool | bStat | ) |
Definition at line 77 of file muParserBytecode.cpp.
void mu::ParserByteCode::Finalize | ( | ) |
const SToken * mu::ParserByteCode::GetBase | ( | ) | const |
Definition at line 462 of file muParserBytecode.cpp.
std::size_t mu::ParserByteCode::GetMaxStackSize | ( | ) | const |
Definition at line 471 of file muParserBytecode.cpp.
std::size_t mu::ParserByteCode::GetSize | ( | ) | const |
Returns the number of entries in the bytecode.
Definition at line 478 of file muParserBytecode.cpp.
ParserByteCode & mu::ParserByteCode::operator= | ( | const ParserByteCode & | a_ByteCode | ) |
Assignment operator.
Implemented in Terms of Assign(const ParserByteCode &a_ByteCode)
Definition at line 70 of file muParserBytecode.cpp.
|
private |
Definition at line 106 of file muParserBytecode.h.
|
private |
Maximum size needed for the stack.
Definition at line 101 of file muParserBytecode.h.
|
private |
Position in the Calculation array.
Definition at line 98 of file muParserBytecode.h.
|
private |
The actual rpn storage.
Definition at line 104 of file muParserBytecode.h.