summaryrefslogtreecommitdiff
path: root/cparser/Env.mli
blob: 01f95ca9447ed32893932a979f162f4e9906312f (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 2 of the License, or  *)
(*  (at your option) any later version.  This file is also distributed *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)

type error =
    Unbound_identifier of string
  | Unbound_tag of string * string
  | Tag_mismatch of string * string * string
  | Unbound_typedef of string
  | No_member of string * string * string
val error_message : error -> string
exception Error of error

val fresh_ident : string -> C.ident

type composite_info = {
  ci_kind: C.struct_or_union;
  ci_members: C.field list;             (* members, in order *)
  ci_alignof: int option;               (* alignment; None if incomplete *)
  ci_sizeof: int option;                (* size; None if incomplete *)
  ci_attr: C.attributes                 (* attributes, if any *)
}

type ident_info = II_ident of C.storage * C.typ | II_enum of int64

type typedef_info = C.typ

type t

val empty : t

val new_scope : t -> t
val in_current_scope : t -> C.ident -> bool

val lookup_ident : t -> string -> C.ident * ident_info
val lookup_tag : t -> string -> C.ident * composite_info
val lookup_struct : t -> string -> C.ident * composite_info
val lookup_union : t -> string -> C.ident * composite_info
val lookup_composite : t -> string -> (C.ident * composite_info) option
val lookup_typedef : t -> string -> C.ident * typedef_info

val ident_is_bound : t -> string -> bool

val find_ident : t -> C.ident -> ident_info
val find_tag : t -> C.ident -> composite_info
val find_struct : t -> C.ident -> composite_info
val find_union : t -> C.ident -> composite_info
val find_member : C.field list -> string -> C.field
val find_struct_member : t -> C.ident * string -> C.field
val find_union_member : t -> C.ident * string -> C.field
val find_typedef : t -> C.ident -> typedef_info

val enter_ident : t -> string -> C.storage -> C.typ -> C.ident * t
val enter_composite : t -> string -> composite_info -> C.ident * t
val enter_enum_item : t -> string -> int64 -> C.ident * t
val enter_typedef : t -> string -> typedef_info -> C.ident * t

val add_ident : t -> C.ident -> C.storage -> C.typ -> t
val add_composite : t -> C.ident -> composite_info -> t
val add_typedef : t -> C.ident -> typedef_info -> t