Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement QAST::Node.unique.
  • Loading branch information
jnthn committed Jul 9, 2012
1 parent 2b6d5b7 commit 171f251
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/QAST/Node.nqp
Expand Up @@ -31,4 +31,12 @@ class QAST::Node is NQPCapture {
method push($value) { nqp::push(self.list, $value) }
method shift() { nqp::shift(self.list) }
method unshift($value) { nqp::unshift(self.list, $value) }

my %uniques;
method unique($prefix) {
my $id := nqp::existskey(%uniques, $prefix) ??
(%uniques{$prefix} := %uniques{$prefix} + 1) !!
(%uniques{$prefix} := 1);
$prefix ~ '_' ~ $id
}
}

0 comments on commit 171f251

Please sign in to comment.