Merge branch 'master' of git://github.com/UpstandingHackers/hammer into h_bind

This commit is contained in:
Sven M. Hallberg 2015-01-30 20:48:49 +01:00
commit 7ba5931095
15 changed files with 119 additions and 59 deletions

View file

@ -11,19 +11,9 @@ static void switch_bit_order(HInputStream *input)
{
assert(input->bit_offset <= 8);
if((input->bit_offset % 8) != 0) {
// switching bit order in the middle of a byte
// we leave bit_offset untouched. this means that something like
// le(bits(5)),le(bits(3))
// is equivalent to
// le(bits(5),bits(3)) .
// on the other hand,
// le(bits(5)),be(bits(5))
// will read the same 5 bits twice and discard the top 3.
} else {
// flip offset (0 <-> 8)
input->bit_offset = 8 - input->bit_offset;
}
char tmp = input->bit_offset;
input->bit_offset = input->margin;
input->margin = tmp;
}
static HParseResult *parse_endianness(void *env, HParseState *state)

View file

@ -18,6 +18,7 @@ static inline HParseResult* make_result(HArena *arena, HParsedToken *tok) {
HParseResult *ret = h_arena_malloc(arena, sizeof(HParseResult));
ret->ast = tok;
ret->arena = arena;
ret->bit_length = 0; // This way it gets overridden in h_do_parse
return ret;
}