1 #include "elementencoding.h"
3 #include "naiveencoder.h"
6 void initElementEncoding(ElementEncoding * This, Element *element) {
8 This->type=ELEM_UNASSIGNED;
10 This->encodingArray=NULL;
11 This->inUseArray=NULL;
15 void deleteElementEncoding(ElementEncoding *This) {
16 if (This->variables!=NULL)
17 ourfree(This->variables);
18 if (This->encodingArray!=NULL)
19 ourfree(This->encodingArray);
20 if (This->inUseArray!=NULL)
21 ourfree(This->inUseArray);
24 void allocEncodingArrayElement(ElementEncoding *This, uint size) {
25 This->encodingArray=ourcalloc(1, sizeof(uint64_t)*size);
28 void allocInUseArrayElement(ElementEncoding *This, uint size) {
29 This->inUseArray=ourcalloc(1, size >> 6);
32 void allocElementConstraintVariables(ElementEncoding* This, uint numVars){
33 This->numVars = numVars;
34 This->variables = ourmalloc(sizeof(Constraint*) * numVars);
37 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type){
41 void generateBinaryIndexEncodingVars(NaiveEncoder* encoder, ElementEncoding* This){
42 ASSERT(This->type==BINARYINDEX);
43 uint size = getElementSize(This->element);
44 allocElementConstraintVariables(This, NUMBITS(size-1));
45 getArrayNewVars(encoder, This->numVars, This->variables);
48 void generateElementEncodingVariables(NaiveEncoder* encoder, ElementEncoding* This){
49 ASSERT(This->type!=ELEM_UNASSIGNED);
50 ASSERT(This->variables==NULL);
53 generateBinaryIndexEncodingVars(encoder, This);