Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / plugins.ml @ 61df3cb9

History | View | Annotate | Download (1.79 KB)

1
open Lustre_types
2

    
3
open PluginList
4

    
5

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

    
15
let init () =
16
  List.iter (fun m ->
17
      let module M = (val m : PluginType.PluginType) in
18
      M.init ()
19
    ) plugins
20
  
21
let check_force_stateful () =
22
  List.exists (fun m ->
23
	let module M = (val m : PluginType.PluginType) in
24
	M.check_force_stateful ()
25
  ) plugins
26

    
27
let refine_machine_code prog machine_code =
28
  List.fold_left (fun accu m ->
29
    let module M = (val m : PluginType.PluginType) in
30
    M.refine_machine_code prog accu
31
  ) machine_code plugins
32

    
33

    
34
let c_backend_main_loop_body_prefix basename mname fmt () = 
35
  List.iter (fun (m: (module PluginType.PluginType)) -> 
36
    let module M = (val m : PluginType.PluginType) in
37
    M.c_backend_main_loop_body_prefix basename mname fmt ()) plugins
38

    
39
let c_backend_main_loop_body_suffix fmt () = 
40
  List.iter (fun (m: (module PluginType.PluginType)) -> 
41
    let module M = (val m : PluginType.PluginType) in
42
    M.c_backend_main_loop_body_suffix fmt ()) plugins
43

    
44
(* Specific treatment of annotations when inlining, specific of declared plugins *)
45

    
46
let inline_annots rename_var_fun annot_list =
47
  List.map (
48
    fun ann -> 
49
      { ann with 
50
	annots = List.fold_left (
51
	  fun accu (sl, eexpr) -> 
52
	    let items = 
53
	      match sl with 
54
	      | plugin_name::args -> 
55
		if plugin_name = "salsa" then
56
		  match args with
57
		  | ["ranges";varname] -> 
58
		    [["salsa";"ranges";(rename_var_fun varname)], eexpr]
59
		  | _ -> [(sl, eexpr)]
60
		else
61
		  [(sl, eexpr)]
62
	    | _ -> assert false
63
	    in
64
	    items@accu
65
	) [] ann.annots
66
      }
67
  ) annot_list
68

    
69
(* Local Variables: *)
70
(* compile-command:"make -C .." *)
71
(* End: *)