1
|
(* ----------------------------------------------------------------------------
|
2
|
* SchedMCore - A MultiCore Scheduling Framework
|
3
|
* Copyright (C) 2009-2011, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE
|
4
|
*
|
5
|
* This file is part of Prelude
|
6
|
*
|
7
|
* Prelude is free software; you can redistribute it and/or
|
8
|
* modify it under the terms of the GNU Lesser General Public License
|
9
|
* as published by the Free Software Foundation ; either version 2 of
|
10
|
* the License, or (at your option) any later version.
|
11
|
*
|
12
|
* Prelude is distributed in the hope that it will be useful, but
|
13
|
* WITHOUT ANY WARRANTY ; without even the implied warranty of
|
14
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
* Lesser General Public License for more details.
|
16
|
*
|
17
|
* You should have received a copy of the GNU Lesser General Public
|
18
|
* License along with this program ; if not, write to the Free Software
|
19
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
20
|
* USA
|
21
|
*---------------------------------------------------------------------------- *)
|
22
|
|
23
|
(** Generic inference environments. Used both for typing and
|
24
|
clock-calculus. *)
|
25
|
open Utils
|
26
|
|
27
|
(* Same namespace for nodes, variables and constants *)
|
28
|
let initial = IMap.empty
|
29
|
|
30
|
let add_value env ident ty =
|
31
|
IMap.add ident ty env
|
32
|
|
33
|
let lookup_value env ident =
|
34
|
IMap.find ident env
|
35
|
|
36
|
let exists_value env ident =
|
37
|
IMap.mem ident env
|
38
|
|
39
|
let iter env f = IMap.iter f env
|
40
|
|
41
|
(* Merges x and y. In case of conflicting definitions,
|
42
|
overwrites definitions in x by definitions in y *)
|
43
|
let overwrite x y =
|
44
|
IMap.merge (
|
45
|
fun k _old _new -> match _new with
|
46
|
| Some _ -> _new
|
47
|
| _ -> _old
|
48
|
) x y
|
49
|
|
50
|
open Format
|
51
|
|
52
|
let pp_env pp_fun fmt env =
|
53
|
let (lid,lty) = list_of_imap env in
|
54
|
let l' = List.combine lid lty in
|
55
|
let pp_fun fmt (id,value) =
|
56
|
Format.fprintf fmt "%s |-> %a" id pp_fun value
|
57
|
in
|
58
|
Format.fprintf fmt "{ @[<v 2>%a@] }" (fprintf_list ~sep:"@," pp_fun) l'
|
59
|
|
60
|
(* Local Variables: *)
|
61
|
(* compile-command:"make -C .." *)
|
62
|
(* End: *)
|