Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency of trie.ml and leapfrog.ml on Named_ref. #3650

Merged
merged 5 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
Ekdohibs committed Mar 4, 2025
commit 35bb1aeeb7f04a99ab852582252f9b3804de147c
3 changes: 1 addition & 2 deletions middle_end/flambda2/datalog/cursor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
(* *)
(**************************************************************************)

open Heterogenous_list
open With_name
open Datalog_imports

type vm_action =
| Unless :
Expand Down
3 changes: 1 addition & 2 deletions middle_end/flambda2/datalog/cursor.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
(* *)
(**************************************************************************)

open Heterogenous_list
open With_name
open Datalog_imports

type action

Expand Down
3 changes: 1 addition & 2 deletions middle_end/flambda2/datalog/datalog.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
(* *)
(**************************************************************************)

open Heterogenous_list
open With_name
open Datalog_imports

module Parameter = struct
type 'a t =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,23 @@ type 'a with_names =
{ values : 'a;
names : string list
}

include Heterogenous_list

module Option_ref = struct
include Make (struct
type 'a t = 'a option ref
end)

let rec get : type s. s hlist -> s Constant.hlist = function
| [] -> []
| r :: rs -> Option.get r.contents :: get rs

let rec set : type s. s hlist -> s Constant.hlist -> unit =
fun refs values ->
match refs, values with
| [], [] -> ()
| r :: rs, v :: vs ->
r.contents <- Some v;
set rs vs
end
18 changes: 0 additions & 18 deletions middle_end/flambda2/datalog/heterogenous_list.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,3 @@ end
module Constant = Make (struct
type 'a t = 'a
end)

module Option_ref = struct
include Make (struct
type 'a t = 'a option ref
end)

let rec get : type s. s hlist -> s Constant.hlist = function
| [] -> []
| r :: rs -> Option.get r.contents :: get rs

let rec set : type s. s hlist -> s Constant.hlist -> unit =
fun refs values ->
match refs, values with
| [], [] -> ()
| r :: rs, v :: vs ->
r.contents <- Some v;
set rs vs
end
5 changes: 2 additions & 3 deletions middle_end/flambda2/datalog/table.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(* *)
(**************************************************************************)

open With_name
open Datalog_imports

module Int = struct
include Numbers.Int
Expand Down Expand Up @@ -60,8 +60,7 @@ module Id = struct
{ id : ('t * 'k) Type.Id.t;
name : string;
is_trie : ('t, 'k, 'v) Trie.is_trie;
print_keys :
Format.formatter -> 'k Heterogenous_list.Constant.hlist -> unit;
print_keys : Format.formatter -> 'k Constant.hlist -> unit;
default_value : 'v
}

Expand Down
4 changes: 2 additions & 2 deletions middle_end/flambda2/datalog/table.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(* *)
(**************************************************************************)

open With_name
open Datalog_imports

module Type : sig
type (_, _) eq = Equal : ('a, 'a) eq
Expand Down Expand Up @@ -53,7 +53,7 @@ module Id : sig
val create :
name:string ->
is_trie:('t, 'k, 'v) Trie.is_trie ->
print_keys:(Format.formatter -> 'k Heterogenous_list.Constant.hlist -> unit) ->
print_keys:(Format.formatter -> 'k Constant.hlist -> unit) ->
default_value:'v ->
('t, 'k, 'v) t

Expand Down
3 changes: 1 addition & 2 deletions middle_end/flambda2/datalog/virtual_machine.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
(* *)
(**************************************************************************)

open Heterogenous_list
open With_name
open Datalog_imports

type outcome =
| Accept
Expand Down
12 changes: 5 additions & 7 deletions middle_end/flambda2/datalog/virtual_machine.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(* *)
(**************************************************************************)

open With_name
open Datalog_imports

(** Outcome for user-defined actions. *)
type outcome =
Expand Down Expand Up @@ -116,16 +116,15 @@ module Make (Iterator : Leapfrog.Iterator) : sig
associated with levels in the stack at the point the [call] instruction
is executed, and {b must not} be [None] at that point. *)
val call :
('a Heterogenous_list.Constant.hlist -> unit) ->
('a Constant.hlist -> unit) ->
name:string ->
'a Heterogenous_list.Option_ref.hlist with_names ->
'a Option_ref.hlist with_names ->
('x, 's) instruction ->
('x, 's) instruction

type t

val create :
evaluate:('a -> outcome) -> ('a, Heterogenous_list.nil) instruction -> t
val create : evaluate:('a -> outcome) -> ('a, nil) instruction -> t

val run : t -> unit

Expand All @@ -135,6 +134,5 @@ module Make (Iterator : Leapfrog.Iterator) : sig
iterates over all the values of an iterator heterogenous list. *)
val iterator : 's Iterator.hlist with_names -> 's iterator

val iter :
('y Heterogenous_list.Constant.hlist -> unit) -> 'y iterator -> unit
val iter : ('y Constant.hlist -> unit) -> 'y iterator -> unit
end
Loading