KSeExpr
4.0.4.0
|
#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 {} |
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.
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.
using KSeExpr::Interpreter::VarToLoc = std::map<const ExprLocalVar *, int> |
Not needed for eval only building.
Definition at line 40 of file Interpreter.h.
|
inline |
Definition at line 54 of file Interpreter.h.
References s.
|
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::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreter(), KSeExpr::ExprIfThenElseNode::buildInterpreter(), KSeExpr::ExprAssignNode::buildInterpreter(), KSeExpr::ExprVecNode::buildInterpreter(), KSeExpr::ExprUnaryOpNode::buildInterpreter(), KSeExpr::ExprSubscriptNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall(), KSeExpr::copyVarToPromotedPosition(), and KSeExpr::Expression::prep().
|
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::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreter(), KSeExpr::ExprIfThenElseNode::buildInterpreter(), KSeExpr::ExprAssignNode::buildInterpreter(), KSeExpr::ExprVecNode::buildInterpreter(), KSeExpr::ExprUnaryOpNode::buildInterpreter(), KSeExpr::ExprSubscriptNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall(), KSeExpr::copyVarToPromotedPosition(), and KSeExpr::Expression::prep().
|
inline |
! Allocate a floating point set of data of dimension n
Definition at line 94 of file Interpreter.h.
References d.
Referenced by KSeExpr::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalVar::buildInterpreter(), KSeExpr::ExprVecNode::buildInterpreter(), KSeExpr::ExprUnaryOpNode::buildInterpreter(), KSeExpr::ExprSubscriptNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprNumNode::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall(), and KSeExpr::Expression::prep().
|
inline |
Allocate a pointer location (can be anything, but typically space for char*)
Definition at line 101 of file Interpreter.h.
References s.
Referenced by KSeExpr::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalVar::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprStrNode::buildInterpreter(), and KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall().
|
inline |
Definition at line 73 of file Interpreter.h.
References _startedOp, callStack, d, opData, ops, and s.
Referenced by KSeExpr::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreter(), KSeExpr::ExprIfThenElseNode::buildInterpreter(), KSeExpr::ExprAssignNode::buildInterpreter(), KSeExpr::ExprVecNode::buildInterpreter(), KSeExpr::ExprUnaryOpNode::buildInterpreter(), KSeExpr::ExprSubscriptNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall(), KSeExpr::copyVarToPromotedPosition(), and KSeExpr::Expression::prep().
void KSeExpr::Interpreter::eval | ( | VarBlock * | varBlock, |
bool | debug = false |
||
) |
Evaluate program.
Definition at line 20 of file Interpreter.cpp.
References _pcStart, callStack, d, KSeExpr::VarBlock::d, KSeExpr::VarBlock::data(), KSeExpr::VarBlock::indirectIndex, opData, ops, print(), s, KSeExpr::VarBlock::s, and KSeExpr::VarBlock::threadSafe.
Referenced by KSeExpr::Expression::evalFP(), and KSeExpr::Expression::evalStr().
|
inline |
Return the position that the next instruction will be placed at.
Definition at line 60 of file Interpreter.h.
References ops.
Referenced by KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreter(), KSeExpr::ExprIfThenElseNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), and KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall().
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().
|
inline |
Definition at line 112 of file Interpreter.h.
References _pcStart.
|
private |
Definition at line 51 of file Interpreter.h.
Referenced by eval(), and setPCStart().
|
private |
Definition at line 50 of file Interpreter.h.
Referenced by addOp(), addOperand(), and endOp().
std::vector<int> KSeExpr::Interpreter::callStack |
Definition at line 47 of file Interpreter.h.
Referenced by KSeExpr::ExprFuncSimple::buildInterpreter(), endOp(), and eval().
std::vector<double> KSeExpr::Interpreter::d |
Double data (constants and evaluated)
Definition at line 33 of file Interpreter.h.
Referenced by allocFP(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprNumNode::buildInterpreter(), endOp(), eval(), KSeExpr::Expression::evalFP(), and print().
std::vector<int> KSeExpr::Interpreter::opData |
Ooperands to op.
Definition at line 37 of file Interpreter.h.
Referenced by addOp(), addOperand(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprIfThenElseNode::buildInterpreter(), KSeExpr::ExprCompareNode::buildInterpreter(), KSeExpr::ExprLocalFunctionNode::buildInterpreterForCall(), endOp(), eval(), and print().
std::vector<std::pair<OpF, int> > KSeExpr::Interpreter::ops |
Definition at line 46 of file Interpreter.h.
Referenced by addOp(), KSeExpr::ExprFuncSimple::buildInterpreter(), endOp(), eval(), nextPC(), and print().
std::vector<char*> KSeExpr::Interpreter::s |
constant and evaluated pointer data
Definition at line 35 of file Interpreter.h.
Referenced by allocPtr(), KSeExpr::ExprFuncStandard::buildInterpreter(), KSeExpr::ExprFuncSimple::buildInterpreter(), KSeExpr::ExprBinaryOpNode::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), KSeExpr::ExprStrNode::buildInterpreter(), endOp(), eval(), KSeExpr::Expression::evalStr(), Interpreter(), and print().
VarToLoc KSeExpr::Interpreter::varToLoc {} |
Definition at line 41 of file Interpreter.h.
Referenced by KSeExpr::ExprLocalVar::buildInterpreter(), KSeExpr::ExprVarNode::buildInterpreter(), and KSeExpr::copyVarToPromotedPosition().