ref: 8cc199bcdeb207351248b0450e1e6a7114507b47
parent: 9288183824541a1e91d6e8674550efe9340f6f0e
author: Ori Bernstein <[email protected]>
date: Mon May 19 17:04:54 EDT 2014
Pickle/unpickle Nimpl. We currently seem broken on the type ids.
--- a/parse/use.c
+++ b/parse/use.c
@@ -263,17 +263,6 @@
wrsym(fd, tr->funcs[i]);
}
-static void implpickle(FILE *fd, Node *n)
-{
- size_t i;
-
- pickle(fd, n->impl.traitname);
- wrint(fd, n->impl.trait->uid);
- wrtype(fd, n->impl.type);
- for (i = 0; i < n->impl.ndecls; i++)
- pickle(fd, n->impl.decls[i]);
-}
-
static void wrtype(FILE *fd, Type *ty)
{
if (ty->tid >= Builtinmask)
@@ -514,7 +503,12 @@
pickle(fd, n->func.body);
break;
case Nimpl:
- die("Ntrait/Nimpl not yet supported!");
+ pickle(fd, n->impl.traitname);
+ wrint(fd, n->impl.trait->uid);
+ wrtype(fd, n->impl.type);
+ wrint(fd, n->impl.ndecls);
+ for (i = 0; i < n->impl.ndecls; i++)
+ pickle(fd, n->impl.decls[i]);
break;
case Nnone:
die("Nnone should not be seen as node type!");
@@ -649,7 +643,13 @@
popstab();
break;
case Nimpl:
- die("Ntrait/Nimpl not yet supported!");
+ n->impl.traitname = unpickle(fd);
+ n->impl.trait = htget(trmap, (void*)rdint(fd));
+ rdtype(fd, &n->impl.type);
+ n->impl.ndecls = rdint(fd);
+ n->impl.decls = zalloc(sizeof(Node *)*n->impl.ndecls);
+ for (i = 0; i < n->impl.ndecls; i++)
+ n->impl.decls[i] = unpickle(fd);
break;
case Nnone:
die("Nnone should not be seen as node type!");
@@ -694,6 +694,8 @@
*/
for (i = 0; i < ntypefixdest; i++) {
t = htget(tidmap, (void*)typefixid[i]);
+ if (!t)
+ die("Unable to find type for id %zd\n", i);
if (t->type == Tyname && !t->issynth) {
old = htget(tydedup, t->name);
if (old != t)
@@ -730,7 +732,7 @@
intptr_t tid;
size_t i;
char *pkg;
- Node *dcl;
+ Node *dcl, *impl;
Stab *s;
Type *ty;
Trait *tr;
@@ -805,7 +807,8 @@
}
break;
case 'I':
- die("Impls not yet implemented");
+ impl = unpickle(f);
+ putimpl(s, impl);
break;
case EOF:
break;
@@ -904,7 +907,7 @@
assert(!exportimpls[i]->impl.isproto);
if (exportimpls[i]->impl.vis == Visexport || exportimpls[i]->impl.vis == Vishidden) {
wrbyte(f, 'I');
- implpickle(f, exportimpls[i]);
+ pickle(f, exportimpls[i]);
}
}