From aa198d93e6a28bd8c040d82a00a9256d97d61516 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 8 Aug 2020 06:18:42 +0200 Subject: wstring: add support for evaluation of wide string Evaluation doesn't know about wide strings. Fix this by: 1) selecting the right base type (char_ctype vs wchar_ctype) 2) adapting the type, size & alignment of the underlying array to this base type. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/evaluate.c b/evaluate.c index dddea761..acad11ab 100644 --- a/evaluate.c +++ b/evaluate.c @@ -102,9 +102,10 @@ static struct symbol *evaluate_string(struct expression *expr) struct expression *addr = alloc_expression(expr->pos, EXPR_SYMBOL); struct expression *initstr = alloc_expression(expr->pos, EXPR_STRING); unsigned int length = expr->string->length; + struct symbol *char_type = expr->wide ? wchar_ctype : &char_ctype; sym->array_size = alloc_const_expression(expr->pos, length); - sym->bit_size = bytes_to_bits(length); + sym->bit_size = length * char_type->bit_size; sym->ctype.alignment = 1; sym->string = 1; sym->ctype.modifiers = MOD_STATIC; @@ -117,10 +118,10 @@ static struct symbol *evaluate_string(struct expression *expr) initstr->string = expr->string; array->array_size = sym->array_size; - array->bit_size = bytes_to_bits(length); - array->ctype.alignment = 1; + array->bit_size = sym->bit_size; + array->ctype.alignment = char_type->ctype.alignment; array->ctype.modifiers = MOD_STATIC; - array->ctype.base_type = &char_ctype; + array->ctype.base_type = char_type; array->examined = 1; array->evaluated = 1; -- cgit 1.2.3-korg