summaryrefslogtreecommitdiff
path: root/parse/dump.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2019-02-26 14:07:58 -0800
committerOri Bernstein <ori@markovcorp.com>2019-02-26 14:07:58 -0800
commitd87c0959d85b40fcf60b9c6dd0a2f2111f888b55 (patch)
tree3d9ee97668eda3d4e2656ac069f8575250edc7e2 /parse/dump.c
parent02201160614e5f25a7a73d86ed26a1f90fa4f5bb (diff)
downloadmc-d87c0959d85b40fcf60b9c6dd0a2f2111f888b55.tar.gz
Accept that `file` isn't a node.
Shrink node sizes, simplify code a bit.
Diffstat (limited to 'parse/dump.c')
-rw-r--r--parse/dump.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/parse/dump.c b/parse/dump.c
index c24ac0f..fbcbefe 100644
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -134,18 +134,18 @@ dumpenv(Tyenv *e, FILE *fd)
}
void
-dumpfilestabs(Node *file, int depth, FILE *fd)
+dumpfilestabs(int depth, FILE *fd)
{
size_t nk, i;
void **k;
- k = htkeys(file->file.ns, &nk);
- for (i = 0; i < nk; i++) {
- outstab(htget(file->file.ns, k[i]), fd, depth);
- }
+ k = htkeys(file.ns, &nk);
+ for (i = 0; i < nk; i++)
+ outstab(htget(file.ns, k[i]), fd, depth);
free(k);
}
+
/* Outputs a node in indented tree form. This i
* not a full serialization, but mainly an aid for
* understanding and debugging. */
@@ -164,14 +164,6 @@ outnode(Node *n, FILE *fd, int depth)
}
findentf(fd, depth, "%s.%zd@%i", nodestr[n->type], n->nid, lnum(n->loc));
switch (n->type) {
- case Nfile:
- fprintf(fd, "(name = %s)\n", n->file.files[0]);
- dumpfilestabs(file, depth + 1, fd);
- for (i = 0; i < n->file.nuses; i++)
- outnode(n->file.uses[i], fd, depth + 1);
- for (i = 0; i < n->file.nstmts; i++)
- outnode(n->file.stmts[i], fd, depth + 1);
- break;
case Ndecl:
tr = "";
if (n->decl.trait)
@@ -290,7 +282,20 @@ outnode(Node *n, FILE *fd, int depth)
}
void
-dump(Node *n, FILE *fd) { outnode(n, fd, 0); }
+dump(FILE *fd)
+{
+ size_t i;
+
+ fprintf(fd, "(name = %s)\n", file.files[0]);
+ dumpfilestabs(1, fd);
+ for (i = 0; i < file.nuses; i++)
+ outnode(file.uses[i], fd, 1);
+ for (i = 0; i < file.nstmts; i++)
+ outnode(file.stmts[i], fd, 1);
+}
void
-dumpn(Node *n) { dump(n, stdout); }
+dumpn(Node *n, FILE *fd) {
+ outnode(n, fd, 0);
+}
+