diff options
| author | rajdakin <rajdakin@gmail.com> | 2024-11-23 22:01:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-23 22:01:40 +0100 |
| commit | b8ed1b964693c4f17d44f0da3b1536afce409c8f (patch) | |
| tree | de739da870cc0d56bb2cf1f9885b16aa1aa4f36f /wrapperhelper/src/parse.c | |
| parent | 0912e8f16d8c937d9f115d22539d2ac5255925ab (diff) | |
| download | box64-b8ed1b964693c4f17d44f0da3b1536afce409c8f.tar.gz box64-b8ed1b964693c4f17d44f0da3b1536afce409c8f.zip | |
[WRAPPERHELPER] Added support to cast to enum (#2061)
Diffstat (limited to 'wrapperhelper/src/parse.c')
| -rw-r--r-- | wrapperhelper/src/parse.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/wrapperhelper/src/parse.c b/wrapperhelper/src/parse.c index 8f593f22..398fd75b 100644 --- a/wrapperhelper/src/parse.c +++ b/wrapperhelper/src/parse.c @@ -1239,8 +1239,16 @@ static int eval_expression(loginfo_t *li, machine_t *target, expr_t *e, khash_t( case ETY_CAST: if (!eval_expression(li, target, e->val.cast.e, const_map, dest, fatal)) return 0; - if (e->val.cast.typ->typ == TYPE_BUILTIN) { - switch (e->val.cast.typ->val.builtin) { + if ((e->val.cast.typ->typ == TYPE_BUILTIN) || (e->val.cast.typ->typ == TYPE_ENUM)) { + type_t *cast = e->val.cast.typ; + if (cast->typ == TYPE_ENUM) { + cast = cast->val.typ; + if (cast->typ != TYPE_BUILTIN) { + log_internal(li, "invalid cast to enum with non-builtin base type\n"); + return 0; + } + } + switch (cast->val.builtin) { case BTT_VOID: if (fatal) log_error(li, "invalid cast to void\n"); return 0; @@ -1411,7 +1419,7 @@ static int eval_expression(loginfo_t *li, machine_t *target, expr_t *e, khash_t( case BTT_IFLOAT128: case BTT_VA_LIST: default: - if (fatal) log_TODO(li, "unsupported cast to builtin %s in constant expression\n", builtin2str[e->val.cast.typ->val.builtin]); + if (fatal) log_TODO(li, "unsupported cast to builtin %s in constant expression\n", builtin2str[cast->val.builtin]); return 0; } } else { |