Skip to content

Commit

Permalink
refactor(engine): specialize phase: cleanup & comments
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Apr 30, 2024
1 parent 232cc5d commit fc6b832
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions engine/lib/phases/phase_specialize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ module Make (F : Features.T) =
args : (expr -> bool) list;
ret : ty -> bool;
}
(** A pattern that helps matching against function applications *)

type ('a, 'b) predicate = 'a -> 'b option
(** Instead of working directly with boolean predicate, we
work with `_ -> _ option` so that we can chain them *)

(** Constructs a predicate out of predicates and names *)
let mk (args : ('a, 'b) predicate list) (ret : ('c, 'd) predicate)
(fn : name) (fn_replace : name) : pattern =
let args = List.map ~f:(fun p x -> p x |> Option.is_some) args in
Expand Down Expand Up @@ -65,35 +69,9 @@ module Make (F : Features.T) =
mk [ etyp >> (tref >>& is_int); etyp >> (tref >>& is_int) ] any

let any_rint = mk [ any ] (tref >>& is_int)

(* let is_type0 (ty_name : name) : (expr -> bool) option = *)
(* Some *)
(* (typ *)
(* >> [%matches? *)
(* TApp { ident; args = [] } when Ast.Global_ident.eq_name *)
(* ty_name ident]) *)

(* let is_ref_type0 (ty_name : name) : (expr -> bool) option = *)
(* Some *)
(* (typ *)
(* >> [%matches? *)
(* TRef { typ = TApp { ident; args = [] }; _ } when Ast *)
(* .Global_ident *)
(* .eq_name *)
(* ty_name *)
(* ident]) *)

(* let is_int = is_type0 Hax_lib__int__Int *)
(* let is_ref_int = is_ref_type0 Hax_lib__int__Int *)

(* let mk_ref_int n f f' = *)
(* { *)
(* fn = f; *)
(* fn_replace = f'; *)
(* args = List.init n ~f:(fun _ -> is_ref_int); *)
(* } *)
end

(** The list of replacements *)
let patterns =
[
int_int_any Core__ops__arith__Add__add
Expand Down

0 comments on commit fc6b832

Please sign in to comment.