LustreAstDependenciesGraph analysis on Lustre Ast Declarations.
We build a dependency graph of the lustre declarations to detect circular dependencies and reject them. We also reorder node and contract declarations to resolve forward references as backend cannot handle them.
Note Types of dependency analysis: There are two different kinds of graph dependency analysis and sorting done here.
1. Top level constants and type declarations (starts at sort_globals) We resolve all the forward references in this step.
2a. Nodes, functions and contracts (starts at sort_and_check_nodes_contracts) We resolve all the forward references in this step.
2b. Sort contract equations and perform cirularity check of node equations.
module LA = LustreAstmodule IMap = HString.HStringMapmodule IntMap : sig ... endtype error_kind = | Unknown of string| IdentifierRedeclared of HString.t| WidthLengthsUnequal of LA.expr * LA.expr| EquationWidthsUnequal| ContractDependencyOnCurrentOutput of LA.SI.t| CyclicDependency of HString.t list| ImportedCyclicDependency of HString.t list * NodeId.t| MismatchedDecreasesArity of HString.t list| RecursiveAnnotationWithoutRecursion of HString.tval error_message : error_kind -> stringReturns an message describing the error kind
type node_summary = node_summary_entry NodeId.Map.tReturns a topological order to resolve forward references of globals. This step processes 1. type declarations, and 2. constant declarations
val sort_and_check_nodes_contracts :
LA.t ->
(LA.t * LA.ident list * int IMap.t * node_summary, [> error ]) Stdlib.resultReturns a topological order of declarations to resolve all forward references, with a list of toplevel nodes. It also reorders contract equations and checks for circularity of node equations. This step processes 1. nodes, 2. contracts and 3. functions