MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / Finalize

Method Finalize

libraries/muparser/src/muParserBytecode.cpp:492–527  ·  view source on GitHub ↗

\brief Add end marker to bytecode. \throw nothrow */

Source from the content-addressed store, hash-verified

490 \throw nothrow
491 */
492 void ParserByteCode::Finalize()
493 {
494 SToken tok;
495 tok.Cmd = cmEND;
496 m_vRPN.push_back(tok);
497 rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit
498
499 // Determine the if-then-else jump offsets
500 std::stack<int> stIf, stElse;
501 int idx;
502 for (int i = 0; i < (int)m_vRPN.size(); ++i)
503 {
504 switch (m_vRPN[i].Cmd)
505 {
506 case cmIF:
507 stIf.push(i);
508 break;
509
510 case cmELSE:
511 stElse.push(i);
512 idx = stIf.top();
513 stIf.pop();
514 m_vRPN[idx].Oprt.offset = i - idx;
515 break;
516
517 case cmENDIF:
518 idx = stElse.top();
519 stElse.pop();
520 m_vRPN[idx].Oprt.offset = i - idx;
521 break;
522
523 default:
524 break;
525 }
526 }
527 }
528
529
530 std::size_t ParserByteCode::GetMaxStackSize() const

Callers 1

CreateRPNMethod · 0.80

Calls 3

topMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected