Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some of the non-API conundrum #1747

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#define attribute_hidden
#define _(string) (string)
#define RLANG_PRENV(x) TAG(x)
#define RLANG_PREXPR(x) R_BytecodeExpr(CDR(x))

static Rboolean dotDotVal(SEXP);
static SEXP capturedot(SEXP, int);
Expand Down Expand Up @@ -36,8 +38,8 @@ SEXP attribute_hidden new_captured_promise(SEXP x, SEXP env) {

SEXP expr = x;
while (TYPEOF(expr) == PROMSXP) {
expr_env = PRENV(expr);
expr = PREXPR(expr);
expr_env = RLANG_PRENV(expr);
expr = RLANG_PREXPR(expr);

if (expr_env == R_NilValue)
break;
Expand Down Expand Up @@ -77,7 +79,7 @@ SEXP attribute_hidden rlang_capturearginfo(SEXP call, SEXP op, SEXP args, SEXP r
return value;
}

sym = PREXPR(sym);
sym = RLANG_PREXPR(sym);

if (TYPEOF(sym) != SYMSXP) {
UNPROTECT(nProt);
Expand Down
2 changes: 1 addition & 1 deletion src/internal/dots-ellipsis.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool ellipsis_promise_forced(r_obj* x) {
if (r_typeof(x) != R_TYPE_promise) {
return true;
} else {
return PRVALUE(x) != r_syms.unbound;
return RLANG_PRVALUE(x) != r_syms.unbound;
}
}
r_obj* ffi_ellipsis_promise_forced(r_obj* x) {
Expand Down
12 changes: 6 additions & 6 deletions src/internal/exported.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@
r_abort("Can't change the parent of the empty environment");
}

SET_ENCLOS(env, new_parent);
RLANG_SET_ENCLOS(env, new_parent);
return env;
}

r_obj* ffi_env_frame(r_obj* env) {
return FRAME(env);
return RLANG_FRAME(env);

Check warning on line 480 in src/internal/exported.c

View check run for this annotation

Codecov / codecov/patch

src/internal/exported.c#L480

Added line #L480 was not covered by tests
}
r_obj* ffi_env_hash_table(r_obj* env) {
return HASHTAB(env);
return RLANG_HASHTAB(env);

Check warning on line 483 in src/internal/exported.c

View check run for this annotation

Codecov / codecov/patch

src/internal/exported.c#L483

Added line #L483 was not covered by tests
}

r_obj* ffi_env_inherits(r_obj* env, r_obj* ancestor) {
Expand Down Expand Up @@ -771,15 +771,15 @@

r_obj* ffi_promise_expr(r_obj* x, r_obj* env) {
r_obj* prom = rlang_get_promise(x, env);
return PREXPR(prom);
return RLANG_PREXPR(prom);
}
r_obj* ffi_promise_env(r_obj* x, r_obj* env) {
r_obj* prom = rlang_get_promise(x, env);
return PRENV(prom);
return RLANG_PRENV(prom);
}
r_obj* ffi_promise_value(r_obj* x, r_obj* env) {
r_obj* prom = rlang_get_promise(x, env);
r_obj* value = PRVALUE(prom);
r_obj* value = RLANG_PRVALUE(prom);
if (value == r_syms.unbound) {
return r_sym("R_UnboundValue");
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/rlang/env-binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

bool r_env_binding_is_promise(r_obj* env, r_obj* sym) {
r_obj* obj = r_env_find(env, sym);
return r_typeof(obj) == R_TYPE_promise && PRVALUE(obj) == r_syms.unbound;
return r_typeof(obj) == R_TYPE_promise && RLANG_PRVALUE(obj) == r_syms.unbound;
}
bool r_env_binding_is_active(r_obj* env, r_obj* sym) {
return R_BindingIsActive(sym, env);
Expand Down
2 changes: 1 addition & 1 deletion src/rlang/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ r_obj* r_env_parent(r_obj* env) {
}
static inline
void r_env_poke_parent(r_obj* env, r_obj* new_parent) {
SET_ENCLOS(env, new_parent);
RLANG_SET_ENCLOS(env, new_parent);
}

static inline
Expand Down
10 changes: 5 additions & 5 deletions src/rlang/fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ r_obj* r_fn_body(r_obj* fn) {
}
static inline
void r_fn_poke_body(r_obj* fn, r_obj* body) {
SET_BODY(fn, body);
RLANG_SET_BODY(fn, body);
}

static inline
Expand All @@ -21,15 +21,15 @@ r_obj* r_fn_env(r_obj* fn) {
}
static inline
void r_fn_poke_env(r_obj* fn, r_obj* env) {
SET_CLOENV(fn, env);
RLANG_SET_CLOENV(fn, env);
}

static inline
r_obj* r_new_function(r_obj* formals, r_obj* body, r_obj* env) {
SEXP fn = Rf_allocSExp(R_TYPE_closure);
SET_FORMALS(fn, formals);
SET_BODY(fn, body);
SET_CLOENV(fn, env);
RLANG_SET_FORMALS(fn, formals);
RLANG_SET_BODY(fn, body);
RLANG_SET_CLOENV(fn, env);
return fn;
}

Expand Down
10 changes: 9 additions & 1 deletion src/rlang/rlang-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,16 @@ struct r_lazy {
FREE(1); \
} while (0)


#define RLANG_ASSERT(condition) ((void)sizeof(char[1 - 2*!(condition)]))

#define RLANG_FRAME(x) CAR(x)
#define RLANG_HASHTAB(x) TAG(x)
#define RLANG_PRENV(x) TAG(x)
#define RLANG_PREXPR(x) R_BytecodeExpr(CDR(x))
#define RLANG_PRVALUE(x) CAR(x)
#define RLANG_SET_ENCLOS(x, v) SETCDR(x, v)
#define RLANG_SET_FORMALS(x, v) SETCAR(x, v)
#define RLANG_SET_BODY(x, v) SETCDR(x, v)
#define RLANG_SET_CLOENV(x, v) SET_TAG(x, v)

#endif
12 changes: 6 additions & 6 deletions src/rlang/walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
.x = r_null,
.parent = r_null,
};

FREE(1);
return p_it;
}
Expand Down Expand Up @@ -315,8 +315,8 @@
enum r_sexp_it_relation* p_rel) {
switch (type) {
case R_TYPE_closure: *p_rel = R_SEXP_IT_RELATION_function_fmls; return FORMALS(x);
case R_TYPE_environment: *p_rel = R_SEXP_IT_RELATION_environment_frame; return FRAME(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_value; return PRVALUE(x);
case R_TYPE_environment: *p_rel = R_SEXP_IT_RELATION_environment_frame; return RLANG_FRAME(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_value; return RLANG_PRVALUE(x);

Check warning on line 319 in src/rlang/walk.c

View check run for this annotation

Codecov / codecov/patch

src/rlang/walk.c#L319

Added line #L319 was not covered by tests
case R_TYPE_pairlist:
case R_TYPE_call:
case R_TYPE_dots: *p_rel = R_SEXP_IT_RELATION_node_car; return CAR(x);
Expand All @@ -331,7 +331,7 @@
switch (type) {
case R_TYPE_closure: *p_rel = R_SEXP_IT_RELATION_function_body; return BODY(x);
case R_TYPE_environment: *p_rel = R_SEXP_IT_RELATION_environment_enclos; return ENCLOS(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_expr; return PREXPR(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_expr; return RLANG_PREXPR(x);

Check warning on line 334 in src/rlang/walk.c

View check run for this annotation

Codecov / codecov/patch

src/rlang/walk.c#L334

Added line #L334 was not covered by tests
case R_TYPE_pointer: *p_rel = R_SEXP_IT_RELATION_pointer_prot; return EXTPTR_PROT(x);
case R_TYPE_pairlist:
case R_TYPE_call:
Expand All @@ -345,8 +345,8 @@
enum r_sexp_it_relation* p_rel) {
switch (type) {
case R_TYPE_closure: *p_rel = R_SEXP_IT_RELATION_function_env; return CLOENV(x);
case R_TYPE_environment: *p_rel = R_SEXP_IT_RELATION_environment_hashtab; return HASHTAB(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_env; return PRENV(x);
case R_TYPE_environment: *p_rel = R_SEXP_IT_RELATION_environment_hashtab; return RLANG_HASHTAB(x);
case R_TYPE_promise: *p_rel = R_SEXP_IT_RELATION_promise_env; return RLANG_PRENV(x);

Check warning on line 349 in src/rlang/walk.c

View check run for this annotation

Codecov / codecov/patch

src/rlang/walk.c#L349

Added line #L349 was not covered by tests
case R_TYPE_pointer: *p_rel = R_SEXP_IT_RELATION_pointer_tag; return EXTPTR_TAG(x);
case R_TYPE_pairlist:
case R_TYPE_call:
Expand Down
Loading