Project

General

Profile

Download (1.6 KB) Statistics
| Branch: | Tag: | Revision:
1
open Lustrec
2
open Basetypes
3
open Datatype
4
open CPS_transformer
5
open Theta
6

    
7
module Semantics = functor (T: TransformerType) (M: MODEL_T) ->
8
struct
9

    
10
module Prog =
11
struct
12
  let init, defs, state_vars, globals =
13
    let Program (init, defs, globals) = M.model in
14
    let state_vars = SF.states M.model in
15
    init, defs, state_vars, globals
16

    
17
(*let _ = Format.printf "Model definitions@.%a@.####" Simulink.pp_src defs; () *)
18
end
19

    
20

    
21
module Interp = CPS_interpreter.Interpreter (T)
22
module KenvTheta = KenvTheta (T)
23
module Tables = KenvTheta.MemoThetaTables ()
24

    
25
let eval ((modular_entry:bool), (modular_during:bool), (modular_exit:bool)) =
26
  let module Modularity : KenvTheta.ModularType =
27
      struct
28
	let modular : type b. (path_t, b, bool) tag_t -> path_t -> b =
29
			fun tag ->
30
			  match tag with
31
			  | E -> (fun p p' f -> modular_entry)
32
			  | D -> (fun p      -> modular_during)
33
			  | X -> (fun p f    -> modular_exit)
34
      end
35
  in
36
  let module Thetaify = KenvTheta.ModularThetaify (Tables) (Modularity) in
37
  let module EvalProg = Interp.Evaluation (Thetaify) (Prog) in
38
  (module EvalProg: Interp.EvaluationType)
39

    
40
let compute modular  =
41
  let module Eval = (val (eval modular)) in
42
  Eval.eval_prog
43

    
44
let code_gen modular  =
45
  let module Eval = (val (eval modular)) in
46
  let principal, components =  Eval.eval_prog, Eval.eval_components in
47
  List.flatten (List.map (fun (c, tr) -> T.mkcomponent Ecall c tr) (components Ecall))@
48
    List.flatten (List.map (fun (c, tr) -> T.mkcomponent Dcall c tr) (components Dcall))@
49
    List.flatten (List.map (fun (c, tr) -> T.mkcomponent Xcall c tr) (components Xcall))@
50
    (T.mkprincipal principal)
51
end
(2-2/10)