diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/hamt.h | 30 | ||||
-rw-r--r-- | inc/murmur3.h | 9 | ||||
-rw-r--r-- | inc/parse.h | 2 | ||||
-rw-r--r-- | inc/reducer.h | 4 | ||||
-rw-r--r-- | inc/term.h | 4 |
5 files changed, 47 insertions, 2 deletions
diff --git a/inc/hamt.h b/inc/hamt.h new file mode 100644 index 0000000..da5f876 --- /dev/null +++ b/inc/hamt.h @@ -0,0 +1,30 @@ +#ifndef HAMT_H +#define HAMT_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +typedef int (*hamt_cmp_fn)(const void *lhs, const void *rhs); +typedef uint32_t (*hamt_key_hash_fn)(const void *key, const size_t gen); + +typedef struct hamt_impl *HAMT; + +struct hamt_allocator { + void *(*malloc)(const size_t size); + void *(*realloc)(void *chunk, const size_t size); + void (*free)(void *chunk); +}; + +extern struct hamt_allocator hamt_allocator_default; + +HAMT hamt_create(hamt_key_hash_fn key_hash, hamt_cmp_fn key_cmp, + struct hamt_allocator *ator); +void hamt_delete(HAMT); + +void *hamt_get(const HAMT trie, void *key); +HAMT hamt_pset(const HAMT trie, void *key, void *value); + +typedef struct hamt_iterator_impl *hamt_iterator; + +#endif diff --git a/inc/murmur3.h b/inc/murmur3.h new file mode 100644 index 0000000..c042642 --- /dev/null +++ b/inc/murmur3.h @@ -0,0 +1,9 @@ +#ifndef MURMUR3_H +#define MURMUR3_H + +#include <stdint.h> +#include <stdlib.h> + +uint32_t murmur3_32(const uint8_t *key, size_t len, uint32_t seed); + +#endif diff --git a/inc/parse.h b/inc/parse.h index cfd9102..fc5ffb2 100644 --- a/inc/parse.h +++ b/inc/parse.h @@ -1,3 +1,5 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> + #ifndef PARSE_H #define PARSE_H diff --git a/inc/reducer.h b/inc/reducer.h index 28fe8b1..a5cfda1 100644 --- a/inc/reducer.h +++ b/inc/reducer.h @@ -1,8 +1,10 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> + #ifndef REDUCER_H #define REDUCER_H #include <term.h> -struct term *reduce(struct term *term); +struct term *reduce(struct term *term, void (*callback)(int, char)); #endif @@ -1,7 +1,9 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> + #ifndef TERM_H #define TERM_H -typedef enum { INV, ABS, APP, VAR, CLO, CACHE } term_type; +typedef enum { INV, ABS, APP, VAR, CLOSURE, CACHE } term_type; struct term { term_type type; |