diff options
-rw-r--r-- | plugins/kaitai/grammar.y | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/kaitai/grammar.y b/plugins/kaitai/grammar.y index 9e31113..2f2b820 100644 --- a/plugins/kaitai/grammar.y +++ b/plugins/kaitai/grammar.y @@ -1734,6 +1734,26 @@ bool resolve_kaitai_expression_as_boolean(const kaitai_scope_t *locals, const ch if (result) result = reduce_resolved_kaitai_expression(out); + if (result) + { + if (out->type == GVT_UNSIGNED_INTEGER) + { + out->status = (out->unsigned_integer != 0); + out->type = GVT_BOOLEAN; + } + else if (out->type == GVT_SIGNED_INTEGER) + { + out->status = (out->signed_integer != 0); + out->type = GVT_BOOLEAN; + } + else if (out->type == GVT_FLOAT) + { + out->status = (out->floating_number != 0); + out->type = GVT_BOOLEAN; + } + + } + if (result && out->type != GVT_BOOLEAN) { EXIT_RESOLVED_VALUE(*out); |