aboutsummaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authors-over-42023-06-23 01:07:48 -0400
committers-over-42023-06-23 01:07:48 -0400
commit76e952ec1756deae78d9a88a67b97eff3550959e (patch)
tree6922d0f97dc89e3961393dca7660125e34b62a97 /src/tree.c
parent0bc9c5bd16475f0d855e5929ea39b2f601564556 (diff)
basic tree init/destroy
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/tree.c b/src/tree.c
index bb162cd..1f57d5b 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -1,50 +1,33 @@
#include "include/tree.h"
-
-prim_t* prim_init(int type) {
- prim_t* prim = calloc(1, sizeof(struct PRIM_STRUC));
-
- prim->type = type;
- prim->is_mutable = 0;
-
- switch (type) {
- case STR:
- prim->val.prim_str.len = NULL;
- prim->val.prim_str.val = NULL;
- break;
- case INT:
- prim->val.prim_int.val = NULL;
- default:
- prim->val.prim_unkwn.val = NULL;
- }
-
- return prim;
-}
-
-
tree_t* tree_init(int type) {
- tree_t* tree = calloc(1, sizeof(struct TREE_STRUC));
+ tree_t* tree;
+ tree = calloc(1, sizeof(struct TREE_STRUC));
tree->type = type;
-
+
switch (type) {
- case TREE_PRIM:
- tree->oftype.prim.val = NULL;
- break;
- case TREE_SUBTREE:
- tree->oftype.subtree.size = 0;
- tree->oftype.subtree.val = NULL;
- break;
case TREE_DEF:
- tree->oftype.def.args = NULL;
- tree->oftype.def.name = NULL;
- tree->oftype.def.val = NULL;
+ tree->data.def.mutability = 0;
+ tree->data.def.name = (void*) 0;
+ tree->data.def.value = (void*) 0;
break;
case TREE_CALL:
- tree->oftype.call.args = NULL;
- tree->oftype.call.name = NULL;
+ tree->data.call.args = (void*) 0;
+ tree->data.call.args_size = 0;
+ tree->data.call.target = (void*) 0;
+ break;
+ case TREE_TYPE_STR:
+ tree->data.type_str.value = (void*) 0;
+ break;
+ case TREE_TYPE_INT:
+ tree->data.type_int.value = (void*) 0;
break;
}
return tree;
}
+
+void tree_destroy(tree_t* tree) {
+ free(tree);
+}