summaryrefslogtreecommitdiff
path: root/parse/node.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-20 23:06:03 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-20 23:06:03 -0800
commit6361a241f462769284053e07d51cd0638d3e94af (patch)
tree9c69b768bdccb941da1384e53745f87e4c94afa5 /parse/node.c
parent631e14604ba34ad97514cf302de75c3c3102d316 (diff)
downloadmc-6361a241f462769284053e07d51cd0638d3e94af.tar.gz
Add a distinction between label values and names.
This allows us to have labels work across scopes in assembly source.
Diffstat (limited to 'parse/node.c')
-rw-r--r--parse/node.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/parse/node.c b/parse/node.c
index 023dd01..038eec7 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -231,6 +231,7 @@ Node *mklbl(Srcloc loc, char *lbl)
assert(lbl != NULL);
n = mknode(loc, Nlit);
n->lit.littype = Llbl;
+ n->lit.lblname = NULL;
n->lit.lblval = strdup(lbl);
return mkexpr(loc, Olit, n, NULL);
}
@@ -238,7 +239,10 @@ Node *mklbl(Srcloc loc, char *lbl)
char *genlblstr(char *buf, size_t sz, char *suffix)
{
static int nextlbl;
- bprintf(buf, 128, ".L%d%s", nextlbl++, suffix);
+ size_t len;
+
+ len = snprintf(buf, 128, ".L%d.%s", nextlbl++, suffix);
+ assert(len <= sz);
return buf;
}