SeExpr

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

`#include <Interpreter.h>`

## Public Types
typedef std::map< const ExprLocalVar *, int > | VarToLoc
| Not needed for eval only building. More...
typedef int(* | OpF) (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 ()
| 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 40 of file Interpreter.h.

## Member Typedef Documentation

## ◆ OpF

typedef int(* SeExpr2::Interpreter::OpF) (int *, double *, char **, std::vector< int > &)

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

Definition at line 54 of file Interpreter.h.

## ◆ VarToLoc

typedef std::map<const ExprLocalVar*, int> SeExpr2::Interpreter::VarToLoc

Not needed for eval only building.

Definition at line 50 of file Interpreter.h.

## Constructor & Destructor Documentation

## ◆ Interpreter()

SeExpr2::Interpreter::Interpreter | ( |  | ) |
| inline

Definition at line 64 of file Interpreter.h.

References s.

## Member Function Documentation

## ◆ addOp()

int SeExpr2::Interpreter::addOp | ( | OpF | op | ) |
| inline

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

Definition at line 73 of file Interpreter.h.

References _startedOp, opData, and ops.

Referenced by SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreter(), SeExpr2::ExprIfThenElseNode::buildInterpreter(), SeExpr2::ExprAssignNode::buildInterpreter(), SeExpr2::ExprVecNode::buildInterpreter(), SeExpr2::ExprUnaryOpNode::buildInterpreter(), SeExpr2::ExprSubscriptNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall(), SeExpr2::copyVarToPromotedPosition(), and SeExpr2::Expression::prep().

## ◆ addOperand()

int SeExpr2::Interpreter::addOperand | ( | int | param | ) |
| inline

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

Definition at line 96 of file Interpreter.h.

References _startedOp, and opData.

Referenced by SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreter(), SeExpr2::ExprIfThenElseNode::buildInterpreter(), SeExpr2::ExprAssignNode::buildInterpreter(), SeExpr2::ExprVecNode::buildInterpreter(), SeExpr2::ExprUnaryOpNode::buildInterpreter(), SeExpr2::ExprSubscriptNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall(), SeExpr2::copyVarToPromotedPosition(), and SeExpr2::Expression::prep().

## ◆ allocFP()

int SeExpr2::Interpreter::allocFP | ( | int | n | ) |
| inline

! Allocate a floating point set of data of dimension n

Definition at line 104 of file Interpreter.h.

References d.

Referenced by SeExpr2::ExprLocalVar::buildInterpreter(), SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprVecNode::buildInterpreter(), SeExpr2::ExprUnaryOpNode::buildInterpreter(), SeExpr2::ExprSubscriptNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprNumNode::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall(), and SeExpr2::Expression::prep().

## ◆ allocPtr()

int SeExpr2::Interpreter::allocPtr | ( |  | ) |
| inline

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

Definition at line 111 of file Interpreter.h.

References s.

Referenced by SeExpr2::ExprLocalVar::buildInterpreter(), SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprStrNode::buildInterpreter(), and SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall().

## ◆ endOp()

void SeExpr2::Interpreter::endOp | ( | bool | execute = `true` | ) |
| inline

Definition at line 83 of file Interpreter.h.

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

Referenced by SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreter(), SeExpr2::ExprIfThenElseNode::buildInterpreter(), SeExpr2::ExprAssignNode::buildInterpreter(), SeExpr2::ExprVecNode::buildInterpreter(), SeExpr2::ExprUnaryOpNode::buildInterpreter(), SeExpr2::ExprSubscriptNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall(), SeExpr2::copyVarToPromotedPosition(), and SeExpr2::Expression::prep().

## ◆ eval()

void SeExpr2::Interpreter::eval | ( | VarBlock * | varBlock,
|  | bool | debug = `false`
| ) |  |

Evaluate program.

Definition at line 31 of file Interpreter.cpp.

References _pcStart, callStack, d, SeExpr2::VarBlock::d, SeExpr2::VarBlock::data(), SeExpr2::VarBlock::indirectIndex, opData, ops, print(), s, SeExpr2::VarBlock::s, and SeExpr2::VarBlock::threadSafe.

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

## ◆ nextPC()

int SeExpr2::Interpreter::nextPC | ( |  | ) |
| inline

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

Definition at line 70 of file Interpreter.h.

References ops.

Referenced by SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreter(), SeExpr2::ExprIfThenElseNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), and SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall().

## ◆ print()

void SeExpr2::Interpreter::print | ( | int | pc = `-1` | ) | const

Debug by printing program.

Definition at line 69 of file Interpreter.cpp.

References d, endif(), opData, ops, and s.

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

## ◆ setPCStart()

void SeExpr2::Interpreter::setPCStart | ( | int | pcStart | ) |
| inline

Definition at line 122 of file Interpreter.h.

References _pcStart.

## Member Data Documentation

## ◆ _pcStart

int SeExpr2::Interpreter::_pcStart
| private

Definition at line 61 of file Interpreter.h.

Referenced by eval(), and setPCStart().

## ◆ _startedOp

bool SeExpr2::Interpreter::_startedOp
| private

Definition at line 60 of file Interpreter.h.

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

## ◆ callStack

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

Definition at line 57 of file Interpreter.h.

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

## ◆ d

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

Double data (constants and evaluated)

Definition at line 43 of file Interpreter.h.

Referenced by allocFP(), SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprNumNode::buildInterpreter(), endOp(), eval(), SeExpr2::Expression::evalFP(), and print().

## ◆ opData

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

Ooperands to op.

Definition at line 47 of file Interpreter.h.

Referenced by addOp(), addOperand(), SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprIfThenElseNode::buildInterpreter(), SeExpr2::ExprCompareNode::buildInterpreter(), SeExpr2::ExprLocalFunctionNode::buildInterpreterForCall(), endOp(), eval(), and print().

## ◆ ops

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

Definition at line 56 of file Interpreter.h.

Referenced by addOp(), SeExpr2::ExprFuncSimple::buildInterpreter(), endOp(), eval(), nextPC(), and print().

## ◆ s

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

constant and evaluated pointer data

Definition at line 45 of file Interpreter.h.

Referenced by allocPtr(), SeExpr2::ExprFuncSimple::buildInterpreter(), SeExpr2::ExprFuncStandard::buildInterpreter(), SeExpr2::ExprBinaryOpNode::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), SeExpr2::ExprStrNode::buildInterpreter(), endOp(), eval(), SeExpr2::Expression::evalStr(), Interpreter(), and print().

## ◆ varToLoc

VarToLoc SeExpr2::Interpreter::varToLoc

Definition at line 51 of file Interpreter.h.

Referenced by SeExpr2::ExprLocalVar::buildInterpreter(), SeExpr2::ExprVarNode::buildInterpreter(), and SeExpr2::copyVarToPromotedPosition().

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

- /build/seexpr/src/SeExpr/src/SeExpr2/Interpreter.h
- /build/seexpr/src/SeExpr/src/SeExpr2/Interpreter.cpp