KSeExpr 6.0.0.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.
 
using OpF = int(*)(int *, double *, char **, std::vector< int > &)
 Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStackurrS)
 

Public Member Functions

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

Public Attributes

std::vector< doubled
 Double data (constants and evaluated)
 
std::vector< char * > s
 constant and evaluated pointer data
 
std::vector< intopData
 Ooperands to op.
 
VarToLoc varToLoc {}
 
std::vector< std::pair< OpF, int > > ops
 
std::vector< intcallStack
 

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

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

! adds an operator to the program (pointing to the data at the current location)

Definition at line 63 of file Interpreter.h.

References _startedOp, opData, and ops.

Referenced by KSeExpr::Expression::prep().

◆ addOperand()

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

! Adds an operand. Note this should be done after doing the addOp!

Definition at line 86 of file Interpreter.h.

References _startedOp, and opData.

Referenced by KSeExpr::Expression::prep().

◆ allocFP()

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

! Allocate a floating point set of data of dimension n

Definition at line 94 of file Interpreter.h.

References d.

Referenced by KSeExpr::Expression::prep().

◆ allocPtr()

int KSeExpr::Interpreter::allocPtr ( )
inline

Allocate a pointer location (can be anything, but typically space for char*)

Definition at line 101 of file Interpreter.h.

References s.

◆ endOp()

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

Definition at line 73 of file Interpreter.h.

References _startedOp, callStack, d, opData, ops, and s.

Referenced by KSeExpr::Expression::prep().

◆ eval()

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

Evaluate program.

Definition at line 20 of file Interpreter.cpp.

References _pcStart, callStack, d, opData, ops, print(), and s.

Referenced by KSeExpr::Expression::evalFP(), and KSeExpr::Expression::evalStr().

◆ nextPC()

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

Return the position that the next instruction will be placed at.

Definition at line 60 of file Interpreter.h.

References ops.

◆ 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::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 endOp(), and eval().

◆ d

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

Double data (constants and evaluated)

Definition at line 33 of file Interpreter.h.

Referenced by allocFP(), endOp(), eval(), KSeExpr::Expression::evalFP(), and print().

◆ opData

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

Ooperands to op.

Definition at line 37 of file Interpreter.h.

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

◆ ops

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

Definition at line 46 of file Interpreter.h.

Referenced by addOp(), endOp(), eval(), nextPC(), and print().

◆ s

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

constant and evaluated pointer data

Definition at line 35 of file Interpreter.h.

Referenced by allocPtr(), endOp(), eval(), KSeExpr::Expression::evalStr(), Interpreter(), and print().

◆ varToLoc

VarToLoc KSeExpr::Interpreter::varToLoc {}

Definition at line 41 of file Interpreter.h.


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