File tree Expand file tree Collapse file tree 3 files changed +30
-16
lines changed Expand file tree Collapse file tree 3 files changed +30
-16
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,27 @@ role QAST::Children {
31
31
}
32
32
}
33
33
34
+ method extra_children () {
35
+ [];
36
+ }
37
+
34
38
method dump_children (int $ indent , @ onto ) {
35
- self . dump_node_list($ indent , @ onto , @ ! children );
39
+ my $ extra := 0 ;
40
+ for self . extra_children -> $ tag , $ nodes {
41
+ if $ nodes {
42
+ nqp :: push (@ onto , nqp ::x (' ' , $ indent ));
43
+ nqp :: push (@ onto , " [" ~ $ tag ~ " ]" );
44
+ nqp :: push (@ onto , " \n " );
45
+ self . dump_node_list($ indent + 2, @ onto , $ nodes );
46
+ }
47
+ $ extra := $ extra + nqp :: elems ($ nodes );
48
+ }
49
+
50
+ if $ extra && @ ! children {
51
+ nqp :: push (@ onto , nqp ::x (' ' , $ indent ) ~ " [children]\n " );
52
+ self . dump_node_list($ indent + 2, @ onto , @ ! children );
53
+ } else {
54
+ self . dump_node_list($ indent , @ onto , @ ! children );
55
+ }
36
56
}
37
57
}
Original file line number Diff line number Diff line change @@ -59,20 +59,10 @@ class QAST::CompUnit is QAST::Node does QAST::Children {
59
59
$ ! code_ref_blocks := $ value unless $ value =:= NO_VALUE; $ ! code_ref_blocks
60
60
}
61
61
62
- method dump_children (int $ indent , @ onto ) {
63
- if self . pre_deserialize {
64
- nqp :: push (@ onto , nqp ::x (' ' , $ indent ) ~ " [pre deserialize]\n " );
65
- self . dump_node_list($ indent , @ onto , self . pre_deserialize);
66
- }
67
-
68
- if self . post_deserialize {
69
- nqp :: push (@ onto , nqp ::x (' ' , $ indent ) ~ " [post deserialize]\n " );
70
- self . dump_node_list($ indent , @ onto , self . post_deserialize);
71
- }
72
-
73
- if self . pre_deserialize || self . post_deserialize {
74
- nqp :: push (@ onto , nqp ::x (' ' , $ indent ) ~ " [children]\n " )
75
- }
76
- self . dump_node_list($ indent , @ onto , self . list);
62
+ method extra_children () {
63
+ [
64
+ ' pre_deserialize' , self . pre_deserialize,
65
+ ' post_deserialize' , self . post_deserialize
66
+ ];
77
67
}
78
68
}
Original file line number Diff line number Diff line change 1
1
class QAST::VarWithFallback is QAST ::Var {
2
2
has $ ! fallback ;
3
3
method fallback ($ value = NO_VALUE) { $ ! fallback := $ value unless $ value =:= NO_VALUE; $ ! fallback }
4
+
5
+ method extra_children () {
6
+ $ ! fallback ?? [' fallback' , [$ ! fallback ]] !! [];
7
+ }
4
8
}
You can’t perform that action at this time.
0 commit comments