Summary: For now: just moving this list behind an abstract type. Next: changing the internal representation. Reviewed By: ngorogiannis Differential Revision: D8140926 fbshipit-source-id: 5b959b0master
parent
256b74b289
commit
4927e31c2f
@ -0,0 +1,55 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
module F = Format
|
||||
|
||||
type t = Sil.instr list
|
||||
|
||||
let empty = []
|
||||
|
||||
let single instr = [instr]
|
||||
|
||||
let append_list = List.append
|
||||
|
||||
let prepend_one instr instrs = instr :: instrs
|
||||
|
||||
let reverse_order = List.rev
|
||||
|
||||
let is_empty = List.is_empty
|
||||
|
||||
let exists = List.exists
|
||||
|
||||
let for_all = List.for_all
|
||||
|
||||
let count = List.length
|
||||
|
||||
let nth_exists instrs index = List.drop instrs index |> List.is_empty |> not
|
||||
|
||||
let nth_exn = List.nth_exn
|
||||
|
||||
let last = List.last
|
||||
|
||||
let find_map = List.find_map
|
||||
|
||||
let pp pe fmt instrs =
|
||||
List.iter instrs ~f:(fun instr -> F.fprintf fmt "%a;@\n" (Sil.pp_instr pe) instr)
|
||||
|
||||
|
||||
let filter_map = List.filter_map
|
||||
|
||||
let fold = List.fold
|
||||
|
||||
let iter = List.iter
|
||||
|
||||
let map_changed ~equal instrs ~f = IList.map_changed ~equal instrs ~f
|
||||
|
||||
let of_list instrs = instrs
|
||||
|
||||
let of_rev_list instrs = List.rev instrs
|
@ -0,0 +1,52 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
type t
|
||||
|
||||
val empty : t
|
||||
|
||||
val single : Sil.instr -> t
|
||||
|
||||
val append_list : t -> Sil.instr list -> t
|
||||
|
||||
val prepend_one : Sil.instr -> t -> t
|
||||
|
||||
val reverse_order : t -> t
|
||||
|
||||
val is_empty : t -> bool
|
||||
|
||||
val count : t -> int
|
||||
|
||||
val exists : t -> f:(Sil.instr -> bool) -> bool
|
||||
|
||||
val for_all : t -> f:(Sil.instr -> bool) -> bool
|
||||
|
||||
val nth_exists : t -> int -> bool
|
||||
|
||||
val nth_exn : t -> int -> Sil.instr
|
||||
|
||||
val last : t -> Sil.instr option
|
||||
|
||||
val find_map : t -> f:(Sil.instr -> 'a option) -> 'a option
|
||||
|
||||
val pp : Pp.env -> Format.formatter -> t -> unit
|
||||
|
||||
val filter_map : t -> f:(Sil.instr -> Sil.instr option) -> t
|
||||
|
||||
val map_changed : equal:(Sil.instr -> Sil.instr -> bool) -> t -> f:(Sil.instr -> Sil.instr) -> t
|
||||
|
||||
val fold : (t, Sil.instr, 'a) Container.fold
|
||||
|
||||
val iter : (t, Sil.instr) Container.iter
|
||||
|
||||
val of_list : Sil.instr list -> t
|
||||
|
||||
val of_rev_list : Sil.instr list -> t
|
@ -0,0 +1,12 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
let find_value_exn = function None -> raise Caml.Not_found | Some v -> v
|
@ -0,0 +1,13 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val find_value_exn : 'a option -> 'a
|
||||
(** Like [Option.value_exn] but raises [Caml.Not_found] when called with [None]. *)
|
Loading…
Reference in new issue