/
Op.nqp
33 lines (29 loc) · 1003 Bytes
/
Op.nqp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class QAST::Op is QAST::Node {
has str $!name;
has str $!op;
has str $!childorder;
method name(*@value) { $!name := @value[0] if @value; $!name || "" }
method op(*@value) { $!op := @value[0] if @value; $!op }
method childorder(*@value) { $!childorder := @value[0] if @value; $!childorder || "" }
method substitute_inline_placeholders(@fillers) {
my $result := self.shallow_clone();
my $i := 0;
my $elems := +@(self);
while $i < $elems {
$result[$i] := self[$i].substitute_inline_placeholders(@fillers);
$i := $i + 1;
}
$result
}
method evaluate_unquotes(@unquotes) {
my $result := self.shallow_clone();
my $i := 0;
my $elems := +@(self);
while $i < $elems {
$result[$i] := self[$i].evaluate_unquotes(@unquotes);
$i := $i + 1;
}
$result
}
method dump_extra_node_info() { "$!op $!name"; }
}