From 2b53e53504d5c7d698b1edb3fd35c4ccb2d4b31b Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 12 Oct 2018 09:04:09 -0700 Subject: [PATCH] [sledge] Update loc Reviewed By: mbouaziz Differential Revision: D9846744 fbshipit-source-id: b72291e5b --- sledge/src/llair/loc.ml | 22 +++++++++++----------- sledge/src/llair/loc.mli | 12 +++--------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/sledge/src/llair/loc.ml b/sledge/src/llair/loc.ml index 0911df1c9..47ce11db0 100644 --- a/sledge/src/llair/loc.ml +++ b/sledge/src/llair/loc.ml @@ -8,23 +8,23 @@ (** Source code debug locations *) type t = {dir: string; file: string; line: int; col: int} -[@@deriving compare, sexp] +[@@deriving compare, hash, sexp] let none = {dir= ""; file= ""; line= 0; col= 0} +let is_none loc = compare loc none = 0 let mk ?(dir = none.dir) ?(file = none.file) ?(col = none.col) ~line = {dir; file; line; col} - -let fmt ff {dir; file; line; col} = - Format.pp_print_string ff dir ; +let pp fs {dir; file; line; col} = + Format.pp_print_string fs dir ; if not (String.is_empty dir) then - Format.pp_print_string ff Filename.dir_sep ; - Format.pp_print_string ff file ; - if not (String.is_empty file) then Format.pp_print_char ff ':' ; + Format.pp_print_string fs Filename.dir_sep ; + Format.pp_print_string fs file ; + if not (String.is_empty file) then Format.pp_print_char fs ':' ; if line > 0 then ( - Format.pp_print_int ff line ; - Format.pp_print_char ff ':' ) ; + Format.pp_print_int fs line ; + Format.pp_print_char fs ':' ) ; if col > 0 then ( - Format.pp_print_int ff col ; - Format.pp_print_char ff ':' ) + Format.pp_print_int fs col ; + Format.pp_print_char fs ':' ) diff --git a/sledge/src/llair/loc.mli b/sledge/src/llair/loc.mli index f829d898e..c635c2f4b 100644 --- a/sledge/src/llair/loc.mli +++ b/sledge/src/llair/loc.mli @@ -8,15 +8,9 @@ (** Source code debug locations *) type t = {dir: string; file: string; line: int; col: int} +[@@deriving compare, hash, sexp] -val compare : t -> t -> int - -val t_of_sexp : Sexp.t -> t - -val sexp_of_t : t -> Sexp.t - -val fmt : t fmt - +val pp : t pp val none : t - +val is_none : t -> bool val mk : ?dir:string -> ?file:string -> ?col:int -> line:int -> t