/* *** equality *** */ bool val_equal(value_t a, value_t b) { if (val_eq(a, b)) { return true; } if (IS_VAL(a) || IS_VAL(b)) { // if both are only plain values, // they should have been equal by <eq?> return false; } ptrvalue_t *pa = AS_PTR(a); ptrvalue_t *pb = AS_PTR(b); if (pa->type != pb->type) { return false; } if (pa->type == T_CONS) { cons_t *consa = (cons_t *) pa; cons_t *consb = (cons_t *) pb; return val_equal(consa->car, consb->car) && val_equal(consa->cdr, consb->cdr); } else if (pa->type == T_STRING) { string_t *stra = (string_t *) pa; string_t *strb = (string_t *) pb; return stra->len == strb->len && stra->hash == strb->hash && memcmp(stra->value, strb->value, stra->len * sizeof(char)) == 0; } else if (pa->type == T_SYMBOL) { symbol_t *syma = (symbol_t *) pa; symbol_t *symb = (symbol_t *) pb; if ((syma->len == symb->len) && (memcmp(syma->name, symb->name, syma->len * sizeof(char)) == 0)) { // we should never get here! - two symbols with same name are eq? fprintf(stderr, "Error: symbol not interned!"); } return false; } else if (pa->type == T_VECTOR) { vector_t *veca = (vector_t *) pa; vector_t *vecb = (vector_t *) pb; if (veca->count != vecb->count) { return false; } for (uint32_t i = 0; i < veca->count; i++) { if (!val_equal(veca->data[i], vecb->data[i])) { return false; } } return true; } return false; }
static void _remove_edges(DepNode** dep_network, int size, Val name) { for (int i = 0; i < size; i++) { DepNode* node = dep_network[i]; DepNode* prev = node; DepNode* tail = node->next; while (tail) { if (val_eq(name, tail->ctx_name)) { prev->next = tail->next; tail = prev->next; } else { prev = tail; tail = tail->next; } } } }