aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-08-04 11:51:56 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-08-04 11:51:56 -0400
commit081f3735abf4add6dbbd6ba4ca56da10bd54139e (patch)
treea85fdf47600b40f28ac706c610f58dcbc53cd722
parent9c6c1af62993bdb2474ddde4384215f95fede85f (diff)
Fix adding variable to scope during assignment
-rw-r--r--pc.y4
-rw-r--r--scope.c7
2 files changed, 8 insertions, 3 deletions
diff --git a/pc.y b/pc.y
index d63d8fc..54e4ede 100644
--- a/pc.y
+++ b/pc.y
@@ -260,12 +260,12 @@ TD: TO | DT;
var
:ID
{
- $$ = mkid(scope_insert(cur_scope,$1));
+ $$ = mkid(scope_safe_search_all(cur_scope,$1));
}
|ID '[' expr ']'
{
node* tmp;
- tmp = scope_insert(cur_scope, $1);
+ tmp = scope_safe_search_all(cur_scope, $1);
$$ = mktree(ARRAY_ACCESS, mkid(tmp), $3);
}
diff --git a/scope.c b/scope.c
index 6706765..eca78cd 100644
--- a/scope.c
+++ b/scope.c
@@ -138,9 +138,14 @@ scope *s;
{
int i;
node * tmp;
+
+ fprintf(stderr, "\n\nSCOPE\n"
+ "==========================================================\n");
+
for (i = 0; i < HASH_SIZE; i++) {
for( tmp=s->table[i]; tmp; tmp = tmp->next) {
- fprintf(stderr, "\t%s\n", tmp->name);
+ fprintf(stderr, "\t%s:%s\n", tmp->name,
+ pretty_type(tmp->var_type));
}
}
}