ppx_compare Var

Reviewed By: sblackshear

Differential Revision: D4232396

fbshipit-source-id: 25dc464
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent aa5998a9d1
commit 9bc72ad790

@ -12,8 +12,12 @@ open! Utils
(** Single abstraction for all the kinds of variables in SIL *)
type t =
| ProgramVar of Pvar.t
| LogicalVar of Ident.t
| ProgramVar of Pvar.t
[@@deriving compare]
let equal v1 v2 =
compare v1 v2 = 0
let of_id id =
LogicalVar id
@ -25,15 +29,6 @@ let to_exp = function
| ProgramVar pvar -> Exp.Lvar pvar
| LogicalVar id -> Exp.Var id
let compare v1 v2 = match v1, v2 with
| ProgramVar pv1, ProgramVar pv2 -> Pvar.compare pv1 pv2
| LogicalVar sv1, LogicalVar sv2 -> Ident.compare sv1 sv2
| ProgramVar _, _ -> 1
| LogicalVar _, _ -> -1
let equal v1 v2 =
compare v1 v2 = 0
let pp fmt = function
| ProgramVar pv -> (Pvar.pp pe_text) fmt pv
| LogicalVar id -> (Ident.pp pe_text) fmt id

@ -10,8 +10,11 @@
(** Single abstraction for all the kinds of variables in SIL *)
type t = private
| ProgramVar of Pvar.t
| LogicalVar of Ident.t
| ProgramVar of Pvar.t
[@@deriving compare]
val equal : t -> t -> bool
val of_id : Ident.t -> t
@ -19,10 +22,6 @@ val of_pvar : Pvar.t -> t
val to_exp : t -> Exp.t
val equal : t -> t -> bool
val compare : t -> t -> int
val pp : Format.formatter -> t -> unit
module Map : PrettyPrintable.PPMap with type key = t

Loading…
Cancel
Save