summaryrefslogtreecommitdiff
path: root/parse/stab.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-09 10:18:26 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-09 10:18:26 -0700
commit95f4d0b36eb2d25889eed6ab48fb025d5b346b67 (patch)
treed5e206f2a9c6713c193911370958826928c91294 /parse/stab.c
parent25d91f98a97df36e1da381b273219ceedf256a4d (diff)
downloadmc-95f4d0b36eb2d25889eed6ab48fb025d5b346b67.tar.gz
Style(9)-ify.
Diffstat (limited to 'parse/stab.c')
-rw-r--r--parse/stab.c108
1 files changed, 71 insertions, 37 deletions
diff --git a/parse/stab.c b/parse/stab.c
index e380afd..cf622b3 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -33,19 +33,22 @@ static Stab *stabstk[Maxstabdepth];
int stabstkoff;
/* scope management */
-Stab *curstab()
+Stab *
+curstab()
{
assert(stabstkoff > 0);
return stabstk[stabstkoff - 1];
}
-void pushstab(Stab *st)
+void
+pushstab(Stab *st)
{
assert(stabstkoff < Maxstabdepth);
stabstk[stabstkoff++] = st;
}
-void popstab(void)
+void
+popstab(void)
{
assert(stabstkoff > 0);
stabstkoff--;
@@ -54,17 +57,20 @@ void popstab(void)
/* name hashing: we want namespaced lookups to find the
* name even if we haven't set the namespace up, since
* we can update it after the fact. */
-ulong nsnamehash(void *n)
+ulong
+nsnamehash(void *n)
{
return strhash(namestr(n));
}
-int nsnameeq(void *a, void *b)
+int
+nsnameeq(void *a, void *b)
{
return a == b || !strcmp(namestr(a), namestr(b));
}
-static ulong implhash(void *p)
+static ulong
+implhash(void *p)
{
Node *n;
ulong h;
@@ -75,7 +81,8 @@ static ulong implhash(void *p)
return h;
}
-Stab *findstab(Stab *st, Node *n)
+Stab *
+findstab(Stab *st, Node *n)
{
Stab *ns;
@@ -90,7 +97,8 @@ Stab *findstab(Stab *st, Node *n)
return st;
}
-static int impleq(void *pa, void *pb)
+static int
+impleq(void *pa, void *pb)
{
Node *a, *b;
@@ -101,7 +109,8 @@ static int impleq(void *pa, void *pb)
return 0;
}
-Stab *mkstab(int isfunc)
+Stab *
+mkstab(int isfunc)
{
Stab *st;
@@ -119,7 +128,8 @@ Stab *mkstab(int isfunc)
return st;
}
-Node *getclosed(Stab *st, Node *n)
+Node *
+getclosed(Stab *st, Node *n)
{
while (st && !st->env)
st = st->super;
@@ -128,7 +138,8 @@ Node *getclosed(Stab *st, Node *n)
return NULL;
}
-Node **getclosure(Stab *st, size_t *n)
+Node **
+getclosure(Stab *st, size_t *n)
{
size_t nkeys, i;
void **keys;
@@ -153,15 +164,16 @@ Node **getclosure(Stab *st, size_t *n)
/*
* Searches for declarations from current
- * scope, and all enclosing scopes. Does
+ * scope, and all enclosing scopes. Doe
* not resolve namespaces -- that is the job
* of the caller of this function.
*
- * If a resoved name is not global, and is
+ * If a resoved name is not global, and i
* not in the current scope, it is recorded
* in the scope's closure.
*/
-Node *getdcl(Stab *st, Node *n)
+Node *
+getdcl(Stab *st, Node *n)
{
Node *s;
Stab *fn;
@@ -182,7 +194,8 @@ Node *getdcl(Stab *st, Node *n)
return NULL;
}
-void putlbl(Stab *st, char *name, Node *lbl)
+void
+putlbl(Stab *st, char *name, Node *lbl)
{
assert(st && st->isfunc);
if (hthas(st->lbl, name))
@@ -190,7 +203,8 @@ void putlbl(Stab *st, char *name, Node *lbl)
htput(st->lbl, name, lbl);
}
-Node *getlbl(Stab *st, Srcloc loc, char *name)
+Node *
+getlbl(Stab *st, Srcloc loc, char *name)
{
while (st && !st->isfunc)
st = st->super;
@@ -199,7 +213,8 @@ Node *getlbl(Stab *st, Srcloc loc, char *name)
return htget(st->lbl, name);
}
-Type *gettype_l(Stab *st, Node *n)
+Type *
+gettype_l(Stab *st, Node *n)
{
Tydefn *t;
@@ -208,7 +223,8 @@ Type *gettype_l(Stab *st, Node *n)
return NULL;
}
-Type *gettype(Stab *st, Node *n)
+Type *
+gettype(Stab *st, Node *n)
{
Tydefn *t;
@@ -220,7 +236,8 @@ Type *gettype(Stab *st, Node *n)
return NULL;
}
-int hastype(Stab *st, Node *n)
+int
+hastype(Stab *st, Node *n)
{
do {
if (hthas(st->ty, n))
@@ -230,7 +247,8 @@ int hastype(Stab *st, Node *n)
return 0;
}
-Ucon *getucon(Stab *st, Node *n)
+Ucon *
+getucon(Stab *st, Node *n)
{
Ucon *uc;
@@ -242,7 +260,8 @@ Ucon *getucon(Stab *st, Node *n)
return NULL;
}
-Trait *gettrait(Stab *st, Node *n)
+Trait *
+gettrait(Stab *st, Node *n)
{
Traitdefn *c;
@@ -256,11 +275,13 @@ Trait *gettrait(Stab *st, Node *n)
return NULL;
}
-Stab *getns(Node *file, char *name) {
+Stab *
+getns(Node *file, char *name) {
return htget(file->file.ns, name);
}
-static int mergedecl(Node *old, Node *new)
+static int
+mergedecl(Node *old, Node *new)
{
Node *e, *g;
@@ -320,14 +341,16 @@ static int mergedecl(Node *old, Node *new)
return 1;
}
-void forcedcl(Stab *st, Node *s)
+void
+forcedcl(Stab *st, Node *s)
{
setns(s->decl.name, st->name);
htput(st->dcl, s->decl.name, s);
assert(htget(st->dcl, s->decl.name) != NULL);
}
-void putdcl(Stab *st, Node *s)
+void
+putdcl(Stab *st, Node *s)
{
Node *old;
@@ -340,7 +363,8 @@ void putdcl(Stab *st, Node *s)
lnum(s->loc));
}
-void updatetype(Stab *st, Node *n, Type *t)
+void
+updatetype(Stab *st, Node *n, Type *t)
{
Tydefn *td;
@@ -350,7 +374,8 @@ void updatetype(Stab *st, Node *n, Type *t)
td->type = t;
}
-int mergetype(Type *old, Type *new)
+int
+mergetype(Type *old, Type *new)
{
if (!new) {
lfatal(old->loc, "double prototyping of %s", tystr(old));
@@ -370,7 +395,8 @@ int mergetype(Type *old, Type *new)
return 0;
}
-void puttype(Stab *st, Node *n, Type *t)
+void
+puttype(Stab *st, Node *n, Type *t)
{
Tydefn *td;
Type *ty;
@@ -398,7 +424,8 @@ void puttype(Stab *st, Node *n, Type *t)
}
}
-void putucon(Stab *st, Ucon *uc)
+void
+putucon(Stab *st, Ucon *uc)
{
Ucon *old;
@@ -410,7 +437,8 @@ void putucon(Stab *st, Ucon *uc)
htput(st->uc, uc->name, uc);
}
-static int mergetrait(Trait *old, Trait *new)
+static int
+mergetrait(Trait *old, Trait *new)
{
if (old->isproto && !new->isproto)
*old = *new;
@@ -421,7 +449,8 @@ static int mergetrait(Trait *old, Trait *new)
return 1;
}
-void puttrait(Stab *st, Node *n, Trait *c)
+void
+puttrait(Stab *st, Node *n, Trait *c)
{
Traitdefn *td;
Trait *t;
@@ -444,7 +473,8 @@ void puttrait(Stab *st, Node *n, Trait *c)
htput(st->tr, td->name, td);
}
-static int mergeimpl(Node *old, Node *new)
+static int
+mergeimpl(Node *old, Node *new)
{
Vis vis;
@@ -466,7 +496,8 @@ static int mergeimpl(Node *old, Node *new)
return 1;
}
-void putimpl(Stab *st, Node *n)
+void
+putimpl(Stab *st, Node *n)
{
Node *impl;
@@ -484,7 +515,8 @@ void putimpl(Stab *st, Node *n)
htput(st->impl, n, n);
}
-Node *getimpl(Stab *st, Node *n)
+Node *
+getimpl(Stab *st, Node *n)
{
Node *imp;
@@ -496,7 +528,8 @@ Node *getimpl(Stab *st, Node *n)
return NULL;
}
-void putns(Node *file, Stab *scope)
+void
+putns(Node *file, Stab *scope)
{
Stab *s;
@@ -508,10 +541,11 @@ void putns(Node *file, Stab *scope)
/*
* Sets the namespace of a symbol table, and
- * changes the namespace of all contained symbols
+ * changes the namespace of all contained symbol
* to match it.
*/
-void updatens(Stab *st, char *name)
+void
+updatens(Stab *st, char *name)
{
void **k;
size_t i, nk;