From 2860a8b28b93728ed48cfc94fc11e2ae29051858 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 6 Feb 2011 20:01:55 +0900 Subject: [PATCH] enum too is a scalar. --- tools/qfcc/include/type.h | 1 + tools/qfcc/source/type.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/include/type.h b/tools/qfcc/include/type.h index 96bb61acc..d38bed8c7 100644 --- a/tools/qfcc/include/type.h +++ b/tools/qfcc/include/type.h @@ -142,6 +142,7 @@ void print_type (type_t *type); const char *encode_params (type_t *type); void encode_type (struct dstring_s *encoding, type_t *type); type_t *parse_type (const char *str); +int is_enum (type_t *type); int is_scalar (type_t *type); int is_math (type_t *type); int is_struct (type_t *type); diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index e3e18d7a0..673ca7bca 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -411,6 +411,8 @@ print_type_str (dstring_t *str, type_t *type) dasprintf (str, " %s", type->t.class->name); break; case ty_enum: + dasprintf (str, " enum %s", type->name); + break; case ty_struct: case ty_union: { @@ -419,8 +421,6 @@ print_type_str (dstring_t *str, type_t *type) if (type->t.symtab) {//FIXME if (type->t.symtab->type == stab_union) tag = "union"; - else if (type->t.symtab->type == stab_union) - tag = "enum"; } dasprintf (str, " %s %s", tag, type->name); } @@ -751,6 +751,14 @@ parse_type (const char *str) return type; } +int +is_enum (type_t *type) +{ + if (type->type == ev_invalid && type->ty == ty_enum) + return 1; + return 0; +} + int is_scalar (type_t *type) { @@ -758,7 +766,7 @@ is_scalar (type_t *type) if (t == ev_float || t == ev_integer || t == ev_short) return 1; - return 0; + return is_enum (type); } int