ref: 34b564c77abf63d69b15d47ec4c76081285f4830
parent: 274de043f67e79f1582d25a998fbf67b092fd60d
author: Ori Bernstein <[email protected]>
date: Sat Dec 20 17:44:13 EST 2014
Tag exported symbols from traits. We weren't treating them as exported, which caused errors when trying to import them, obviously.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1972,20 +1972,41 @@
void **k;
Node *s;
Type *t;
+ Trait *tr;
size_t i, j, n;
k = htkeys(st->dcl, &n);
for (i = 0; i < n; i++) {
s = getdcl(st, k[i]);
- if (s->decl.vis != Visexport)
- continue;
- nodetag(st, s, 0, hidelocal);
+ if (s->decl.vis == Visexport)
+ nodetag(st, s, 0, hidelocal);
}
free(k);
- for (i = 0; i < nexportimpls; i++) {
- nodetag(st, exportimpls[i], 0, hidelocal);
+ k = htkeys(st->impl, &n);
+ for (i = 0; i < n; i++) {
+ s = getimpl(st, k[i]);
+ if (s->impl.vis == Visexport)
+ nodetag(st, s, 0, hidelocal);
}
+ free(k);
+
+ k = htkeys(st->tr, &n);
+ for (i = 0; i < n; i++) {
+ tr = gettrait(st, k[i]);
+ if (tr->vis == Visexport) {
+ tr->param->vis = Visexport;
+ for (i = 0; i < tr->nmemb; i++) {
+ tr->memb[i]->decl.vis = Visexport;
+ nodetag(st, tr->memb[i], 0, hidelocal);
+ }
+ for (i = 0; i < tr->nfuncs; i++) {
+ tr->funcs[i]->decl.vis = Visexport;
+ nodetag(st, tr->funcs[i], 0, hidelocal);
+ }
+ }
+ }
+ free(k);
/* get the explicitly exported symbols */
k = htkeys(st->ty, &n);
--- a/parse/node.c
+++ b/parse/node.c
@@ -15,8 +15,6 @@
size_t maxnid;
Node **decls;
size_t ndecls;
-Node **exportimpls;
-size_t nexportimpls;
char *fname(Srcloc l)
{
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -174,8 +174,7 @@
int uid; /* unique id */
Srcloc loc;
Vis vis;
- int isproto; /* is it a prototype (for exporting purposes) */
- int ishidden; /* should user code be able to use this? */
+
Node *name; /* the name of the trait */
Type *param; /* the type parameter */
Node **memb; /* type must have these members */
@@ -182,6 +181,9 @@
size_t nmemb;
Node **funcs; /* and declare these funcs */
size_t nfuncs;
+
+ char isproto; /* is it a prototype (for exporting purposes) */
+ char ishidden; /* should user code be able to use this? */
};
struct Node {
--- a/parse/use.c
+++ b/parse/use.c
@@ -930,14 +930,17 @@
}
}
- for (i = 0; i < nexportimpls; i++) {
+ k = htkeys(st->impl, &n);
+ for (i = 0; i < n; i++) {
/* merging during inference should remove all protos */
- assert(!exportimpls[i]->impl.isproto);
- if (exportimpls[i]->impl.vis == Visexport || exportimpls[i]->impl.vis == Vishidden) {
+ s = getimpl(st, k[i]);
+ assert(!s->impl.isproto);
+ if (s->impl.vis == Visexport || s->impl.vis == Vishidden) {
wrbyte(f, 'I');
- pickle(f, exportimpls[i]);
+ pickle(f, s);
}
}
+ free(k);
k = htkeys(st->dcl, &n);
for (i = 0; i < n; i++) {