7 bool compareArray(Array<Boolean *> * inputs1, Array<Boolean *> *inputs2) {
8 if (inputs1->getSize() != inputs2->getSize())
10 for(uint i=0;i<inputs1->getSize();i++) {
11 if (inputs1->get(i) != inputs2->get(i))
17 bool compareArray(Array<Element *> * inputs1, Array<Element *> *inputs2) {
18 if (inputs1->getSize() != inputs2->getSize())
20 for(uint i=0;i<inputs1->getSize();i++) {
21 if (inputs1->get(i) != inputs2->get(i))
27 uint hashArray(Array<Boolean *> * inputs) {
28 uint hash = inputs->getSize();
29 for(uint i=0;i<inputs->getSize();i++) {
30 uint newval = (uint)(uintptr_t) inputs->get(i);
32 hash = (hash << 3) | (hash >> 29);
37 uint hashArray(Array<Element *> * inputs) {
38 uint hash = inputs->getSize();
39 for(uint i=0;i<inputs->getSize();i++) {
40 uint newval = (uint)(uintptr_t) inputs->get(i);
42 hash = (hash << 3) | (hash >> 29);
47 uint hashBoolean(Boolean * b) {
50 BooleanOrder * o=(BooleanOrder *)b;
51 return ((uint)(uintptr_t) o->order) ^ ((uint) o->first) ^ (((uint)(o->second)) << 2);
54 return (uint)(uintptr_t) b;
57 BooleanLogic * l=(BooleanLogic *)b;
58 return ((uint)l->op) ^ hashArray(&l->inputs);
61 BooleanPredicate * p=(BooleanPredicate *)b;
62 return ((uint)(uintptr_t) p->predicate) ^
63 (((uint)(uintptr_t) p->undefStatus) << 1) ^
64 hashArray(&p->inputs);
71 bool compareBoolean(Boolean *b1, Boolean *b2) {
72 if (b1->type != b2->type)
76 BooleanOrder * o1=(BooleanOrder *)b1;
77 BooleanOrder * o2=(BooleanOrder *)b2;
78 return (o1->order == o2->order) && (o1->first == o2->first) && (o1->second == o2->second);
84 BooleanLogic * l1=(BooleanLogic *)b1;
85 BooleanLogic * l2=(BooleanLogic *)b2;
86 return (l1->op == l2->op) && compareArray(&l1->inputs, &l2->inputs);
89 BooleanPredicate * p1=(BooleanPredicate *)b1;
90 BooleanPredicate * p2=(BooleanPredicate *)b2;
91 return (p1->predicate == p2->predicate) &&
92 p1->undefStatus == p2->undefStatus &&
93 compareArray(&p1->inputs, &p2->inputs);
100 uint hashElement(Element *e) {
103 return (uint)(uintptr_t) e;
105 case ELEMFUNCRETURN: {
106 ElementFunction * ef=(ElementFunction *) e;
107 return ((uint)(uintptr_t) ef->function) ^
108 ((uint)(uintptr_t) ef->overflowstatus) ^
109 hashArray(&ef->inputs);
112 ElementConst * ec=(ElementConst *) e;
113 return ((uint) ec->value);
120 bool compareElement(Element *e1, Element *e2) {
121 if (e1->type != e2->type)
127 case ELEMFUNCRETURN: {
128 ElementFunction * ef1=(ElementFunction *) e1;
129 ElementFunction * ef2=(ElementFunction *) e2;
130 return (ef1->function == ef2->function) &&
131 (ef1->overflowstatus == ef2->overflowstatus) &&
132 compareArray(&ef1->inputs, &ef2->inputs);
135 ElementConst * ec1=(ElementConst *) e1;
136 ElementConst * ec2=(ElementConst *) e2;
137 return (ec1->value == ec2->value);