Skip to content

Instantly share code, notes, and snippets.

@nohajc
Created December 22, 2016 13:43
Show Gist options
  • Select an option

  • Save nohajc/725de8d191b9aa9eeb8fa59bcda128c1 to your computer and use it in GitHub Desktop.

Select an option

Save nohajc/725de8d191b9aa9eeb8fa59bcda128c1 to your computer and use it in GitHub Desktop.
address <- function(x) .Internal(inspect(x))
qq <- function() {
q(save = "no")
}
test <- list()
test[[1]] <- function() {
a = 1
b = 2
c = b
}
test[[2]] <- function(a) {
b = a
c = 1
}
test[[3]] <- function(a, b){
vec = a + b
vec[1] = 3 # Vector is not copied
}
test[[4]] <- function(a, b){
vec = a + b
ptr = vec
vec[1] = 2 # Vector is copied
}
test[[5]] <- function(){
func <- function(){
}
vec = 2
func
}
test[[6]] <- function(a, b, c, d) {
v1 = a + b
v2 = a * b
if (c) {
v3 = v1
}
else {
v3 = v2
}
v3 = a - b
}
test[[7]] <- function(a, b, c, d) {
v1 = a + b
v2 = a * b
if (c) {
v3 = v1
v4 = v2
}
else {
v3 = v2
v4 = v1
}
if (d) {
v3 = a - b
}
else {
v4 = a / b
}
}
disasm <- function(fn) {
rir.disassemble(rir.compile(fn))
}
vec_an <- function(fn) {
rir.analysis.vector(rir.compile(fn))
}
.First <- function() {
library("compiler")
dyn.load("rir/librir.so")
source("rir/rir/R/rir.R")
t = test[[6]]
#disasm(t)
vec_an(t)
#for (fn in test) {
# vec_an(fn)
#}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment