scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 18f8c9b9a58001bdc8f00443b2b349ff01bac518
parent af9f64086ce4a32c58c096e56b6ca8432d1fcf88
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 13 May 2014 17:41:43 +0200

Remove sym field of Type

This field was used when fields of aggregate types were stored
as identifiers with custom namespace. Since we are not using
this representation anymore this field is not needed anymore.

Diffstat:
Mcc1/cc1.h | 4+---
Mcc1/decl.c | 9++++-----
Mcc1/expr.c | 4++--
Mcc1/lex.c | 2+-
Mcc1/types.c | 8+++-----
5 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -37,7 +37,6 @@ struct ctype { char letter; /* letter of the type */ bool defined : 1; /* type defined (is not a forward reference) */ bool sign : 1; /* sign type */ - struct symbol *sym; /* symbol of the tag identifier */ struct ctype *type; /* base type */ struct ctype *next; /* next element in the hash */ union { @@ -93,8 +92,7 @@ extern void freesyms(uint8_t ns); extern Type *qualifier(Type *tp, uint8_t qlf), *ctype(int8_t type, int8_t sign, int8_t size), - *mktype(Type *tp, - uint8_t op, Symbol *tag, uint16_t nelem); + *mktype(Type *tp, uint8_t op, uint16_t nelem); extern Symbol *lookup(char *s, unsigned char ns), diff --git a/cc1/decl.c b/cc1/decl.c @@ -143,13 +143,13 @@ declarator(Type *tp, int8_t flags) for (bp = declarator0(data, flags); bp >= data; --bp) { switch (bp->op) { case PTR: - tp = qualifier(mktype(tp, PTR, NULL, 0), bp->u.qlf); + tp = qualifier(mktype(tp, PTR, 0), bp->u.qlf); break; case ARY: - tp = mktype(tp, ARY, NULL, bp->u.nelem); + tp = mktype(tp, ARY, bp->u.nelem); break; case FTN: - tp = mktype(tp, FTN, NULL, 0); + tp = mktype(tp, FTN, 0); break; case IDEN: sym = bp->u.sym; @@ -348,8 +348,7 @@ newtag(uint8_t tag) } else { sym = install("", NS_TAG); } - tp = sym->type = mktype(NULL, tag, NULL, 0); - tp->sym = sym; + tp = sym->type = mktype(NULL, tag, 0); return tp; bad_tag: diff --git a/cc1/expr.c b/cc1/expr.c @@ -90,7 +90,7 @@ addr2ptr(Node *np) { Type *tp; - tp = mktype(np->utype->type, PTR, NULL, 0); + tp = mktype(np->utype->type, PTR, 0); return unarycode(OADDR, tp, np); } @@ -374,7 +374,7 @@ address(char op, Node *np) goto no_lvalue; if (np->b.symbol && np->u.sym->s.isregister) goto reg_address; - return unarycode(op, mktype(np->type, PTR, NULL, 0), np); + return unarycode(op, mktype(np->type, PTR, 0), np); no_lvalue: err = "lvalue required in unary expression"; diff --git a/cc1/lex.c b/cc1/lex.c @@ -184,7 +184,7 @@ end_string: *bp = '\0'; sym = install("", NS_IDEN); sym->u.s = xstrdup(buf); - sym->type = mktype(chartype, PTR, NULL, 0); + sym->type = mktype(chartype, PTR, 0); yynlval.sym = sym; return STRING; } diff --git a/cc1/types.c b/cc1/types.c @@ -141,8 +141,7 @@ ctype(int8_t type, int8_t sign, int8_t size) } Type * -mktype(Type *tp, uint8_t op, - Symbol *sym, uint16_t nelem) +mktype(Type *tp, uint8_t op, uint16_t nelem) { static Type *typetab[NR_TYPE_HASH], **tbl; static uint8_t t; @@ -157,7 +156,7 @@ mktype(Type *tp, uint8_t op, if (op != FTN || op != STRUCT || op != UNION || op != ENUM) { for (bp = *tbl; bp; bp = bp->next) { if (bp->type == tp && bp->op == op && - bp->sym == sym && bp->u.nelem == nelem) { + (op != ARY || bp->u.nelem == nelem)) { return bp; } } @@ -176,7 +175,6 @@ mktype(Type *tp, uint8_t op, bp->type = tp; bp->op = op; bp->u.nelem = nelem; - bp->sym = sym; bp->letter = letter; return *tbl = bp; } @@ -194,6 +192,6 @@ qualifier(Type *tp, uint8_t qlf) tp = tp->type; qlf |= q; } - return mktype(tp, qlf|TQUALIFIER, NULL, 0); + return mktype(tp, qlf|TQUALIFIER, 0); }