CXXR (C++ R)
Macros | Typedefs | Enumerations | Functions
eval.cpp File Reference

($Id: eval.cpp 1351 2013-03-08 15:12:28Z arr $)

#include <iostream>
#include <config.h>
#include <Defn.h>
#include <Rinterface.h>
#include <Fileio.h>
#include "arithmetic.h"
#include "basedecl.h"
#include "CXXR/ArgList.hpp"
#include "CXXR/BailoutContext.hpp"
#include "CXXR/ByteCode.hpp"
#include "CXXR/ClosureContext.hpp"
#include "CXXR/DottedArgs.hpp"
#include "CXXR/ListFrame.hpp"
#include "CXXR/LoopBailout.hpp"
#include "CXXR/LoopException.hpp"
#include "CXXR/PlainContext.hpp"
#include "CXXR/ProvenanceTracker.h"
#include "CXXR/ReturnBailout.hpp"
#include "CXXR/ReturnException.hpp"
#include "CXXR/S3Launcher.hpp"
#include "CXXR/ArgMatcher.hpp"
Include dependency graph for eval.cpp:

Macros

#define R_NO_REMAP
#define SET_TEMPVARLOC_FROM_CAR(loc, lhs)
#define simple_as_environment(arg)   (IS_S4_OBJECT(arg) && (TYPEOF(arg) == S4SXP) ? R_getS4DataSlot(arg, ENVSXP) : R_NilValue)
#define NSFROMEND(i)   (s_nodestack->fromEnd(i))
#define GETSTACK(i)   NSFROMEND(-i)
#define SETSTACK(i, v)   NSFROMEND(-i) = v
#define SETSTACK_REAL(i, v)   (NSFROMEND(-i) = Rf_ScalarReal(v))
#define SETSTACK_INTEGER(i, v)   (NSFROMEND(-i) = Rf_ScalarInteger(v))
#define SETSTACK_LOGICAL(i, v)
#define DO_FAST_RELOP2(op, a, b)
#define FastRelop2(op, opval, opsym)
#define Builtin1(do_fun, which, rho)
#define Builtin2(do_fun, which, rho)
#define NewBuiltin2(do_fun, opval, opsym, rho)
#define Arith1(opsym)
#define Arith2(opval, opsym)   NewBuiltin2(cmp_arith2,opval,opsym,rho)
#define Math1(which)   Builtin1(do_math1,which,rho)
#define Relop2(opval, opsym)   NewBuiltin2(cmp_relop,opval,opsym,rho)
#define DO_FAST_BINOP(op, a, b)
#define DO_FAST_BINOP_INT(op, a, b)
#define FastBinary(op, opval, opsym)
#define BCNPUSH(v)   (s_nodestack->push(v))
#define BCNDUP()   (s_nodestack->push(s_nodestack->fromEnd(1)))
#define BCNDUP2ND()   (s_nodestack->push(s_nodestack->fromEnd(2)))
#define BCNPOP(v)   (s_nodestack->topnpop())
#define BCNPOP_IGNORE_VALUE()   (s_nodestack->pop())
#define BCNSTACKCHECK(n)
#define BCIPUSHPTR(v)
#define BCIPUSHINT(v)
#define BCIPOPPTR()   ((--R_BCIntStackTop)->p)
#define BCIPOPINT()   ((--R_BCIntStackTop)->i)
#define BCCONSTS(e)   (SEXP_downcast<ByteCode*>(e)->constants())
#define OP(name, argc)   case name##_OP
#define BEGIN_MACHINE   loop: switch(*pc++)
#define LASTOP   default: Rf_error(_("Bad opcode"))
#define INITIALIZE_MACHINE()
#define NEXT()   goto loop
#define GETOP()   *pc++
#define SKIP_OP()   (pc++)
#define BINDING_SYMBOL(loc)   const_cast<Symbol*>(loc->symbol())
#define GET_CACHED_BINDING_CELL(vcache, sidx)   R_NilValue
#define GET_SMALLCACHE_BINDING_CELL(vcache, sidx)   R_NilValue
#define SET_CACHED_BINDING(vcache, sidx, cell)
#define MAYBE_MISSING_ARGUMENT_ERROR(symbol, keepmiss)   do { if (! keepmiss) MISSING_ARGUMENT_ERROR(symbol); } while (0)
#define INLINE_GETVAR
#define DO_GETVAR(dd, keepmiss)
#define PUSHCALLARG(v)   PUSHCALLARG_CELL(PairList::cons(v))
#define PUSHCALLARG_CELL(c)
#define DO_STARTDISPATCH(generic)
#define DO_DFLTDISPATCH(fun, symbol)
#define DO_START_ASSIGN_DISPATCH(generic)
#define DO_DFLT_ASSIGN_DISPATCH(fun, symbol)
#define DO_STARTDISPATCH_N(generic)
#define DO_START_ASSIGN_DISPATCH_N(generic)
#define DO_ISTEST(fun)
#define DO_ISTYPE(type)
#define isNumericOnly(x)   (Rf_isNumeric(x) && ! Rf_isLogical(x))
#define BC_COUNT_DELTA   1000
#define BC_CHECK_SIGINT()
#define DO_VECSUBSET(rho)
#define INTEGER_TO_REAL(x)   ((x) == NA_INTEGER ? NA_REAL : (x))
#define LOGICAL_TO_REAL(x)   ((x) == NA_LOGICAL ? NA_REAL : (x))
#define FIXUP_SCALAR_LOGICAL(callidx, arg, op)
#define GET_VEC_LOOP_VALUE(var, pos)
#define R_COMPILED_EXTENSION   ".Rc"

Typedefs

typedef int BCODE
typedef void * R_binding_cache_t

Enumerations

enum  { ,
  RETURN_OP, GOTO_OP, BRIFNOT_OP, POP_OP,
  DUP_OP, PRINTVALUE_OP, STARTLOOPCNTXT_OP, ENDLOOPCNTXT_OP,
  DOLOOPNEXT_OP, DOLOOPBREAK_OP, STARTFOR_OP, STEPFOR_OP,
  ENDFOR_OP, SETLOOPVAL_OP, INVISIBLE_OP, LDCONST_OP,
  LDNULL_OP, LDTRUE_OP, LDFALSE_OP, GETVAR_OP,
  DDVAL_OP, SETVAR_OP, GETFUN_OP, GETGLOBFUN_OP,
  GETSYMFUN_OP, GETBUILTIN_OP, GETINTLBUILTIN_OP, CHECKFUN_OP,
  MAKEPROM_OP, DOMISSING_OP, SETTAG_OP, DODOTS_OP,
  PUSHARG_OP, PUSHCONSTARG_OP, PUSHNULLARG_OP, PUSHTRUEARG_OP,
  PUSHFALSEARG_OP, CALL_OP, CALLBUILTIN_OP, CALLSPECIAL_OP,
  MAKECLOSURE_OP, UMINUS_OP, UPLUS_OP, ADD_OP,
  SUB_OP, MUL_OP, DIV_OP, EXPT_OP,
  SQRT_OP, EXP_OP, EQ_OP, NE_OP,
  LT_OP, LE_OP, GE_OP, GT_OP,
  AND_OP, OR_OP, NOT_OP, DOTSERR_OP,
  STARTASSIGN_OP, ENDASSIGN_OP, STARTSUBSET_OP, DFLTSUBSET_OP,
  STARTSUBASSIGN_OP, DFLTSUBASSIGN_OP, STARTC_OP, DFLTC_OP,
  STARTSUBSET2_OP, DFLTSUBSET2_OP, STARTSUBASSIGN2_OP, DFLTSUBASSIGN2_OP,
  DOLLAR_OP, DOLLARGETS_OP, ISNULL_OP, ISLOGICAL_OP,
  ISINTEGER_OP, ISDOUBLE_OP, ISCOMPLEX_OP, ISCHARACTER_OP,
  ISSYMBOL_OP, ISOBJECT_OP, ISNUMERIC_OP, VECSUBSET_OP,
  MATSUBSET_OP, SETVECSUBSET_OP, SETMATSUBSET_OP, AND1ST_OP,
  AND2ND_OP, OR1ST_OP, OR2ND_OP, GETVAR_MISSOK_OP,
  DDVAL_MISSOK_OP, VISIBLE_OP, SETVAR2_OP, STARTASSIGN2_OP,
  ENDASSIGN2_OP, SETTER_CALL_OP, GETTER_CALL_OP, SWAP_OP,
  DUP2ND_OP, SWITCH_OP, RETURNJMP_OP, STARTVECSUBSET_OP,
  STARTMATSUBSET_OP, STARTSETVECSUBSET_OP, STARTSETMATSUBSET_OP, OPCOUNT
}

Functions

SEXP attribute_hidden do_Rprof (SEXP call, SEXP op, SEXP args, SEXP rho)
attribute_hidden void Rf_SrcrefPrompt (const char *prefix, SEXP srcref)
void attribute_hidden R_init_jit_enabled (void)
SEXP attribute_hidden R_cmpfun (SEXP fun)
SEXP attribute_hidden do_enablejit (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_compilepkgs (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP R_execMethod (SEXP op, SEXP rho)
SEXP attribute_hidden do_if (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_for (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_while (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_repeat (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_break (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_paren (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_begin (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_return (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_function (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_set (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden Rf_evalListKeepMissing (SEXP el, SEXP rho)
SEXP attribute_hidden do_eval (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_withVisible (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_recall (SEXP call, SEXP op, SEXP args, SEXP rho)
attribute_hidden int Rf_DispatchOrEval (SEXP call, SEXP op, const char *generic, SEXP args, SEXP rho, SEXP *ans, int dropmissing, int argsevald)
attribute_hidden int Rf_DispatchGroup (const char *group, SEXP call, SEXP op, SEXP args, SEXP rho, SEXP *ans)
attribute_hidden void R_initialize_bcode (void)
SEXP R_PromiseExpr (SEXP p)
SEXP R_ClosureExpr (SEXP p)
SEXP attribute_hidden do_mkcode (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_bcclose (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_is_builtin_internal (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_disassemble (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_bcversion (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_loadfile (SEXP call, SEXP op, SEXP args, SEXP env)
SEXP attribute_hidden do_savefile (SEXP call, SEXP op, SEXP args, SEXP env)
char * R_CompiledFileName (char *fname, char *buf, std::size_t bsize)
FILE * R_OpenCompiledFile (char *fname, char *buf, std::size_t bsize)
SEXP attribute_hidden do_growconst (SEXP call, SEXP op, SEXP args, SEXP env)
SEXP attribute_hidden do_putconst (SEXP call, SEXP op, SEXP args, SEXP env)
SEXP attribute_hidden do_getconst (SEXP call, SEXP op, SEXP args, SEXP env)
SEXP R_getbcprofcounts ()
SEXP R_startbcprof ()
SEXP R_stopbcprof ()
SEXP attribute_hidden do_setnumthreads (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden do_setmaxnumthreads (SEXP call, SEXP op, SEXP args, SEXP rho)
SEXP attribute_hidden Rf_promiseArgs (SEXP el, SEXP rho)

Detailed Description

General evaluation of expressions, including implementation of R flow control constructs, and R profiling.


Macro Definition Documentation

#define Arith1 (   opsym)
Value:
do { \
SEXP call = (*constants)[GETOP()]; \
SEXP x = GETSTACK(-1); \
SETSTACK(-1, cmp_arith1(call, opsym, x, rho)); \
NEXT(); \
} while(0)
#define BC_CHECK_SIGINT ( )
Value:
do { \
if (++evalcount > BC_COUNT_DELTA) { \
R_CheckUserInterrupt(); \
evalcount = 0; \
} \
} while (0)
#define BCIPUSHINT (   v)
Value:
do { \
int __value__ = (v); \
IStackval *__ntop__ = R_BCIntStackTop + 1; \
if (__ntop__ > R_BCIntStackEnd) intStackOverflow(); \
__ntop__[-1].i = __value__; \
R_BCIntStackTop = __ntop__; \
} while (0)
#define BCIPUSHPTR (   v)
Value:
do { \
void *__value__ = (v); \
IStackval *__ntop__ = R_BCIntStackTop + 1; \
if (__ntop__ > R_BCIntStackEnd) intStackOverflow(); \
*__ntop__[-1].p = __value__; \
R_BCIntStackTop = __ntop__; \
} while (0)
#define Builtin1 (   do_fun,
  which,
  rho 
)
Value:
do { \
SEXP call = (*constants)[GETOP()]; \
SETSTACK(-1, CONS(GETSTACK(-1), R_NilValue)); \
SETSTACK(-1, do_fun(call, getPrimitive(which, BUILTINSXP), \
GETSTACK(-1), rho)); \
NEXT(); \
} while(0)
#define Builtin2 (   do_fun,
  which,
  rho 
)
Value:
do { \
SEXP call = (*constants)[GETOP()]; \
PairList* tmp = PairList::cons(GETSTACK(-1)); \
SETSTACK(-2, CONS(GETSTACK(-2), tmp)); \
s_nodestack->pop(); \
SETSTACK(-1, do_fun(call, getPrimitive(which, BUILTINSXP), \
GETSTACK(-1), rho)); \
NEXT(); \
} while(0)
#define DO_DFLT_ASSIGN_DISPATCH (   fun,
  symbol 
)
Value:
do { \
SEXP rhs = GETSTACK(-4); \
SEXP call = GETSTACK(-3); \
SEXP args = GETSTACK(-2); \
PUSHCALLARG(rhs); \
value = fun(call, symbol, args, rho); \
s_nodestack->pop(4); \
SETSTACK(-1, value); \
NEXT(); \
} while (0)
#define DO_DFLTDISPATCH (   fun,
  symbol 
)
Value:
do { \
SEXP call = GETSTACK(-3); \
SEXP args = GETSTACK(-2); \
value = fun(call, symbol, args, rho); \
s_nodestack->pop(3); \
SETSTACK(-1, value); \
NEXT(); \
} while (0)
#define DO_FAST_BINOP (   op,
  a,
 
)
Value:
do { \
SKIP_OP(); \
SETSTACK_REAL(-2, (a) op (b)); \
s_nodestack->pop(); \
NEXT(); \
} while (0)
#define DO_FAST_BINOP_INT (   op,
  a,
 
)
Value:
do { \
double dval = (double( (a))) op (double( (b))); \
if (dval <= INT_MAX && dval >= INT_MIN + 1) { \
SKIP_OP(); \
SETSTACK_INTEGER(-2, int( dval)); \
s_nodestack->pop(); \
NEXT(); \
} \
} while(0)
#define DO_FAST_RELOP2 (   op,
  a,
 
)
Value:
do { \
SKIP_OP(); \
SETSTACK_LOGICAL(-2, ((a) op (b)) ? TRUE : FALSE); \
s_nodestack->pop(); \
NEXT(); \
} while (0)
#define DO_ISTEST (   fun)
Value:
do { \
SETSTACK(-1, fun(GETSTACK(-1)) ? R_TrueValue : R_FalseValue); \
NEXT(); \
} while(0)
#define DO_ISTYPE (   type)
Value:
do { \
SETSTACK(-1, TYPEOF(GETSTACK(-1)) == type ? Rf_mkTrue() : Rf_mkFalse()); \
NEXT(); \
} while (0)
#define DO_VECSUBSET (   rho)
Value:
do { \
NSFROMEND(2) = VECSUBSET_PTR(NSFROMEND(2), NSFROMEND(1), rho); \
s_nodestack->pop(); \
} while(0)
#define FIXUP_SCALAR_LOGICAL (   callidx,
  arg,
  op 
)
Value:
do { \
SEXP val = GETSTACK(-1); \
if (TYPEOF(val) != LGLSXP || LENGTH(val) != 1) { \
if (!Rf_isNumber(val)) \
Rf_errorcall(VECTOR_ELT(constants, callidx), \
_("invalid %s type in 'x %s y'"), arg, op); \
SETSTACK(-1, Rf_ScalarLogical(Rf_asLogical(val))); \
} \
} while(0)
#define GET_VEC_LOOP_VALUE (   var,
  pos 
)
Value:
do { \
(var) = GETSTACK(pos); \
if (NAMED(var) == 2) { \
(var) = Rf_allocVector(TYPEOF(seq), 1); \
SETSTACK(pos, var); \
SET_NAMED(var, 1); \
} \
} while (0)
#define NewBuiltin2 (   do_fun,
  opval,
  opsym,
  rho 
)
Value:
do { \
SEXP call = (*constants)[GETOP()]; \
SEXP x = GETSTACK(-2); \
SEXP y = GETSTACK(-1); \
SETSTACK(-2, do_fun(call, opval, opsym, x, y,rho)); \
s_nodestack->pop(); \
NEXT(); \
} while(0)
#define PUSHCALLARG_CELL (   c)
Value:
do { \
SEXP __cell__ = (c); \
if (GETSTACK(-2) == R_NilValue) SETSTACK(-2, __cell__); \
else SETCDR(GETSTACK(-1), __cell__); \
SETSTACK(-1, __cell__); \
} while (0)
#define SET_TEMPVARLOC_FROM_CAR (   loc,
  lhs 
)
Value:
do { \
SEXP __lhs__ = (lhs); \
SEXP __v__ = CAR(__lhs__); \
if (NAMED(__v__) == 2) { \
__v__ = Rf_duplicate(__v__); \
SET_NAMED(__v__, 1); \
SETCAR(__lhs__, __v__); \
} \
R_SetVarLocValue(loc, __v__); \
} while(0)
#define SETSTACK_LOGICAL (   i,
 
)
Value:
do { \
int __ssl_v__ = (v); \
if (__ssl_v__ == NA_LOGICAL) \
NSFROMEND(-i) = Rf_ScalarLogical(NA_LOGICAL); \
else \
NSFROMEND(-i) = ( __ssl_v__ ? R_TrueValue : R_FalseValue); \
} while(0)