[hackers] [scc] Add arith and integer flags to type || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 8 Jan 2016 13:13:57 +0100 (CET)

commit 624848780072de338c258596833708934bed9204
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 7 19:00:46 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 8 10:47:01 2016 +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.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index cb79a73..a3c32ec 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -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
index 74fb338..491a5fd 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -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
_AT_@ -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,
_AT_@ -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
_AT_@ -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,
_AT_@ -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
_AT_@ -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,
_AT_@ -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
_AT_@ -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,
_AT_@ -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,
_AT_@ -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
_AT_@ -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
_AT_@ -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,
_AT_@ -211,6 +235,7 @@ static Type types[] = {
                 .letter = L_FLOAT,
                 .defined = 1,
                 .size = 4,
+ .arith = 1,
                 .align = 1,
                 .n.rank = RANK_FLOAT,
                 .printed = 1
_AT_@ -220,6 +245,7 @@ static Type types[] = {
                 .letter = L_DOUBLE,
                 .defined = 1,
                 .size = 8,
+ .arith = 1,
                 .align = 1,
                 .n.rank = RANK_DOUBLE,
                 .printed = 1
_AT_@ -229,6 +255,7 @@ static Type types[] = {
                 .letter = L_LDOUBLE,
                 .defined = 1,
                 .size = 16,
+ .arith = 1,
                 .align = 1,
                 .n.rank = RANK_LDOUBLE,
                 .printed = 1
_AT_@ -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:
Received on Fri Jan 08 2016 - 13:13:57 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 08 2016 - 13:24:24 CET