Binary encoding for ElementSet and table-based ElementFunction
[satune.git] / src / AST / set.c
1 #include "set.h"
2 #include <stddef.h>
3
4 Set * allocSet(VarType t, uint64_t* elements, uint num) {
5         Set * tmp=(Set *)ourmalloc(sizeof(Set));
6         tmp->type=t;
7         tmp->isRange=false;
8         tmp->low=0;
9         tmp->high=0;
10         tmp->members=allocVectorArrayInt(num, elements);
11         return tmp;
12 }
13
14 Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange) {
15         Set * tmp=(Set *)ourmalloc(sizeof(Set));
16         tmp->type=t;
17         tmp->isRange=true;
18         tmp->low=lowrange;
19         tmp->high=highrange;
20         tmp->members=NULL;
21         return tmp;
22 }
23
24 uint getSetSize(Set* set){
25         if(set->isRange){
26                 return set->high- set->low+1;
27         }else{
28                 return getSizeVectorInt(set->members);
29         }
30 }
31
32 void deleteSet(Set * set) {
33         if (!set->isRange)
34                 deleteVectorInt(set->members);
35         ourfree(set);
36 }