mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-20 08:47:14 +03:00
4ae392c900
Many changes got bundled in here and would be too tedious to separate. Closes #330 See changes in `shared_ast/definitions.ml` to check the main point. - the biggest change is a modification of the struct and enum types in expressions: they are now stored as `Map`s throughout passes, and no longer converted to indexed lists after scopelang. Their accessors are also changed, and tuples only exist in Lcalc (they're used for closure conversion). This implied adding some more information in the contexts, to keep the mapping between struct fields and scope output variables. It should also be much more robust (no longer relying on assumptions upon different orderings). - another very pervasive change is more cosmetic: the rewrite of the main AST to use inline records, labelling individual subfields. - moved the checks for correct definitions and accesses of structures from `Scope_to_dcalc` to `Typing` - defining some new shallow iterators in module `Shared_ast.Expr`, and factorising a few same-pass rewriting functions accordingly (closure conversion, optimisations, etc.) - some smaller style improvements (ensuring we use the proper compare/equal functions instead of `=` in a few `when` closes, for example)
40 lines
1.5 KiB
OCaml
40 lines
1.5 KiB
OCaml
(* This file is part of the Catala compiler, a specification language for tax
|
|
and social benefits computation rules. Copyright (C) 2020-2022 Inria,
|
|
contributor: Denis Merigoux <denis.merigoux@inria.fr>, Alain Delaët-Tixeuil
|
|
<alain.delaet--tixeuil@inria.fr>, Louis Gesbert <louis.gesbert@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. *)
|
|
|
|
open Definitions
|
|
|
|
(** {2 Transformations} *)
|
|
|
|
val map_exprs :
|
|
f:('expr1 -> 'expr2 boxed) ->
|
|
varf:('expr1 Var.t -> 'expr2 Var.t) ->
|
|
'expr1 program ->
|
|
'expr2 program Bindlib.box
|
|
|
|
val get_scope_body :
|
|
(([< dcalc | lcalc ], _) gexpr as 'e) program -> ScopeName.t -> 'e scope_body
|
|
|
|
val untype :
|
|
(([< dcalc | lcalc ] as 'a), 'm mark) gexpr program ->
|
|
('a, untyped mark) gexpr program
|
|
|
|
val to_expr :
|
|
(([< dcalc | lcalc ], _) gexpr as 'e) program -> ScopeName.t -> 'e boxed
|
|
(** Usage: [build_whole_program_expr program main_scope] builds an expression
|
|
corresponding to the main program and returning the main scope as a
|
|
function. *)
|