opt_constant_folding: Optimizer: Constant Folding.

View source: R/opt-constant-folding.R

opt_constant_foldingR Documentation

Optimizer: Constant Folding.

Description

Performs one constant folding pass. Carefully examine the results after running this function!

Usage

opt_constant_folding(texts, fold_floats = FALSE, in_fun_call = FALSE)

Arguments

texts

A list of character vectors with the code to optimize.

fold_floats

A logical indicating if floating-point results should be folded (will reduce precision).

in_fun_call

A logical indicating whether it should propagate in function calls. Note: this could change the semantics of the program.

Examples

code <- paste(
  "i <- 320 * 200 * 32",
  "x <- i * 20 + 100",
  sep = "\n"
)
cat(opt_constant_folding(list(code))$codes[[1]])

jcrodriguez1989/rco documentation built on Nov. 12, 2024, 12:23 p.m.