Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make passes dependency-aware.

  • Loading branch information...
commit 826af57fefa9537c5ab591082620a296c4e4fb60 1 parent fd9186d
tcurtis authored
Showing with 13 additions and 12 deletions.
  1. +2 −11 src/Tree/Optimizer.nqp
  2. +11 −1 src/Tree/Optimizer/Pass.nqp
View
13 src/Tree/Optimizer.nqp
@@ -35,17 +35,8 @@ method find-pass ($name) {
method register ($transformation, *%adverbs) {
my $pass := Tree::Optimizer::Pass.new($transformation, |%adverbs);
%!passes{$pass.name} := $pass;
- my $depends-on := %adverbs<depends-on>;
- if $depends-on {
- my @dependencies;
- if pir::isa__IPP($depends-on, String) {
- @dependencies := pir::split__PSS(' ', $depends-on);
- } else {
- @dependencies := $depends-on;
- }
- for @dependencies -> $dependency {
- self.add-dependency($pass.name, $dependency);
- }
+ for $pass.dependencies -> $dependency {
+ self.add-dependency($pass.name, $dependency);
}
}
View
12 src/Tree/Optimizer/Pass.nqp
@@ -1,10 +1,14 @@
class Tree::Optimizer::Pass;
+has @!dependencies;
has $!name;
has $!recursive;
has $!transformation;
has $!when;
+our multi method dependencies () { @!dependencies; }
+our multi method dependencies (@deps) { @!dependencies := @deps; }
+
our multi method name () { $!name; }
our multi method name ($name) { $!name := $name; }
@@ -29,11 +33,17 @@ my $current-gen-name := 0;
sub gen-name () {
'__unnamed_' ~ $current-gen-name++;
}
-method BUILD (:$transformation, :$name, :$recursive, :$when, *%ignored) {
+method BUILD (:$transformation, :$name, :$recursive, :$when, *%rest) {
$!name := $name || gen-name();
$!recursive := $recursive || 0;
$!transformation := $transformation;
$!when := $when;
+ my $depends-on := %rest<depends-on>;
+ if $depends-on {
+ @!dependencies := (pir::isa__IPP($depends-on, String)
+ ?? [ $depends-on ]
+ !! $depends-on);
+ }
}
method run ($tree) {
Please sign in to comment.
Something went wrong with that request. Please try again.