shithub: mc

Download patch

ref: dc0ce7c68fd5e1a56a13960ba7121a38da0a55cb
parent: a1a5414ed17ae07d53d8e908267e9539a838d22f
author: Ori Bernstein <[email protected]>
date: Mon Dec 16 08:23:57 EST 2013

More work towards getting std.htab() working.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -424,6 +424,7 @@
 static void putbindings(Inferstate *st, Htab *bt, Type *t)
 {
     size_t i;
+    char *s;
 
     if (!t)
         return;
@@ -430,6 +431,11 @@
     if (t->type != Typaram)
         return;
 
+    if (debugopt['u']) {
+        s = tystr(t);
+        printf("\tBind %s", s);
+        free(s);
+    }
     if (hthas(bt, t->pname))
         unify(st, NULL, htget(bt, t->pname), t);
     else if (isbound(st, t))
@@ -443,9 +449,15 @@
 static void tybind(Inferstate *st, Type *t)
 {
     Htab *bt;
+    char *s;
 
     if (t->type != Tyname && !t->isgeneric)
         return;
+    if (debugopt['u']) {
+        s = tystr(t);
+        printf("Binding %s", s);
+        free(s);
+    }
     bt = mkht(strhash, streq);
     lappend(&st->tybindings, &st->ntybindings, bt);
     putbindings(st, bt, t);
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -60,7 +60,7 @@
                     tmp = mktyvar(t->param[i]->line);
                     htput(tsmap, t->param[i], tmp);
                 }
-                ret = mktyname(t->line, t->name, NULL, 0, tyspecialize(t->sub[0], tsmap));
+                ret = mktyname(t->line, t->name, t->param, t->nparam, tyspecialize(t->sub[0], tsmap));
                 ret->issynth = 1;
                 htput(tsmap, t, ret);
                 for (i = 0; i < t->nparam; i++)
--- a/parse/use.c
+++ b/parse/use.c
@@ -217,12 +217,15 @@
             pickle(ty->name, fd);
             wrbool(fd, ty->isgeneric);
             wrbool(fd, ty->issynth);
+
             wrint(fd, ty->nparam);
             for (i = 0; i < ty->nparam; i++)
                 wrtype(fd, ty->param[i]);
+
             wrint(fd, ty->narg);
             for (i = 0; i < ty->narg; i++)
                 wrtype(fd, ty->arg[i]);
+
             wrtype(fd, ty->sub[0]);
             break;
         default:
@@ -313,6 +316,7 @@
             ty->arg = zalloc(ty->narg * sizeof(Type *));
             for (i = 0; i < ty->narg; i++)
                 rdtype(fd, &ty->arg[i]);
+
             rdtype(fd, &ty->sub[0]);
             break;
         default: