aboutsummaryrefslogtreecommitdiff
path: root/src/tree.c
blob: aadfc3f0e07b723c584af52a061d05922feb3897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "include/tree.h"

tree_t* tree_init(int type) {
   tree_t* tree;

   tree = calloc(1, sizeof(struct TREE_STRUC));
   tree->type = type;
   
   switch (type) {
      case TREE_COMP:
         tree->data.comp.value         = (void*) 0;
         tree->data.comp.size          = 0;
         break;
      case TREE_DEF:
         tree->data.def.mutability     = 0;
         tree->data.def.name           = (void*) 0;
         tree->data.def.value          = (void*) 0;
         break;
      case TREE_CALL:
         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);
}