Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
assert(argc == 3);
int16_t low = atoi(argv[1]);
int16_t high = atoi(argv[2]);
printf("LOW = %d\nHIGH=%d\n", low, high);
}
void gen_int_range(HAllocator *mm__, HCFStack *stk__, uint64_t low, uint64_t high, uint8_t bytes) {
/* Possible FIXME: TallerThanMe */
if (1 == bytes) {
HCharset cs = new_charset(mm__);
for (uint64_t i=low; i<=high; ++i) {
charset_set(cs, i, 1);
}
HCFS_ADD_CHARSET(cs);
}
else if (1 < bytes) {
uint8_t low_head, hi_head;
low_head = ((low >> (8*(bytes - 1))) & 0xFF);
hi_head = ((high >> (8*(bytes - 1))) & 0xFF);
if (low_head != hi_head) {
HCFS_BEGIN_CHOICE() {
HCFS_BEGIN_SEQ() {
HCFS_ADD_CHAR(low_head);
gen_int_range(mm__, stk__, low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1);
} HCFS_END_SEQ();
HCFS_BEGIN_SEQ() {
HCharset hd = new_charset(mm__);
HCharset rest = new_charset(mm__);
for (int i = 0; i < 256; i++) {
charset_set(hd, i, (i > low_head && i < hi_head));
charset_set(rest, i, 1);
}
HCFS_ADD_CHARSET(hd);
for (int i = 2; i < bytes; i++)
HCFS_ADD_CHARSET(rest);
} HCFS_END_SEQ();
HCFS_BEGIN_SEQ() {
HCFS_ADD_CHAR(hi_head);
gen_int_range(mm__, stk__, 0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1);
} HCFS_END_SEQ();
} HCFS_END_CHOICE();
} else {
// TODO: find a way to merge this with the higher-up SEQ
HCFS_BEGIN_CHOICE() {
HCFS_BEGIN_SEQ() {
HCFS_ADD_CHAR(low_head);
gen_int_range(mm__, stk__,
low & ((1 << (8 * (bytes - 1))) - 1),
high & ((1 << (8 * (bytes - 1))) - 1),
bytes - 1);
} HCFS_END_SEQ();
} HCFS_END_CHOICE();
}
}
}