#include <muParserBytecode.h>
Public Types | |
typedef bytecode_type | map_type |
Underlying type of the container. | |
Public Member Functions | |
ParserByteCode () | |
~ParserByteCode () | |
Destructor (trivial). | |
ParserByteCode (const ParserByteCode &a_ByteCode) | |
Copy constructor. | |
ParserByteCode & | operator= (const ParserByteCode &a_ByteCode) |
Assignment operator. | |
void | Assign (const ParserByteCode &a_ByteCode) |
Copy state of another object to this. | |
void | AddVar (value_type *a_pVar) |
Add a Variable pointer to bytecode. | |
void | AddVal (value_type a_fVal) |
Add a Variable pointer to bytecode. | |
void | AddOp (ECmdCode a_Oprt) |
Add an operator identifier to bytecode. | |
void | AddAssignOp (value_type *a_pVar) |
Add an assignement operator. | |
void | AddFun (void *a_pFun, int a_iArgc) |
Add function to bytecode. | |
void | AddStrFun (void *a_pFun, int a_iArgc, int a_iIdx) |
Add Strung function entry to the parser bytecode. | |
void | Finalize () |
Add end marker to bytecode. | |
void | clear () |
Delete the bytecode. | |
std::size_t | GetBufSize () const |
const map_type * | GetRawData () const |
Get Pointer to bytecode data storage. | |
unsigned | GetValSize () const |
Return size of a value entry. | |
unsigned | GetPtrSize () const |
Return size of a pointer entry. | |
void | RemoveValEntries (unsigned a_iNumber) |
Remove a value number of entries from the bytecode. | |
void | AsciiDump () |
Dump bytecode (for debugging only!). | |
Private Types | |
typedef ParserToken < value_type, string_type > | token_type |
Token type for internal use only. | |
typedef std::vector< map_type > | storage_type |
Core type of the bytecode. | |
Private Member Functions | |
void | StorePtr (void *a_pAddr) |
Store an address in bytecode. | |
Private Attributes | |
unsigned | m_iStackPos |
Position in the Calculation array. | |
storage_type | m_vBase |
Core type of the bytecode. | |
const int | mc_iSizeVal |
Size of a value entry in the bytecode, relative to TMapType size. | |
const int | mc_iSizePtr |
Size of a pointer, relative to size of underlying TMapType. | |
const int | mc_iSizeValEntry |
A value entry requires that much entires in the bytecode. |
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.
Underlying type of the container.
The bytecode is a vector of this type containing control codes, values and pointers. Values and pointer will be casted to this type before their storage.
mu::ParserByteCode::ParserByteCode | ( | ) |
Bytecode default constructor.
References m_vBase.
mu::ParserByteCode::ParserByteCode | ( | const ParserByteCode & | a_ByteCode | ) |
Copy constructor.
Implemented in Terms of Assign(const ParserByteCode &a_ByteCode)
References Assign().
void mu::ParserByteCode::StorePtr | ( | void * | a_pAddr | ) | [private] |
Store an address in bytecode.
a_pAddr | Address to be stored. |
nothrow |
References m_vBase, and mc_iSizePtr.
Referenced by AddAssignOp(), AddFun(), AddStrFun(), and AddVar().
ParserByteCode & mu::ParserByteCode::operator= | ( | const ParserByteCode & | a_ByteCode | ) |
Assignment operator.
Implemented in Terms of Assign(const ParserByteCode &a_ByteCode)
References Assign().
void mu::ParserByteCode::Assign | ( | const ParserByteCode & | a_ByteCode | ) |
Copy state of another object to this.
nowthrow |
References m_iStackPos, and m_vBase.
Referenced by operator=(), and ParserByteCode().
void mu::ParserByteCode::AddVar | ( | value_type * | a_pVar | ) |
Add a Variable pointer to bytecode.
a_pVar | Pointer to be added. |
nothrow |
References mu::cmVAR, m_iStackPos, m_vBase, mc_iSizePtr, mc_iSizeVal, and StorePtr().
Referenced by mu::ParserBase::ParseString().
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 |
References mu::cmVAL, m_iStackPos, m_vBase, and mc_iSizeVal.
Referenced by mu::ParserBase::ApplyNumFunc(), and mu::ParserBase::ParseString().
void mu::ParserByteCode::AddOp | ( | ECmdCode | a_Oprt | ) |
Add an operator identifier to bytecode.
Operator entries in byte code consist of:
References m_iStackPos, and m_vBase.
void mu::ParserByteCode::AddAssignOp | ( | value_type * | a_pVar | ) |
Add an assignement operator.
Operator entries in byte code consist of:
References mu::cmASSIGN, m_iStackPos, m_vBase, and StorePtr().
void mu::ParserByteCode::AddFun | ( | void * | 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. |
References mu::cmFUNC, m_iStackPos, m_vBase, and StorePtr().
Referenced by mu::ParserBase::ApplyNumFunc().
void mu::ParserByteCode::AddStrFun | ( | void * | 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. |
References mu::cmFUNC_STR, m_iStackPos, m_vBase, and StorePtr().
Referenced by mu::ParserBase::ApplyStrFunc().
void mu::ParserByteCode::Finalize | ( | ) |
Add end marker to bytecode.
nothrow |
References mu::cmEND, and m_vBase.
Referenced by mu::ParserBase::ParseString().
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. |
References m_iStackPos, and m_vBase.
Referenced by mu::ParserBase::ClearFormula(), and mu::ParserBase::ReInit().
unsigned mu::ParserByteCode::GetValSize | ( | ) | const [inline] |
Return size of a value entry.
That many bytecode entries are necessary to store a value.
References mc_iSizeVal.
Referenced by mu::ParserBase::ParseCmdCode(), and mu::ParserBase::ParseString().
unsigned mu::ParserByteCode::GetPtrSize | ( | ) | const [inline] |
Return size of a pointer entry.
That many bytecode entries are necessary to store a pointer.
References mc_iSizePtr.
Referenced by mu::ParserBase::ParseCmdCode().
void mu::ParserByteCode::RemoveValEntries | ( | unsigned | a_iNumber | ) |
Remove a value number of entries from the bytecode.
References m_iStackPos, m_vBase, and mc_iSizeValEntry.
Referenced by mu::ParserBase::ApplyNumFunc().
const int mu::ParserByteCode::mc_iSizePtr [private] |
Size of a pointer, relative to size of underlying TMapType.
Referenced by AddVar(), AsciiDump(), GetPtrSize(), and StorePtr().
const int mu::ParserByteCode::mc_iSizeValEntry [private] |
A value entry requires that much entires in the bytecode.
Value entry consists of:
Referenced by RemoveValEntries().