Project

General

Profile

Download (1.84 KB) Statistics
| Branch: | Tag: | Revision:
1 22fe1c93 ploc
(* ----------------------------------------------------------------------------
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 5c1184ad ploc
let iter env f = IMap.iter f env
40
 
41 22fe1c93 ploc
let overwrite x y =
42
  IMap.merge (
43
    fun k _old _new -> match _new with
44
      | Some _ -> _new
45
      | _ -> _old
46
  ) x y
47
48
open Format
49
50
let pp_env pp_fun fmt env =
51
  let (lid,lty) = list_of_imap env in
52
  let l' = List.combine lid lty in
53
  let pp_fun fmt (id,value) =
54
    Format.fprintf fmt "%s |-> %a" id pp_fun value
55
  in
56
  Format.fprintf fmt "{ @[<v 2>%a@] }" (fprintf_list ~sep:"@," pp_fun) l'
57
58
(* Local Variables: *)
59
(* compile-command:"make -C .." *)
60
(* End: *)