[hackers] [scc] [cc2] Simplify code.c:addr() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 31 May 2016 08:42:00 +0200 (CEST)

commit bb043d47fd80b8aafdacb217ce4f48677c587df1
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue May 31 08:30:36 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue May 31 08:41:17 2016 +0200

    [cc2] Simplify code.c:addr()
    
    This function can be called with multiple different arguments, and
    we where dealing the different symbols like different cases, but it
    was the same case because we only had to use the storage class
    already stored in the symbol by parser.c:vardecl().

diff --git a/cc2/code.c b/cc2/code.c
index 40be482..829a695 100644
--- a/cc2/code.c
+++ b/cc2/code.c
_AT_@ -29,26 +29,31 @@ nextpc(void)
 static void
 addr(Node *np, Addr *addr)
 {
+ Symbol *sym;
+
         switch (np->op) {
         case OREG:
+ /* TODO:
+ * At this moment this op is used also for register variables
+ */
                 addr->kind = SREG;
                 addr->u.reg = np->u.reg;
                 break;
         case OCONST:
- addr->kind = OCONST;
+ addr->kind = SCONST;
+ /* TODO: Add support for more type of constants */
                 addr->u.i = np->u.i;
                 break;
+ case OTMP:
         case OLABEL:
- addr->kind = SLABEL;
- goto symbol;
         case OAUTO:
- addr->kind = SAUTO;
- goto symbol;
- case OTMP:
- addr->kind = STMP;;
- symbol:
- addr->u.sym = np->u.sym;
+ case OMEM:
+ sym = np->u.sym;
+ addr->kind = sym->kind;
+ addr->u.sym = sym;
                 break;
+ default:
+ abort();
         }
 }
 
Received on Tue May 31 2016 - 08:42:00 CEST

This archive was generated by hypermail 2.3.0 : Tue May 31 2016 - 08:48:17 CEST