Skip to content
Snippets Groups Projects
Commit 918b9e98 authored by Basile Desloges's avatar Basile Desloges
Browse files

[eacsl] Move pre-analyses in a separate module

parent c10e0175
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,8 @@ SRC_ANALYSES:= \ ...@@ -71,7 +71,8 @@ SRC_ANALYSES:= \
typing \ typing \
literal_strings \ literal_strings \
memory_tracking \ memory_tracking \
exit_points exit_points \
analyses
SRC_ANALYSES:=$(addprefix src/analyses/, $(SRC_ANALYSES)) SRC_ANALYSES:=$(addprefix src/analyses/, $(SRC_ANALYSES))
# code generator # code generator
......
...@@ -81,6 +81,8 @@ share/e-acsl/e_acsl.h: CEA_LGPL_OR_PROPRIETARY.E_ACSL ...@@ -81,6 +81,8 @@ share/e-acsl/e_acsl.h: CEA_LGPL_OR_PROPRIETARY.E_ACSL
share/e-acsl/e_acsl_rtl.c: CEA_LGPL_OR_PROPRIETARY.E_ACSL share/e-acsl/e_acsl_rtl.c: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/analyses_datatype.ml: CEA_LGPL_OR_PROPRIETARY.E_ACSL src/analyses/analyses_datatype.ml: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/analyses_datatype.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL src/analyses/analyses_datatype.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/analyses.ml: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/analyses.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/analyses_types.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL src/analyses/analyses_types.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/bound_variables.ml: CEA_LGPL_OR_PROPRIETARY.E_ACSL src/analyses/bound_variables.ml: CEA_LGPL_OR_PROPRIETARY.E_ACSL
src/analyses/bound_variables.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL src/analyses/bound_variables.mli: CEA_LGPL_OR_PROPRIETARY.E_ACSL
......
(**************************************************************************)
(* *)
(* This file is part of the Frama-C's E-ACSL plug-in. *)
(* *)
(* Copyright (C) 2012-2021 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
let analyses_feedback msg =
Options.feedback ~level:2 "%s in %a" msg Project.pretty (Project.current ())
let preprocess () =
let ast = Ast.get () in
analyses_feedback "preprocessing annotations";
Logic_normalizer.preprocess ast;
analyses_feedback "normalizing quantifiers";
Bound_variables.preprocess ast;
analyses_feedback "typing annotations";
Typing.type_program ast
let reset () =
Memory_tracking.reset ();
Literal_strings.reset ();
Bound_variables.clear_guards ();
Logic_normalizer.clear ();
Typing.clear ()
(**************************************************************************)
(* *)
(* This file is part of the Frama-C's E-ACSL plug-in. *)
(* *)
(* Copyright (C) 2012-2021 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
(** General module for E-ACSL analyses *)
val preprocess: unit -> unit
(** Analyses to run before starting the translation *)
val reset: unit -> unit
(** Clear the results of the analyses *)
...@@ -840,13 +840,9 @@ let reset_all ast = ...@@ -840,13 +840,9 @@ let reset_all ast =
(* by default, do not run E-ACSL on the generated code *) (* by default, do not run E-ACSL on the generated code *)
Options.Run.off (); Options.Run.off ();
(* reset all the E-ACSL environments to their original states *) (* reset all the E-ACSL environments to their original states *)
Memory_tracking.reset ();
Logic_functions.reset (); Logic_functions.reset ();
Literal_strings.reset ();
Global_observer.reset (); Global_observer.reset ();
Bound_variables.clear_guards (); Analyses.reset ();
Logic_normalizer.clear ();
Typing.clear ();
(* reset some kernel states: *) (* reset some kernel states: *)
(* reset the CFG that has been heavily modified by the code generation step *) (* reset the CFG that has been heavily modified by the code generation step *)
Cfg.clearFileCFG ~clear_id:false ast; Cfg.clearFileCFG ~clear_id:false ast;
...@@ -856,23 +852,10 @@ let reset_all ast = ...@@ -856,23 +852,10 @@ let reset_all ast =
Ast.mark_as_grown () Ast.mark_as_grown ()
let inject () = let inject () =
Gmp_types.init ();
let ast = Ast.get () in let ast = Ast.get () in
let current_project = Project.current() in let current_project = Project.current() in
Options.feedback ~level:2 Options.feedback ~level:2
"preprocessing annotations in project %a" "injecting annotations as code in %a"
Project.pretty current_project;
Logic_normalizer.preprocess ast;
Options.feedback ~level:2
"normalizing quantifiers in project %a"
Project.pretty current_project;
Bound_variables.preprocess ast;
Options.feedback ~level:2
"typing annotations in project %a"
Project.pretty current_project;
Typing.type_program ast;
Options.feedback ~level:2
"injecting annotations as code in project %a"
Project.pretty current_project; Project.pretty current_project;
inject_in_file ast; inject_in_file ast;
reset_all ast; reset_all ast;
......
...@@ -69,7 +69,13 @@ let generate_code = ...@@ -69,7 +69,13 @@ let generate_code =
Kernel.SignedOverflow.unsafe_set signed; Kernel.SignedOverflow.unsafe_set signed;
Kernel.UnsignedOverflow.unsafe_set unsigned Kernel.UnsignedOverflow.unsafe_set unsigned
in in
Extlib.try_finally ~finally Injector.inject (); Extlib.try_finally
~finally
(fun () ->
Gmp_types.init ();
Analyses.preprocess ();
Injector.inject ())
();
(* remove the RTE's results computed from E-ACSL: they are partial (* remove the RTE's results computed from E-ACSL: they are partial
and associated with the wrong kernel function (the one of the old and associated with the wrong kernel function (the one of the old
project). *) project). *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment