commit 9ef7864a898be6b779d7ff1981227999c213f9e6
parent b0f0a5fc5dfa715dc85d42797c1194e1cc2ec491
Author: FRIGN <dev@frign.de>
Date: Tue, 17 May 2016 17:06:13 +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
Diffstat:
4 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -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
@@ -133,6 +133,7 @@ struct type {
struct symbol {
Type type;
+ Type rtype;
unsigned short id;
unsigned short numid;
char *name;
@@ -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
@@ -11,7 +11,6 @@
Node *curstmt;
Symbol *curfun;
-Type rtype;
struct arena {
Node *mem;
diff --git a/cc2/parser.c b/cc2/parser.c
@@ -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)