Skip to content

Compiler steps for an RCfunction (or nimbleFunction class method)

Fritz Obermeyer edited this page Apr 26, 2017 · 4 revisions

Steps in processing an "RCfunction", which is a simple nimbleFunction (no setup code) or a method of a nimbleFunction class.

These steps are in the process method of RCfunProcessing.

Most of the following steps have a dedicated "genCpp_XYZ.R" file.

  • exprClasses_processSpecificCalls: (mostly) lightweight processing based on call names, such as changing the name.

    • specificHandlers is a list of R function names (to process the call) indexed by DSL function name.
  • exprClasses_buildInterms : Vestigial step to insert intermediates (temporaries).

  • exprClasses_initSizes initialize typeEnv with types from arguments and return type.

  • exprClasses_setSizes ("size processing"):

    • annotate syntax tree with dimensionality, type, and eigenizability (["yes"|"no"|"maybe"]).
    • generate intermediates and run-time checks (asserts) for later insertion
    • populates symbol table (newLocalSymbolTable) with local variables.
  • exprClasses_insertAssertions Adds "assertions" (misnamed) collected during size processing to AST.

  • exprClasses_labelForEigenization Inserts an eigenize(x) node in the AST around each node (line) x to be eigenized.

  • exprClasses_eigenize ("eigenization") Add Eigen::Map<>s, initialization code, and AST changes for Eigen.

  • exprClasses_liftMaps Handle maps (slices) that will be implement in C++ NimArr<>s, not Eigen.

Note: C++ generation is done from some kind of "cppDef" object, which contains the AST, using nimGenerateCpp.

Clone this wiki locally