Permalink
Browse files

intermediate code for debugging

For some reason, this hangs inside src/QAST/Unquote.nqp
  • Loading branch information...
1 parent 1f54496 commit 1be56d43bb5301c661569aa819cfc55f8de0b452 @masak masak committed Aug 18, 2012
Showing with 74 additions and 0 deletions.
  1. +4 −0 src/QAST/IVal.nqp
  2. +4 −0 src/QAST/Node.nqp
  3. +12 −0 src/QAST/Op.nqp
  4. +12 −0 src/QAST/Stmt.nqp
  5. +12 −0 src/QAST/Stmts.nqp
  6. +10 −0 src/QAST/Unquote.nqp
  7. +4 −0 src/QAST/Var.nqp
  8. +4 −0 src/QAST/WVal.nqp
  9. +12 −0 src/QAST/Want.nqp
View
@@ -1,4 +1,8 @@
class QAST::IVal is QAST::Node {
has int $!value;
method value(*@value) { $!value := @value[0] if @value; $!value }
+
+ method evaluate_unquotes(@unquotes) {
+ self
+ }
}
View
@@ -100,4 +100,8 @@ class QAST::Node {
(%uniques{$prefix} := 1);
$prefix ~ '_' ~ $id
}
+
+ method evaluate_unquotes(@unquotes) {
+ nqp::die(self.HOW.name(self) ~ " does not support evaluating unquotes");
+ }
}
View
@@ -6,4 +6,16 @@ class QAST::Op is QAST::Node {
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 evaluate_unquotes(@unquotes) {
+ say('op');
+ my $result := pir::repr_clone__PP(self);
+ my $i := 0;
+ my $elems := +@(self);
+ while $i < $elems {
+ $result[$i] := self[$i].evaluate_unquotes(@unquotes);
+ $i := $i + 1;
+ }
+ $result
+ }
}
View
@@ -2,4 +2,16 @@ class QAST::Stmt is QAST::Node {
has $!resultchild;
method resultchild(*@value) { $!resultchild := @value[0] if @value; $!resultchild }
+
+ method evaluate_unquotes(@unquotes) {
+ say('stmt');
+ my $result := pir::repr_clone__PP(self);
+ my $i := 0;
+ my $elems := +@(self);
+ while $i < $elems {
+ $result[$i] := self[$i].evaluate_unquotes(@unquotes);
+ $i := $i + 1;
+ }
+ $result
+ }
}
View
@@ -2,4 +2,16 @@ class QAST::Stmts is QAST::Node {
has $!resultchild;
method resultchild(*@value) { $!resultchild := @value[0] if @value; $!resultchild }
+
+ method evaluate_unquotes(@unquotes) {
+ say('stmts');
+ my $result := pir::repr_clone__PP(self);
+ my $i := 0;
+ my $elems := +@(self);
+ while $i < $elems {
+ $result[$i] := self[$i].evaluate_unquotes(@unquotes);
+ $i := $i + 1;
+ }
+ $result
+ }
}
View
@@ -1,2 +1,12 @@
class QAST::Unquote is QAST::Node {
+ has int $!position;
+
+ method position(*@value) {
+ @value ?? ($!position := @value[0]) !! $!position
+ }
+
+ method evaluate_unquotes(@unquotes) {
+ say('unquote');
+ @unquotes[$!position];
+ }
}
View
@@ -10,4 +10,8 @@ class QAST::Var is QAST::Node {
method decl(*@value) { $!decl := @value[0] if @value; $!decl }
method slurpy(*@value) { $!slurpy := @value[0] if @value; $!slurpy }
method default(*@value) { $!default := @value[0] if @value; $!default }
+
+ method evaluate_unquotes(@unquotes) {
+ self
+ }
}
View
@@ -4,4 +4,8 @@ class QAST::WVal is QAST::Node does QAST::CompileTimeValue {
?? self.set_compile_time_value(@value[0])
!! self.compile_time_value()
}
+
+ method evaluate_unquotes(@unquotes) {
+ self
+ }
}
View
@@ -8,4 +8,16 @@ class QAST::Want is QAST::Node {
method compile_time_value() {
self[0].compile_time_value()
}
+
+ method evaluate_unquotes(@unquotes) {
+ say('want');
+ my $result := pir::repr_clone__PP(self);
+ my $i := 0;
+ my $elems := +@(self);
+ while $i < $elems {
+ $result[$i] := self[$i].evaluate_unquotes(@unquotes);
+ $i := $i + 2;
+ }
+ $result
+ }
}

0 comments on commit 1be56d4

Please sign in to comment.