[dispatcher] Typename dispatcher

Summary:
Extends `ProcnameDispatcher` to allow matching typenames only.
There isn't much new here, mainly moving stuff so that we only have to open one module to use the operators.

Reviewed By: skcho

Differential Revision: D6408245

fbshipit-source-id: afc6533
master
Mehdi Bouaziz 8 years ago committed by Facebook Github Bot
parent 43758e9fd7
commit 73906d537d

@ -136,9 +136,13 @@ type ('f_in, 'f_out) all_args_matcher =
{ on_objc_cpp: 'f_in -> objc_cpp -> FuncArg.t list -> 'f_out pre_result { on_objc_cpp: 'f_in -> objc_cpp -> FuncArg.t list -> 'f_out pre_result
; on_c: 'f_in -> c -> FuncArg.t list -> 'f_out pre_result } ; on_c: 'f_in -> c -> FuncArg.t list -> 'f_out pre_result }
type 'f typ_matcher = Typ.name -> 'f option
(* they are actually just the same thing *) (* they are actually just the same thing *)
type 'f dispatcher = 'f matcher type 'f dispatcher = 'f matcher
type 'f typ_dispatcher = 'f typ_matcher
(* Combinators *) (* Combinators *)
let empty : ('f, 'f, unit, 'markers, 'markers, empty) path_matcher = let empty : ('f, 'f, unit, 'markers, 'markers, empty) path_matcher =
@ -285,46 +289,130 @@ let args_end
{on_c; on_objc_cpp} {on_c; on_objc_cpp}
let make_matcher : ('f_in, 'f_out) all_args_matcher -> 'f_in -> 'f_out matcher = module type Common = sig
fun m f -> (* Template arguments *)
let {on_c; on_objc_cpp} : (_, _) all_args_matcher = m in
fun procname args ->
match procname with
| ObjC_Cpp objc_cpp ->
on_objc_cpp f objc_cpp args |> pre_to_opt procname args
| C c ->
on_c f c args |> pre_to_opt procname args
| _ ->
None
val any_typ :
('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, accept_more) template_arg
(** Eats a type *)
(** Simple implementation of a dispatcher, could be optimized later *) val capt_typ :
let make_dispatcher : 'f matcher list -> 'f dispatcher = 'marker
fun matchers procname args -> List.find_map matchers ~f:(fun matcher -> matcher procname args) -> ( 'marker mtyp -> 'f
, 'f
, 'captured_types
, 'marker mtyp * 'captured_types
, 'markers
, 'marker * 'markers
, accept_more )
template_arg
(** Captures a type than can be back-referenced *)
val capt_int :
( Int64.t -> 'f
, 'f
, 'captured_types
, 'captured_types
, 'markers
, 'markers
, accept_more )
template_arg
(** Captures an int *)
val capt_all :
( Typ.template_arg list -> 'f
, 'f
, 'captured_types
, 'captured_types
, 'markers
, 'markers
, end_of_list )
template_arg
(** Captures all template args *)
(* Template arguments *) val ( ~- ) : string -> ('f, 'f, unit, 'markers, 'markers) name_matcher
(** Starts a path with a name *)
let add_no_marker capture_markers = capture_markers val ( &+ ) :
( 'f_in
, 'f_interm
, 'captured_types_in
, 'markers_interm
, 'markers_out
, accept_more )
templ_matcher
-> ( 'f_interm
, 'f_out
, 'captured_types_in
, 'captured_types_out
, 'markers_in
, 'markers_interm
, 'lc )
template_arg
-> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher
(** Separate template arguments *)
(** Eats all template args *) val ( < ) :
let any_template_args ('f_in, 'f_interm, 'captured_types_in, 'markers_interm, 'markers_out) name_matcher
-> ( 'f_interm
, 'f_out
, 'captured_types_in
, 'captured_types_out
, 'markers_in
, 'markers_interm
, 'lc )
template_arg
-> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher
(** Starts template arguments after a name *)
val ( >:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, _) templ_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Ends template arguments and starts a name *)
val ( &+...>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, accept_more) templ_matcher
-> string -> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Ends template arguments with eats-ALL and starts a name *)
val ( &:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts ALL template arguments on the left one) *)
val ( <>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts NO template arguments on the left one) *)
end
module Common = struct
(* Template arguments *)
let add_no_marker capture_markers = capture_markers
(** Eats all template args *)
let any_template_args
: ('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, end_of_list) template_arg = : ('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, end_of_list) template_arg =
let eat_template_arg (f, captured_types, _) = Some (f, captured_types, []) in let eat_template_arg (f, captured_types, _) = Some (f, captured_types, []) in
{eat_template_arg; add_marker= add_no_marker} {eat_template_arg; add_marker= add_no_marker}
(** Eats a type *) (** Eats a type *)
let any_typ let any_typ
: ('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, accept_more) template_arg = : ('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, accept_more) template_arg =
let eat_template_arg (f, captured_types, template_args) = let eat_template_arg (f, captured_types, template_args) =
match template_args with (Typ.TType _) :: rest -> Some (f, captured_types, rest) | _ -> None match template_args with
| (Typ.TType _) :: rest ->
Some (f, captured_types, rest)
| _ ->
None
in in
{eat_template_arg; add_marker= add_no_marker} {eat_template_arg; add_marker= add_no_marker}
(** Captures a type than can be back-referenced *) (** Captures a type than can be back-referenced *)
let capt_typ let capt_typ
: 'marker : 'marker
-> ( 'marker mtyp -> 'f -> ( 'marker mtyp -> 'f
, 'f , 'f
@ -347,8 +435,8 @@ let capt_typ
{eat_template_arg; add_marker} {eat_template_arg; add_marker}
(** Captures an int *) (** Captures an int *)
let capt_int let capt_int
: ( Int64.t -> 'f : ( Int64.t -> 'f
, 'f , 'f
, 'captured_types , 'captured_types
@ -358,13 +446,17 @@ let capt_int
, accept_more ) , accept_more )
template_arg = template_arg =
let eat_template_arg (f, captured_types, template_args) = let eat_template_arg (f, captured_types, template_args) =
match template_args with (Typ.TInt i) :: rest -> Some (f i, captured_types, rest) | _ -> None match template_args with
| (Typ.TInt i) :: rest ->
Some (f i, captured_types, rest)
| _ ->
None
in in
{eat_template_arg; add_marker= add_no_marker} {eat_template_arg; add_marker= add_no_marker}
(** Captures all template args *) (** Captures all template args *)
let capt_all let capt_all
: ( Typ.template_arg list -> 'f : ( Typ.template_arg list -> 'f
, 'f , 'f
, 'captured_types , 'captured_types
@ -379,21 +471,63 @@ let capt_all
{eat_template_arg; add_marker= add_no_marker} {eat_template_arg; add_marker= add_no_marker}
(* Function args *) let ( <! ) name_matcher () = templ_begin name_matcher
let ( >! ) templ_matcher () = templ_end templ_matcher
let ( &::! ) path_matcher name = name_cons path_matcher name
let ( ~- ) name = empty &::! name
let ( &+ ) templ_matcher template_arg = templ_cons templ_matcher template_arg
let ( < ) name_matcher template_arg = name_matcher <! () &+ template_arg
let ( >:: ) templ_matcher name = templ_matcher >! () &::! name
let ( &+...>:: ) templ_matcher name = templ_matcher &+ any_template_args >:: name
let ( &:: ) path_matcher name = path_matcher < any_template_args >:: name
let ( <>:: ) name_matcher name = name_matcher <! () >:: name
end
let no_checker _ = true module Procname = struct
include Common
let eat_one_func_arg ~match_if capt (f, args) = let make_matcher : ('f_in, 'f_out) all_args_matcher -> 'f_in -> 'f_out matcher =
fun m f ->
let {on_c; on_objc_cpp} : (_, _) all_args_matcher = m in
fun procname args ->
match procname with
| ObjC_Cpp objc_cpp ->
on_objc_cpp f objc_cpp args |> pre_to_opt procname args
| C c ->
on_c f c args |> pre_to_opt procname args
| _ ->
None
(** Simple implementation of a dispatcher, could be optimized later *)
let make_dispatcher : 'f matcher list -> 'f dispatcher =
fun matchers procname args -> List.find_map matchers ~f:(fun matcher -> matcher procname args)
(* Function args *)
let no_checker _ = true
let eat_one_func_arg ~match_if capt (f, args) =
match args with arg :: rest when match_if capt arg -> Some (f, rest) | _ -> None match args with arg :: rest when match_if capt arg -> Some (f, rest) | _ -> None
(** Eats one arg *) (** Eats one arg *)
let any_arg : ('f, 'f, _, _) func_arg = let any_arg : ('f, 'f, _, _) func_arg =
let eat_func_arg capt = eat_one_func_arg ~match_if:(fun _ _ -> true) capt in let eat_func_arg capt = eat_one_func_arg ~match_if:(fun _ _ -> true) capt in
{eat_func_arg; marker_static_checker= no_checker} {eat_func_arg; marker_static_checker= no_checker}
let mk_typ_nth let mk_typ_nth
: ('markers -> 'marker) -> ('captured_types -> 'marker mtyp) -> 'marker : ('markers -> 'marker) -> ('captured_types -> 'marker mtyp) -> 'marker
-> ('f, 'f, 'captured_types, 'markers) func_arg = -> ('f, 'f, 'captured_types, 'markers) func_arg =
fun get_m get_c marker -> fun get_m get_c marker ->
@ -405,46 +539,45 @@ let mk_typ_nth
{eat_func_arg; marker_static_checker} {eat_func_arg; marker_static_checker}
(** Matches first captured type *) (** Matches first captured type *)
let typ1 : 'marker -> ('f, 'f, 'marker mtyp * _, 'marker * _) func_arg = let typ1 : 'marker -> ('f, 'f, 'marker mtyp * _, 'marker * _) func_arg =
let pos1 (x, _) = x in let pos1 (x, _) = x in
fun marker -> mk_typ_nth pos1 pos1 marker fun marker -> mk_typ_nth pos1 pos1 marker
(** Matches second captured type *) (** Matches second captured type *)
let typ2 : 'marker -> ('f, 'f, _ * ('marker mtyp * _), _ * ('marker * _)) func_arg = let typ2 : 'marker -> ('f, 'f, _ * ('marker mtyp * _), _ * ('marker * _)) func_arg =
let pos2 (_, (x, _)) = x in let pos2 (_, (x, _)) = x in
fun marker -> mk_typ_nth pos2 pos2 marker fun marker -> mk_typ_nth pos2 pos2 marker
(** Matches third captured type *) (** Matches third captured type *)
let typ3 : 'marker -> ('f, 'f, _ * (_ * ('marker mtyp * _)), _ * (_ * ('marker * _))) func_arg = let typ3 : 'marker -> ('f, 'f, _ * (_ * ('marker mtyp * _)), _ * (_ * ('marker * _))) func_arg =
let pos3 (_, (_, (x, _))) = x in let pos3 (_, (_, (x, _))) = x in
fun marker -> mk_typ_nth pos3 pos3 marker fun marker -> mk_typ_nth pos3 pos3 marker
let capt_arg : (FuncArg.t -> 'f, 'f, _, _) func_arg = let capt_arg : (FuncArg.t -> 'f, 'f, _, _) func_arg =
let eat_func_arg _capt (f, args) = let eat_func_arg _capt (f, args) =
match args with arg :: rest -> Some (f arg, rest) | _ -> None match args with arg :: rest -> Some (f arg, rest) | _ -> None
in in
{eat_func_arg; marker_static_checker= no_checker} {eat_func_arg; marker_static_checker= no_checker}
(* Function args end *) (* Function args end *)
(** Matches if there is no function arguments left *)
(** Matches if there is no function arguments left *) let no_args_left : (_, _, _) func_args_end =
let no_args_left : (_, _, _) func_args_end =
let match_empty_args = function Some (f, []) -> Matches f | _ -> DoesNotMatch in let match_empty_args = function Some (f, []) -> Matches f | _ -> DoesNotMatch in
fun ~on_args args (f, capt) -> on_args capt (f, args) |> match_empty_args fun ~on_args args (f, capt) -> on_args capt (f, args) |> match_empty_args
(** Matches any function arguments *) (** Matches any function arguments *)
let any_func_args : (_, _, _) func_args_end = let any_func_args : (_, _, _) func_args_end =
fun ~on_args args (f, capt) -> on_args capt (f, args) |> pre_map_opt ~f:fst fun ~on_args args (f, capt) -> on_args capt (f, args) |> pre_map_opt ~f:fst
(** If [func_args_end1] does not match, use [func_args_end2] *) (** If [func_args_end1] does not match, use [func_args_end2] *)
let alternative_args_end let alternative_args_end
: ('f_in, 'f_out, 'captured_types) func_args_end : ('f_in, 'f_out, 'captured_types) func_args_end
-> ('f_in, 'f_out, 'captured_types) func_args_end -> ('f_in, 'f_out, 'captured_types) func_args_end
-> ('f_in, 'f_out, 'captured_types) func_args_end = -> ('f_in, 'f_out, 'captured_types) func_args_end =
@ -456,74 +589,77 @@ let alternative_args_end
otherwise otherwise
(** Retries matching with another matcher *) (** Retries matching with another matcher *)
let args_end_retry : _ -> (_, _, _) func_args_end = fun f ~on_args:_ _args _f_capt -> RetryWith f let args_end_retry : _ -> (_, _, _) func_args_end = fun f ~on_args:_ _args _f_capt -> RetryWith f
(** Retries matching with another matcher if the function does not have the (** Retries matching with another matcher if the function does not have the
exact number/types of args *) exact number/types of args *)
let exact_args_or_retry : 'f -> (_, _, _) func_args_end = let exact_args_or_retry : 'f -> (_, _, _) func_args_end =
fun f -> alternative_args_end no_args_left (args_end_retry f) fun f -> alternative_args_end no_args_left (args_end_retry f)
let wrong_args_internal_error procname _args = let wrong_args_internal_error procname _args =
Logging.(die InternalError) Logging.(die InternalError)
"Unexpected number/types of arguments for %a" Typ.Procname.pp procname "Unexpected number/types of arguments for %a" Typ.Procname.pp procname
(* Notation shorthands *) let ( $! ) path_matcher () = args_begin path_matcher
let ( <! ) name_matcher () = templ_begin name_matcher
let ( >! ) templ_matcher () = templ_end templ_matcher let ( >$! ) templ_matcher () = templ_matcher >! () $! ()
let ( $! ) path_matcher () = args_begin path_matcher let ( $*--> ) all_args_matcher f = make_matcher all_args_matcher f
let ( >$! ) templ_matcher () = templ_matcher >! () $! () let ( $+ ) args_matcher func_arg = args_cons args_matcher func_arg
let ( &::! ) path_matcher name = name_cons path_matcher name let ( >$ ) templ_matcher func_arg = templ_matcher >$! () $+ func_arg
let ( $*--> ) all_args_matcher f = make_matcher all_args_matcher f let ( $* ) args_matcher func_args_end = args_end args_matcher func_args_end
let ( ~- ) name = empty &::! name let ( $--> ) args_matcher f = args_matcher $* no_args_left $*--> f
let ( &+ ) templ_matcher template_arg = templ_cons templ_matcher template_arg let ( $ ) name_matcher func_arg = name_matcher < any_template_args >$ func_arg
let ( < ) name_matcher template_arg = name_matcher <! () &+ template_arg let ( <>$ ) name_matcher func_arg = name_matcher <! () >$ func_arg
let ( >:: ) templ_matcher name = templ_matcher >! () &::! name let ( $+...$--> ) args_matcher f = args_matcher $* any_func_args $*--> f
let ( $+ ) args_matcher func_arg = args_cons args_matcher func_arg let ( >--> ) templ_matcher f = templ_matcher >$! () $+...$--> f
let ( >$ ) templ_matcher func_arg = templ_matcher >$! () $+ func_arg let ( >$$--> ) templ_matcher f = templ_matcher >$! () $--> f
let ( $* ) args_matcher func_args_end = args_end args_matcher func_args_end let ( $$--> ) name_matcher f = name_matcher < any_template_args >$$--> f
let ( $--> ) args_matcher f = args_matcher $* no_args_left $*--> f let ( <>$$--> ) name_matcher f = name_matcher <! () >$$--> f
let ( &+...>:: ) templ_matcher name = templ_matcher &+ any_template_args >:: name let ( &--> ) name_matcher f = name_matcher < any_template_args >--> f
let ( &:: ) path_matcher name = path_matcher < any_template_args >:: name let ( <>--> ) name_matcher f = name_matcher <! () >--> f
let ( <>:: ) name_matcher name = name_matcher <! () >:: name let ( $!--> ) args_matcher f =
args_matcher $* exact_args_or_retry wrong_args_internal_error $*--> f
let ( $ ) name_matcher func_arg = name_matcher < any_template_args >$ func_arg
let ( <>$ ) name_matcher func_arg = name_matcher <! () >$ func_arg end
let ( $+...$--> ) args_matcher f = args_matcher $* any_func_args $*--> f module TypName = struct
include Common
let ( >--> ) templ_matcher f = templ_matcher >$! () $+...$--> f let make_matcher
: ('f_in, 'f_out, _, _, _, non_empty) path_matcher -> 'f_in -> 'f_out typ_matcher =
fun m f ->
let {on_templated_name} = m in
function
| name -> name |> templated_name_of_class_name |> on_templated_name f |> Option.map ~f:fst
let ( >$$--> ) templ_matcher f = templ_matcher >$! () $--> f
let ( $$--> ) name_matcher f = name_matcher < any_template_args >$$--> f let make_dispatcher : 'f typ_matcher list -> 'f typ_dispatcher =
fun matchers typname -> List.find_map matchers ~f:(fun matcher -> matcher typname)
let ( <>$$--> ) name_matcher f = name_matcher <! () >$$--> f
let ( &--> ) name_matcher f = name_matcher < any_template_args >--> f let ( &-->! ) path_matcher f = make_matcher path_matcher f
let ( <>--> ) name_matcher f = name_matcher <! () >--> f let ( >--> ) templ_matcher f = templ_matcher >! () &-->! f
let ( $!--> ) args_matcher f = let ( <>--> ) name_matcher f = name_matcher <! () >--> f
args_matcher $* exact_args_or_retry wrong_args_internal_error $*--> f
let ( &--> ) name_matcher f = name_matcher < any_template_args >--> f
end

@ -54,16 +54,33 @@ type 'f matcher = Typ.Procname.t -> FuncArg.t list -> 'f option
type 'f dispatcher = 'f matcher type 'f dispatcher = 'f matcher
val make_dispatcher : 'f matcher list -> 'f dispatcher type 'f typ_matcher = Typ.name -> 'f option
(** Combines matchers to create a dispatcher *)
(* Template arguments *) type 'f typ_dispatcher = 'f typ_matcher
val any_typ : (* A matcher is a rule associating a function [f] to a [C/C++ function/method]:
- [C/C++ function/method] --> [f]
The goal is to write the C/C++ function/method as naturally as possible, with the following
exceptions:
Start with -
Use $ instead of parentheses for function arguments
Use + instead of comma to separate function/template arguments
Concatenate consecutive symbols (e.g. >:: instead of > ::)
Operators must start with & $ < >
E.g. std::vector<T, A>::vector(A) --> f becomes
-"std" &:: "vector" < capt_typ T &+ capt_typ A >:: "vector" $ typ2 A $--> f
*)
module type Common = sig
(* Template arguments *)
val any_typ :
('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, accept_more) template_arg ('f, 'f, 'captured_types, 'captured_types, 'markers, 'markers, accept_more) template_arg
(** Eats a type *) (** Eats a type *)
val capt_typ : val capt_typ :
'marker 'marker
-> ( 'marker mtyp -> 'f -> ( 'marker mtyp -> 'f
, 'f , 'f
@ -73,9 +90,9 @@ val capt_typ :
, 'marker * 'markers , 'marker * 'markers
, accept_more ) , accept_more )
template_arg template_arg
(** Captures a type than can be back-referenced *) (** Captures a type than can be back-referenced *)
val capt_int : val capt_int :
( Int64.t -> 'f ( Int64.t -> 'f
, 'f , 'f
, 'captured_types , 'captured_types
@ -84,9 +101,9 @@ val capt_int :
, 'markers , 'markers
, accept_more ) , accept_more )
template_arg template_arg
(** Captures an int *) (** Captures an int *)
val capt_all : val capt_all :
( Typ.template_arg list -> 'f ( Typ.template_arg list -> 'f
, 'f , 'f
, 'captured_types , 'captured_types
@ -95,45 +112,19 @@ val capt_all :
, 'markers , 'markers
, end_of_list ) , end_of_list )
template_arg template_arg
(** Captures all template args *) (** Captures all template args *)
(* Function args *)
val any_arg : ('f, 'f, _, _) func_arg
(** Eats one arg *)
val capt_arg : (FuncArg.t -> 'f, 'f, _, _) func_arg
(** Captures one arg *)
val typ1 : 'marker -> ('f, 'f, 'marker mtyp * _, 'marker * _) func_arg
(** Matches first captured type *)
val typ2 : 'marker -> ('f, 'f, _ * ('marker mtyp * _), _ * ('marker * _)) func_arg
(** Matches second captured type *)
val typ3 : 'marker -> ('f, 'f, _ * (_ * ('marker mtyp * _)), _ * (_ * ('marker * _))) func_arg
(** Matches third captured type *)
(* A matcher is a rule associating a function [f] to a [C/C++ function/method]:
- [C/C++ function/method] --> [f]
The goal is to write the C/C++ function/method as naturally as possible, with the following
exceptions:
Start with -
Use $ instead of parentheses for function arguments
Use + instead of comma to separate function/template arguments
Concatenate consecutive symbols (e.g. >:: instead of > ::)
Operators must start with & $ < >
E.g. std::vector<T, A>::vector(A) --> f becomes
-"std" &:: "vector" < capt_typ T &+ capt_typ A >:: "vector" $ typ2 A $--> f
*)
val ( ~- ) : string -> ('f, 'f, unit, 'markers, 'markers) name_matcher val ( ~- ) : string -> ('f, 'f, unit, 'markers, 'markers) name_matcher
(** Starts a path with a name *) (** Starts a path with a name *)
val ( &+ ) : val ( &+ ) :
('f_in, 'f_interm, 'captured_types_in, 'markers_interm, 'markers_out, accept_more) templ_matcher ( 'f_in
, 'f_interm
, 'captured_types_in
, 'markers_interm
, 'markers_out
, accept_more )
templ_matcher
-> ( 'f_interm -> ( 'f_interm
, 'f_out , 'f_out
, 'captured_types_in , 'captured_types_in
@ -143,9 +134,9 @@ val ( &+ ) :
, 'lc ) , 'lc )
template_arg template_arg
-> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher -> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher
(** Separate template arguments *) (** Separate template arguments *)
val ( < ) : val ( < ) :
('f_in, 'f_interm, 'captured_types_in, 'markers_interm, 'markers_out) name_matcher ('f_in, 'f_interm, 'captured_types_in, 'markers_interm, 'markers_out) name_matcher
-> ( 'f_interm -> ( 'f_interm
, 'f_out , 'f_out
@ -156,85 +147,127 @@ val ( < ) :
, 'lc ) , 'lc )
template_arg template_arg
-> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher -> ('f_in, 'f_out, 'captured_types_out, 'markers_in, 'markers_out, 'lc) templ_matcher
(** Starts template arguments after a name *) (** Starts template arguments after a name *)
val ( >:: ) : val ( >:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, _) templ_matcher -> string ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, _) templ_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Ends template arguments and starts a name *) (** Ends template arguments and starts a name *)
val ( &+...>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, accept_more) templ_matcher
-> string -> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Ends template arguments with eats-ALL and starts a name *)
val ( &:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts ALL template arguments on the left one) *)
val ( <>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts NO template arguments on the left one) *)
end
module Procname : sig
include Common
(* Function args *)
val any_arg : ('f, 'f, _, _) func_arg
(** Eats one arg *)
val capt_arg : (FuncArg.t -> 'f, 'f, _, _) func_arg
(** Captures one arg *)
val typ1 : 'marker -> ('f, 'f, 'marker mtyp * _, 'marker * _) func_arg
(** Matches first captured type *)
val ( $+ ) : val typ2 : 'marker -> ('f, 'f, _ * ('marker mtyp * _), _ * ('marker * _)) func_arg
(** Matches second captured type *)
val typ3 : 'marker -> ('f, 'f, _ * (_ * ('marker mtyp * _)), _ * (_ * ('marker * _))) func_arg
(** Matches third captured type *)
val make_dispatcher : 'f matcher list -> 'f dispatcher
(** Combines matchers to create a dispatcher *)
val ( $+ ) :
('f_in, 'f_proc_out, 'f_interm, 'captured_types, 'markers) args_matcher ('f_in, 'f_proc_out, 'f_interm, 'captured_types, 'markers) args_matcher
-> ('f_interm, 'f_out, 'captured_types, 'markers) func_arg -> ('f_interm, 'f_out, 'captured_types, 'markers) func_arg
-> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher -> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher
(** Separate function arguments *) (** Separate function arguments *)
val ( >$ ) : val ( >$ ) :
('f_in, 'f_proc_out, 'ct, unit, 'cm, _) templ_matcher -> ('f_proc_out, 'f_out, 'ct, 'cm) func_arg ('f_in, 'f_proc_out, 'ct, unit, 'cm, _) templ_matcher
-> ('f_proc_out, 'f_out, 'ct, 'cm) func_arg
-> ('f_in, 'f_proc_out, 'f_out, 'ct, 'cm) args_matcher -> ('f_in, 'f_proc_out, 'f_out, 'ct, 'cm) args_matcher
(** Ends template arguments and starts function arguments *) (** Ends template arguments and starts function arguments *)
val ( $--> ) : val ( $--> ) :
('f_in, _, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher ('f_in, _, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher
(** Ends function arguments, binds the function *) (** Ends function arguments, binds the function *)
val ( &+...>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out, accept_more) templ_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Ends template arguments with eats-ALL and starts a name *)
val ( &:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts ALL template arguments on the left one) *)
val ( <>:: ) :
('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher -> string
-> ('f_in, 'f_out, 'captured_types, 'markers_in, 'markers_out) name_matcher
(** Separates names (accepts NO template arguments on the left one) *)
val ( $ ) : val ( $ ) :
('f_in, 'f_proc_out, 'captured_types, unit, 'markers) name_matcher ('f_in, 'f_proc_out, 'captured_types, unit, 'markers) name_matcher
-> ('f_proc_out, 'f_out, 'captured_types, 'markers) func_arg -> ('f_proc_out, 'f_out, 'captured_types, 'markers) func_arg
-> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher -> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher
(** Ends a name with accept-ALL template arguments and starts function arguments *) (** Ends a name with accept-ALL template arguments and starts function arguments *)
val ( <>$ ) : val ( <>$ ) :
('f_in, 'f_proc_out, 'captured_types, unit, 'markers) name_matcher ('f_in, 'f_proc_out, 'captured_types, unit, 'markers) name_matcher
-> ('f_proc_out, 'f_out, 'captured_types, 'markers) func_arg -> ('f_proc_out, 'f_out, 'captured_types, 'markers) func_arg
-> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher -> ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher
(** Ends a name with accept-NO template arguments and starts function arguments *) (** Ends a name with accept-NO template arguments and starts function arguments *)
val ( >--> ) : val ( >--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers, _) templ_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers, _) templ_matcher -> 'f_in -> 'f_out matcher
(** Ends template arguments, accepts ALL function arguments, binds the function *) (** Ends template arguments, accepts ALL function arguments, binds the function *)
val ( $+...$--> ) : val ( $+...$--> ) :
('f_in, _, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher ('f_in, _, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher
(** Ends function arguments with eats-ALL and binds the function *) (** Ends function arguments with eats-ALL and binds the function *)
val ( >$$--> ) : val ( >$$--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers, _) templ_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers, _) templ_matcher -> 'f_in -> 'f_out matcher
(** Ends template arguments, accepts NO function arguments, binds the function *) (** Ends template arguments, accepts NO function arguments, binds the function *)
val ( $$--> ) : val ( $$--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher
(** After a name, accepts ALL template arguments, accepts NO function arguments, binds the function *) (** After a name, accepts ALL template arguments, accepts NO function arguments, binds the function *)
val ( <>$$--> ) : val ( <>$$--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher
(** After a name, accepts NO template arguments, accepts NO function arguments, binds the function *) (** After a name, accepts NO template arguments, accepts NO function arguments, binds the function *)
val ( &--> ) : val ( &--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher
(** After a name, accepts ALL template arguments, accepts ALL function arguments, binds the function *) (** After a name, accepts ALL template arguments, accepts ALL function arguments, binds the function *)
val ( <>--> ) : val ( <>--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out matcher
(** After a name, accepts NO template arguments, accepts ALL function arguments, binds the function *) (** After a name, accepts NO template arguments, accepts ALL function arguments, binds the function *)
val ( $!--> ) : val ( $!--> ) :
('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher ('f_in, 'f_proc_out, 'f_out, 'captured_types, 'markers) args_matcher -> 'f_in -> 'f_out matcher
(** Ends function arguments, accepts NO more function arguments. (** Ends function arguments, accepts NO more function arguments.
If the args do not match, raise an internal error. If the args do not match, raise an internal error.
*) *)
end
module TypName : sig
include Common
val make_dispatcher : 'f typ_matcher list -> 'f typ_dispatcher
val ( >--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers, _) templ_matcher -> 'f_in
-> 'f_out typ_matcher
val ( <>--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out typ_matcher
val ( &--> ) :
('f_in, 'f_out, 'captured_types, unit, 'markers) name_matcher -> 'f_in -> 'f_out typ_matcher
end

@ -154,7 +154,7 @@ module Make (CFG : ProcCfg.S) = struct
let dispatcher : model ProcnameDispatcher.dispatcher = let dispatcher : model ProcnameDispatcher.dispatcher =
let open ProcnameDispatcher in let open ProcnameDispatcher.Procname in
make_dispatcher make_dispatcher
[ -"__inferbo_min" <>$ capt_arg $+ capt_arg $!--> inferbo_min [ -"__inferbo_min" <>$ capt_arg $+ capt_arg $!--> inferbo_min
; -"__inferbo_set_size" <>$ capt_arg $+ capt_arg $!--> inferbo_set_size ; -"__inferbo_set_size" <>$ capt_arg $+ capt_arg $!--> inferbo_set_size

Loading…
Cancel
Save