KSeExpr  4.0.4.0
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
KSeExpr::Interpreter Class Reference

#include <Interpreter.h>

Public Types

using VarToLoc = std::map< const ExprLocalVar *, int >
 Not needed for eval only building. More...
 
using OpF = int(*)(int *, double *, char **, std::vector< int > &)
 Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStackurrS) More...
 

Public Member Functions

 Interpreter ()
 
int nextPC () const
 Return the position that the next instruction will be placed at. More...
 
int addOp (OpF op)
 ! adds an operator to the program (pointing to the data at the current location) More...
 
void endOp (bool execute=true)
 
int addOperand (int param)
 ! Adds an operand. Note this should be done after doing the addOp! More...
 
int allocFP (int n)
 ! Allocate a floating point set of data of dimension n More...
 
int allocPtr ()
 Allocate a pointer location (can be anything, but typically space for char*) More...
 
void eval (VarBlock *varBlock, bool debug=false)
 Evaluate program. More...
 
void print (int pc=-1) const
 Debug by printing program. More...
 
void setPCStart (int pcStart)
 

Public Attributes

std::vector< double > d
 Double data (constants and evaluated) More...
 
std::vector< char * > s
 constant and evaluated pointer data More...
 
std::vector< int > opData
 Ooperands to op. More...
 
VarToLoc varToLoc {}
 
std::vector< std::pair< OpF, int > > ops
 
std::vector< int > callStack
 

Private Attributes

bool _startedOp {}
 
int _pcStart {}
 

Detailed Description

Non-LLVM manual interpreter. This is a simple computation machine. There are no dynamic activation records just fixed locations, because we have no recursion!

Definition at line 30 of file Interpreter.h.

Member Typedef Documentation

◆ OpF

using KSeExpr::Interpreter::OpF = int (*)(int *, double *, char **, std::vector<int> &)

Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStackurrS)

Definition at line 44 of file Interpreter.h.

◆ VarToLoc

using KSeExpr::Interpreter::VarToLoc = std::map<const ExprLocalVar *, int>

Not needed for eval only building.

Definition at line 40 of file Interpreter.h.

Constructor & Destructor Documentation

◆ Interpreter()

KSeExpr::Interpreter::Interpreter ( )
inline

Definition at line 54 of file Interpreter.h.

References s.

Member Function Documentation

◆ addOp()

int KSeExpr::Interpreter::addOp ( OpF  op)
inline

◆ addOperand()

int KSeExpr::Interpreter::addOperand ( int  param)
inline

◆ allocFP()

int KSeExpr::Interpreter::allocFP ( int  n)
inline

◆ allocPtr()

int KSeExpr::Interpreter::allocPtr ( )
inline

◆ endOp()

void KSeExpr::Interpreter::endOp ( bool  execute = true)
inline

◆ eval()

void KSeExpr::Interpreter::eval ( VarBlock varBlock,
bool  debug = false 
)

◆ nextPC()

int KSeExpr::Interpreter::nextPC ( ) const
inline

◆ print()

void KSeExpr::Interpreter::print ( int  pc = -1) const

Debug by printing program.

Definition at line 58 of file Interpreter.cpp.

References d, opData, ops, and s.

Referenced by KSeExpr::ExprFuncStandard::buildInterpreter(), KSeExpr::Expression::debugPrintInterpreter(), eval(), and KSeExpr::Expression::prep().

◆ setPCStart()

void KSeExpr::Interpreter::setPCStart ( int  pcStart)
inline

Definition at line 112 of file Interpreter.h.

References _pcStart.

Member Data Documentation

◆ _pcStart

int KSeExpr::Interpreter::_pcStart {}
private

Definition at line 51 of file Interpreter.h.

Referenced by eval(), and setPCStart().

◆ _startedOp

bool KSeExpr::Interpreter::_startedOp {}
private

Definition at line 50 of file Interpreter.h.

Referenced by addOp(), addOperand(), and endOp().

◆ callStack

std::vector<int> KSeExpr::Interpreter::callStack

Definition at line 47 of file Interpreter.h.

Referenced by KSeExpr::ExprFuncSimple::buildInterpreter(), endOp(), and eval().

◆ d

std::vector<double> KSeExpr::Interpreter::d

◆ opData

std::vector<int> KSeExpr::Interpreter::opData

◆ ops

std::vector<std::pair<OpF, int> > KSeExpr::Interpreter::ops

◆ s

std::vector<char*> KSeExpr::Interpreter::s

◆ varToLoc

VarToLoc KSeExpr::Interpreter::varToLoc {}

The documentation for this class was generated from the following files: