shithub: mc

Download patch

ref: 07cf448ccf4c27ad905272d6d6033676710b7541
parent: 99e0ccb6af41fe98470068acf846634ae19c8810
parent: 7901a7550dfe881ef5f7ead2a84a05316351b573
author: Ori Bernstein <[email protected]>
date: Sun Apr 22 07:44:28 EDT 2012

Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/mc2

--- a/parse/stab.c
+++ b/parse/stab.c
@@ -72,7 +72,6 @@
     st->ns = mkht(namehash, nameeq);
     st->dcl = mkht(namehash, nameeq);
     st->ty = mkht(namehash, nameeq);
-    st->closure = mkht(namehash, nameeq);
     return st;
 }
 
@@ -80,9 +79,18 @@
 Sym *getdcl(Stab *st, Node *n)
 {
     Sym *s;
+    Stab *orig;
+
+    orig = st;
     do {
-        if ((s = htget(st->dcl, n)))
+        if ((s = htget(st->dcl, n))) {
+            /* record that this is in the closure of this scope */
+            if (!st->closure)
+                st->closure = mkht(namehash, nameeq);
+            if (st != orig)
+                htput(st->closure, s->name, s);
             return s;
+        }
         st = st->super;
     } while (st);
     return NULL;
@@ -145,4 +153,3 @@
         fatal(scope->name->line, "Ns %s already defined", name(s->name));
     htput(st->ns, scope->name, scope);
 }
-