Dcalc.Binded_representationSourceAlternative representation of the Dcalc Ast. It is currently used in the transformation without exceptions. We make heavy use of bindlib, binding each scope-let-variable and each scope explicitly.
type scope_lets = | Result of D.expr Utils.Pos.marked| ScopeLet of {scope_let_kind : D.scope_let_kind;scope_let_typ : D.typ Utils.Pos.marked;scope_let_expr : D.expr Utils.Pos.marked;scope_let_next : (D.expr, scope_lets) Bindlib.binder;scope_let_pos : Utils.Pos.t;}In Ast, Ast.scope_lets is defined as a list of kind, var, and boxed expression. This representation binds using bindlib the tail of the list with the variable defined in the let.
type scope_body = {scope_body_input_struct : D.StructName.t;scope_body_output_struct : D.StructName.t;scope_body_result : (D.expr, scope_lets) Bindlib.binder;}As a consequence, the scope_body contains only a result and input/output signature, as the other elements are stored inside the scope_let. The binder present is the argument of type scope_body_input_struct.
type scopes = | Nil| ScopeDef of {scope_name : D.ScopeName.t;scope_body : scope_body;scope_next : (D.expr, scopes) Bindlib.binder;}Finally, we do the same transformation for the whole program for the kinded lets. This permit us to use bindlib variables for scopes names.
List of variables not binded inside a scope_lets
List of variables not binded inside a scope_body.
val bind_scopes :
(D.ScopeName.t * D.expr Bindlib.var * D.scope_body) list ->
scopes Bindlib.boxTransform a list of scopes into our representation of scopes. It requires that scopes are topologically-well-ordered, and ensure there is no free variables in the returned scopes