aboutsummaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/scope.c b/scope.c
index d09f1b4..379be97 100644
--- a/scope.c
+++ b/scope.c
@@ -56,26 +56,29 @@ char* s;
return h % HASH_SIZE;
}
-scope* push_scope(root)
-scope *root;
+void push_scope(root)
+scope **root;
{
- scope *p = mkscope();
- p->next = root;
- return p;
+ scope *tmp = mkscope();
+
+ assert(tmp);
+
+ tmp->prev = *root;
+ *root = tmp;
}
-scope* pop_scope(root)
-scope *root;
+void pop_scope(root)
+scope **root;
{
- scope *p;
+ scope *tmp;
- if (!root)
- return NULL;
+ if (!*root)
+ return;
- p = root->next;
+ tmp = *root;
+ *root = (*root)->prev;
- free_scope(root);
- return p;
+ free_scope(tmp);
}
node* scope_insert(root, name)
@@ -105,7 +108,7 @@ char *name;
scope *p;
node *tmp;
- for (p = root; p; p = p->next)
+ for (p = root; p; p = p->prev)
if (tmp = scope_search(p, name))
return tmp;
@@ -119,10 +122,10 @@ char *name;
scope *p;
node *tmp;
- for (p = root; p; p = p->next) {
+ for (p = root; p; p = p->prev) {
if (tmp = scope_search(p, name))
return tmp;
- if (p->function_boundry)
+ if (p->ret_var)
return NULL;
}