scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 624848780072de338c258596833708934bed9204
parent e06a619d7769dc7e2081c1ede01949991041b3a5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  7 Jan 2016 19:00:46 +0100

Add arith and integer flags to type

These flags help in the code, because they can simplify
a lot some of the conditions where we are using
complex switches.

Diffstat:
Mcc1/cc1.h | 2++
Mcc1/types.c | 29+++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -42,6 +42,8 @@ struct type { bool defined : 1; /* type defined */ bool sign : 1; /* signess of the type */ bool printed : 1; /* the type already was printed */ + bool integer : 1; /* this type is INT or enum */ + bool arith : 1; /* this type is INT, ENUM, FLOAT */ size_t size; /* sizeof the type */ size_t align; /* align of the type */ Type *type; /* base type */ diff --git a/cc1/types.c b/cc1/types.c @@ -97,6 +97,8 @@ static Type types[] = { .letter = L_BOOL, .defined = 1, .size = 1, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_BOOL, .printed = 1 @@ -106,6 +108,8 @@ static Type types[] = { .letter = L_SCHAR, .defined = 1, .size = 1, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_SCHAR, @@ -116,6 +120,8 @@ static Type types[] = { .letter = L_UCHAR, .defined = 1, .size = 1, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_UCHAR, .printed = 1 @@ -125,6 +131,8 @@ static Type types[] = { .letter = L_CHAR, .defined = 1, .size = 1, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_CHAR, @@ -135,6 +143,8 @@ static Type types[] = { .letter = L_USHORT, .defined = 1, .size = 2, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_USHORT, .printed = 1 @@ -144,6 +154,8 @@ static Type types[] = { .letter = L_SHORT, .defined = 1, .size = 2, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_SHORT, @@ -154,6 +166,8 @@ static Type types[] = { .letter = L_UINT, .defined = 1, .size = 2, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_UINT, .printed = 1 @@ -163,6 +177,8 @@ static Type types[] = { .letter = L_INT, .defined = 1, .size = 2, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_INT, @@ -173,6 +189,8 @@ static Type types[] = { .letter = L_LONG, .defined = 1, .size = 4, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_LONG, @@ -183,6 +201,8 @@ static Type types[] = { .letter = L_ULONG, .defined = 1, .size = 4, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_ULONG, .printed = 1 @@ -192,6 +212,8 @@ static Type types[] = { .letter = L_ULLONG, .defined = 1, .size = 8, + .integer = 1, + .arith = 1, .align = 1, .n.rank = RANK_ULLONG, .printed = 1 @@ -201,6 +223,8 @@ static Type types[] = { .letter = L_LLONG, .defined = 1, .size = 8, + .integer = 1, + .arith = 1, .align = 1, .sign = 1, .n.rank = RANK_LLONG, @@ -211,6 +235,7 @@ static Type types[] = { .letter = L_FLOAT, .defined = 1, .size = 4, + .arith = 1, .align = 1, .n.rank = RANK_FLOAT, .printed = 1 @@ -220,6 +245,7 @@ static Type types[] = { .letter = L_DOUBLE, .defined = 1, .size = 8, + .arith = 1, .align = 1, .n.rank = RANK_DOUBLE, .printed = 1 @@ -229,6 +255,7 @@ static Type types[] = { .letter = L_LDOUBLE, .defined = 1, .size = 16, + .arith = 1, .align = 1, .n.rank = RANK_LDOUBLE, .printed = 1 @@ -436,6 +463,8 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) break; case ENUM: type.printed = 1; + type.integer = 1; + type.arith = 1; /* PASSTROUGH */ case STRUCT: case UNION: