Lcalc.Splitval split_program :
threshold:int ->
(Shared_ast.lcalc, Shared_ast.typed) Shared_ast.gexpr Shared_ast.program ->
(Shared_ast.lcalc, Shared_ast.typed) Shared_ast.gexpr Shared_ast.programSplits the program ensuring that expressions are not larger to the given threshold. We approximate an expression size as its number of AST nodes. Split expressions will be lifted as topdefs and original expressions are replaced by calls to the generated functions. We iterate until every program's expression satisfies the size requirements.
This is necessary in the java backend as there is a bytecode size limit in each java's method. However, this mechanism is generic enough to be ported to other backends.