9
9
# ' @param code (`character`, `language` or `expression`) code to evaluate.
10
10
# ' It is possible to preserve original formatting of the `code` by providing a `character` or an
11
11
# ' `expression` being a result of `parse(keep.source = TRUE)`.
12
- # ' @param cache (`logical(1)`) whether to cache returned value of the code evaluation.
12
+ # ' @param keep_output (`logical(1)`) whether to keep the output of the code evaluation.
13
13
# '
14
14
# ' @param ... ([`dots`]) additional arguments passed to future methods.
15
15
# '
28
28
# ' @aliases eval_code,qenv.error-method
29
29
# '
30
30
# ' @export
31
- setGeneric ("eval_code ", function(object, code, cache = FALSE, ...) standardGeneric("eval_code"))
31
+ setGeneric ("eval_code ", function(object, code, keep_output = FALSE, ...) standardGeneric("eval_code"))
32
32
33
- setMethod ("eval_code ", signature = c(object = "qenv"), function(object, code, cache = FALSE, ...) {
33
+ setMethod ("eval_code ", signature = c(object = "qenv"), function(object, code, keep_output = FALSE, ...) {
34
34
if (! is.language(code ) && ! is.character(code )) {
35
35
stop(" eval_code accepts code being language or character" )
36
36
}
37
37
code <- .preprocess_code(code )
38
38
# preprocess code to ensure it is a character vector
39
- .eval_code(object = object , code = code , cache = cache , ... )
39
+ .eval_code(object = object , code = code , keep_output = keep_output , ... )
40
40
})
41
41
42
- setMethod ("eval_code ", signature = c(object = "qenv.error"), function(object, code, cache = FALSE, ...) object)
42
+ setMethod ("eval_code ", signature = c(object = "qenv.error"), function(object, code, keep_output = FALSE, ...) object)
43
43
44
44
# ' @keywords internal
45
- .eval_code <- function (object , code , cache = FALSE , ... ) {
45
+ .eval_code <- function (object , code , keep_output = FALSE , ... ) {
46
46
if (identical(code , " " )) {
47
47
return (object )
48
48
}
@@ -64,8 +64,8 @@ setMethod("eval_code", signature = c(object = "qenv.error"), function(object, co
64
64
tryCatch(
65
65
{
66
66
out <- eval(current_call , envir = object @ .xData )
67
- if (cache && i == length(code_split )) {
68
- attr(current_code , " cache " ) <- out
67
+ if (keep_output && i == length(code_split )) {
68
+ attr(current_code , " output " ) <- out
69
69
}
70
70
if (! identical(parent.env(object @ .xData ), parent.env(.GlobalEnv ))) {
71
71
# needed to make sure that @.xData is always a sibling of .GlobalEnv
0 commit comments