Permalink
Browse files

Refactor determination of reduction type for base operator.

  • Loading branch information...
1 parent ed46bdb commit 46dacb9537159b5562c020cdc1adf0d32fa381b1 @pmichaud pmichaud committed Jun 27, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/Perl6/Actions.pm
View
@@ -4074,6 +4074,15 @@ class Perl6::Actions is HLL::Actions {
}
}
+ sub baseop_reduce($/) {
+ my $reduce := 'left';
+ if $<assoc> eq 'right'
+ || $<assoc> eq 'list' { $reduce := $<assoc>; }
+ elsif $<prec> eq 'm=' { $reduce := 'chain'; }
+ elsif $<pasttype> eq 'xor' { $reduce := 'xor'; }
+ $reduce;
+ }
+
method infixish($/) {
if $<infix_postfix_meta_operator> {
my $base := $<infix>;
@@ -4124,11 +4133,7 @@ class Perl6::Actions is HLL::Actions {
?? $base.ast[0]
!! PAST::Var.new(:name("&infix:<" ~ $base<OPER><sym> ~ ">"),
:scope<lexical_6model>);
- my $metaop := '&METAOP_REDUCE_LEFT';
- if $base<OPER><O><assoc> eq 'right' { $metaop := '&METAOP_REDUCE_RIGHT' }
- elsif $base<OPER><O><assoc> eq 'list' { $metaop := '&METAOP_REDUCE_LIST' }
- elsif $base<OPER><O><prec> eq 'm=' { $metaop := '&METAOP_REDUCE_CHAIN' }
- elsif $base<OPER><O><pasttype> eq 'xor' { $metaop := '&METAOP_REDUCE_XOR' }
+ my $metaop := '&METAOP_REDUCE_' ~ nqp::uc(baseop_reduce($base<OPER><O>));
my $metapast := PAST::Op.new( :pasttype<call>, :name($metaop), $basepast);
if $<triangle> {
my $tri := $*W.add_constant('Int', 'int', 1);

0 comments on commit 46dacb9

Please sign in to comment.