-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from ocaml/small-findlib-improvements
Rewrite the findlib predicate stuff
- Loading branch information
Showing
7 changed files
with
122 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
open Import | ||
|
||
module type S = sig | ||
type t | ||
|
||
val make : string -> t | ||
val compare : t -> t -> int | ||
|
||
module Set : sig | ||
include Set.S with type elt = t | ||
|
||
val make : string list -> t | ||
end | ||
|
||
module Map : Map.S with type key = t | ||
end | ||
|
||
module Int = struct | ||
type t = int | ||
let compare : int -> int -> int = compare | ||
end | ||
module Int_set = Set.Make(Int) | ||
module Int_map = Map.Make(Int) | ||
|
||
module Make() = struct | ||
include Int | ||
|
||
let table = Hashtbl.create 1024 | ||
let next = ref 0 | ||
|
||
let make s = | ||
Hashtbl.find_or_add table s ~f:(fun _ -> | ||
let n = !next in | ||
next := n + 1; | ||
n) | ||
|
||
module Set = struct | ||
include Int_set | ||
|
||
let make l = | ||
List.fold_left l ~init:empty ~f:(fun acc s -> add (make s) acc) | ||
end | ||
|
||
module Map = Int_map | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(** Interned strings *) | ||
|
||
open! Import | ||
|
||
module type S = sig | ||
type t | ||
|
||
val make : string -> t | ||
val compare : t -> t -> int | ||
|
||
module Set : sig | ||
include Set.S with type elt = t | ||
|
||
val make : string list -> t | ||
end | ||
|
||
module Map : Map.S with type key = t | ||
end | ||
|
||
module Make() : S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include Interned.Make() | ||
|
||
let ppx_driver = make "ppx_driver" | ||
let mt = make "mt" | ||
let mt_posix = make "mt_posix" | ||
let byte = make "byte" | ||
let native = make "native" | ||
let plugin = make "plugin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(** Library variants *) | ||
|
||
(** Library variants allow to select the implementation of a library | ||
at link time. | ||
They are directly mapped to findlib predicates. | ||
*) | ||
|
||
include Interned.S | ||
|
||
(** Well-known variants *) | ||
val ppx_driver : t | ||
val mt : t | ||
val mt_posix : t | ||
val byte : t | ||
val native : t | ||
val plugin : t |