[hackers] [scc] Re-add rtype-field to Symbol-type || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 17 May 2016 17:09:22 +0200 (CEST)

commit 9ef7864a898be6b779d7ff1981227999c213f9e6
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Tue May 17 17:06:13 2016 +0200
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Tue May 17 17:09:18 2016 +0200

    Re-add rtype-field to Symbol-type
    
    The global rtype worked previously, but now we have not only one return
    type. So we move that one back into the Symbol-type.
    
    "Hay un cierto placer en la locura, que solo el loco conoce."
       - Pablo Neruda

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 99624fc..5c88ce1 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -303,7 +303,7 @@ writeout(void)
 
         if (curfun->kind == SGLOB)
                 fputs("export ", stdout);
- printf("function %s %s(", size2asm(&rtype), symname(curfun));
+ printf("function %s %s(", size2asm(&curfun->rtype), symname(curfun));
 
         /* declare formal parameters */
         for (sep = "", p = locals; p; p = p->next, sep = ",") {
diff --git a/cc2/cc2.h b/cc2/cc2.h
index 4dbbd45..b73a6da 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
_AT_@ -133,6 +133,7 @@ struct type {
 
 struct symbol {
         Type type;
+ Type rtype;
         unsigned short id;
         unsigned short numid;
         char *name;
_AT_@ -223,7 +224,6 @@ extern void pushctx(void);
 extern void freesym(Symbol *sym);
 
 /* globals */
-extern Type rtype;
 extern Symbol *curfun;
 extern Symbol *locals;
 extern Inst *pc, *prog;
diff --git a/cc2/node.c b/cc2/node.c
index 4120869..8c7e024 100644
--- a/cc2/node.c
+++ b/cc2/node.c
_AT_@ -11,7 +11,6 @@
 
 Node *curstmt;
 Symbol *curfun;
-Type rtype;
 
 struct arena {
         Node *mem;
diff --git a/cc2/parser.c b/cc2/parser.c
index fdc1513..2ba511e 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -513,7 +513,7 @@ vardecl(void)
         sym->name = name;
         sym->type = *tp;
         if (tp->flags & FUNF)
- rtype = *rp;
+ sym->rtype = *rp;
         sym->kind = sclass;
 
         if (ininit)
Received on Tue May 17 2016 - 17:09:22 CEST

This archive was generated by hypermail 2.3.0 : Tue May 17 2016 - 17:12:15 CEST