File: prefix.ml

package info (click to toggle)
camlidl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,572 kB
  • sloc: ml: 5,236; ansic: 945; cpp: 908; makefile: 358; xml: 213; sh: 74
file content (38 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(***********************************************************************)
(*                                                                     *)
(*                              CamlIDL                                *)
(*                                                                     *)
(*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
(*                                                                     *)
(*  Copyright 1999 Institut National de Recherche en Informatique et   *)
(*  en Automatique.  All rights reserved.  This file is distributed    *)
(*  under the terms of the GNU Lesser General Public License LGPL v2.1 *)
(*                                                                     *)
(***********************************************************************)

(* $Id: prefix.ml,v 1.1 2002-01-16 09:42:03 xleroy Exp $ *)

open Idltypes
open Utils

module StringMap = Map.Make(struct type t = string let compare = compare end)

type t = string StringMap.t

let empty = StringMap.empty

let enter_function params =
  List.fold_left (fun e (name, _, _) -> StringMap.add name "" e)
                 StringMap.empty params

let enter_struct pref sd base =
  let base' = base ^ "." in
  List.fold_left
    (fun e f -> StringMap.add f.field_name base' e)
    StringMap.empty sd.sd_fields

let for_ident pref id =
  try
    StringMap.find id pref
  with Not_found ->
    error (Printf.sprintf "Illegal reference to dependent variable %s.  This variable is not in scope." id)