aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-08-04 11:52:30 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-08-04 11:56:45 -0400
commit89fca11404f818b1ece0abb03b42acbcb1f3a280 (patch)
tree3281d866e3484270adc9a7646717773712a5b5bd
parent9c6c1af62993bdb2474ddde4384215f95fede85f (diff)
Fix tree print with variable types
-rw-r--r--tree.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tree.c b/tree.c
index 8a2c3bf..e0216fd 100644
--- a/tree.c
+++ b/tree.c
@@ -27,7 +27,7 @@ ptree* mkid(n)
node *n;
{
ptree *p = mktree(ID, NULL, NULL);
- p->attr.nval = n; /* memory leak? double strdup*/
+ p->attr.nval = n;
return p;
}
@@ -70,7 +70,8 @@ ptree *list;
list = list->l;
continue; /*Continue down list*/
} else if (list->l->type == ID)
- /*Set type of first declared ID (only left node in LIST)*/
+ /*Set type of first declared ID
+ (only left node in LIST)*/
list->l->attr.nval->var_type = type;
}
return; /*At _end_ of list (did not continue)*/
@@ -120,7 +121,16 @@ int spaces;
fprintf(stderr, "[LIST]");
break;
case ID:
- fprintf(stderr, "[ID: %s %d]", t->attr.nval->name, t->attr.nval->var_type);
+ if (t->r && t->r->attr.nval)
+ fprintf(stderr, "[ID: %s %s]",
+ t->r->attr.nval->name,
+ pretty_type(
+ t->attr.nval->var_type));
+ else
+ fprintf(stderr, "[ID: %s %s]",
+ t->attr.nval->name,
+ pretty_type(
+ t->attr.nval->var_type));
break;
case INUM:
fprintf(stderr, "[INUM: %d]", t->attr.ival);