From 97d95b0015fd5e31237bd677b14a6ae9cb2dc95d Mon Sep 17 00:00:00 2001 From: tcurtis Date: Sat, 31 Jul 2010 12:08:59 -0500 Subject: [PATCH] Pass the match result into the transformation for :when passes. --- src/Tree/Optimizer/Pass.nqp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Tree/Optimizer/Pass.nqp b/src/Tree/Optimizer/Pass.nqp index 3e6ddfd..db4677c 100644 --- a/src/Tree/Optimizer/Pass.nqp +++ b/src/Tree/Optimizer/Pass.nqp @@ -29,9 +29,14 @@ method BUILD (:$transformation, :$name, :$when, *%ignored) { } method run ($tree) { - if !pir::defined__IPP($!when) || $tree ~~ $!when { - $!transformation($tree); + if pir::defined__IPP($!when) { + my $/ := $tree ~~ $!when; + if $/ { + $!transformation($/); + } else { + $tree; + } } else { - $tree; + $!transformation($tree); } }