2705f13a666d388e9f857f11af350300b48ff5d0
[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     table->range =range;
12                 return table;
13 }
14
15 void addNewTableEntry(Table* table, uint64_t* inputs, uint inputSize, uint64_t result){
16     ASSERT(getSizeVectorSet( table->domains) == inputSize);
17     pushVectorTableEntry(table->entries, allocTableEntry(inputs, inputSize, result));
18 }
19
20 void deleteTable(Table* table){
21         deleteInlineArraySet(&table->domains);
22         uint size = getSizeVectorTableEntry(table->entries);
23         for(uint i=0; i<size; i++){
24                 deleteTableEntry(getVectorTableEntry(table->entries, i));
25         }
26         deleteVectorTableEntry(table->entries);
27         ourfree(table);
28 }
29