ability to set tag values of enums

also remove support for enums with 0 values

closes #305
This commit is contained in:
Andrew Kelley
2017-12-02 22:31:42 -05:00
parent 98237f7c0b
commit 137c8f5e8a
13 changed files with 452 additions and 147 deletions

View File

@@ -1224,3 +1224,35 @@ Cmp bigint_cmp_zero(const BigInt *op) {
}
return op->is_negative ? CmpLT : CmpGT;
}
uint32_t bigint_hash(BigInt x) {
if (x.digit_count == 0) {
return 0;
} else {
return bigint_ptr(&x)[0];
}
}
bool bigint_eql(BigInt a, BigInt b) {
return bigint_cmp(&a, &b) == CmpEQ;
}
void bigint_incr(BigInt *x) {
if (x->digit_count == 0) {
bigint_init_unsigned(x, 1);
return;
}
if (x->digit_count == 1 && x->data.digit != UINT64_MAX) {
x->data.digit += 1;
return;
}
BigInt copy;
bigint_init_bigint(&copy, x);
BigInt one;
bigint_init_unsigned(&one, 1);
bigint_add(x, &copy, &one);
}