ref: 62f7dc8a82a51b9b043587ee0ca52c62c7420999
parent: 857f6990c4a840a8ab4808962b9680d8057f14d7
author: Ori Bernstein <[email protected]>
date: Fri Oct 12 15:45:31 EDT 2012
Refactor the tf() function a little bit. It should make a bit more sense.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -230,9 +230,9 @@
if (t->resolved)
return;
- t->resolved = 1;
if (t->type == Tygeneric)
t = tyfreshen(st, t);
+ t->resolved = 1;
tybind(st, t);
/* if this is a generic type, bind the params. */
/* Walk through aggregate type members */
@@ -275,21 +275,20 @@
assert(t != NULL);
lu = NULL;
- while (1) {
- if (!tytab[t->tid] && t->type == Tyunres) {
- ns = curstab();
- if (t->name->name.ns) {
- ns = getns_str(ns, t->name->name.ns);
- }
- if (!(lu = gettype(ns, t->name)))
- fatal(t->name->line, "Could not resolve type %s", namestr(t->name));
- tytab[t->tid] = lu;
- }
-
- if (!tytab[t->tid])
- break;
+ while (tytab[t->tid])
t = tytab[t->tid];
+
+ if (t->type == Tyunres) {
+ ns = curstab();
+ if (t->name->name.ns) {
+ ns = getns_str(ns, t->name->name.ns);
+ }
+ if (!(lu = gettype(ns, t->name)))
+ fatal(t->name->line, "Could not resolve type %s", namestr(t->name));
+ tytab[t->tid] = lu;
}
+ if (t->type == Tygeneric)
+ t = tyfreshen(st, t);
tyresolve(st, t);
return t;
}