Skip to content

Commit

Permalink
Refactor determination of reduction type for base operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jun 27, 2012
1 parent ed46bdb commit 46dacb9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Perl6/Actions.pm
Expand Up @@ -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>;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 46dacb9

Please sign in to comment.