ref: 7b85dc85c01282002571b52f207747da080c2802
parent: eda1a5eb2a36e7274ac0af63604abbd95347a564
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed May 6 15:28:36 EDT 2015
Convert emitret into private of code.c
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -155,7 +155,7 @@
OCOMMA, OCAST, OSYM, OASK, OFIELD, OTYP,
OLABEL, ODEFAULT, OCASE, OSTRUCT, OJUMP, OBRANCH,
OEXPR, OEFUN, OESTRUCT, OELOOP, OBLOOP, OPRINT,
- OFUN,
+ OFUN, ORET,
/* TODO: This order is important, but must be changed */
OAND, OOR,
/*
@@ -169,8 +169,7 @@
extern void
emitdcl(Symbol *),
emit(uint8_t, void *),
- emitswitch(short),
- emitret(Type *tp);
+ emitswitch(short);
extern Node *node(uint8_t op, Type *tp, Node *left, Node *rigth);
extern Node *symbol(Symbol *sym);
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -12,7 +12,8 @@
emitsym(uint8_t, void *), emitfield(uint8_t, void *),
emitsizeof(uint8_t, void *), emitexp(uint8_t, void *),
emitsymid(uint8_t, void *), emittext(uint8_t, void *),
- emitprint(uint8_t, void *), emitfun(uint8_t, void *);
+ emitprint(uint8_t, void *), emitfun(uint8_t, void *),
+ emitret(uint8_t, void *);
char *optxt[] = {
[OADD] = "+",
@@ -118,7 +119,8 @@
[OELOOP] = emittext,
[OBLOOP] = emittext,
[OPRINT] = emitprint,
- [OFUN] = emitfun
+ [OFUN] = emitfun,
+ [ORET] = emitret
};
void
@@ -276,9 +278,11 @@
sym->isglobal ? 'G' : 'Y', sym->id, sym->name);
}
-void
-emitret(Type *tp)
+static void
+emitret(uint8_t op, void *arg)
{
+ Type *tp = arg;
+
fputs("\ty", stdout);
emittype(tp);
}
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -174,7 +174,7 @@
else if ((np = convert(np, tp, 0)) == NULL)
error("incorrect type in return");
}
- emitret(tp);
+ emit(ORET, tp);
emit(OEXPR, np);
freetree(np);
}