Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
intermediate code for debugging
For some reason, this hangs inside src/QAST/Unquote.nqp
  • Loading branch information
Carl Masak committed Aug 18, 2012
1 parent 1f54496 commit 1be56d4
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/QAST/IVal.nqp
@@ -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
}
}
4 changes: 4 additions & 0 deletions src/QAST/Node.nqp
Expand Up @@ -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");
}
}
12 changes: 12 additions & 0 deletions src/QAST/Op.nqp
Expand Up @@ -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
}
}
12 changes: 12 additions & 0 deletions src/QAST/Stmt.nqp
Expand Up @@ -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
}
}
12 changes: 12 additions & 0 deletions src/QAST/Stmts.nqp
Expand Up @@ -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
}
}
10 changes: 10 additions & 0 deletions src/QAST/Unquote.nqp
@@ -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];
}
}
4 changes: 4 additions & 0 deletions src/QAST/Var.nqp
Expand Up @@ -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
}
}
4 changes: 4 additions & 0 deletions src/QAST/WVal.nqp
Expand Up @@ -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
}
}
12 changes: 12 additions & 0 deletions src/QAST/Want.nqp
Expand Up @@ -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.