Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / plugins.ml @ 684d39e7

History | View | Annotate | Download (1.59 KB)

1 8446bf03 ploc
open Lustre_types
2 2b476ad8 xthirioux
3 1954d776 ploc
open PluginList
4 2b476ad8 xthirioux
5
6 f6acf47b ploc
let options () = 
7
  List.flatten (
8 1bff14ac ploc
    List.map Options_management.plugin_opt (
9 f6acf47b ploc
      List.map (fun m ->
10 ad4774b0 ploc
	let module M = (val m : PluginType.S) in
11 f6acf47b ploc
	(M.name, M.activate, M.options)
12
      ) plugins
13
    ))
14 2b476ad8 xthirioux
15 f6acf47b ploc
let check_force_stateful () =
16
  List.exists (fun m ->
17 ad4774b0 ploc
	let module M = (val m : PluginType.S) in
18 f6acf47b ploc
	M.check_force_stateful ()
19
  ) plugins
20
21
let refine_machine_code prog machine_code =
22
  List.fold_left (fun accu m ->
23 ad4774b0 ploc
    let module M = (val m : PluginType.S) in
24 f6acf47b ploc
    M.refine_machine_code prog accu
25
  ) machine_code plugins
26
27
28 7ab1c5bd ploc
let c_backend_main_loop_body_prefix basename mname fmt () = 
29 ad4774b0 ploc
  List.iter (fun (m: (module PluginType.S)) -> 
30
    let module M = (val m : PluginType.S) in
31 7ab1c5bd ploc
    M.c_backend_main_loop_body_prefix basename mname fmt ()) plugins
32
33 f6acf47b ploc
let c_backend_main_loop_body_suffix fmt () = 
34 ad4774b0 ploc
  List.iter (fun (m: (module PluginType.S)) -> 
35
    let module M = (val m : PluginType.S) in
36 f6acf47b ploc
    M.c_backend_main_loop_body_suffix fmt ()) plugins
37
38
(* Specific treatment of annotations when inlining, specific of declared plugins *)
39 2b476ad8 xthirioux
40
let inline_annots rename_var_fun annot_list =
41
  List.map (
42
    fun ann -> 
43
      { ann with 
44
	annots = List.fold_left (
45
	  fun accu (sl, eexpr) -> 
46
	    let items = 
47
	      match sl with 
48
	      | plugin_name::args -> 
49
		if plugin_name = "salsa" then
50
		  match args with
51
		  | ["ranges";varname] -> 
52
		    [["salsa";"ranges";(rename_var_fun varname)], eexpr]
53
		  | _ -> [(sl, eexpr)]
54
		else
55
		  [(sl, eexpr)]
56
	    | _ -> assert false
57
	    in
58
	    items@accu
59
	) [] ann.annots
60
      }
61
  ) annot_list
62
63
(* Local Variables: *)
64
(* compile-command:"make -C .." *)
65
(* End: *)