Skip to content

Commit

Permalink
backport R_existsVarInFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
crowding committed Jul 1, 2024
1 parent 4f8f006 commit 124dc10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
16 changes: 16 additions & 0 deletions src/vadr.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,19 @@ SEXP new_weird_promise(SEXP expr, SEXP env, SEXP value) {
UNPROTECT(1);
return out;
}

#if R_VERSION < R_Version(4, 4, 1)
SEXP allocLang(int n)
{
if (n > 0)
return LCONS(R_NilValue, allocList(n - 1));
else
return R_NilValue;
}
#endif

#if R_VERSION < R_Version(4, 2, 0)
Rboolean R_existsVarInFrame(SEXP rho, SEXP symbol) {
return (Rf_findVarInFrame3(rho, symbol, FALSE) != R_UnboundValue);
}
#endif
12 changes: 5 additions & 7 deletions src/vadr.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ SEXP peek_promise(SEXP prom);
#endif

#if R_VERSION < R_Version(4, 4, 1)
SEXP allocLang(int n)
{
if (n > 0)
return LCONS(R_NilValue, allocList(n - 1));
else
return R_NilValue;
}
SEXP allocLang(int n);
#endif

#if R_VERSION < R_Version(4, 5, 0)
# define R_ClosureFormals(x) FORMALS(x)
# define R_ClosureEnv(x) CLOENV(x)
# define R_ParentEnv(x) ENCLOS(x)
#endif

#if R_VERSION < R_Version(4, 2, 0)
Rboolean R_existsVarInFrame(SEXP rho, SEXP symbol);
#endif

0 comments on commit 124dc10

Please sign in to comment.