Skip to content

Commit

Permalink
infix_prefix_meta_operator refactor!
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Mar 21, 2010
1 parent 2067a57 commit a61c40c
Showing 1 changed file with 18 additions and 42 deletions.
60 changes: 18 additions & 42 deletions src/Perl6/Actions.pm
Expand Up @@ -1945,50 +1945,26 @@ method infixish($/) {
$base_opsub := "&infix:<==>";
}
unless %*METAOPGEN{$opsub} {
my $helper := "";
if $metaop eq '!' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($opsub), :scope('package') ),
PAST::Op.new( :pasttype('callmethod'),
:name('assuming'),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
'&notresults' ),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$base_opsub ) ) ) );
}
if $metaop eq 'R' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($opsub), :scope('package') ),
PAST::Op.new( :pasttype('callmethod'),
:name('assuming'),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
'&reverseargs' ),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$base_opsub ) ) ) );
}
if $metaop eq 'X' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($opsub), :scope('package') ),
PAST::Op.new( :pasttype('callmethod'),
:name('assuming'),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
'&crosswith' ),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$base_opsub ) ) ) );
}
if $metaop eq 'Z' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($opsub), :scope('package') ),
PAST::Op.new( :pasttype('callmethod'),
:name('assuming'),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
'&zipwith' ),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$base_opsub ) ) ) );
$helper := '&notresults';
} elsif $metaop eq 'R' {
$helper := '&reverseargs';
} elsif $metaop eq 'X' {
$helper := '&crosswith';
} elsif $metaop eq 'Z' {
$helper := '&zipwith';
}

@BLOCK[0].loadinit.push(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($opsub), :scope('package') ),
PAST::Op.new( :pasttype('callmethod'),
:name('assuming'),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$helper ),
PAST::Op.new( :pirop('find_sub_not_null__Ps'),
$base_opsub ) ) ) );
%*METAOPGEN{$opsub} := 1;
}

Expand Down

0 comments on commit a61c40c

Please sign in to comment.