summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-15 15:00:11 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-15 15:00:11 -0700
commitd7c4bac9357a6d5e3dfd691434f8d9a47d79f0dc (patch)
tree6555367f2f5a8ab98cc6ac37396b9852efbfe11a
parent2fd7aa8d72729ccec6c611fb3586e9c4c7b5e067 (diff)
downloadmc-d7c4bac9357a6d5e3dfd691434f8d9a47d79f0dc.tar.gz
Inline remapping function.
Easier to read, clearer what's going on.
-rw-r--r--parse/infer.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/parse/infer.c b/parse/infer.c
index a919d84..d05bfa3 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -513,37 +513,25 @@ tysearch(Type *t)
return t;
}
-static Type *
-remapping(Type *t)
-{
- Stab *ns;
- Type *lu;
-
- if (t->type != Tyunres)
- return NULL;
-
- ns = curstab();
- if (t->name->name.ns)
- ns = getns(file, t->name->name.ns);
- if (!ns)
- fatal(t->name, "no namespace \"%s\"", t->name->name.ns);
- lu = gettype(ns, t->name);
- if (!lu)
- fatal(t->name, "no type %s", tystr(t));
- return lu;
-}
-
/* Look up the best type to date in the unification table, returning it */
static Type *
tylookup(Type *t)
{
Type *lu;
+ Stab *ns;
assert(t != NULL);
lu = NULL;
while (1) {
- if (!tytab[t->tid]) {
- lu = remapping(t);
+ if (!tytab[t->tid] && t->type == Tyunres) {
+ ns = curstab();
+ if (t->name->name.ns)
+ ns = getns(file, t->name->name.ns);
+ if (!ns)
+ fatal(t->name, "no namespace \"%s\"", t->name->name.ns);
+ lu = gettype(ns, t->name);
+ if (!lu)
+ fatal(t->name, "no type %s", tystr(t));
if (lu && lu != t)
tytab[t->tid] = lu;
}