Summary: public Move the naming of types to it own module, so that it can be used by modules `Sil` depends from like `Procname` Reviewed By: jberdine Differential Revision: D2773148 fb-gh-sync-id: a89f595master
parent
4143d4eb2d
commit
2e7f5735d3
@ -0,0 +1,39 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*)
|
||||||
|
|
||||||
|
(** Named types. *)
|
||||||
|
type t =
|
||||||
|
| TN_typedef of Mangled.t
|
||||||
|
| TN_enum of Mangled.t
|
||||||
|
| TN_csu of Csu.t * Mangled.t
|
||||||
|
|
||||||
|
let to_string = function
|
||||||
|
| TN_enum name
|
||||||
|
| TN_typedef name -> Mangled.to_string name
|
||||||
|
| TN_csu (csu, name) ->
|
||||||
|
Csu.name csu ^ " " ^ Mangled.to_string name
|
||||||
|
|
||||||
|
let name = function
|
||||||
|
| TN_enum name
|
||||||
|
| TN_typedef name
|
||||||
|
| TN_csu (_, name) -> Mangled.to_string name
|
||||||
|
|
||||||
|
let compare tn1 tn2 = match tn1, tn2 with
|
||||||
|
| TN_typedef n1, TN_typedef n2 -> Mangled.compare n1 n2
|
||||||
|
| TN_typedef _, _ -> - 1
|
||||||
|
| _, TN_typedef _ -> 1
|
||||||
|
| TN_enum n1, TN_enum n2 -> Mangled.compare n1 n2
|
||||||
|
| TN_enum _, _ -> -1
|
||||||
|
| _, TN_enum _ -> 1
|
||||||
|
| TN_csu (csu1, n1), TN_csu (csu2, n2) ->
|
||||||
|
let n = Csu.compare csu1 csu2 in
|
||||||
|
if n <> 0 then n else Mangled.compare n1 n2
|
||||||
|
|
||||||
|
let equal tn1 tn2 =
|
||||||
|
compare tn1 tn2 = 0
|
@ -0,0 +1,26 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*)
|
||||||
|
|
||||||
|
(** Named types. *)
|
||||||
|
type t =
|
||||||
|
| TN_typedef of Mangled.t
|
||||||
|
| TN_enum of Mangled.t
|
||||||
|
| TN_csu of Csu.t * Mangled.t
|
||||||
|
|
||||||
|
(** convert the typename to a string *)
|
||||||
|
val to_string : t -> string
|
||||||
|
|
||||||
|
(** name of the typename without qualifier *)
|
||||||
|
val name : t -> string
|
||||||
|
|
||||||
|
(** Comparison for typenames *)
|
||||||
|
val compare : t -> t -> int
|
||||||
|
|
||||||
|
(** Equality for typenames *)
|
||||||
|
val equal : t -> t -> bool
|
Loading…
Reference in new issue