18 #ifndef Rcpp_api_meat_Rcpp_eval_h
19 #define Rcpp_api_meat_Rcpp_eval_h
25 namespace Rcpp {
namespace internal {
27 #ifdef RCPP_USING_UNWIND_PROTECT
32 EvalData(SEXP expr_, SEXP env_) : expr(expr_), env(env_) { }
35 inline SEXP Rcpp_protected_eval(
void* eval_data) {
36 EvalData* data =
static_cast<EvalData*
>(eval_data);
37 return ::Rf_eval(data->expr, data->env);
49 return ::Rf_eval(expr, env);
59 #ifdef RCPP_USING_UNWIND_PROTECT
62 internal::EvalData data(expr, env);
78 Shield<SEXP> identity(Rf_findFun(::Rf_install(
"identity"), R_BaseNamespace));
80 if (identity == R_UnboundValue) {
81 stop(
"Failed to find 'base::identity()'");
85 Shield<SEXP> evalqCall(Rf_lang3(::Rf_install(
"evalq"), expr, env));
88 Shield<SEXP> call(Rf_lang4(::Rf_install(
"tryCatch"), evalqCall, identity, identity));
89 SET_TAG(CDDR(call), ::Rf_install(
"error"));
90 SET_TAG(CDDR(CDR(call)), ::Rf_install(
"interrupt"));
95 if (Rf_inherits(res,
"condition")) {
97 if (Rf_inherits(res,
"error")) {
99 Shield<SEXP> conditionMessageCall(::Rf_lang2(::Rf_install(
"conditionMessage"), res));
102 throw eval_error(CHAR(STRING_ELT(conditionMessage, 0)));
106 if (Rf_inherits(res,
"interrupt")) {
SEXP Rcpp_eval_impl(SEXP expr, SEXP env)
SEXP Rcpp_fast_eval(SEXP expr, SEXP env)
SEXP Rcpp_eval(SEXP expr, SEXP env)
void NORET stop(const char *fmt, Args &&... args)
SEXP unwindProtect(SEXP(*callback)(void *data), void *data)