123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120(* This file is part of the Catala compiler, a specification language for tax
and social benefits computation rules. Copyright (C) 2021 Inria, contributor:
Denis Merigoux <denis.merigoux@inria.fr>
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License. *)openCatala_utilsopenShared_astmoduleL=Lcalc.AstmoduleFuncName=Uid.Gen(structletstyle=Ocolor_types.(Fg(C4green))end)()moduleVarName=Uid.Gen(structletstyle=Ocolor_types.Default_fgend)()typeoperator=Shared_ast.lcalcShared_ast.operatortypeexpr=naked_exprMark.posandnaked_expr=|EVarofVarName.t|EFuncofFuncName.t|EStructof{fields:exprStructField.Map.t;name:StructName.t}|EStructFieldAccessof{e1:expr;field:StructField.t;name:StructName.t;}|ETupleofexprlist|ETupleAccessof{e1:expr;index:int;typ:typ}|EInjof{e1:expr;cons:EnumConstructor.t;name:EnumName.t;expr_typ:typ;}|EArrayofexprlist|ELitoflit|EPosLit|EAppof{f:expr;args:exprlist;typ:typ;poly:bool}(** [typ] is the return type ; [poly] indicates if the function return is
polymorphic (in which case the return value might need a cast) *)|EAppOpof{op:operatorMark.pos;args:exprlist;tys:typlist}|EExternalof{modname:VarName.tMark.pos;name:stringMark.pos}typestmt=|SInnerFuncDefof{name:VarName.tMark.pos;func:func}|SLocalDeclof{name:VarName.tMark.pos;typ:typ}|SLocalInitof{name:VarName.tMark.pos;typ:typ;expr:expr}|SLocalDefof{name:VarName.tMark.pos;typ:typ;expr:expr}|SFatalErrorof{pos_expr:expr;error:Catala_runtime.error}(** [pos_expr] here is the position reified into an expression *)|SIfThenElseof{if_expr:expr;then_block:block;else_block:block}|SSwitchof{switch_var:VarName.t;switch_var_typ:typ;enum_name:EnumName.t;switch_cases:switch_caselist;}|SReturnofexpr|SAssertof{pos_expr:expr;expr:expr}(** [pos_expr] here is the position reified into an expression *)|SSpecialOpofspecial_operatorandspecial_operator=|andblock=stmtMark.poslistandswitch_case={case_block:block;payload_var_name:VarName.t;payload_var_typ:typ;}andfunc={func_params:(VarName.tMark.pos*typ)list;func_body:block;func_return_typ:typ;}typescope_body={scope_body_name:ScopeName.t;scope_body_var:FuncName.t;scope_body_func:func;scope_body_visibility:visibility;}typecode_item=|SVarof{var:VarName.t;expr:expr;typ:typ;visibility:visibility}|SFuncof{var:FuncName.t;func:func;visibility:visibility}|SScopeofscope_bodytypectx={decl_ctx:decl_ctx;modules:VarName.tModuleName.Map.t}typeprogram={ctx:ctx;code_items:code_itemlist;tests:code_itemlist*(ScopeName.t*block)list;(** The first element may contain lifted closures. It can be assumed to be
empty when closure conversion is disabled. *)module_name:(ModuleName.t*module_intf_id)option;}