summaryrefslogtreecommitdiff
path: root/6/genp9.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-09 16:49:09 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-09 16:49:09 -0700
commited8711e68e441e9884d734932373317834665833 (patch)
tree08a3f37550af1b6adb1ad912ee6df70fa6c1ceaf /6/genp9.c
parentbd5fb6d0628831cde25f13e3fe461786d616a06e (diff)
downloadmc-ed8711e68e441e9884d734932373317834665833.tar.gz
Refactor code to add jump tables, and prepare to generate them.
Diffstat (limited to '6/genp9.c')
-rw-r--r--6/genp9.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/6/genp9.c b/6/genp9.c
index ee93db3..0a9082e 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -265,7 +265,7 @@ static size_t writebytes(FILE *fd, char *name, size_t off, char *p, size_t sz)
static size_t writelit(FILE *fd, char *name, size_t off, Htab *strtab, Node *v, Type *ty)
{
char buf[128];
- char *lbl;
+ char *lbl, *local;
size_t sz;
union {
float fv;
@@ -299,14 +299,17 @@ static size_t writelit(FILE *fd, char *name, size_t off, Htab *strtab, Node *v,
if (hthas(strtab, &v->lit.strval)) {
lbl = htget(strtab, &v->lit.strval);
} else {
- lbl = genlocallblstr(buf, sizeof buf);
+ lbl = genlblstr(buf, sizeof buf);
htput(strtab, &v->lit.strval, strdup(lbl));
}
+ local = "";
+ if (*name == '.')
+ local = "<>";
if (v->lit.strval.len > 0)
- fprintf(fd, "DATA %s+%zd(SB)/8,$%s+0(SB)\n", name, off, lbl);
+ fprintf(fd, "DATA %s%s+%zd(SB)/8,$%s+0(SB)\n", name, local, off, lbl);
else
- fprintf(fd, "DATA %s+%zd(SB)/8,$0\n", name, off);
- fprintf(fd, "DATA %s+%zd(SB)/8,$%zd\n", name, off+8, v->lit.strval.len);
+ fprintf(fd, "DATA %s%s+%zd(SB)/8,$0\n", name, local, off);
+ fprintf(fd, "DATA %s%s+%zd(SB)/8,$%zd\n", name, local, off+8, v->lit.strval.len);
break;
case Lfunc:
die("Generating this shit ain't ready yet ");
@@ -314,6 +317,9 @@ static size_t writelit(FILE *fd, char *name, size_t off, Htab *strtab, Node *v,
case Llbl:
die("Can't generate literal labels, ffs. They're not data.");
break;
+ case Ljtab:
+ die("jump table in data section?");
+ break;
}
return sz;
}