ref: 04f63c1843d6eef8a9e1c0b2d0329c6359403e09
parent: 1499a3610e424af329f9e236bc9eefe181512322
author: Ori Bernstein <[email protected]>
date: Mon Jan 9 18:43:22 EST 2012
Try to look up named types.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -27,16 +27,22 @@
/* find the most accurate type mapping */
static Type *tf(Type *t)
{
+ Type *lu;
assert(t != NULL);
-
- if (tytab[t->tid]) {
- printf ("%s => ", tystr(t));
- while (tytab[t->tid]) {
- t = tytab[t->tid];
- printf("%s => ", tystr(t));
+
+ while (1) {
+ if (!tytab[t->tid] && t->type == Tyname) {
+ if (!(lu = gettype(curstab(), t->name)))
+ fatal(t->name->line, "Could not find type %s", t->name->name.parts[t->name->name.nparts - 1]);
+ tytab[t->tid] = lu;
}
- printf("nil\n");
+
+ printf("%s => ", tystr(t));
+ if (!tytab[t->tid])
+ break;
+ t = tytab[t->tid];
}
+ printf("nil\n");
return t;
}