[inferbo] Use algebraic data type for allocsite

Summary: It revises the type of Allocsite.t.

Reviewed By: mbouaziz

Differential Revision: D9569574

fbshipit-source-id: 62865a5c8
master
Sungkeun Cho 6 years ago committed by Facebook Github Bot
parent bdc1ad751d
commit d261f94624

@ -12,20 +12,24 @@ open! IStd
module F = Format
module Allocsite = struct
include String
type t = Unknown | Known of {proc_name: string; node_hash: int; inst_num: int; dimension: int}
[@@deriving compare]
let pp fmt = function
| Unknown ->
F.fprintf fmt "Unknown"
| Known {proc_name : string; node_hash : int; inst_num : int; dimension : int} ->
F.fprintf fmt "%s-%d-%d-%d" proc_name node_hash inst_num dimension
let pp fmt s = Format.pp_print_string fmt s
let to_string x = F.asprintf "%a" pp x
let make : Typ.Procname.t -> node_hash:int -> inst_num:int -> dimension:int -> t =
fun proc_name ~node_hash ~inst_num ~dimension ->
let proc_name = Typ.Procname.to_string proc_name in
let node_num = string_of_int node_hash in
let inst_num = string_of_int inst_num in
let dimension = string_of_int dimension in
proc_name ^ "-" ^ node_num ^ "-" ^ inst_num ^ "-" ^ dimension
Known {proc_name= Typ.Procname.to_string proc_name; node_hash; inst_num; dimension}
let unknown = "Unknown"
let unknown = Unknown
end
module Loc = struct

Loading…
Cancel
Save