/** * Implementation of vlist.h */ #include "vlist.h" #include #include "val.h" #include "str.h" #include "type.h" #include "interp.h" bool ValueListEquals(ListElemData* d1, ListElemData* d2) { ValueStruct v1 = (ValueStruct)d1; ValueStruct v2 = (ValueStruct)d2; int i; if ((v1 == null) || (v2 == null)) {// || // (v1->tag != StructTag) || (v2->tag != StructTag)) { return false; } /* * The following will happen on the construction of mixed lists. May want * to do somethig about it, but it's not a fundamental problem. I.e., * nothing is semantically violated if we bail in this way. */ if (v1->tag != v2->tag) return false; switch (v1->tag) { /* Since Structs (tuples) are Lists under the hood, try this */ case StructTag: /* 1jul09: Hack to get around bus error. TODO: fix properly */ if (v2->tag != StructTag) return false; return ListEqualsWithFunction(v1->val.StructVal, v2->val.StructVal, ValueListEquals); case ListTag: /* 12apr09: Hack to get around bus error. TODO: fix properly */ if (v2->tag != ListTag) return false; return ListEqualsWithFunction(v1->val.ListVal, v2->val.ListVal, ValueListEquals); case StringTag: return StringEqual(v1->val.StringVal, v2->val.StringVal); case IntTag: return (v1->val.IntVal == v2->val.IntVal); default: return !(memcmp(&(v1->val), &(v2->val), v1->size)); } // end switch // no reason we ever should reach this point return false; } // end ValueListEqualsFunc