Project

General

Profile

Download (2.46 KB) Statistics
| Branch: | Tag: | Revision:
1 a2d97a3e ploc
(********************************************************************)
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 22fe1c93 ploc
open Init
13 ca7ff3f7 Lélio Brun
(** Base types and predefined operator types. *)
14 22fe1c93 ploc
15
let init_zero = new_univar ()
16
17
let init_un =
18
  let univ = new_univar () in
19 ca7ff3f7 Lélio Brun
  new_init Isucc univ
20 22fe1c93 ploc
21 ca7ff3f7 Lélio Brun
let rec init_omega = { init_desc = Isucc init_omega; iid = -1 }
22 22fe1c93 ploc
23
let is_omega init =
24
  let rec search path init =
25 ca7ff3f7 Lélio Brun
    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 22fe1c93 ploc
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 ca7ff3f7 Lélio Brun
  new_init (Iarrow (new_init (Ituple [ univ; init_un ]), univ))
44 22fe1c93 ploc
45
let init_fby_op_1 =
46
  let univ = new_univar () in
47 ca7ff3f7 Lélio Brun
  new_init (Iarrow (init_zero, init_zero))
48 22fe1c93 ploc
49 ca7ff3f7 Lélio Brun
let init_fby_op_2 = init_pre_op
50 22fe1c93 ploc
51
let init_bin_poly_op =
52
  let univ = new_univar () in
53 ca7ff3f7 Lélio Brun
  new_init (Iarrow (new_init (Ituple [ univ; univ ]), univ))
54 22fe1c93 ploc
55
let init_ter_poly_op =
56
  let univ = new_univar () in
57 ca7ff3f7 Lélio Brun
  new_init (Iarrow (new_init (Ituple [ univ; univ; univ ]), univ))
58 22fe1c93 ploc
59
let env =
60
  let init_env = Env.initial in
61 ca7ff3f7 Lélio Brun
  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 22fe1c93 ploc
  env'
94
95
(* Local Variables: *)
96
(* compile-command:"make -C .." *)
97
(* End: *)