scc

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

commit c4e13ecd202af5a26d6040a8f076fd14bc001e9e
parent 370c020ff1b057611556aed2d0583d093ad61cc3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 23 Jan 2016 07:28:11 +0100

Remove definition of letters in cc.h

It is impossible to make a total separation between
cc1 and cc2 without writing very bad code, so it is
better to mark totally the isolation between them,
because at this moment we have some constants in
cc.h and others hardcoded in code.c.

Diffstat:
Mcc1/cc1.h | 25+++++++++++++++++++++++++
Mcc1/code.c | 14+++++++-------
Minc/cc.h | 33---------------------------------
3 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -123,6 +123,31 @@ struct input { * Definition of enumerations */ +/* data type letters */ +enum { + L_INT8 = 'C', + L_INT16 = 'I', + L_INT32 = 'W', + L_INT64 = 'Q', + L_UINT8 = 'K', + L_UINT16 = 'N', + L_UINT32 = 'Z', + L_UINT64 = 'O', + L_BOOL = 'B', + + L_FLOAT = 'J', + L_DOUBLE = 'D', + L_LDOUBLE = 'H', + + L_ELLIPSIS = 'E', + L_VOID = '0', + L_POINTER = 'P', + L_FUNCTION = 'F', + L_ARRAY = 'V', + L_UNION = 'U', + L_STRUCT = 'S', +}; + /* recovery points */ enum { END_DECL, diff --git a/cc1/code.c b/cc1/code.c @@ -166,19 +166,19 @@ emitvar(Symbol *sym) short flags = sym->flags; if (flags & ISLOCAL) - c = L_LOCAL; + c = 'T'; else if (flags & ISPRIVATE) - c = L_PRIVATE; + c = 'Y'; else if (flags & ISGLOBAL) - c = L_PUBLIC; + c = 'G'; else if (flags & ISREGISTER) - c = L_REGISTER; + c = 'R'; else if (flags & ISFIELD) - c = L_FIELD; + c = 'M'; else if (flags & ISEXTERN) - c = L_EXTERN; + c = 'X'; else - c = L_AUTO; + c = 'A'; printf("%c%u", c, sym->id); } diff --git a/inc/cc.h b/inc/cc.h @@ -16,39 +16,6 @@ extern int debug; #define DBGON() #endif -#define L_INT8 'C' -#define L_INT16 'I' -#define L_INT32 'W' -#define L_INT64 'Q' -#define L_UINT8 'K' -#define L_UINT16 'N' -#define L_UINT32 'Z' -#define L_UINT64 'O' -#define L_BOOL 'B' - -#define L_FLOAT 'J' -#define L_DOUBLE 'D' -#define L_LDOUBLE 'H' - -#define L_ELLIPSIS 'E' -#define L_VOID '0' -#define L_POINTER 'P' -#define L_FUNCTION 'F' -#define L_ARRAY 'V' -#define L_UNION 'U' -#define L_STRUCT 'S' - -#define L_PUBLIC 'G' -#define L_PRIVATE 'Y' -#define L_LOCAL 'T' -#define L_REGISTER 'R' -#define L_FIELD 'M' -#define L_AUTO 'A' -#define L_EXTERN 'X' -#define L_LABEL 'L' - -#define L_NAME '"' - extern void die(const char *fmt, ...); extern void dbg(const char *fmt, ...); extern void *xmalloc(size_t size);