99# ' @param code (`character`, `language` or `expression`) code to evaluate.
1010# ' It is possible to preserve original formatting of the `code` by providing a `character` or an
1111# ' `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.
1313# '
1414# ' @param ... ([`dots`]) additional arguments passed to future methods.
1515# '
2828# ' @aliases eval_code,qenv.error-method
2929# '
3030# ' @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"))
3232
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, ...) {
3434 if (! is.language(code ) && ! is.character(code )) {
3535 stop(" eval_code accepts code being language or character" )
3636 }
3737 code <- .preprocess_code(code )
3838 # 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 , ... )
4040})
4141
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)
4343
4444# ' @keywords internal
45- .eval_code <- function (object , code , cache = FALSE , ... ) {
45+ .eval_code <- function (object , code , keep_output = FALSE , ... ) {
4646 if (identical(code , " " )) {
4747 return (object )
4848 }
@@ -64,8 +64,8 @@ setMethod("eval_code", signature = c(object = "qenv.error"), function(object, co
6464 tryCatch(
6565 {
6666 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
6969 }
7070 if (! identical(parent.env(object @ .xData ), parent.env(.GlobalEnv ))) {
7171 # needed to make sure that @.xData is always a sibling of .GlobalEnv
0 commit comments