File tree Expand file tree Collapse file tree 9 files changed +74
-0
lines changed Expand file tree Collapse file tree 9 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1
1
class QAST::IVal is QAST ::Node {
2
2
has int $ ! value ;
3
3
method value (* @ value ) { $ ! value := @ value [0 ] if @ value ; $ ! value }
4
+
5
+ method evaluate_unquotes (@ unquotes ) {
6
+ self
7
+ }
4
8
}
Original file line number Diff line number Diff line change @@ -100,4 +100,8 @@ class QAST::Node {
100
100
(% uniques {$ prefix } := 1 );
101
101
$ prefix ~ ' _' ~ $ id
102
102
}
103
+
104
+ method evaluate_unquotes (@ unquotes ) {
105
+ nqp ::die(self . HOW . name (self ) ~ " does not support evaluating unquotes" );
106
+ }
103
107
}
Original file line number Diff line number Diff line change @@ -6,4 +6,16 @@ class QAST::Op is QAST::Node {
6
6
method name (* @ value ) { $ ! name := @ value [0 ] if @ value ; $ ! name || " " }
7
7
method op (* @ value ) { $ ! op := @ value [0 ] if @ value ; $ ! op }
8
8
method childorder (* @ value ) { $ ! childorder := @ value [0 ] if @ value ; $ ! childorder || " " }
9
+
10
+ method evaluate_unquotes (@ unquotes ) {
11
+ say (' op' );
12
+ my $ result := pir::repr_clone__PP(self );
13
+ my $ i := 0 ;
14
+ my $ elems := + @ (self );
15
+ while $ i < $ elems {
16
+ $ result [$ i ] := self [$ i ]. evaluate_unquotes(@ unquotes );
17
+ $ i := $ i + 1 ;
18
+ }
19
+ $ result
20
+ }
9
21
}
Original file line number Diff line number Diff line change @@ -2,4 +2,16 @@ class QAST::Stmt is QAST::Node {
2
2
has $ ! resultchild ;
3
3
4
4
method resultchild (* @ value ) { $ ! resultchild := @ value [0 ] if @ value ; $ ! resultchild }
5
+
6
+ method evaluate_unquotes (@ unquotes ) {
7
+ say (' stmt' );
8
+ my $ result := pir::repr_clone__PP(self );
9
+ my $ i := 0 ;
10
+ my $ elems := + @ (self );
11
+ while $ i < $ elems {
12
+ $ result [$ i ] := self [$ i ]. evaluate_unquotes(@ unquotes );
13
+ $ i := $ i + 1 ;
14
+ }
15
+ $ result
16
+ }
5
17
}
Original file line number Diff line number Diff line change @@ -2,4 +2,16 @@ class QAST::Stmts is QAST::Node {
2
2
has $ ! resultchild ;
3
3
4
4
method resultchild (* @ value ) { $ ! resultchild := @ value [0 ] if @ value ; $ ! resultchild }
5
+
6
+ method evaluate_unquotes (@ unquotes ) {
7
+ say (' stmts' );
8
+ my $ result := pir::repr_clone__PP(self );
9
+ my $ i := 0 ;
10
+ my $ elems := + @ (self );
11
+ while $ i < $ elems {
12
+ $ result [$ i ] := self [$ i ]. evaluate_unquotes(@ unquotes );
13
+ $ i := $ i + 1 ;
14
+ }
15
+ $ result
16
+ }
5
17
}
Original file line number Diff line number Diff line change 1
1
class QAST::Unquote is QAST ::Node {
2
+ has int $ ! position ;
3
+
4
+ method position (* @ value ) {
5
+ @ value ?? ($ ! position := @ value [0 ]) !! $ ! position
6
+ }
7
+
8
+ method evaluate_unquotes (@ unquotes ) {
9
+ say (' unquote' );
10
+ @ unquotes [$ ! position ];
11
+ }
2
12
}
Original file line number Diff line number Diff line change @@ -10,4 +10,8 @@ class QAST::Var is QAST::Node {
10
10
method decl (* @ value ) { $ ! decl := @ value [0 ] if @ value ; $ ! decl }
11
11
method slurpy (* @ value ) { $ ! slurpy := @ value [0 ] if @ value ; $ ! slurpy }
12
12
method default (* @ value ) { $ ! default := @ value [0 ] if @ value ; $ ! default }
13
+
14
+ method evaluate_unquotes (@ unquotes ) {
15
+ self
16
+ }
13
17
}
Original file line number Diff line number Diff line change @@ -4,4 +4,8 @@ class QAST::WVal is QAST::Node does QAST::CompileTimeValue {
4
4
?? self . set_compile_time_value(@ value [0 ])
5
5
!! self . compile_time_value()
6
6
}
7
+
8
+ method evaluate_unquotes (@ unquotes ) {
9
+ self
10
+ }
7
11
}
Original file line number Diff line number Diff line change @@ -8,4 +8,16 @@ class QAST::Want is QAST::Node {
8
8
method compile_time_value () {
9
9
self [0 ]. compile_time_value()
10
10
}
11
+
12
+ method evaluate_unquotes (@ unquotes ) {
13
+ say (' want' );
14
+ my $ result := pir::repr_clone__PP(self );
15
+ my $ i := 0 ;
16
+ my $ elems := + @ (self );
17
+ while $ i < $ elems {
18
+ $ result [$ i ] := self [$ i ]. evaluate_unquotes(@ unquotes );
19
+ $ i := $ i + 2 ;
20
+ }
21
+ $ result
22
+ }
11
23
}
You can’t perform that action at this time.
0 commit comments