Resolving Conflicts ... Still there're errors that should be fixed
[satune.git] / src / AST / table.c
1 #include "table.h"
2 #include "common.h"
3 #include "structs.h"
4 #include "tableentry.h"
5 #include "set.h"
6
7
8 Table * allocTable(Set **domains, uint numDomain, Set * range){
9     Table* table = (Table*) ourmalloc(sizeof(Table));
10     allocInlineArrayInitSet(&table->domains, domains, numDomain);
11     allocInlineDefVectorTableEntry(&table->entries);
12     table->range =range;
13     return table;
14 }
15
16 void addNewTableEntry(Table* table, uint64_t* inputs, uint inputSize, uint64_t result){
17     ASSERT(getSizeVectorSet( table->domains) == inputSize);
18     pushVectorTableEntry(&table->entries, allocTableEntry(inputs, inputSize, result));
19 }
20
21 void deleteTable(Table* table){
22   deleteInlineArraySet(&table->domains);
23   uint size = getSizeVectorTableEntry(&table->entries);
24   for(uint i=0; i<size; i++){
25     deleteTableEntry(getVectorTableEntry(&table->entries, i));
26   }
27   deleteVectorArrayTableEntry(&table->entries);
28   ourfree(table);
29 }
30