summaryrefslogtreecommitdiff
path: root/parse/use.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-31 22:18:17 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-31 22:49:31 -0800
commit128470e404d843b3d71c5837cac05d4d4203bd66 (patch)
tree267d7879867aebd35a7f8203d0ff9f77fb9238f0 /parse/use.c
parentfb8753c942a8d06926977d221d5c89c3a867fa29 (diff)
downloadmc-128470e404d843b3d71c5837cac05d4d4203bd66.tar.gz
Add support for generic impls.
You can now implement generic shit like iterators.
Diffstat (limited to 'parse/use.c')
-rw-r--r--parse/use.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/parse/use.c b/parse/use.c
index acdefab..f1dbb71 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -813,14 +813,20 @@ static void protomap(Trait *tr, Type *ty, Node *dcl)
{
size_t i, len;
char *protoname, *dclname, *p;
+ Node *proto;
dclname = declname(dcl);
for (i = 0; i < tr->nfuncs; i++) {
- protoname = declname(tr->funcs[i]);
+ proto = tr->funcs[i];
+ protoname = declname(proto);
len = strlen(protoname);
p = strstr(dclname, protoname);
if (p && p[len] == '$')
- htput(tr->funcs[i]->decl.impls, ty, dcl);
+ htput(proto->decl.__impls, ty, dcl);
+ if (ty->type == Tygeneric || hasparams(ty)) {
+ lappend(&proto->decl.gimpl, &proto->decl.ngimpl, dcl);
+ lappend(&proto->decl.gtype, &proto->decl.ngtype, ty);
+ }
}
}
@@ -948,7 +954,7 @@ foundextlib:
puttrait(s, tr->name, tr);
for (i = 0; i < tr->nfuncs; i++) {
putdcl(s, tr->funcs[i]);
- tr->funcs[i]->decl.impls = mkht(tyhash, tyeq);
+ tr->funcs[i]->decl.__impls = mkht(tyhash, tyeq);
}
break;
case 'T':