Project

General

Profile

Download (1.62 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
(** Generic inference environments. Used both for typing and
13
    clock-calculus. *)
14
open Utils
15

    
16
(* Same namespace for nodes, variables and constants *)
17
let initial = IMap.empty
18

    
19
let add_value env ident ty =
20
  IMap.add ident ty env
21

    
22
let lookup_value env ident =
23
  IMap.find ident env
24

    
25
let exists_value env ident =
26
  IMap.mem ident env
27

    
28
let iter env f = IMap.iter f env
29

    
30
(* Merges x and y. In case of conflicting definitions,
31
   overwrites definitions in x by definitions in y *)
32
let overwrite x y =
33
  IMap.merge (
34
    fun k _old _new -> match _new with
35
      | Some _ -> _new
36
      | _ -> _old
37
  ) x y
38

    
39
open Format
40

    
41
let pp_env pp_fun fmt env =
42
  let (lid,lty) = list_of_imap env in
43
  let l' = List.combine lid lty in
44
  let pp_fun fmt (id,value) =
45
    Format.fprintf fmt "%s |-> %a" id pp_fun value
46
  in
47
  Format.fprintf fmt "{ @[<v 2>%a@] }" (fprintf_list ~sep:"@," pp_fun) l'
48

    
49
(* Local Variables: *)
50
(* compile-command:"make -C .." *)
51
(* End: *)
(17-17/50)