How to transform ES6 AST into ES5 AST directly? - abstract-syntax-tree

I learnt that packages like Babel can do the job converting ES6 code to JavaScript in ES5, but can I just start from the ES6 AST I got somewhere?

I posted a similar question in babel's Issues and got an anwser from the maintainer:
https://github.com/babel/babel/issues/1122
require("babel").transform.fromAST(ast, originalCode, options);
variable originalCode could be null and that will finish this task.

Related

How can I generate files from Rust procedural macros?

I am building an extension API for R in Rust. I annotate my functions with a procedural macro to generate C wrappers with the appropriate conversion and error handling:
use extendr_api::*;
#[export_function]
fn hello() -> &'static str {
"hello"
}
This generates a C function hello__wrapper__ that is callable from R
using the .Call mechanism.
In addition to this, we need to generate a NAMESPACE file for the R
metatdata:
export(hello)
useDynLib(libhello, "__wrap__hello")
And a file lib.R
hello <- function() {
.Call("__wrap__hello")
}
What is the simplest way to extend cargo or rustc
to write this additional information? I'm guessing
that writing a file from the procedural macro code is
a bad idea.
From what I understand, procedural macros generate code at compile time, but it has to be valid Rust code. I do not think that a procedural macro is the way to go in this case.
One possible solution is to create a script that will go through and find your exported functions in the Rust file and generate the 2 extra files you need. You could make a build script that runs before compiling if you want to do all the parsing in Rust, otherwise I would suggest something like Python.

Can I use an R library embedded in Scala with rscala?

I imported the org.ddahl.rscala class into my Scala project and have gotten the minimal example found here: https://dahl.byu.edu/software/rscala/scaladoc/org/ddahl/rscala/RClient.html to run. Now I would like to use an R library embedded in my Scala code if possible; however I cannot find what syntax I would use to import an external library from the rscala package.
Calling from RClient object is not supported, the below does not work:
val R = org.ddahl.rscala.RClient()
R.library("libraryname")
Is this something which is possible to do, or is rscala limited in scope to the methods listed on the scaladocs page?
R.eval("require {library_name}")

Adding Code of missing functions in frama-c

Forgive my ignorance. I need to do calculate backward slices for a project. After some searching, I came across frama-c. I downloaded the package on my ubuntu system which got me Frama-c Version: Fluorine-20130601. I am trying to use it for the first time. When finding out the undefined functions in my project almost all library functions are undefined, even printf, scanf etc(Neither code nor specification for function printf). According to the tutorial, I have to add stubs for all the undefined functions. Do I really have to add code for every library function that I am using even printf? Please guide.
You should update to Frama-C Phosphorus, which brings tons of improvements regarding Variadic functions. In particular, specifications are automatically generated for printf/scanf-like functions when they are called on a constant format string. For non-variadic functions, some basic implementations are available in the directory $FRAMA_C_INSTALL/share/libc/*.c (in recent releases of Frama-C).

Rcpp integrated with R package: Documentation of CPP code objects

I have been developing a package with Rcpp for C++ integration. I used RcppExport to make the functions return SEXP objects.
The issue is travis-ci seems to give warnings telling that there are undocumented code objects. (These are cpp functions). However I do not want users to directly access those functions as well.
How can I resolve this issue? How can I document these functions as well?
You seem to have an elementary misunderstanding here.
If your NAMESPACE contains a wildcard 'export all' a la exportPattern("^[[:alpha:]]+") then each global symbol is exported and per R standards that are clearly documented needs a help entry.
One easy fix is NOT to export everything and just write documentation for what you want exported. We sometimes do that and call the Rcpp function something like foo_impl and then have R functions foo (with documentation) call foo_impl. In that case you would just export foo and all is good.
In short, you are confused about R packages and not so much Rcpp. I would recommend downloading the sources of a few (small) Rcpp packages to get a feel for what they do.

Is it possible to implement `Lists` functions of Compass in plain vanilla Sass?

The Lists functions in Compass is here:
https://github.com/chriseppstein/compass/blob/stable/lib/compass/sass_extensions/functions/lists.rb
If someone has tried either success or fail…

Resources