Skip to content

Commit cc73915

Browse files
authored
enables enumeration of objects in the knowledge base (#1212)
Adds the `objects` function that returns a sequence of all objects in the knowledge base.
1 parent ba8622c commit cc73915

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/knowledge/bap_knowledge.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,10 @@ module Knowledge = struct
28892889
Format.fprintf ppf "@,%a)@]@\n"
28902890
(Sexp.pp_hum_indent 2) (Dict.sexp_of_t data)))
28912891

2892+
let objects cls = objects cls >>| fun {vals} ->
2893+
Map.to_sequence vals |>
2894+
Sequence.map ~f:fst
2895+
28922896
module Rule = struct
28932897
type def = Registry.def
28942898
type doc = Registry.doc

lib/knowledge/bap_knowledge.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ module Knowledge : sig
152152
(** a fully qualified name *)
153153
type name
154154

155+
(** [objects cls] is a seqeuence of all objects of the class [cls].
156+
@since 2.2.0 *)
157+
val objects : ('a,_) cls -> 'a obj Sequence.t t
158+
155159
(** [collect p x] collects the value of the property [p].
156160
157161
If the object [x] doesn't have a value for the property [p] and

0 commit comments

Comments
 (0)