static Node *rdsym(FILE *fd, Trait *ctx) { int line; Node *name; Node *n; line = rdint(fd); name = unpickle(fd); n = mkdecl(Zloc, name, NULL); n->loc.line = line; n->loc.file = file->file.nfiles - 1; rdtype(fd, &n->decl.type); if (rdint(fd) == Vishidden) n->decl.ishidden = 1; n->decl.trait = ctx; n->decl.isconst = rdbool(fd); n->decl.isgeneric = rdbool(fd); n->decl.isextern = rdbool(fd); n->decl.ispkglocal = rdbool(fd); n->decl.isnoret = rdbool(fd); n->decl.isimport = 1; n->decl.isexportinit = rdbool(fd); n->decl.isinit = rdbool(fd); if (n->decl.isexportinit) n->decl.init = unpickle(fd); return n; }
static Node *gentemp(Simp *simp, Node *e, Type *ty, Node **dcl) { char buf[128]; static int nexttmp; Node *t, *r, *n; snprintf(buf, 128, ".t%d", nexttmp++); n = mkname(e->line, buf); t = mkdecl(e->line, n, ty); r = mkexpr(e->line, Ovar, n, NULL); r->expr.type = t->decl.type; r->expr.did = t->decl.did; if (dcl) *dcl = t; return r; }
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; }
static Node *simpblob(Simp *s, Node *blob, Node ***l, size_t *nl) { Node *n, *d, *r; char lbl[128]; n = mkname(blob->line, genlblstr(lbl, 128)); d = mkdecl(blob->line, n, blob->expr.type); r = mkexpr(blob->line, Ovar, n, NULL); d->decl.init = blob; d->decl.type = blob->expr.type; d->decl.isconst = 1; htput(s->globls, d, strdup(lbl)); r->expr.did = d->decl.did; r->expr.type = blob->expr.type; r->expr.isconst = 1; lappend(l, nl, d); return r; }
static void initconsts(Htab *globls) { Type *ty; Node *name; Node *dcl; tyintptr = mktype(Zloc, Tyuint64); tyword = mktype(Zloc, Tyuint); tyvoid = mktype(Zloc, Tyvoid); ty = mktyfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid)); ty->type = Tycode; name = mknsname(Zloc, "_rt", "abort_oob"); dcl = mkdecl(Zloc, name, ty); dcl->decl.isconst = 1; dcl->decl.isextern = 1; htput(globls, dcl, asmname(dcl)); abortoob = mkexpr(Zloc, Ovar, name, NULL); abortoob->expr.type = ty; abortoob->expr.did = dcl->decl.did; abortoob->expr.isconst = 1; }