-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86e98e9
commit 5154f5d
Showing
332 changed files
with
17,176 additions
and
8,082 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(executables | ||
(modes byte exe) | ||
(names generate_pow_overflow_bounds) | ||
(libraries num) | ||
(libraries zarith) | ||
(preprocess no_preprocessing)) |
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,4 @@ | ||
module Big_int_Z = Big_int_Z | ||
module Q = Q | ||
module Z = Z | ||
module Zarith_version = Zarith_version |
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,78 @@ | ||
(module | ||
(import "env" "Int32_val" (func $Int32_val (param (ref eq)) (result i32))) | ||
(import "env" "Int64_val" (func $Int64_val (param (ref eq)) (result i64))) | ||
(import "env" "Double_val" | ||
(func $Double_val (param (ref eq)) (result f64))) | ||
(import "env" "caml_copy_int32" | ||
(func $caml_copy_int32 (param $i i32) (result (ref eq)))) | ||
(import "env" "caml_hash_mix_int" | ||
(func $caml_hash_mix_int (param i32) (param i32) (result i32))) | ||
(import "env" "caml_hash_mix_int64" | ||
(func $caml_hash_mix_int64 (param i32) (param i64) (result i32))) | ||
(import "env" "caml_hash_mix_double" | ||
(func $caml_hash_mix_double (param i32) (param f64) (result i32))) | ||
(import "env" "caml_hash_mix_string" | ||
(func $caml_hash_mix_string | ||
(param i32) (param (ref $string)) (result i32))) | ||
(import "env" "caml_hash_mix_final" | ||
(func $caml_hash_mix_final (param i32) (result i32))) | ||
|
||
(type $string (array (mut i8))) | ||
(type $compare | ||
(func (param (ref eq)) (param (ref eq)) (param i32) (result i32))) | ||
(type $hash | ||
(func (param (ref eq)) (result i32))) | ||
(type $fixed_length (struct (field $bsize_32 i32) (field $bsize_64 i32))) | ||
(type $serialize | ||
(func (param (ref eq)) (param (ref eq)) (result i32) (result i32))) | ||
(type $deserialize (func (param (ref eq)) (result (ref eq)) (result i32))) | ||
(type $dup (func (param (ref eq)) (result (ref eq)))) | ||
(type $custom_operations | ||
(struct | ||
(field $id (ref $string)) | ||
(field $compare (ref null $compare)) | ||
(field $compare_ext (ref null $compare)) | ||
(field $hash (ref null $hash)) | ||
(field $fixed_length (ref null $fixed_length)) | ||
(field $serialize (ref null $serialize)) | ||
(field $deserialize (ref null $deserialize)) | ||
(field $dup (ref null $dup)))) | ||
(type $custom (sub (struct (field (ref $custom_operations))))) | ||
(type $int32 | ||
(sub final $custom (struct (field (ref $custom_operations)) (field i32)))) | ||
|
||
(func (export "Base_internalhash_fold_int64") | ||
(param $st (ref eq)) (param $i (ref eq)) (result (ref eq)) | ||
(call $caml_copy_int32 | ||
(call $caml_hash_mix_int64 | ||
(call $Int32_val (local.get $st)) | ||
(call $Int64_val (local.get $i))))) | ||
|
||
(func (export "Base_internalhash_fold_int") | ||
(param $st (ref eq)) (param $i (ref eq)) (result (ref eq)) | ||
(call $caml_copy_int32 | ||
(call $caml_hash_mix_int | ||
(call $Int32_val (local.get $st)) | ||
(i31.get_s (ref.cast (ref i31) (local.get $i)))))) | ||
|
||
(func (export "Base_internalhash_fold_float") | ||
(param $st (ref eq)) (param $f (ref eq)) (result (ref eq)) | ||
(call $caml_copy_int32 | ||
(call $caml_hash_mix_double | ||
(call $Int32_val (local.get $st)) | ||
(call $Double_val (local.get $f))))) | ||
|
||
(func (export "Base_internalhash_fold_string") | ||
(param $st (ref eq)) (param $s (ref eq)) (result (ref eq)) | ||
(call $caml_copy_int32 | ||
(call $caml_hash_mix_string | ||
(call $Int32_val (local.get $st)) | ||
(ref.cast (ref $string) (local.get $s))))) | ||
|
||
(func (export "Base_internalhash_get_hash_value") | ||
(param $st (ref eq)) (result (ref eq)) | ||
(ref.i31 | ||
(i32.and | ||
(call $caml_hash_mix_final (call $Int32_val (local.get $st))) | ||
(i32.const 0x3FFFFFFF)))) | ||
) |
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,6 @@ | ||
# ppx_base_internal | ||
|
||
This ppx is intended only for use inside Base itself, to help write certain repeated code | ||
patterns. It is not designed for use in other contexts. For example, it may refer to | ||
internal names like `Bool0`, or be specialized to use cases in `Base` that are not | ||
applicable to other code. |
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,6 @@ | ||
(library | ||
(name ppx_base_internal) | ||
(kind ppx_deriver) | ||
(libraries base ppxlib) | ||
(preprocess | ||
(pps ppxlib.metaquot))) |
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,79 @@ | ||
open! Base | ||
open Ppxlib | ||
|
||
module Specialize_polymorphic_compare = struct | ||
let signature ~loc = | ||
[%sig: | ||
[@@@ocaml.ppwarning "ppx_base_internal: intended only for use inside Base"] | ||
|
||
external ( = ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
external ( <> ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%notequal" | ||
external ( < ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%lessthan" | ||
external ( > ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%greaterthan" | ||
external ( <= ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%lessequal" | ||
external ( >= ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%greaterequal" | ||
external compare : (t[@local_opt]) -> (t[@local_opt]) -> int = "%compare" | ||
external compare__local : (t[@local_opt]) -> (t[@local_opt]) -> int = "%compare" | ||
external equal : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
external equal__local : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
val ascending : t -> t -> int | ||
val descending : t -> t -> int | ||
val max : t -> t -> t | ||
val min : t -> t -> t] | ||
;; | ||
|
||
let structure ~loc = | ||
[%str | ||
[@@@ocaml.ppwarning "ppx_base_internal: intended only for use inside Base"] | ||
|
||
external ( = ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
external ( <> ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%notequal" | ||
external ( < ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%lessthan" | ||
external ( > ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%greaterthan" | ||
external ( <= ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%lessequal" | ||
external ( >= ) : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%greaterequal" | ||
external compare : (t[@local_opt]) -> (t[@local_opt]) -> int = "%compare" | ||
external compare__local : (t[@local_opt]) -> (t[@local_opt]) -> int = "%compare" | ||
external equal : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
external equal__local : (t[@local_opt]) -> (t[@local_opt]) -> bool = "%equal" | ||
|
||
let ascending x y = compare x y | ||
let descending x y = compare y x | ||
let max x y = Bool0.select (x >= y) x y | ||
let min x y = Bool0.select (x <= y) x y] | ||
;; | ||
|
||
let check_decl decl = | ||
match core_type_of_type_declaration decl with | ||
| [%type: t] -> Ok () | ||
| _ -> | ||
Error | ||
(Location.Error.to_extension | ||
(Location.Error.createf | ||
~loc:decl.ptype_loc | ||
"deriving specialize_polymorphic_compare: expected [type t], no other name \ | ||
or parameters")) | ||
;; | ||
|
||
let sig_type_decl = | ||
Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, decls) -> | ||
List.concat_map decls ~f:(fun decl -> | ||
let loc = decl.ptype_loc in | ||
match check_decl decl with | ||
| Ok () -> signature ~loc | ||
| Error ext -> [ Ast_builder.Default.psig_extension ~loc ext [] ])) | ||
;; | ||
|
||
let str_type_decl = | ||
Deriving.Generator.V2.make_noarg (fun ~ctxt:_ (_, decls) -> | ||
List.concat_map decls ~f:(fun decl -> | ||
let loc = decl.ptype_loc in | ||
match check_decl decl with | ||
| Ok () -> structure ~loc | ||
| Error ext -> [ Ast_builder.Default.pstr_extension ~loc ext [] ])) | ||
;; | ||
|
||
let deriver = | ||
Deriving.add "specialize_polymorphic_compare" ~sig_type_decl ~str_type_decl | ||
;; | ||
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,6 @@ | ||
open! Base | ||
open Ppxlib | ||
|
||
module Specialize_polymorphic_compare : sig | ||
val deriver : Deriving.t | ||
end |
Empty file.
Oops, something went wrong.