diff options
Diffstat (limited to 'inc/tree.h')
-rw-r--r-- | inc/tree.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/inc/tree.h b/inc/tree.h new file mode 100644 index 0000000..8f11f1b --- /dev/null +++ b/inc/tree.h @@ -0,0 +1,46 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_TREE_H +#define BLOC_TREE_H + +#include <stdint.h> + +#include <term.h> + +#define VALIDATED_TREE ((int)0x0) +#define INVALIDATED_TREE ((int)0xffffffff) +#define FREEABLE_TREE(t) \ + ((t)->state != VALIDATED_TREE && (t)->state != INVALIDATED_TREE) + +struct tree { + term_type type; + uint32_t hash; + int state; // zero or index to ref + int size; // blc length + union { + struct { + struct tree *term; + } abs; + struct { + struct tree *lhs; + struct tree *rhs; + } app; + struct { + int index; + } var; + struct { + size_t index; + } ref; + } u; +}; + +struct list { + int val; // length or priority + void *data; + struct list *next; +}; + +struct list *tree_merge_duplicates(struct term *term); + +#endif |