Add 64-bit integer support to ASN.1 compiler

ASN.1 INTEGERs will now compile to C int64_t or uint64_t, depending
    on whether the constraint ranges include numbers that cannot be
    represented in 32-bit ints and whether they include negative
    numbers.

    Template backend support included.  check-template is now built with
    --template, so we know we're testing it.

    Tests included.
This commit is contained in:
Nicolas Williams
2011-06-22 17:11:40 -05:00
committed by Nicolas Williams
parent 0e7437ba2e
commit 19d378f44d
20 changed files with 426 additions and 48 deletions

View File

@@ -129,14 +129,16 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
fprintf(codefile, "}\n;");
} else if (t->range == NULL) {
encode_primitive ("heim_integer", name);
} else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {
} else if (t->range->min < INT_MIN && t->range->max <= INT64_MAX) {
encode_primitive ("integer64", name);
} else if (t->range->min >= 0 && t->range->max > UINT_MAX) {
encode_primitive ("unsigned64", name);
} else if (t->range->min >= INT_MIN && t->range->max <= INT_MAX) {
encode_primitive ("integer", name);
} else if (t->range->min == 0 && t->range->max == UINT_MAX) {
encode_primitive ("unsigned", name);
} else if (t->range->min == 0 && t->range->max == INT_MAX) {
} else if (t->range->min >= 0 && t->range->max <= UINT_MAX) {
encode_primitive ("unsigned", name);
} else
errx(1, "%s: unsupported range %d -> %d",
errx(1, "%s: unsupported range %lld -> %lld",
name, t->range->min, t->range->max);
constructed = 0;
break;