Skip to content

Commit

Permalink
Easyfy matching Block WVals with their QAST::Blocks…
Browse files Browse the repository at this point in the history
…when looking through QAST dumps.

- Teach QAST::Node.dump to dump value for statement_id
- Teach QAST::WVal.dump_extra_node_info to rake for CUID
    from past_block annotation, if one's present
  • Loading branch information
zoffixznet committed Jan 24, 2018
1 parent 3ce6994 commit 0264b23
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
37 changes: 18 additions & 19 deletions src/QAST/Node.nqp
Expand Up @@ -155,26 +155,25 @@ class QAST::Node {
}

method dump_annotations() {
my @anns;
nqp::push(@anns, self.dump_flags);

my @anns;
nqp::push(@anns, self.dump_flags);
if nqp::ishash(%!annotations) {
for %!annotations {
my $k := $_.key;
my $v := $_.value;
try {
if nqp::isconcrete($v) {
if $k eq 'IN_DECL' || $k eq 'BY' {
nqp::push(@anns, ':' ~ $k ~ '<' ~ $v ~ '>');
}
else { # dunno how to introspect
nqp::push(@anns, ':' ~ $k ~ '<?>');
}
}
}
}
}
nqp::join(' ',@anns);
for %!annotations {
my $k := $_.key;
my $v := $_.value;
try {
if nqp::isconcrete($v) {
if $k eq 'IN_DECL' || $k eq 'BY' || $k eq 'statement_id' {
nqp::push(@anns, ':' ~ $k ~ '<' ~ $v ~ '>');
}
else { # dunno how to introspect
nqp::push(@anns, ':' ~ $k ~ '<?>');
}
}
}
}
}
nqp::join(' ',@anns);
}

method dump_children(int $indent, @onto) { }
Expand Down
9 changes: 7 additions & 2 deletions src/QAST/WVal.nqp
Expand Up @@ -24,8 +24,13 @@ class QAST::WVal is QAST::Node does QAST::CompileTimeValue {
}

method dump_extra_node_info() {
CATCH { return "?" }
CATCH { return "?" }
my $v := self.compile_time_value();
$v.HOW.name($v);
my $info := $v.HOW.name($v);
if self.ann('past_block') -> $qast {
$info := "$info :cuid("
~ nqp::ifnull(nqp::getattr($qast, QAST::Block, '$!cuid'), '?') ~ ")";
}
$info;
}
}

0 comments on commit 0264b23

Please sign in to comment.