[pulse][minor] reduce code duplication for attribute "getters"

Summary: This will be more useful later when adding another one.

Reviewed By: ezgicicek, jberdine

Differential Revision: D18115231

fbshipit-source-id: a0a01901a
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent 4e7c794334
commit 127ba72982

@ -82,15 +82,14 @@ let check_valid address memory =
Ok ()
let get_closure_proc_name address memory =
Graph.find_opt address (snd memory)
|> Option.bind ~f:(fun attributes -> Attributes.get_closure_proc_name attributes)
let get_attribute getter address memory =
let open Option.Monad_infix in
Graph.find_opt address (snd memory) >>= getter
let get_constant address memory =
Graph.find_opt address (snd memory)
|> Option.bind ~f:(fun attributes -> Attributes.get_constant attributes)
let get_closure_proc_name = get_attribute Attributes.get_closure_proc_name
let get_constant = get_attribute Attributes.get_constant
let std_vector_reserve address memory = add_attribute address Attribute.StdVectorReserve memory

Loading…
Cancel
Save