allow access path base to be an ident as well

Reviewed By: dkgi

Differential Revision: D3584658

fbshipit-source-id: ec77b3f
master
Sam Blackshear 8 years ago committed by Facebook Github Bot 7
parent d4a9a6cde1
commit a33e047377

@ -11,7 +11,7 @@ open! Utils
module F = Format
type base = Pvar.t * Typ.t
type base = Var.t * Typ.t
type access =
| FieldAccess of Ident.fieldname * Typ.t
@ -27,7 +27,7 @@ let base_compare ((var1, typ1) as base1) ((var2, typ2) as base2) =
if base1 == base2
then 0
else
Pvar.compare var1 var2
Var.compare var1 var2
|> next Typ.compare typ1 typ2
let base_equal base1 base2 =
@ -68,7 +68,10 @@ let equal ap1 ap2 =
compare ap1 ap2 = 0
let of_pvar pvar typ =
(pvar, typ), []
(Var.of_pvar pvar, typ), []
let of_id id typ =
(Var.of_id id, typ), []
let append (base, accesses) access =
base, accesses @ [access]
@ -102,7 +105,7 @@ let (<=) ~lhs ~rhs =
| (Exact lhs_ap | Abstracted lhs_ap), Abstracted rhs_ap -> is_prefix rhs_ap lhs_ap
let pp_base fmt (pvar, _) =
(Pvar.pp pe_text) fmt pvar
Var.pp fmt pvar
let pp_access fmt = function
| FieldAccess (field_name, _) -> F.fprintf fmt ".%a" Ident.pp_fieldname field_name

@ -9,7 +9,7 @@
(** Module for naming heap locations via the path used to access them (e.g., x.f.g, y[a].b) *)
type base = Pvar.t * Typ.t
type base = Var.t * Typ.t
type access =
| FieldAccess of Ident.fieldname * Typ.t (* field name * field type *)
@ -38,6 +38,9 @@ val access_equal : access -> access -> bool
(** create an access path from a pvar *)
val of_pvar : Pvar.t -> Typ.t -> raw
(** create an access path from an ident *)
val of_id : Ident.t -> Typ.t -> raw
(** append a new access to an existing access path; e.g., `append_access g x.f` produces `x.f.g` *)
val append : raw -> access -> raw

@ -12,7 +12,7 @@ open !Utils
module F = Format
let make_base base_str =
Pvar.mk (Mangled.from_string base_str) Procname.empty_block, Typ.Tvoid
Var.of_pvar (Pvar.mk (Mangled.from_string base_str) Procname.empty_block), Typ.Tvoid
let make_field_access access_str =
AccessPath.FieldAccess (Ident.create_fieldname (Mangled.from_string access_str) 0, Typ.Tvoid)

@ -22,7 +22,7 @@ module MockTraceDomain =
module Domain = AccessTree.Make (MockTraceDomain)
let make_base base_str =
Pvar.mk (Mangled.from_string base_str) Procname.empty_block, Typ.Tvoid
Var.of_pvar (Pvar.mk (Mangled.from_string base_str) Procname.empty_block), Typ.Tvoid
let make_field_access access_str =
AccessPath.FieldAccess (Ident.create_fieldname (Mangled.from_string access_str) 0, Typ.Tvoid)

Loading…
Cancel
Save