Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make --target=ast dump pre_deserialize and post_deserialize code for …
…CompUnits.
  • Loading branch information
pmurias committed Oct 23, 2015
1 parent 88ef425 commit 78a6682
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/QAST/Children.nqp
Expand Up @@ -17,8 +17,8 @@ role QAST::Children {
@!children := @children;
}

method dump_children(int $indent, @onto) {
for @!children {
method dump_node_list(int $indent, @onto, @node_list) {
for @node_list {
if nqp::istype($_, QAST::Node) {
nqp::push(@onto, $_.dump($indent));
}
Expand All @@ -30,4 +30,8 @@ role QAST::Children {
}
}
}

method dump_children(int $indent, @onto) {
self.dump_node_list($indent, @onto, @!children);
}
}
17 changes: 17 additions & 0 deletions src/QAST/CompUnit.nqp
Expand Up @@ -58,4 +58,21 @@ class QAST::CompUnit is QAST::Node does QAST::Children {
method code_ref_blocks($value = NO_VALUE) {
$!code_ref_blocks := $value unless $value =:= NO_VALUE; $!code_ref_blocks
}

method dump_children(int $indent, @onto) {
if self.pre_deserialize {
nqp::push(@onto, nqp::x(' ', $indent) ~ "[pre deserialize]\n");
self.dump_node_list($indent, @onto, self.pre_deserialize);
}

if self.post_deserialize {
nqp::push(@onto, nqp::x(' ', $indent) ~ "[post deserialize]\n");
self.dump_node_list($indent, @onto, self.post_deserialize);
}

if self.pre_deserialize || self.post_deserialize {
nqp::push(@onto, nqp::x(' ', $indent) ~ "[children]\n")
}
self.dump_node_list($indent, @onto, self.list);
}
}

0 comments on commit 78a6682

Please sign in to comment.