// Bugfix for Bulkmode:\r
// for details see:\r
// https://groups.google.com/forum/embed/?place=forum/muparser-dev&showsearch=true&showpopout=true&showtabs=false&parenturl=http://muparser.beltoforion.de/mup_forum.html&afterlogin&pli=1#!topic/muparser-dev/szgatgoHTws\r
- --sidx; Stack[sidx] = *(pTok->Oprt.ptr + nOffset) = Stack[sidx + 1]; continue;\r
+ --sidx; Stack[sidx] = *(pTok->u.Oprt.ptr + nOffset) = Stack[sidx + 1]; continue;\r
// original code:\r
- //--sidx; Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; continue;\r
+ //--sidx; Stack[sidx] = *pTok->u.Oprt.ptr = Stack[sidx+1]; continue;\r
\r
//case cmBO: // unused, listed for compiler optimization purposes\r
//case cmBC:\r
\r
case cmIF:\r
if (Stack[sidx--]==0)\r
- pTok += pTok->Oprt.offset;\r
+ pTok += pTok->u.Oprt.offset;\r
continue;\r
\r
case cmELSE:\r
- pTok += pTok->Oprt.offset;\r
+ pTok += pTok->u.Oprt.offset;\r
continue;\r
\r
case cmENDIF:\r
// continue;\r
\r
// value and variable tokens\r
- case cmVAR: Stack[++sidx] = *(pTok->Val.ptr + nOffset); continue;\r
- case cmVAL: Stack[++sidx] = pTok->Val.data2; continue;\r
+ case cmVAR: Stack[++sidx] = *(pTok->u.Val.ptr + nOffset); continue;\r
+ case cmVAL: Stack[++sidx] = pTok->u.Val.data2; continue;\r
\r
- case cmVARPOW2: buf = *(pTok->Val.ptr + nOffset);\r
+ case cmVARPOW2: buf = *(pTok->u.Val.ptr + nOffset);\r
Stack[++sidx] = buf*buf;\r
continue;\r
\r
- case cmVARPOW3: buf = *(pTok->Val.ptr + nOffset);\r
+ case cmVARPOW3: buf = *(pTok->u.Val.ptr + nOffset);\r
Stack[++sidx] = buf*buf*buf;\r
continue;\r
\r
- case cmVARPOW4: buf = *(pTok->Val.ptr + nOffset);\r
+ case cmVARPOW4: buf = *(pTok->u.Val.ptr + nOffset);\r
Stack[++sidx] = buf*buf*buf*buf;\r
continue;\r
\r
- case cmVARMUL: Stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2;\r
+ case cmVARMUL: Stack[++sidx] = *(pTok->u.Val.ptr + nOffset) * pTok->u.Val.data + pTok->u.Val.data2;\r
continue;\r
\r
// Next is treatment of numeric functions\r
case cmFUNC:\r
{\r
- int iArgCount = pTok->Fun.argc;\r
+ int iArgCount = pTok->u.Fun.argc;\r
\r
// switch according to argument count\r
switch(iArgCount) \r
{\r
- case 0: sidx += 1; Stack[sidx] = (*(fun_type0)pTok->Fun.ptr)(); continue;\r
- case 1: Stack[sidx] = (*(fun_type1)pTok->Fun.ptr)(Stack[sidx]); continue;\r
- case 2: sidx -= 1; Stack[sidx] = (*(fun_type2)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1]); continue;\r
- case 3: sidx -= 2; Stack[sidx] = (*(fun_type3)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue;\r
- case 4: sidx -= 3; Stack[sidx] = (*(fun_type4)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue;\r
- case 5: sidx -= 4; Stack[sidx] = (*(fun_type5)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue;\r
- case 6: sidx -= 5; Stack[sidx] = (*(fun_type6)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue;\r
- case 7: sidx -= 6; Stack[sidx] = (*(fun_type7)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue;\r
- case 8: sidx -= 7; Stack[sidx] = (*(fun_type8)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue;\r
- case 9: sidx -= 8; Stack[sidx] = (*(fun_type9)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue;\r
- case 10:sidx -= 9; Stack[sidx] = (*(fun_type10)pTok->Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue;\r
+ case 0: sidx += 1; Stack[sidx] = (*(fun_type0)pTok->u.Fun.ptr)(); continue;\r
+ case 1: Stack[sidx] = (*(fun_type1)pTok->u.Fun.ptr)(Stack[sidx]); continue;\r
+ case 2: sidx -= 1; Stack[sidx] = (*(fun_type2)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1]); continue;\r
+ case 3: sidx -= 2; Stack[sidx] = (*(fun_type3)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue;\r
+ case 4: sidx -= 3; Stack[sidx] = (*(fun_type4)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue;\r
+ case 5: sidx -= 4; Stack[sidx] = (*(fun_type5)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue;\r
+ case 6: sidx -= 5; Stack[sidx] = (*(fun_type6)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue;\r
+ case 7: sidx -= 6; Stack[sidx] = (*(fun_type7)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue;\r
+ case 8: sidx -= 7; Stack[sidx] = (*(fun_type8)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue;\r
+ case 9: sidx -= 8; Stack[sidx] = (*(fun_type9)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue;\r
+ case 10:sidx -= 9; Stack[sidx] = (*(fun_type10)pTok->u.Fun.ptr)(Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue;\r
default:\r
if (iArgCount>0) // function with variable arguments store the number as a negative value\r
Error(ecINTERNAL_ERROR, 1);\r
\r
sidx -= -iArgCount - 1;\r
- Stack[sidx] =(*(multfun_type)pTok->Fun.ptr)(&Stack[sidx], -iArgCount);\r
+ Stack[sidx] =(*(multfun_type)pTok->u.Fun.ptr)(&Stack[sidx], -iArgCount);\r
continue;\r
}\r
}\r
// Next is treatment of string functions\r
case cmFUNC_STR:\r
{\r
- sidx -= pTok->Fun.argc -1;\r
+ sidx -= pTok->u.Fun.argc -1;\r
\r
// The index of the string argument in the string table\r
- int iIdxStack = pTok->Fun.idx; \r
+ int iIdxStack = pTok->u.Fun.idx; \r
MUP_ASSERT( iIdxStack>=0 && iIdxStack<(int)m_vStringBuf.size() );\r
\r
- switch(pTok->Fun.argc) // switch according to argument count\r
+ switch(pTok->u.Fun.argc) // switch according to argument count\r
{\r
- case 0: Stack[sidx] = (*(strfun_type1)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str()); continue;\r
- case 1: Stack[sidx] = (*(strfun_type2)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx]); continue;\r
- case 2: Stack[sidx] = (*(strfun_type3)pTok->Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx], Stack[sidx+1]); continue;\r
+ case 0: Stack[sidx] = (*(strfun_type1)pTok->u.Fun.ptr)(m_vStringBuf[iIdxStack].c_str()); continue;\r
+ case 1: Stack[sidx] = (*(strfun_type2)pTok->u.Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx]); continue;\r
+ case 2: Stack[sidx] = (*(strfun_type3)pTok->u.Fun.ptr)(m_vStringBuf[iIdxStack].c_str(), Stack[sidx], Stack[sidx+1]); continue;\r
}\r
\r
continue;\r
\r
case cmFUNC_BULK:\r
{\r
- int iArgCount = pTok->Fun.argc;\r
+ int iArgCount = pTok->u.Fun.argc;\r
\r
// switch according to argument count\r
switch(iArgCount) \r
{\r
- case 0: sidx += 1; Stack[sidx] = (*(bulkfun_type0 )pTok->Fun.ptr)(nOffset, nThreadID); continue;\r
- case 1: Stack[sidx] = (*(bulkfun_type1 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx]); continue;\r
- case 2: sidx -= 1; Stack[sidx] = (*(bulkfun_type2 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1]); continue;\r
- case 3: sidx -= 2; Stack[sidx] = (*(bulkfun_type3 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue;\r
- case 4: sidx -= 3; Stack[sidx] = (*(bulkfun_type4 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue;\r
- case 5: sidx -= 4; Stack[sidx] = (*(bulkfun_type5 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue;\r
- case 6: sidx -= 5; Stack[sidx] = (*(bulkfun_type6 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue;\r
- case 7: sidx -= 6; Stack[sidx] = (*(bulkfun_type7 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue;\r
- case 8: sidx -= 7; Stack[sidx] = (*(bulkfun_type8 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue;\r
- case 9: sidx -= 8; Stack[sidx] = (*(bulkfun_type9 )pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue;\r
- case 10:sidx -= 9; Stack[sidx] = (*(bulkfun_type10)pTok->Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue;\r
+ case 0: sidx += 1; Stack[sidx] = (*(bulkfun_type0 )pTok->u.Fun.ptr)(nOffset, nThreadID); continue;\r
+ case 1: Stack[sidx] = (*(bulkfun_type1 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx]); continue;\r
+ case 2: sidx -= 1; Stack[sidx] = (*(bulkfun_type2 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1]); continue;\r
+ case 3: sidx -= 2; Stack[sidx] = (*(bulkfun_type3 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2]); continue;\r
+ case 4: sidx -= 3; Stack[sidx] = (*(bulkfun_type4 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); continue;\r
+ case 5: sidx -= 4; Stack[sidx] = (*(bulkfun_type5 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); continue;\r
+ case 6: sidx -= 5; Stack[sidx] = (*(bulkfun_type6 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); continue;\r
+ case 7: sidx -= 6; Stack[sidx] = (*(bulkfun_type7 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); continue;\r
+ case 8: sidx -= 7; Stack[sidx] = (*(bulkfun_type8 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); continue;\r
+ case 9: sidx -= 8; Stack[sidx] = (*(bulkfun_type9 )pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); continue;\r
+ case 10:sidx -= 9; Stack[sidx] = (*(bulkfun_type10)pTok->u.Fun.ptr)(nOffset, nThreadID, Stack[sidx], Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); continue;\r
default:\r
Error(ecINTERNAL_ERROR, 2);\r
continue;\r
// optimization does not apply\r
SToken tok;\r
tok.Cmd = cmVAR;\r
- tok.Val.ptr = a_pVar;\r
- tok.Val.data = 1;\r
- tok.Val.data2 = 0;\r
+ tok.u.Val.ptr = a_pVar;\r
+ tok.u.Val.data = 1;\r
+ tok.u.Val.data2 = 0;\r
m_vRPN.push_back(tok);\r
}\r
\r
// If optimization does not apply\r
SToken tok;\r
tok.Cmd = cmVAL;\r
- tok.Val.ptr = NULL;\r
- tok.Val.data = 0;\r
- tok.Val.data2 = a_fVal;\r
+ tok.u.Val.ptr = NULL;\r
+ tok.u.Val.data = 0;\r
+ tok.u.Val.data2 = a_fVal;\r
m_vRPN.push_back(tok);\r
}\r
\r
void ParserByteCode::ConstantFolding(ECmdCode a_Oprt)\r
{\r
std::size_t sz = m_vRPN.size();\r
- value_type &x = m_vRPN[sz-2].Val.data2,\r
- &y = m_vRPN[sz-1].Val.data2;\r
+ value_type &x = m_vRPN[sz-2].u.Val.data2,\r
+ &y = m_vRPN[sz-1].u.Val.data2;\r
switch (a_Oprt)\r
{\r
case cmLAND: x = (int)x && (int)y; m_vRPN.pop_back(); break;\r
// Optimization for ploynomials of low order\r
if (m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-1].Cmd == cmVAL)\r
{\r
- if (m_vRPN[sz-1].Val.data2==2)\r
+ if (m_vRPN[sz-1].u.Val.data2==2)\r
m_vRPN[sz-2].Cmd = cmVARPOW2;\r
- else if (m_vRPN[sz-1].Val.data2==3)\r
+ else if (m_vRPN[sz-1].u.Val.data2==3)\r
m_vRPN[sz-2].Cmd = cmVARPOW3;\r
- else if (m_vRPN[sz-1].Val.data2==4)\r
+ else if (m_vRPN[sz-1].u.Val.data2==4)\r
m_vRPN[sz-2].Cmd = cmVARPOW4;\r
else\r
break;\r
(m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) || \r
(m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL) ||\r
(m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAL) ||\r
- (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ||\r
- (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ||\r
- (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ||\r
- (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) )\r
+ (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].u.Val.ptr == m_vRPN[sz-1].u.Val.ptr) ||\r
+ (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].u.Val.ptr == m_vRPN[sz-1].u.Val.ptr) ||\r
+ (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-2].u.Val.ptr == m_vRPN[sz-1].u.Val.ptr) ||\r
+ (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-2].u.Val.ptr == m_vRPN[sz-1].u.Val.ptr) )\r
{\r
- assert( (m_vRPN[sz-2].Val.ptr==NULL && m_vRPN[sz-1].Val.ptr!=NULL) ||\r
- (m_vRPN[sz-2].Val.ptr!=NULL && m_vRPN[sz-1].Val.ptr==NULL) || \r
- (m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) );\r
+ assert( (m_vRPN[sz-2].u.Val.ptr==NULL && m_vRPN[sz-1].u.Val.ptr!=NULL) ||\r
+ (m_vRPN[sz-2].u.Val.ptr!=NULL && m_vRPN[sz-1].u.Val.ptr==NULL) || \r
+ (m_vRPN[sz-2].u.Val.ptr == m_vRPN[sz-1].u.Val.ptr) );\r
\r
m_vRPN[sz-2].Cmd = cmVARMUL;\r
- m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr)); // variable\r
- m_vRPN[sz-2].Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data2; // offset\r
- m_vRPN[sz-2].Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data; // multiplikatior\r
+ m_vRPN[sz-2].u.Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].u.Val.ptr) | (long long)(m_vRPN[sz-1].u.Val.ptr)); // variable\r
+ m_vRPN[sz-2].u.Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].u.Val.data2; // offset\r
+ m_vRPN[sz-2].u.Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].u.Val.data; // multiplikatior\r
m_vRPN.pop_back();\r
bOptimized = true;\r
} \r
(m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) ) \r
{\r
m_vRPN[sz-2].Cmd = cmVARMUL;\r
- m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr));\r
- m_vRPN[sz-2].Val.data = m_vRPN[sz-2].Val.data2 + m_vRPN[sz-1].Val.data2;\r
- m_vRPN[sz-2].Val.data2 = 0;\r
+ m_vRPN[sz-2].u.Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].u.Val.ptr) | (long long)(m_vRPN[sz-1].u.Val.ptr));\r
+ m_vRPN[sz-2].u.Val.data = m_vRPN[sz-2].u.Val.data2 + m_vRPN[sz-1].u.Val.data2;\r
+ m_vRPN[sz-2].u.Val.data2 = 0;\r
m_vRPN.pop_back();\r
bOptimized = true;\r
} \r
{\r
// Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2\r
m_vRPN[sz-2].Cmd = cmVARMUL;\r
- m_vRPN[sz-2].Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].Val.ptr) | (long long)(m_vRPN[sz-1].Val.ptr));\r
+ m_vRPN[sz-2].u.Val.ptr = (value_type*)((long long)(m_vRPN[sz-2].u.Val.ptr) | (long long)(m_vRPN[sz-1].u.Val.ptr));\r
if (m_vRPN[sz-1].Cmd == cmVAL)\r
{\r
- m_vRPN[sz-2].Val.data *= m_vRPN[sz-1].Val.data2;\r
- m_vRPN[sz-2].Val.data2 *= m_vRPN[sz-1].Val.data2;\r
+ m_vRPN[sz-2].u.Val.data *= m_vRPN[sz-1].u.Val.data2;\r
+ m_vRPN[sz-2].u.Val.data2 *= m_vRPN[sz-1].u.Val.data2;\r
}\r
else\r
{\r
- m_vRPN[sz-2].Val.data = m_vRPN[sz-1].Val.data * m_vRPN[sz-2].Val.data2;\r
- m_vRPN[sz-2].Val.data2 = m_vRPN[sz-1].Val.data2 * m_vRPN[sz-2].Val.data2;\r
+ m_vRPN[sz-2].u.Val.data = m_vRPN[sz-1].u.Val.data * m_vRPN[sz-2].u.Val.data2;\r
+ m_vRPN[sz-2].u.Val.data2 = m_vRPN[sz-1].u.Val.data2 * m_vRPN[sz-2].u.Val.data2;\r
}\r
m_vRPN.pop_back();\r
bOptimized = true;\r
}\r
else if (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR &&\r
- m_vRPN[sz-1].Val.ptr == m_vRPN[sz-2].Val.ptr)\r
+ m_vRPN[sz-1].u.Val.ptr == m_vRPN[sz-2].u.Val.ptr)\r
{\r
// Optimization: a*a -> a^2\r
m_vRPN[sz-2].Cmd = cmVARPOW2;\r
break;\r
\r
case cmDIV:\r
- if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-1].Val.data2!=0)\r
+ if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL && m_vRPN[sz-1].u.Val.data2!=0)\r
{\r
// Optimization: 4*a/2 -> 2*a\r
- m_vRPN[sz-2].Val.data /= m_vRPN[sz-1].Val.data2;\r
- m_vRPN[sz-2].Val.data2 /= m_vRPN[sz-1].Val.data2;\r
+ m_vRPN[sz-2].u.Val.data /= m_vRPN[sz-1].u.Val.data2;\r
+ m_vRPN[sz-2].u.Val.data2 /= m_vRPN[sz-1].u.Val.data2;\r
m_vRPN.pop_back();\r
bOptimized = true;\r
}\r
\r
SToken tok;\r
tok.Cmd = cmASSIGN;\r
- tok.Oprt.ptr = a_pVar;\r
+ tok.u.Oprt.ptr = a_pVar;\r
m_vRPN.push_back(tok);\r
}\r
\r
\r
SToken tok;\r
tok.Cmd = cmFUNC;\r
- tok.Fun.argc = a_iArgc;\r
- tok.Fun.ptr = a_pFun;\r
+ tok.u.Fun.argc = a_iArgc;\r
+ tok.u.Fun.ptr = a_pFun;\r
m_vRPN.push_back(tok);\r
}\r
\r
\r
SToken tok;\r
tok.Cmd = cmFUNC_BULK;\r
- tok.Fun.argc = a_iArgc;\r
- tok.Fun.ptr = a_pFun;\r
+ tok.u.Fun.argc = a_iArgc;\r
+ tok.u.Fun.ptr = a_pFun;\r
m_vRPN.push_back(tok);\r
}\r
\r
\r
SToken tok;\r
tok.Cmd = cmFUNC_STR;\r
- tok.Fun.argc = a_iArgc;\r
- tok.Fun.idx = a_iIdx;\r
- tok.Fun.ptr = a_pFun;\r
+ tok.u.Fun.argc = a_iArgc;\r
+ tok.u.Fun.idx = a_iIdx;\r
+ tok.u.Fun.ptr = a_pFun;\r
m_vRPN.push_back(tok);\r
\r
m_iMaxStackSize = std::max(m_iMaxStackSize, (size_t)m_iStackPos);\r
case cmELSE:\r
stElse.push(i);\r
idx = stIf.pop();\r
- m_vRPN[idx].Oprt.offset = i - idx;\r
+ m_vRPN[idx].u.Oprt.offset = i - idx;\r
break;\r
\r
case cmENDIF:\r
idx = stElse.pop();\r
- m_vRPN[idx].Oprt.offset = i - idx;\r
+ m_vRPN[idx].u.Oprt.offset = i - idx;\r
break;\r
\r
default:\r
switch (m_vRPN[i].Cmd)\r
{\r
case cmVAL: mu::console() << _T("VAL \t");\r
- mu::console() << _T("[") << m_vRPN[i].Val.data2 << _T("]\n");\r
+ mu::console() << _T("[") << m_vRPN[i].u.Val.data2 << _T("]\n");\r
break;\r
\r
case cmVAR: mu::console() << _T("VAR \t");\r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); \r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Val.ptr << _T("]\n"); \r
break;\r
\r
case cmVARPOW2: mu::console() << _T("VARPOW2 \t");\r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); \r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Val.ptr << _T("]\n"); \r
break;\r
\r
case cmVARPOW3: mu::console() << _T("VARPOW3 \t");\r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); \r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Val.ptr << _T("]\n"); \r
break;\r
\r
case cmVARPOW4: mu::console() << _T("VARPOW4 \t");\r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]\n"); \r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Val.ptr << _T("]\n"); \r
break;\r
\r
case cmVARMUL: mu::console() << _T("VARMUL \t");\r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Val.ptr << _T("]"); \r
- mu::console() << _T(" * [") << m_vRPN[i].Val.data << _T("]");\r
- mu::console() << _T(" + [") << m_vRPN[i].Val.data2 << _T("]\n");\r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Val.ptr << _T("]"); \r
+ mu::console() << _T(" * [") << m_vRPN[i].u.Val.data << _T("]");\r
+ mu::console() << _T(" + [") << m_vRPN[i].u.Val.data2 << _T("]\n");\r
break;\r
\r
case cmFUNC: mu::console() << _T("CALL\t");\r
- mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]"); \r
- mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].Fun.ptr << _T("]"); \r
+ mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].u.Fun.argc << _T("]"); \r
+ mu::console() << _T("[ADDR: 0x") << std::hex << m_vRPN[i].u.Fun.ptr << _T("]"); \r
mu::console() << _T("\n");\r
break;\r
\r
case cmFUNC_STR:\r
mu::console() << _T("CALL STRFUNC\t");\r
- mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].Fun.argc << _T("]");\r
- mu::console() << _T("[IDX:") << std::dec << m_vRPN[i].Fun.idx << _T("]");\r
- mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Fun.ptr << _T("]\n"); \r
+ mu::console() << _T("[ARG:") << std::dec << m_vRPN[i].u.Fun.argc << _T("]");\r
+ mu::console() << _T("[IDX:") << std::dec << m_vRPN[i].u.Fun.idx << _T("]");\r
+ mu::console() << _T("[ADDR: 0x") << m_vRPN[i].u.Fun.ptr << _T("]\n"); \r
break;\r
\r
case cmLT: mu::console() << _T("LT\n"); break;\r
case cmPOW: mu::console() << _T("POW\n"); break;\r
\r
case cmIF: mu::console() << _T("IF\t");\r
- mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n");\r
+ mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].u.Oprt.offset << _T("]\n");\r
break;\r
\r
case cmELSE: mu::console() << _T("ELSE\t");\r
- mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].Oprt.offset << _T("]\n");\r
+ mu::console() << _T("[OFFSET:") << std::dec << m_vRPN[i].u.Oprt.offset << _T("]\n");\r
break;\r
\r
case cmENDIF: mu::console() << _T("ENDIF\n"); break;\r
\r
case cmASSIGN: \r
mu::console() << _T("ASSIGN\t");\r
- mu::console() << _T("[ADDR: 0x") << m_vRPN[i].Oprt.ptr << _T("]\n"); \r
+ mu::console() << _T("[ADDR: 0x") << m_vRPN[i].u.Oprt.ptr << _T("]\n"); \r
break; \r
\r
default: mu::console() << _T("(unknown code: ") << m_vRPN[i].Cmd << _T(")\n"); \r