2021-02-12 19:20:14 +03:00
|
|
|
(* This file is part of the Catala compiler, a specification language for tax
|
|
|
|
and social benefits computation rules. Copyright (C) 2020 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. *)
|
|
|
|
|
|
|
|
(** Graph representation of the dependencies between scopes in the Catala
|
|
|
|
program. Vertices are functions, x -> y if x is used in the definition of y. *)
|
|
|
|
|
2022-11-21 12:46:17 +03:00
|
|
|
open Catala_utils
|
2022-08-12 23:42:39 +03:00
|
|
|
open Shared_ast
|
2021-02-12 19:20:14 +03:00
|
|
|
|
2021-02-14 14:01:32 +03:00
|
|
|
(** {1 Scope dependencies} *)
|
|
|
|
|
2023-02-13 17:00:23 +03:00
|
|
|
type vertex = Scope of ScopeName.t | Topdef of TopdefName.t
|
2023-01-23 14:19:36 +03:00
|
|
|
|
2021-02-12 19:20:14 +03:00
|
|
|
(** On the edges, the label is the expression responsible for the use of the
|
|
|
|
function *)
|
|
|
|
module SDependencies :
|
2023-01-23 14:19:36 +03:00
|
|
|
Graph.Sig.P with type V.t = vertex and type E.label = Pos.t
|
2021-02-12 19:20:14 +03:00
|
|
|
|
2022-09-23 18:43:48 +03:00
|
|
|
val build_program_dep_graph : 'm Ast.program -> SDependencies.t
|
2023-02-13 17:00:23 +03:00
|
|
|
val check_for_cycle_in_defs : SDependencies.t -> unit
|
|
|
|
val get_defs_ordering : SDependencies.t -> vertex list
|
2021-02-12 19:20:14 +03:00
|
|
|
|
2021-02-14 14:01:32 +03:00
|
|
|
(** {1 Type dependencies} *)
|
|
|
|
|
2021-02-12 19:20:14 +03:00
|
|
|
module TVertex : sig
|
2022-08-12 23:42:39 +03:00
|
|
|
type t = Struct of StructName.t | Enum of EnumName.t
|
2021-02-12 19:20:14 +03:00
|
|
|
|
2023-07-12 12:48:46 +03:00
|
|
|
val format : Format.formatter -> t -> unit
|
2023-08-30 18:49:29 +03:00
|
|
|
val get_info : t -> Uid.MarkedString.info
|
2021-02-12 19:20:14 +03:00
|
|
|
|
|
|
|
include Graph.Sig.COMPARABLE with type t := t
|
|
|
|
end
|
|
|
|
|
|
|
|
module TVertexSet : Set.S with type elt = TVertex.t
|
|
|
|
|
|
|
|
(** On the edges, the label is the expression responsible for the use of the
|
|
|
|
function *)
|
|
|
|
module TDependencies :
|
|
|
|
Graph.Sig.P with type V.t = TVertex.t and type E.label = Pos.t
|
|
|
|
|
2022-08-25 18:29:00 +03:00
|
|
|
val get_structs_or_enums_in_type : typ -> TVertexSet.t
|
2022-08-25 13:09:51 +03:00
|
|
|
val build_type_graph : struct_ctx -> enum_ctx -> TDependencies.t
|
|
|
|
val check_type_cycles : struct_ctx -> enum_ctx -> TVertex.t list
|