You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
919 B
34 lines
919 B
7 years ago
|
(*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*)
|
||
7 years ago
|
|
||
|
(** Global variables *)
|
||
|
|
||
5 years ago
|
type t = {reg: Reg.t; init: Exp.t option; typ: Typ.t; loc: Loc.t}
|
||
6 years ago
|
[@@deriving compare, equal, hash, sexp]
|
||
6 years ago
|
|
||
5 years ago
|
let pp fs {reg} =
|
||
|
let name = Reg.name reg in
|
||
6 years ago
|
let pf pp =
|
||
|
Format.pp_open_box fs 2 ;
|
||
|
Format.kfprintf (fun fs -> Format.pp_close_box fs ()) fs pp
|
||
|
in
|
||
5 years ago
|
pf "@%s%a" name Reg.pp_demangled reg
|
||
6 years ago
|
|
||
5 years ago
|
let pp_defn fs {reg; init; typ; loc} =
|
||
|
Format.fprintf fs "@[<2>%a %a%a%a@]" Typ.pp typ Reg.pp reg Loc.pp loc
|
||
5 years ago
|
(Option.pp "@ = @[%a@]" Exp.pp)
|
||
6 years ago
|
init
|
||
|
|
||
|
let invariant g =
|
||
|
Invariant.invariant [%here] g [%sexp_of: t]
|
||
|
@@ fun () ->
|
||
5 years ago
|
let {reg; typ} = g in
|
||
5 years ago
|
assert (Typ.is_sized typ) ;
|
||
5 years ago
|
assert (Var.is_global (Reg.var reg))
|
||
6 years ago
|
|
||
5 years ago
|
let mk ?init reg typ loc = {reg; init; typ; loc} |> check invariant
|