-
Notifications
You must be signed in to change notification settings - Fork 23
Compiler steps for an RCfunction (or nimbleFunction class method)
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.
-
matchKeywords("Keyword processing step 1"): fills and order arguments.-
matchKeywords_recursewalks the parse tree. -
matchFunctionscontains the prototypes for matching. -
Note: For a nimbleFunction class, keyword processing is invoked in a separate step.
-
-
processKeywords("Keyword processing step 2"): Creates new setup code and setup outputs, and optionally modifies a call.-
processKeywords_recursewalks the parse tree. -
keywordListmaps keywords to instances ofkeywordInfoClass.
-
-
setupSymbolTables: Initialize local symbol table from arguments and set upreturnSymbol. -
convert the body (code) to
exprClassobjects (bidirectional syntax tree for later processing)
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.-
specificHandlersis a list of R function names (to process the call) indexed by DSL function name.
-
-
exprClasses_buildInterms: Vestigial step to insert intermediates (temporaries). -
exprClasses_initSizesinitializetypeEnvwith 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_insertAssertionsAdds "assertions" (misnamed) collected during size processing to AST. -
exprClasses_labelForEigenizationInserts aneigenize(x)node in the AST around each node (line)xto be eigenized. -
exprClasses_eigenize("eigenization") AddEigen::Map<>s, initialization code, and AST changes for Eigen. -
exprClasses_liftMapsHandle 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.