summaryrefslogtreecommitdiffhomepage
path: root/ast.h
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-07 15:50:52 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-07 16:30:34 +0200
commita35469d34be384d3a5ae7b852acb6d980f6b702e (patch)
treebf94fae7176da654944e765ed5ae1ecc1b2a0fee /ast.h
parentdcf0d1285d12684a5907fecb8aadca7bc2e5f44b (diff)
ast, eval, lexer: keep track of overflows when parsing numbers
This allows number literals that exceed the range INT64_MIN..INT64_MAX to be truncated to the respective min and max values in a defined manner. It also makes it possible to have the expression `{{ -9223372036854775808 }}` actually result in `-9223372036854775808`. Since negation and number declaration are separate operations, the value would be first truncated to `9223372036854775807` and then negated, making it impossible to write a literal INT64_MIN value without tracking the overflow. Also fix the number parsing logic to not trucate intergers to 32bit. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/ast.h b/ast.h
index b3dfa3b..b45ee41 100644
--- a/ast.h
+++ b/ast.h
@@ -54,6 +54,7 @@ struct ut_op {
uint16_t type;
uint16_t is_first:1;
uint16_t is_op:1;
+ uint16_t is_overflow:1;
uint32_t off;
struct json_object *val;
union {