Project

General

Profile

« Previous | Next » 

Revision ca7ff3f7

Added by LĂ©lio Brun 7 months ago

reformatting

View differences:

src/plugins/plugins.ml
1 1
open Lustre_types
2

  
3 2
open PluginList
4 3

  
5 4
let () = Sites.Plugins.Plugins.load_all ()
6 5

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

  
16 15
let init () =
17
  List.iter (fun m ->
16
  List.iter
17
    (fun m ->
18 18
      let module M = (val m : PluginType.S) in
19
      M.init ()
20
    ) (plugins ())
21
  
19
      M.init ())
20
    (plugins ())
21

  
22 22
let check_force_stateful () =
23
  List.exists (fun m ->
24
	let module M = (val m : PluginType.S) in
25
	M.check_force_stateful ()
26
  ) (plugins ())
23
  List.exists
24
    (fun m ->
25
      let module M = (val m : PluginType.S) in
26
      M.check_force_stateful ())
27
    (plugins ())
27 28

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

  
30
  List.fold_left
31
    (fun accu m ->
32
      let module M = (val m : PluginType.S) in
33
      M.refine_machine_code prog accu)
34
    machine_code (plugins ())
34 35

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

  
40
let c_backend_main_loop_body_suffix fmt () = 
41
  List.iter (fun (m: (module PluginType.S)) -> 
42
    let module M = (val m : PluginType.S) in
43
    M.c_backend_main_loop_body_suffix fmt ()) (plugins ())
43
let c_backend_main_loop_body_suffix fmt () =
44
  List.iter
45
    (fun (m : (module PluginType.S)) ->
46
      let module M = (val m : PluginType.S) in
47
      M.c_backend_main_loop_body_suffix fmt ())
48
    (plugins ())
44 49

  
45 50
(* Specific treatment of annotations when inlining, specific of declared plugins *)
46 51

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

  
70 78
(* Local Variables: *)
71 79
(* compile-command:"make -C .." *)

Also available in: Unified diff