-
Notifications
You must be signed in to change notification settings - Fork 10
/
fopen.R
26 lines (20 loc) · 822 Bytes
/
fopen.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(RLLVMCompile)
mod = Module()
FILEType = pointerType(structType(list(o=Int32Type))) # an opaque struct type?
fopen = Function("fopen", FILEType, list(StringType, StringType), module = mod)
Fopen = function(file, mode)
return(fopen(file, mode))
fc = compileFunction(Fopen, FILEType, list(StringType, StringType), module = mod)
o = .llvm(fc, "tmp", "r")
mod = Module()
fopen = Function("fopen", FILEType, list(StringType, StringType), module = mod)
fun = Function("Fopen", FILEType, list(file = StringType, mode = StringType), module = mod)
b = Block(fun, "entry")
ir = IRBuilder(b)
#ans = ir$createLocalVariable(FILEType, "tmp")
params = getParameters(fun)
tmp = ir$createCall(fopen, params[[1]], params[[2]])
#ir$createStore(tmp, ans)
#ans = ir$createLoad(ans)
#ir$createRet(ans)
ir$createRet(tmp)