summaryrefslogtreecommitdiff
path: root/parse/use.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-10-29 18:17:29 -0700
committerOri Bernstein <ori@eigenstate.org>2017-10-29 18:17:29 -0700
commitd359a98ab9cfc42de66ad35333bd6d6c0571b7ca (patch)
tree863b83c7653535a5e0c141733a0553381052921c /parse/use.c
parent4adc2f773870b45442ed27e5e794ade92e4fe2f0 (diff)
downloadmc-d359a98ab9cfc42de66ad35333bd6d6c0571b7ca.tar.gz
Fix traits when exported cross-namespaces.
Diffstat (limited to 'parse/use.c')
-rw-r--r--parse/use.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/parse/use.c b/parse/use.c
index b25e914..28c48f6 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -1032,10 +1032,17 @@ foundextlib:
impl = unpickle(f);
impl->impl.isextern = 1;
impl->impl.vis = vis;
- /* specialized declarations always go into the global stab */
+ /*
+ * Unfortunately, impls can insert their symbols into whatever
+ * namespace the trait comes from. This complicates things a bit.
+ */
for (i = 0; i < impl->impl.ndecls; i++) {
- impl->impl.decls[i]->decl.isglobl = 1;
- putdcl(file->file.globls, impl->impl.decls[i]);
+ dcl = impl->impl.decls[i];
+ dcl->decl.isglobl = 1;
+ ns = file->file.globls;
+ if (dcl->decl.name->name.ns)
+ ns = findstab(s, dcl->decl.name->name.ns);
+ putdcl(ns, dcl);
}
break;
case EOF:
@@ -1212,9 +1219,8 @@ writeuse(FILE *f, Node *file)
}
}
- k = htkeys(st->tr, &n);
- for (i = 0; i < n; i++) {
- tr = gettrait(st, k[i]);
+ for (i = 0; i < ntraittab; i++) {
+ tr = traittab[i];
if (tr->uid < Ntraits)
continue;
if (tr->vis == Visexport || tr->vis == Vishidden) {
@@ -1222,19 +1228,16 @@ writeuse(FILE *f, Node *file)
traitpickle(f, tr);
}
}
- free(k);
- k = htkeys(st->impl, &n);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < nimpltab; i++) {
/* merging during inference should remove all protos */
- s = getimpl(st, k[i]);
+ s = impltab[i];
assert(!s->impl.isproto);
if (s->impl.vis == Visexport || s->impl.vis == Vishidden) {
wrbyte(f, 'I');
pickle(f, s);
}
}
- free(k);
k = htkeys(st->dcl, &n);
for (i = 0; i < n; i++) {