// rpimpl_eval.cpp
// Copyright (c) Menno Rubingh 2016. Web: [http://rubinghsoftware.de]
//
// MR Mar 2016.
//
// Definition of the function 'evaluateRPExpression()':
// Evaluate ParsedOperationList (read-only),
// using a given VarTable instance (read + write) for the variables.
//
// Used internally in the RPInterpreter implementation.
//
//
#include "rpimpl_oplist.h" //ParsedOperationList.
#include "rpimpl_var.h" //VarTable.
#include "rpimpl_stack.h" //StackDbl.
#include "rpimpl_ex.h" //SContext, Ex.
void evaluateRPExpression(
ParsedOperationList const * iOpList,
VarTable * uVars )
{
StackDbl stack;
// Execute the OperationXxx instances.
for ( int k = 0; k < iOpList->getN(); k++ )
{
OperationBase const * pOp = iOpList->getElem(k);
pOp->execute( &stack, uVars );
}
// Check that the stack is now empty.
if ( stack.getN() != 0 )
{
SContext dummy; //Use char number == 0.
throw Ex( &dummy, "stacksize != 0 at end of expression" );
}
}