From b1391241a116d794a091c97bbb63b485f6514fb7 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 5 Oct 2020 12:32:42 +0200 Subject: ast: add helpers to set error token bits Signed-off-by: Jo-Philipp Wich --- ast.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ast.h') diff --git a/ast.h b/ast.h index 67330fb..365d4c0 100644 --- a/ast.h +++ b/ast.h @@ -140,6 +140,19 @@ static inline bool ut_is_type(struct json_object *val, int type) { return (tag && tag->type == type); }; + +#define UT_ET_DIV (sizeof(s->error.info.tokens[0]) * 8) +#define UT_ET_TYPE typeof(s->error.info.tokens[0]) + +static inline void ut_set_error_token(struct ut_state *s, int tokennr) { + s->error.info.tokens[tokennr / UT_ET_DIV] |= ((UT_ET_TYPE)1 << (tokennr % UT_ET_DIV)); +} + +static inline bool ut_is_error_token(struct ut_state *s, int tokennr) { + return (s->error.info.tokens[tokennr / UT_ET_DIV] & ((UT_ET_TYPE)1 << (tokennr % UT_ET_DIV))); +} + + uint32_t ut_new_op(struct ut_state *s, int type, struct json_object *val, ...); uint32_t ut_wrap_op(struct ut_state *s, uint32_t parent, ...); uint32_t ut_append_op(struct ut_state *s, uint32_t a, uint32_t b); -- cgit v1.2.3