summaryrefslogtreecommitdiff
path: root/parse/use.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/use.c
parent25d91f98a97df36e1da381b273219ceedf256a4d (diff)
downloadmc-95f4d0b36eb2d25889eed6ab48fb025d5b346b67.tar.gz
Style(9)-ify.
Diffstat (limited to 'parse/use.c')
-rw-r--r--parse/use.c104
1 files changed, 66 insertions, 38 deletions
diff --git a/parse/use.c b/parse/use.c
index 4c95500..e9a169c 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -38,9 +38,9 @@ static Node *unpickle(FILE *fd);
/* type fixup list */
static Htab *tydeduptab; /* map from name -> type, contains all Tynames loaded ever */
static Htab *trdeduptab; /* map from name -> type, contains all Tynames loaded ever */
-static Htab *tidmap; /* map from tid -> type */
-static Htab *trmap; /* map from trait id -> trait */
-static Htab *initmap; /* map from init name -> int */
+static Htab *tidmap; /* map from tid -> type */
+static Htab *trmap; /* map from trait id -> trait */
+static Htab *initmap; /* map from init name -> int */
#define Builtinmask (1 << 30)
static Typefix *typefix; /* list of types we need to replace */
@@ -49,10 +49,11 @@ static size_t ntypefix; /* size of replacement list */
static Traitfix *traitfix; /* list of traits we need to replace */
static size_t ntraitfix; /* size of replacement list */
-static Node **implfix; /* list of impls we need to fix up */
+static Node **implfix; /* list of impls we need to fix up */
static size_t nimplfix; /* size of replacement list */
-void addextlibs(Node *file, char **libs, size_t nlibs)
+void
+addextlibs(Node *file, char **libs, size_t nlibs)
{
size_t i, j;
@@ -65,9 +66,10 @@ void addextlibs(Node *file, char **libs, size_t nlibs)
}
/* Outputs a symbol table to file in a way that can be
- * read back usefully. Only writes declarations, types
+ * read back usefully. Only writes declarations, type
* and sub-namespaces. Captured variables are ommitted. */
-static void wrstab(FILE *fd, Stab *val)
+static void
+wrstab(FILE *fd, Stab *val)
{
size_t n, i;
void **keys;
@@ -93,7 +95,8 @@ static void wrstab(FILE *fd, Stab *val)
/* Reads a symbol table from file. The converse
* of wrstab. */
-static Stab *rdstab(FILE *fd, int isfunc)
+static Stab *
+rdstab(FILE *fd, int isfunc)
{
Stab *st;
Type *ty;
@@ -118,7 +121,8 @@ static Stab *rdstab(FILE *fd, int isfunc)
return st;
}
-static void wrucon(FILE *fd, Ucon *uc)
+static void
+wrucon(FILE *fd, Ucon *uc)
{
wrint(fd, uc->loc.line);
wrint(fd, uc->id);
@@ -129,7 +133,8 @@ static void wrucon(FILE *fd, Ucon *uc)
wrtype(fd, uc->etype);
}
-static Ucon *rducon(FILE *fd, Type *ut)
+static Ucon *
+rducon(FILE *fd, Type *ut)
{
Type *et;
Node *name;
@@ -154,10 +159,11 @@ static Ucon *rducon(FILE *fd, Type *ut)
}
/* Writes the name and type of a variable,
- * but only writes its intializer for things
+ * but only writes its intializer for thing
* we want to inline cross-file (currently,
* the only cross-file inline is generics) */
-static void wrsym(FILE *fd, Node *val)
+static void
+wrsym(FILE *fd, Node *val)
{
/* sym */
wrint(fd, val->loc.line);
@@ -177,7 +183,8 @@ static void wrsym(FILE *fd, Node *val)
pickle(fd, val->decl.init);
}
-static Node *rdsym(FILE *fd, Trait *ctx)
+static Node *
+rdsym(FILE *fd, Trait *ctx)
{
int line;
Node *name;
@@ -209,7 +216,8 @@ static Node *rdsym(FILE *fd, Trait *ctx)
/* Writes types to a file. Errors on
* internal only types like Tyvar that
* will not be meaningful in another file*/
-static void typickle(FILE *fd, Type *ty)
+static void
+typickle(FILE *fd, Type *ty)
{
size_t i;
@@ -221,7 +229,7 @@ static void typickle(FILE *fd, Type *ty)
wrbyte(fd, ty->vis);
/* tid is generated; don't write */
/* FIXME: since we only support hardcoded traits, we just write
- * out the set of them. we should write out the trait list as
+ * out the set of them. we should write out the trait list a
* well */
if (!ty->traits) {
wrint(fd, 0);
@@ -277,7 +285,8 @@ static void typickle(FILE *fd, Type *ty)
}
}
-static void traitpickle(FILE *fd, Trait *tr)
+static void
+traitpickle(FILE *fd, Trait *tr)
{
size_t i;
@@ -293,7 +302,8 @@ static void traitpickle(FILE *fd, Trait *tr)
wrsym(fd, tr->proto[i]);
}
-static void wrtype(FILE *fd, Type *ty)
+static void
+wrtype(FILE *fd, Type *ty)
{
if (ty->tid >= Builtinmask)
die("Type id %d for %s too big", ty->tid, tystr(ty));
@@ -303,7 +313,8 @@ static void wrtype(FILE *fd, Type *ty)
wrint(fd, ty->tid);
}
-static void rdtype(FILE *fd, Type **dest)
+static void
+rdtype(FILE *fd, Type **dest)
{
uintptr_t tid;
@@ -316,7 +327,8 @@ static void rdtype(FILE *fd, Type **dest)
}
}
-static void rdtrait(FILE *fd, Trait **dest, Type *ty)
+static void
+rdtrait(FILE *fd, Trait **dest, Type *ty)
{
uintptr_t tid;
@@ -335,7 +347,8 @@ static void rdtrait(FILE *fd, Trait **dest, Type *ty)
/* Writes types to a file. Errors on
* internal only types like Tyvar that
* will not be meaningful in another file */
-static Type *tyunpickle(FILE *fd)
+static Type *
+tyunpickle(FILE *fd)
{
size_t i, n;
Type *ty;
@@ -401,7 +414,8 @@ static Type *tyunpickle(FILE *fd)
return ty;
}
-Trait *traitunpickle(FILE *fd)
+Trait *
+traitunpickle(FILE *fd)
{
Trait *tr;
Node *proto;
@@ -409,7 +423,7 @@ Trait *traitunpickle(FILE *fd)
intptr_t uid;
/* create an empty trait */
- tr = mktrait(Zloc, NULL, NULL,
+ tr = mktrait(Zloc, NULL, NULL,
NULL, 0,
NULL, 0,
0);
@@ -439,7 +453,8 @@ Trait *traitunpickle(FILE *fd)
* in-memory representation. Minimal
* checking is done, so a bad type can
* crash the compiler */
-static void pickle(FILE *fd, Node *n)
+static void
+pickle(FILE *fd, Node *n)
{
size_t i;
@@ -572,7 +587,8 @@ static void pickle(FILE *fd, Node *n)
/* Unpickles a node from a file. Minimal checking
* is done. Specifically, no checks are done for
* sane arities, a bad file can crash the compiler */
-static Node *unpickle(FILE *fd)
+static Node *
+unpickle(FILE *fd)
{
size_t i;
Ntype type;
@@ -722,7 +738,8 @@ static Node *unpickle(FILE *fd)
return n;
}
-static Stab *findstab(Stab *st, char *pkg)
+static Stab *
+findstab(Stab *st, char *pkg)
{
Stab *s;
@@ -742,7 +759,8 @@ static Stab *findstab(Stab *st, char *pkg)
return s;
}
-static int isspecialization(Type *t1, Type *t2)
+static int
+isspecialization(Type *t1, Type *t2)
{
if ((t1->type != Tygeneric || t2->type != Tyname) &&
(t1->type != Tyname || t2->type != Tygeneric) &&
@@ -752,7 +770,8 @@ static int isspecialization(Type *t1, Type *t2)
return nameeq(t1->name, t2->name);
}
-static void fixtypemappings(Stab *st)
+static void
+fixtypemappings(Stab *st)
{
size_t i;
Type *t, *u, *old;
@@ -760,7 +779,7 @@ static void fixtypemappings(Stab *st)
/*
* merge duplicate definitions.
* This allows us to compare named types by id, instead
- * of doing a deep walk through the type. This ability is
+ * of doing a deep walk through the type. This ability i
* depended on when we do type inference.
*/
for (i = 0; i < ntypefix; i++) {
@@ -796,7 +815,8 @@ static void fixtypemappings(Stab *st)
lfree(&typefix, &ntypefix);
}
-static void fixtraitmappings(Stab *st)
+static void
+fixtraitmappings(Stab *st)
{
size_t i;
Trait *t, *tr;
@@ -804,7 +824,7 @@ static void fixtraitmappings(Stab *st)
/*
* merge duplicate definitions.
* This allows us to compare named types by id, instead
- * of doing a deep walk through the type. This ability is
+ * of doing a deep walk through the type. This ability i
* depended on when we do type inference.
*/
for (i = 0; i < ntraitfix; i++) {
@@ -828,7 +848,8 @@ static void fixtraitmappings(Stab *st)
ntraitfix = 0;
}
-static void protomap(Trait *tr, Type *ty, Node *dcl)
+static void
+protomap(Trait *tr, Type *ty, Node *dcl)
{
size_t i, len;
char *protoname, *dclname, *p;
@@ -852,7 +873,8 @@ static void protomap(Trait *tr, Type *ty, Node *dcl)
}
}
-static void fiximplmappings(Stab *st)
+static void
+fiximplmappings(Stab *st)
{
Node *impl;
Trait *tr;
@@ -882,7 +904,8 @@ static void fiximplmappings(Stab *st)
* D<picled-decl>
* G<pickled-decl><pickled-initializer>
*/
-int loaduse(char *path, FILE *f, Stab *st, Vis vis)
+int
+loaduse(char *path, FILE *f, Stab *st, Vis vis)
{
intptr_t tid;
size_t i;
@@ -946,7 +969,8 @@ int loaduse(char *path, FILE *f, Stab *st, Vis vis)
/* break out of both loop and switch */
goto foundlib;
lappend(&file->file.libdeps, &file->file.nlibdeps, lib);
-foundlib:
+foundlib
+:
break;
case 'X':
lib = rdstr(f);
@@ -955,7 +979,8 @@ foundlib:
/* break out of both loop and switch */
goto foundextlib;
lappend(&file->file.extlibs, &file->file.nextlibs, lib);
-foundextlib:
+foundextlib
+:
break;
case 'F': lappend(&file->file.files, &file->file.nfiles, rdstr(f)); break;
case 'G':
@@ -1029,7 +1054,8 @@ foundextlib:
return 1;
}
-int hassuffix(char *str, char *suff)
+int
+hassuffix(char *str, char *suff)
{
size_t nstr, nsuff;
@@ -1040,7 +1066,8 @@ int hassuffix(char *str, char *suff)
return !strcmp(str + nstr - nsuff, suff);
}
-void readuse(Node *use, Stab *st, Vis vis)
+void
+readuse(Node *use, Stab *st, Vis vis)
{
size_t i;
FILE *fd;
@@ -1102,7 +1129,8 @@ void readuse(Node *use, Stab *st, Vis vis)
* G<pickled-decl><pickled-initializer>
* Z
*/
-void writeuse(FILE *f, Node *file)
+void
+writeuse(FILE *f, Node *file)
{
Stab *st;
void **k;