Project

General

Profile

Download (1.59 KB) Statistics
| Branch: | Tag: | Revision:
1 eb70bae5 Christophe Garion
open Basetypes
2 2de7fa82 ploc
open Datatype
3
open CPS_transformer
4 eb70bae5 Christophe Garion
open Theta
5 2de7fa82 ploc
6
module Semantics = functor (T: TransformerType) (M: MODEL_T) ->
7
struct
8 eb70bae5 Christophe Garion
9 2de7fa82 ploc
module Prog =
10
struct
11 9c654082 ploc
  let init, defs, state_vars, globals =
12 eb70bae5 Christophe Garion
    let Program (init, defs, globals) = M.model in
13 93119c3f ploc
    let state_vars = SF.states M.model in
14 9c654082 ploc
    init, defs, state_vars, globals
15 eb70bae5 Christophe Garion
16 2de7fa82 ploc
(*let _ = Format.printf "Model definitions@.%a@.####" Simulink.pp_src defs; () *)
17
end
18
19
20
module Interp = CPS_interpreter.Interpreter (T)
21
module KenvTheta = KenvTheta (T)
22
module Tables = KenvTheta.MemoThetaTables ()
23
24
let eval ((modular_entry:bool), (modular_during:bool), (modular_exit:bool)) =
25
  let module Modularity : KenvTheta.ModularType =
26
      struct
27
	let modular : type b. (path_t, b, bool) tag_t -> path_t -> b =
28
			fun tag ->
29
			  match tag with
30
			  | E -> (fun p p' f -> modular_entry)
31
			  | D -> (fun p      -> modular_during)
32
			  | X -> (fun p f    -> modular_exit)
33
      end
34
  in
35
  let module Thetaify = KenvTheta.ModularThetaify (Tables) (Modularity) in
36
  let module EvalProg = Interp.Evaluation (Thetaify) (Prog) in
37
  (module EvalProg: Interp.EvaluationType)
38 eb70bae5 Christophe Garion
39 2de7fa82 ploc
let compute modular  =
40
  let module Eval = (val (eval modular)) in
41 eb70bae5 Christophe Garion
  Eval.eval_prog
42
43 69c96b6c ploc
let code_gen modular  =
44 2de7fa82 ploc
  let module Eval = (val (eval modular)) in
45
  let principal, components =  Eval.eval_prog, Eval.eval_components in
46 69c96b6c ploc
  List.flatten (List.map (fun (c, tr) -> T.mkcomponent Ecall c tr) (components Ecall))@
47
    List.flatten (List.map (fun (c, tr) -> T.mkcomponent Dcall c tr) (components Dcall))@
48
    List.flatten (List.map (fun (c, tr) -> T.mkcomponent Xcall c tr) (components Xcall))@
49
    (T.mkprincipal principal)
50 2de7fa82 ploc
end