summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-01-14 13:25:47 -0800
committerOri Bernstein <ori@eigenstate.org>2018-01-14 13:46:18 -0800
commite7ebda38777e5251b3479c3fdced4cb108f252e4 (patch)
tree79f4c82d261879baa7a13cced78c3c0b67e25c1b
parent8a53929e91acf351a11ec717c726833b2c703be1 (diff)
downloadmc-e7ebda38777e5251b3479c3fdced4cb108f252e4.tar.gz
Fix serializing trait specs in usefiles.
-rw-r--r--lib/iter/bld.sub6
-rw-r--r--parse/export.c12
-rw-r--r--parse/parse.h2
-rw-r--r--parse/use.c27
4 files changed, 41 insertions, 6 deletions
diff --git a/lib/iter/bld.sub b/lib/iter/bld.sub
index 2b8f5e3..0541f80 100644
--- a/lib/iter/bld.sub
+++ b/lib/iter/bld.sub
@@ -9,3 +9,9 @@ lib iter =
lib ../sys:sys
lib ../std:std
;;
+
+testdeps =
+ ../testr:testr
+ ../sys:sys
+ ../std:std
+;;
diff --git a/parse/export.c b/parse/export.c
index 68733fa..2d6e075 100644
--- a/parse/export.c
+++ b/parse/export.c
@@ -71,11 +71,15 @@ tagtype(Stab *st, Type *t, int ingeneric, int hidelocal)
{
size_t i;
- if (t->vis != Visintern)
+ if (!t || t->vis != Visintern)
return;
t->vis = Vishidden;
for (i = 0; i < t->nsub; i++)
tagtype(st, t->sub[i], ingeneric, hidelocal);
+ for (i = 0; i < t->nspec; i++) {
+ tagtype(st, t->spec[i]->param, ingeneric, hidelocal);
+ tagtype(st, t->spec[i]->aux, ingeneric, hidelocal);
+ }
switch (t->type) {
case Tystruct:
for (i = 0; i < t->nmemb; i++)
@@ -259,16 +263,18 @@ tagexports(int hidelocal)
free(k);
/* tag the traits */
- tr = NULL;
for (i = 0; i < ntraittab; i++) {
tr = traittab[i];
if (tr->vis != Visexport)
continue;
if (hidelocal && tr->ishidden)
tr->vis = Vishidden;
+ tagtype(st, tr->param, 0, hidelocal);
tr->param->vis = tr->vis;
- for (j = 0; j < tr->naux; j++)
+ for (j = 0; j < tr->naux; j++) {
+ tagtype(st, tr->aux[j], 0, hidelocal);
tr->aux[j]->vis = tr->vis;
+ }
for (j = 0; j < tr->nproto; j++) {
tr->proto[j]->decl.vis = tr->vis;
tagnode(st, tr->proto[j], 0, hidelocal);
diff --git a/parse/parse.h b/parse/parse.h
index 175bc08..7ac4b05 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -1,4 +1,4 @@
-#define Abiversion 14
+#define Abiversion 15
typedef struct Srcloc Srcloc;
typedef struct Tysubst Tysubst;
diff --git a/parse/use.c b/parse/use.c
index 7c7d48b..906e59b 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -218,7 +218,7 @@ rdsym(FILE *fd, Trait *ctx)
static void
typickle(FILE *fd, Type *ty)
{
- size_t i;
+ size_t i, j;
if (!ty) {
die("trying to pickle null type\n");
@@ -226,6 +226,16 @@ typickle(FILE *fd, Type *ty)
}
wrbyte(fd, ty->type);
wrbyte(fd, ty->vis);
+ wrint(fd, ty->nspec);
+ for (i = 0; i < ty->nspec; i++) {
+ wrint(fd, ty->spec[i]->ntrait);
+ for (j = 0; j < ty->spec[i]->ntrait; j++)
+ pickle(fd, ty->spec[i]->trait[j]);
+ wrtype(fd, ty->spec[i]->param);
+ wrbool(fd, ty->spec[i]->aux != NULL);
+ if (ty->spec[i]->aux)
+ wrtype(fd, ty->spec[i]->aux);
+ }
wrint(fd, ty->nsub);
switch (ty->type) {
case Tyunres:
@@ -350,7 +360,7 @@ rdtrait(FILE *fd, Trait **dest, Type *ty)
static Type *
tyunpickle(FILE *fd)
{
- size_t i, n;
+ size_t i, j, n;
Type *ty;
Ty t;
@@ -359,6 +369,19 @@ tyunpickle(FILE *fd)
ty->isimport = 1;
if (rdbyte(fd) == Vishidden)
ty->ishidden = 1;
+ ty->nspec = rdint(fd);
+ ty->spec = malloc(ty->nspec * sizeof(Traitspec*));
+ for (i = 0; i < ty->nspec; i++) {
+ ty->spec[i] = zalloc(sizeof(Traitspec));
+ n = rdint(fd);
+ ty->spec[i]->ntrait = n;
+ ty->spec[i]->trait = malloc(n * sizeof(Node*));
+ for (j = 0; j < ty->spec[i]->ntrait; j++)
+ ty->spec[i]->trait[j] = unpickle(fd);
+ rdtype(fd, &ty->spec[i]->param);
+ if (rdbool(fd))
+ rdtype(fd, &ty->spec[i]->aux);
+ }
ty->nsub = rdint(fd);
if (ty->nsub > 0)
ty->sub = zalloc(ty->nsub * sizeof(Type *));