summaryrefslogtreecommitdiff
path: root/parse/stab.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-29 15:14:05 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-29 15:14:05 -0700
commit2fa02e1d1d3df890d4349316389633d58c986254 (patch)
treee0a315e6e4bf2f9c3b150aca8f9d465bcdad3d70 /parse/stab.c
parent404ed1ddb3faa4fec7ee4fd8fddc5bbdec284bde (diff)
downloadmc-2fa02e1d1d3df890d4349316389633d58c986254.tar.gz
Finally do a by-scope comparison of generic types.
This should clear the way for better deduplication.
Diffstat (limited to 'parse/stab.c')
-rw-r--r--parse/stab.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/parse/stab.c b/parse/stab.c
index 7a9ae09..4cdee28 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -693,7 +693,7 @@ bindtype_rec(Tyenv *e, Type *t, Bitset *visited)
tt = htget(e->tab, t);
if (tt && tt != t)
tytab[t->tid] = tt;
- else if (!isbound(t))
+ else if (!boundtype(t))
htput(e->tab, t, t);
break;
case Tygeneric:
@@ -740,13 +740,16 @@ bindtype(Tyenv *env, Type *t)
/* If the current environment binds a type,
* we return true */
-int
-isbound(Type *t)
+Type*
+boundtype(Type *t)
{
-
Tyenv *e;
- for (e = curenv(); e; e = e->super)
- if (htget(e->tab, t))
- return 1;
- return 0;
+ Type *r;
+
+ for (e = curenv(); e; e = e->super) {
+ r = htget(e->tab, t);
+ if (r)
+ return r;
+ }
+ return NULL;
}