Project

General

Profile

Download (2.1 KB) Statistics
| Branch: | Tag: | Revision:
1
open Basetypes
2
open ActiveStates
3
open CPS_transformer
4

    
5
module CodeGenerator : ComparableTransformerType =
6
struct
7
  include TransformerStub
8

    
9
  type t =
10
  | Bot
11
  | Act of act_t
12
  | Seq of t list
13
  | Ite of cond_t * t * t
14

    
15
  let null = Seq []
16

    
17
  let bot = Bot
18
 
19
  let ( >> ) tr1 tr2 =
20
    match tr1, tr2 with
21
    | Seq trl1, Seq trl2 -> Seq (trl1@trl2)
22
    | Seq trl1, _        -> Seq (trl1@[tr2])
23
    | _       , Seq trl2 -> Seq (tr1::trl2)
24
    | _                  -> Seq ([tr1;tr2])
25

    
26
  let rec ( == ) tr1 tr2 = tr1 = tr2
27

    
28
  let eval_act kenv (action : act_t) =
29
    (*Format.printf "----- action = %a@." Action.pp_act action;*)
30
    Act action
31

    
32
  (*if (match trans.event with None -> true | _ -> e = trans.event) && trans.condition rho*)
33
  let rec eval_cond condition ok ko =
34
    (*Format.printf "----- cond = %a@." Condition.pp_cond condition;*)
35
    Ite (condition, ok, ko)
36
    
37
  let rec pp_transformer fmt tr =
38
    match tr with
39
    | Bot           -> Format.fprintf fmt "bot"
40
    | Act a         ->
41
       Format.fprintf fmt "<%a>" pp_act a
42
    | Seq trl       ->
43
       Format.fprintf fmt "@[<v 0>%a@]"
44
	 (Utils.fprintf_list ~sep:";@ " pp_transformer)
45
	 trl
46
    | Ite (c, t, e) ->
47
       Format.fprintf fmt "@[<v 0>if %a@ @[<v 2>then@ %a@]@ @[<v 2>else@ %a@]@ endif@]" pp_cond c pp_transformer t pp_transformer e
48

    
49
  let pp_principal fmt tr =
50
    Format.fprintf fmt "principal =@.%a" pp_transformer tr
51
      
52
  let pp_component : type c. Format.formatter -> c call_t -> c -> t -> unit =
53
    fun fmt call -> match call with
54
    | Ecall -> (fun (p, p', f) tr ->
55
      Format.fprintf fmt "component %a(%a, %a, %a) =@.@[<v 2>begin@ %a@]@.end" pp_call call pp_path p pp_path p' pp_frontier f pp_transformer tr)
56
    | Dcall -> (fun p tr ->
57
      Format.fprintf fmt "component %a(%a) =@.@[<v 2>begin@ %a@]@.end" pp_call call pp_path p pp_transformer tr)
58
    | Xcall -> (fun (p, f) tr ->
59
      Format.fprintf fmt "component %a(%a, %a) =@.@[<v 2>begin@ %a@]@.end" pp_call call pp_path p pp_frontier f pp_transformer tr)
60

    
61
		     let mkcomponent _  = assert false
62
		     let mkprincipal _  = assert false
63
		     let mktransformer _  = assert false
64
		       
65
end
66

    
(2-2/9)