README.md

nrc

Travis-CI Build
Status Coverage
status

nrc aims to be an R version of 9cc: R compiler written in R.

Installation

You can install nrc from github with:

# install.packages("remotes")
remotes::install_github("igjit/nrc")

Note: currently nrc only works on Linux.

Try in Docker:

$ docker run --rm -it rocker/tidyverse:3.6.2 R -q
> remotes::install_github("igjit/nrc")

How to play

library(nrc)

compile("1 + 2")
#> .intel_syntax noprefix
#> .global main
#> main:
#>   push rbp
#>   mov rbp, rsp
#>   sub rsp, 0
#>   push 1
#>   push 2
#>   pop rdi
#>   pop rax
#>   add rax, rdi
#>   push rax
#>   pop rax
#>   mov rsp, rbp
#>   pop rbp
#>   ret
compile("1 + 2") %>% assemble() %>% execute()
#> [1] 3
compile("a <- 2; a * 3") %>% assemble() %>% execute()
#> [1] 6
compile("add2 <- function(x) x + 2; add2(40)") %>% assemble() %>% execute()
#> [1] 42


igjit/nrc documentation built on Jan. 10, 2020, 1:42 p.m.