Skip to content

Commit 7da1bc7

Browse files
committed
ParseXS: refactor: always store kid nodes in kids
Some node types have fields to point to particular children. Make these kids also be in the generic @{$self->{kids}} array. That way, hypothetical generic tree-walking code will be able to access the whole tree just by following @{$self->{kids}}, without needing to know for example that the xsub_decl Node type has a child pointed to by $self->{return_type}.
1 parent 5d4af97 commit 7da1bc7

File tree

1 file changed

+3
-0
lines changed
  • dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS

1 file changed

+3
-0
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ sub parse {
294294
$self->{decl} = $decl;
295295
$decl->parse($pxs, $self)
296296
or return;
297+
push @{$self->{kids}}, $decl;
297298

298299
# Append a fake EOF-keyword line. This makes it easy to do "all lines
299300
# until the next keyword" style loops, since the fake END line (which
@@ -678,6 +679,7 @@ sub parse {
678679
or return;
679680

680681
$self->{return_type} = $return_type;
682+
push @{$self->{kids}}, $return_type;
681683

682684
# Decompose the function declaration: match a line like
683685
# Some::Class::foo_bar( args ) const ;
@@ -752,6 +754,7 @@ sub parse {
752754

753755
$params->parse($pxs, $xsub, $params_text);
754756
$self->{params} = $params;
757+
push @{$self->{kids}}, $params;
755758

756759
# How many OUTLIST SVs get returned in addition to RETVAL
757760
$xsub->{XSRETURN_count_extra} =

0 commit comments

Comments
 (0)