Module Closure_conversion
val lambda_to_flambda : backend:(module Backend_intf.S) -> module_ident:Ident.t -> size:int -> filename:string -> Lambda.lambda -> Flambda.programGeneration of
Flambdaintermediate language code fromLambdacode by performing a form of closure conversion.Function declarations (which may bind one or more variables identifying functions, possibly with mutual recursion) are transformed to
Set_of_closuresexpressions.Project_closureexpressions are then used to select a closure for a particular function from aSet_of_closuresexpression. TheSet_of_closuresexpressions say nothing about the actual runtime layout of the closures; this is handled whenFlambdacode is translated toClambdacode.The following transformations are also performed during closure conversion:
- Constant blocks (by which is meant things wrapped in
Lambda.Const_block) are converted to applications of thePmakeblockprimitive. Leventdebugging event nodes are removed and the information within them attached to function, method andraisecalls.- Tuplified functions are converted to curried functions and a stub function emitted to call the curried version. For example: let rec f (x, y) = f (x + 1, y + 1) is transformed to: let rec internal_f x y = f (x + 1,y + 1) and f (x, y) = internal_f x y (*
fis marked as a stub function *) - The
PdirapplyandPrevapplyapplication primitives are removed and converted to normalFlambdaapplication nodes.
The
lambda_to_flambdafunction is not re-entrant.- Constant blocks (by which is meant things wrapped in