Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / plugins.ml @ 7ab1c5bd

History | View | Annotate | Download (1.64 KB)

1
open LustreSpec
2

    
3
open PluginList
4

    
5

    
6
let options () = 
7
  List.flatten (
8
    List.map Options.plugin_opt (
9
      List.map (fun m ->
10
	let module M = (val m : PluginType.PluginType) in
11
	(M.name, M.activate, M.options)
12
      ) plugins
13
    ))
14

    
15
let check_force_stateful () =
16
  List.exists (fun m ->
17
	let module M = (val m : PluginType.PluginType) in
18
	M.check_force_stateful ()
19
  ) plugins
20

    
21
let refine_machine_code prog machine_code =
22
  List.fold_left (fun accu m ->
23
    let module M = (val m : PluginType.PluginType) in
24
    M.refine_machine_code prog accu
25
  ) machine_code plugins
26

    
27

    
28
let c_backend_main_loop_body_prefix basename mname fmt () = 
29
  List.iter (fun (m: (module PluginType.PluginType)) -> 
30
    let module M = (val m : PluginType.PluginType) in
31
    M.c_backend_main_loop_body_prefix basename mname fmt ()) plugins
32

    
33
let c_backend_main_loop_body_suffix fmt () = 
34
  List.iter (fun (m: (module PluginType.PluginType)) -> 
35
    let module M = (val m : PluginType.PluginType) in
36
    M.c_backend_main_loop_body_suffix fmt ()) plugins
37

    
38
(* Specific treatment of annotations when inlining, specific of declared plugins *)
39

    
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: *)