summaryrefslogtreecommitdiff
path: root/parse/node.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-24 15:57:22 -0700
committerOri Bernstein <ori@eigenstate.org>2015-11-06 00:38:56 -0800
commitda4798f000d99dd326a542758da83ad04be72f86 (patch)
tree8f2e086ed1c4c57683bb43db75cb057dafd4080b /parse/node.c
parent74270f8f47a704652ca301975da7ff88926e5cc8 (diff)
downloadmc-da4798f000d99dd326a542758da83ad04be72f86.tar.gz
Shuffle around functions.
Move some code into the frontend so the middle end can call it.
Diffstat (limited to 'parse/node.c')
-rw-r--r--parse/node.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/parse/node.c b/parse/node.c
index c3522cb..eb613ff 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -245,6 +245,22 @@ Node *mklbl(Srcloc loc, char *lbl)
return mkexpr(loc, Olit, n, NULL);
}
+char *genlblstr(char *buf, size_t sz, char *suffix)
+{
+ static int nextlbl;
+ bprintf(buf, 128, ".L%d%s", nextlbl++, suffix);
+ return buf;
+}
+
+Node *genlbl(Srcloc loc)
+{
+ char buf[128];
+
+ genlblstr(buf, 128, "");
+ return mklbl(loc, buf);
+}
+
+
Node *mkstr(Srcloc loc, Str val)
{
Node *n;
@@ -330,6 +346,23 @@ Node *mkdecl(Srcloc loc, Node *name, Type *ty)
return n;
}
+Node *gentemp(Srcloc loc, Type *ty, Node **dcl)
+{
+ char buf[128];
+ static int nexttmp;
+ Node *t, *r, *n;
+
+ bprintf(buf, 128, ".t%d", nexttmp++);
+ n = mkname(loc, buf);
+ t = mkdecl(loc, n, ty);
+ r = mkexpr(loc, Ovar, n, NULL);
+ r->expr.type = t->decl.type;
+ r->expr.did = t->decl.did;
+ if (dcl)
+ *dcl = t;
+ return r;
+}
+
Ucon *mkucon(Srcloc loc, Node *name, Type *ut, Type *et)
{
Ucon *uc;