Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'metanot'
  • Loading branch information
colomon committed Mar 7, 2010
2 parents 9a94503 + df80392 commit 19c36a8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -1686,6 +1686,16 @@ method infixish($/) {
}
make PAST::Op.new( :name($opsub), :pasttype('call') );
}

if $<infix_prefix_meta_operator> {
my $metaop := ~$<infix_prefix_meta_operator><sym>;
my $sym := ~$<infix><sym>;
my $metasub := "&infix_prefix_meta_operator:<$metaop>";
my $opsub := "&infix:<$sym>";
make PAST::Op.new( :name($metasub),
$opsub,
:pasttype('call') );
}
}

method postfixish($/) {
Expand Down
5 changes: 5 additions & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -981,6 +981,7 @@ INIT {
token infixish {
| <OPER=infix> <![=]>
| <infix> <OPER=infix_postfix_meta_operator>
| <OPER=infix_prefix_meta_operator> <infix>
}

token postfixish {
Expand All @@ -1005,6 +1006,8 @@ token postop {

proto token infix_postfix_meta_operator { <...> }

proto token infix_prefix_meta_operator { <...> }

proto token postfix_prefix_meta_operator { <...> }

token postfix_prefix_meta_operator:sym<»> {
Expand Down Expand Up @@ -1157,6 +1160,8 @@ token infix:sym<?? !!> {
<O('%conditional, :reducecheck<ternary>, :pasttype<if>')>
}

token infix_prefix_meta_operator:sym<!> { <sym> <O('%item_assignment')> }

token infix:sym<:=> {
<sym> <O('%item_assignment, :reducecheck<bindish_check>')>
}
Expand Down
27 changes: 27 additions & 0 deletions src/builtins/assign.pir
Expand Up @@ -89,6 +89,33 @@ src/builtins/assign.pir - assignment operations
.tailcall '&infix:<=>'(a, $P1)
.end

.sub '!gen_not_metaop'
.param string sym
.local string opname, metaname
$S0 = concat sym, '>'
opname = concat '&infix:<', $S0
metaname = concat '&infix:<!', $S0
$P0 = get_global metaname
unless null $P0 goto done
$P1 = box opname
.lex '$opname', $P1
.const 'Sub' metasub = '!not_metaop'
$P0 = newclosure metasub
set_global metaname, $P0
done:
.end

# XXX -- we might want this to be a Perl6MultiSub
.sub '!not_metaop' :anon :outer('!gen_not_metaop')
.param pmc a
.param pmc b
$P0 = find_lex '$opname'
$S0 = $P0
$P0 = get_global $S0
$P1 = $P0(a, b)
.tailcall '&prefix:<!>'($P1)
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down
4 changes: 4 additions & 0 deletions src/core/operators.pm
Expand Up @@ -328,3 +328,7 @@ our multi sub infix:<Z>(Iterable $a-iterable, Iterable $b-iterable) {
take $b;
}
}

multi sub infix_prefix_meta_operator:<!>($a, $b, $c) {
!(pir::get_hll_global__CS($a)($b, $c));
}
3 changes: 0 additions & 3 deletions src/old/setting/Operators.pm
Expand Up @@ -369,7 +369,4 @@ multi sub infix:<< >= >>($a, Whatever $b) {
}
}

multi sub infix:<!===>($a, $b) {
!($a === $b);
}
# vim: ft=perl6

0 comments on commit 19c36a8

Please sign in to comment.