shithub: mc

Download patch

ref: 3aca4ae01d6cc83f83faeecb0271bf12b2db5722
parent: 6710eaf7cfe2e15b6c4bc352c4285678efa53212
author: Ori Bernstein <[email protected]>
date: Sun Aug 26 18:27:37 EDT 2012

Push and pop scopes when flattening.

    We will need to look up declarations. This makes it possible.

--- a/6/simp.c
+++ b/6/simp.c
@@ -523,9 +523,11 @@
 {
     size_t i;
 
+    pushstab(n->block.scope);
     for (i = 0; i < n->block.nstmts; i++) {
         simp(s, n->block.stmts[i]);
     }
+    popstab();
 }
 
 static Node *simplit(Simp *s, Node *lit, Node ***l, size_t *nl)
@@ -1263,7 +1265,9 @@
     /* unwrap to the function body */
     n = n->expr.args[0];
     n = n->lit.fnval;
+    pushstab(n->func.scope);
     flatten(s, n);
+    popstab();
 
     if (debug)
         for (i = 0; i < s->nstmts; i++)
@@ -1374,6 +1378,7 @@
     /* We need to define all global variables before use */
     fillglobls(file->file.globls, globls);
 
+    pushstab(file->file.globls);
     for (i = 0; i < file->file.nstmts; i++) {
         n = file->file.stmts[i];
         switch (n->type) {
@@ -1387,6 +1392,7 @@
                 break;
         }
     }
+    popstab();
 
     fd = fopen(out, "w");
     if (!fd)