Project

General

Profile

Download (2.46 KB) Statistics
| Branch: | Tag: | Revision:
1
(********************************************************************)
2
(*                                                                  *)
3
(*  The LustreC compiler toolset   /  The LustreC Development Team  *)
4
(*  Copyright 2012 -    --   ONERA - CNRS - INPT                    *)
5
(*                                                                  *)
6
(*  LustreC is free software, distributed WITHOUT ANY WARRANTY      *)
7
(*  under the terms of the GNU Lesser General Public License        *)
8
(*  version 2.1.                                                    *)
9
(*                                                                  *)
10
(********************************************************************)
11

    
12
open Init
13
(** Base types and predefined operator types. *)
14

    
15
let init_zero = new_univar ()
16

    
17
let init_un =
18
  let univ = new_univar () in
19
  new_init Isucc univ
20

    
21
let rec init_omega = { init_desc = Isucc init_omega; iid = -1 }
22

    
23
let is_omega init =
24
  let rec search path init =
25
    match init.init_desc with
26
    | Isucc init' ->
27
      List.mem init path or search (init :: path) init'
28
    | _ ->
29
      false
30
  in
31
  search [] init
32

    
33
let init_unary_poly_op =
34
  let univ = new_univar () in
35
  new_init (Iarrow (univ, univ))
36

    
37
let init_pre_op =
38
  let univ = new_univar () in
39
  new_init (Iarrow (univ, new_init (Isucc univ)))
40

    
41
let init_arrow_op =
42
  let univ = new_univar () in
43
  new_init (Iarrow (new_init (Ituple [ univ; init_un ]), univ))
44

    
45
let init_fby_op_1 =
46
  let univ = new_univar () in
47
  new_init (Iarrow (init_zero, init_zero))
48

    
49
let init_fby_op_2 = init_pre_op
50

    
51
let init_bin_poly_op =
52
  let univ = new_univar () in
53
  new_init (Iarrow (new_init (Ituple [ univ; univ ]), univ))
54

    
55
let init_ter_poly_op =
56
  let univ = new_univar () in
57
  new_init (Iarrow (new_init (Ituple [ univ; univ; univ ]), univ))
58

    
59
let env =
60
  let init_env = Env.initial in
61
  let env' =
62
    List.fold_right
63
      (fun op env -> Env.add_value env op init_unary_poly_op)
64
      [ "uminus"; "not" ] init_env
65
  in
66
  let env' =
67
    List.fold_right
68
      (fun op env -> Env.add_value env op init_binary_poly_op)
69
      [
70
        "+";
71
        "-";
72
        "*";
73
        "/";
74
        "mod";
75
        "&&";
76
        "||";
77
        "xor";
78
        "impl";
79
        "<";
80
        "<=";
81
        ">";
82
        ">=";
83
        "!=";
84
        "=";
85
      ]
86
      env'
87
  in
88
  let env' =
89
    List.fold_right
90
      (fun op env -> Env.add_value env op init_ternary_poly_op)
91
      [ "ite" ] init_env
92
  in
93
  env'
94

    
95
(* Local Variables: *)
96
(* compile-command:"make -C .." *)
97
(* End: *)
(23-23/66)