tests2/cast.R

library(R2llvm)

f = function(x) 1L + x
cfg = rstatic::to_cfg(f)
types = RTypeInference::infer_types(cfg, init = list(x = typesys::RealType()))
fc = compileFunction(f, cfg = cfg, types = types, optimize = FALSE)
stopifnot(identical(.llvm(fc, 2.5), 3.5))


f = function(x) 1.5 + x
cfg = rstatic::to_cfg(f)
types = RTypeInference::infer_types(cfg, init = list(x = typesys::IntegerType()))
fc = compileFunction(f, cfg = cfg, types = types, optimize = FALSE)
stopifnot(identical(.llvm(fc, 2), 3.5))
duncantl/R2llvm documentation built on May 14, 2019, 9:42 a.m.