summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-03-26 22:06:47 -0700
committerOri Bernstein <ori@eigenstate.org>2015-03-26 22:46:57 -0700
commita52816a45ffc93ae0c913c9dde33943f77991ede (patch)
treedb54651cc5959ed9defde686daaa36aeaf409521 /parse
parent7a946573a2c3edc352c95a356373d1e1174c490f (diff)
downloadmc-a52816a45ffc93ae0c913c9dde33943f77991ede.tar.gz
Generate type descriptions for valists.
the formatting test is still broken, but everything else seems to be working.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 1163a1d..217174f 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -133,6 +133,7 @@ static char *ctxstr(Inferstate *st, Node *n)
nargs = n->expr.nargs;
t1 = NULL;
t2 = NULL;
+ t3 = NULL;
if (exprop(n) == Ovar)
d = namestr(args[0]);
else
@@ -184,6 +185,7 @@ static char *ctxstr(Inferstate *st, Node *n)
free(t);
free(t1);
free(t2);
+ free(t3);
s = strdup(buf);
break;
}
@@ -469,6 +471,7 @@ static Type *tf(Inferstate *st, Type *orig)
int isgeneric;
Type *t;
+ assert(orig != NULL);
t = tysearch(orig);
isgeneric = t->type == Tygeneric;
st->ingeneric += isgeneric;
@@ -906,6 +909,14 @@ static Type *unify(Inferstate *st, Node *ctx, Type *u, Type *v)
return r;
}
+static void markvatypes(Type **types, size_t ntypes)
+{
+ size_t i;
+
+ for (i = 0; i < ntypes; i++)
+ types[i]->isreflect = 1;
+}
+
/* Applies unifications to function calls.
* Funciton application requires a slightly
* different approach to unification. */
@@ -933,8 +944,10 @@ static void unifycall(Inferstate *st, Node *n)
fatal(n, "%s arity mismatch (expected %zd args, got %zd)",
ctxstr(st, n->expr.args[0]), ft->nsub - 1, n->expr.nargs - 1);
- if (ft->sub[i]->type == Tyvalist)
+ if (ft->sub[i]->type == Tyvalist) {
+ markvatypes(&ft->sub[i], ft->nsub - i);
break;
+ }
inferexpr(st, &n->expr.args[i], NULL, NULL);
unify(st, n->expr.args[0], ft->sub[i], type(st, n->expr.args[i]));
}