Skip to content
Snippets Groups Projects
Commit 03028e67 authored by Julien Signoles's avatar Julien Signoles
Browse files

[e-acsl] remove option -e-acsl-prepare

parent 1bf27ed9
No related branches found
No related tags found
No related merge requests found
...@@ -30,91 +30,6 @@ let check = ...@@ -30,91 +30,6 @@ let check =
(Datatype.func Datatype.unit Datatype.bool) (Datatype.func Datatype.unit Datatype.bool)
check check
type extended_project =
| To_be_extended
| Already_extended of Project.t option (* None = keep the current project *)
let extended_ast_project: extended_project ref = ref To_be_extended
let unmemoized_extend_ast () =
let extend () =
let share = Options.Share.get_dir ~mode:`Must_exist "." in
Options.feedback ~level:3 "setting kernel options for E-ACSL.";
Kernel.CppExtraArgs.add
(Format.asprintf " -DE_ACSL_MACHDEP=%s -I%a/memory_model"
(Kernel.Machdep.get ())
Datatype.Filepath.pp_abs share);
Kernel.Keep_unused_specified_functions.off ();
if Plugin.is_present "variadic" then
Dynamic.Parameter.Bool.off "-variadic-translation" ();
let ppc, ppk = File.get_preprocessor_command () in
let register s =
File.pre_register
(File.NeedCPP
(s,
ppc
^ Format.asprintf " -I%a" Datatype.Filepath.pp_abs share,
ppk))
in
List.iter register (Misc.library_files ())
in
if Ast.is_computed () then begin
(* do not modify the existing project: work on a copy.
Must also extend the current AST with the E-ACSL's library files. *)
Options.feedback ~level:2
"AST already computed: E-ACSL is going to work on a copy.";
let name = Project.get_name (Project.current ()) in
let tmpfile =
Extlib.temp_file_cleanup_at_exit ("e_acsl_" ^ name) ".i" in
let cout = open_out tmpfile in
let fmt = Format.formatter_of_out_channel cout in
File.pretty_ast ~fmt ();
let selection =
State_selection.diff
State_selection.full
(State_selection.with_dependencies Ast.self)
in
let prj =
Project.create_by_copy
~last:false
~selection
(Format.asprintf "%s for E-ACSL" name)
in
Project.on prj
(fun () ->
Kernel.Files.set [ Datatype.Filepath.of_string tmpfile ];
extend ())
();
Some prj
end else begin
extend ();
None
end
let extend_ast () = match !extended_ast_project with
| To_be_extended ->
let prj = unmemoized_extend_ast () in
extended_ast_project := Already_extended prj;
(match prj with
| None -> Project.current ()
| Some prj -> prj)
| Already_extended None ->
Project.current ()
| Already_extended(Some prj) ->
prj
let apply_on_e_acsl_ast f x =
let tmp_prj = extend_ast () in
let res = Project.on tmp_prj f x in
(match !extended_ast_project with
| To_be_extended -> assert false
| Already_extended None -> ()
| Already_extended (Some prj) ->
assert (Project.equal prj tmp_prj);
extended_ast_project := To_be_extended;
if Options.Debug.get () = 0 then Project.remove ~project:tmp_prj ());
res
module Resulting_projects = module Resulting_projects =
State_builder.Hashtbl State_builder.Hashtbl
(Datatype.String.Hashtbl) (Datatype.String.Hashtbl)
...@@ -133,32 +48,46 @@ let () = ...@@ -133,32 +48,46 @@ let () =
let generate_code = let generate_code =
Resulting_projects.memo Resulting_projects.memo
(fun name -> (fun name ->
apply_on_e_acsl_ast Options.feedback "beginning translation.";
Temporal.enable (Options.Temporal_validity.get ());
let rtl_prj =
Project.create_by_copy ~last:false "E_ACSL RTL"
in
if Plugin.is_present "variadic" then begin
let opt_name = "-variadic-translation" in
if Dynamic.Parameter.Bool.get opt_name () then begin
if Ast.is_computed () then
Options.abort
"The variadic translation must be turned off for E-ACSL. \
Please use option '-variadic-no-translation'";
Options.warning "deactivating variadic translation";
Dynamic.Parameter.Bool.off opt_name ();
end
end;
Ast.compute ();
let copied_prj = Project.create_by_copy ~last:true name in
Project.on
copied_prj
(fun () -> (fun () ->
Options.feedback "beginning translation."; (* preparation of the AST does not concern the E-ACSL RTL *)
Temporal.enable (Options.Temporal_validity.get ()); Prepare_ast.prepare ();
let copied_prj = Rtl.link rtl_prj;
Project.create_by_copy name ~last:true Injector.inject ();
(* remove the RTE's results computed from E-ACSL: they are partial
and associated with the wrong kernel function (the one of the old
project). *)
(* [TODO ARCHI] what if RTE was already computed? *)
let selection =
State_selection.union
(State_selection.with_dependencies !Db.RteGen.self)
(State_selection.with_dependencies Options.Run.self)
in in
Project.on Project.clear ~selection ~project:copied_prj ();
copied_prj Resulting_projects.mark_as_computed ())
(fun () -> ();
Prepare_ast.prepare (); Options.feedback "translation done in project \"%s\"."
Injector.inject (); (Options.Project_name.get ());
(* remove the RTE's results computed from E-ACSL: they are copied_prj)
partial and associated with the wrong kernel function (the
one of the old project). *)
(* [TODO ARCHI] what if RTE was already computed? *)
let selection =
State_selection.with_dependencies !Db.RteGen.self
in
Project.clear ~selection ~project:copied_prj ();
Resulting_projects.mark_as_computed ())
();
Options.feedback "translation done in project \"%s\"."
(Options.Project_name.get ());
copied_prj)
())
let generate_code = let generate_code =
Dynamic.register Dynamic.register
...@@ -177,15 +106,6 @@ let predicate_to_exp = ...@@ -177,15 +106,6 @@ let predicate_to_exp =
Kernel_function.ty Cil_datatype.Predicate.ty Cil_datatype.Exp.ty) Kernel_function.ty Cil_datatype.Predicate.ty Cil_datatype.Exp.ty)
Translate.predicate_to_exp Translate.predicate_to_exp
let add_e_acsl_library _files =
if Options.must_visit () || Options.Prepare.get () then ignore (extend_ast ())
(* extending the AST as soon as possible reduce the amount of time the AST is
duplicated:
- that is faster
- locations are better (indicate an existing file, and not a temp file) *)
let () = Cmdline.run_after_configuring_stage add_e_acsl_library
(* The Frama-C standard library contains specific built-in variables prefixed by (* The Frama-C standard library contains specific built-in variables prefixed by
"__fc_" and declared as extern: they prevent the generated code to be "__fc_" and declared as extern: they prevent the generated code to be
linked. This modification of the default printer replaces them by their linked. This modification of the default printer replaces them by their
...@@ -251,14 +171,12 @@ let main () = ...@@ -251,14 +171,12 @@ let main () =
Keep_status.clear (); Keep_status.clear ();
if Options.Run.get () then begin if Options.Run.get () then begin
change_printer (); change_printer ();
ignore (generate_code (Options.Project_name.get ())) ignore (generate_code (Options.Project_name.get ()));
end else end else
if Options.Check.get () then if Options.Check.get () then begin
apply_on_e_acsl_ast Gmp_types.init ();
(fun () -> ignore (check ())
Gmp_types.init (); end
ignore (check ()))
()
let () = Db.Main.extend main let () = Db.Main.extend main
......
...@@ -63,13 +63,6 @@ module Valid = ...@@ -63,13 +63,6 @@ module Valid =
let help = "translate annotation which have been proven valid" let help = "translate annotation which have been proven valid"
end) end)
module Prepare =
False
(struct
let option_name = "-e-acsl-prepare"
let help = "prepare the AST to be directly usable by E-ACSL"
end)
module Gmp_only = module Gmp_only =
False False
(struct (struct
...@@ -174,6 +167,6 @@ let dkey_typing = register_category "typing" ...@@ -174,6 +167,6 @@ let dkey_typing = register_category "typing"
(* (*
Local Variables: Local Variables:
compile-command: "make" compile-command: "make -C ../../../.."
End: End:
*) *)
...@@ -25,7 +25,6 @@ include Plugin.S (** implementation of Log.S for E-ACSL *) ...@@ -25,7 +25,6 @@ include Plugin.S (** implementation of Log.S for E-ACSL *)
module Check: Parameter_sig.Bool module Check: Parameter_sig.Bool
module Run: Parameter_sig.Bool module Run: Parameter_sig.Bool
module Valid: Parameter_sig.Bool module Valid: Parameter_sig.Bool
module Prepare: Parameter_sig.Bool
module Gmp_only: Parameter_sig.Bool module Gmp_only: Parameter_sig.Bool
module Full_mmodel: Parameter_sig.Bool module Full_mmodel: Parameter_sig.Bool
module Project_name: Parameter_sig.String module Project_name: Parameter_sig.String
...@@ -49,6 +48,6 @@ val dkey_typing: category ...@@ -49,6 +48,6 @@ val dkey_typing: category
(* (*
Local Variables: Local Variables:
compile-command: "make" compile-command: "make -C ../../../.."
End: End:
*) *)
...@@ -49,7 +49,7 @@ type kind = ...@@ -49,7 +49,7 @@ type kind =
| K_Requires | K_Requires
| K_Ensures | K_Ensures
let pretty_kind fmt k = let _pretty_kind fmt k =
Format.fprintf fmt "%s" Format.fprintf fmt "%s"
(match k with (match k with
| K_Assert -> "assert" | K_Assert -> "assert"
...@@ -119,11 +119,11 @@ let before_translation () = ...@@ -119,11 +119,11 @@ let before_translation () =
(* reset all counters *) (* reset all counters *)
Datatype.String.Hashtbl.iter (fun _ info -> info.cpt <- 0) keep_status Datatype.String.Hashtbl.iter (fun _ info -> info.cpt <- 0) keep_status
let must_translate kf kind = let must_translate _kf _kind = true
(* Options.feedback "GETTING %a for %a" (* Options.feedback "GETTING %a for %a"
pretty_kind kind pretty_kind kind
Kernel_function.pretty kf;*) Kernel_function.pretty kf;*)
!option_check (* !option_check
|| ||
!option_valid !option_valid
|| ||
...@@ -154,7 +154,7 @@ let must_translate kf kind = ...@@ -154,7 +154,7 @@ let must_translate kf kind =
Kernel_function.pretty kf; Kernel_function.pretty kf;
keep keep
with Not_found -> true with Not_found -> true
*)
(* (*
Local Variables: Local Variables:
compile-command: "make -C ../../../../.." compile-command: "make -C ../../../../.."
......
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