Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote branch 'upstream'
  • Loading branch information
unobe committed Mar 15, 2010
2 parents 46e211f + 79085cd commit 8826895
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 48 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -130,6 +130,7 @@ BUILTINS_PIR = \
src/builtins/Junction.pir \
src/builtins/Capture.pir \
src/builtins/assign.pir \
src/builtins/metaops.pir \
src/builtins/control.pir \

# Make sure parrot cheats are last in this list.
Expand Down
44 changes: 34 additions & 10 deletions src/Perl6/Actions.pm
Expand Up @@ -1385,12 +1385,18 @@ method param_var($/) {
}
}
else {
my $twigil := $<twigil> ?? ~$<twigil>[0] !! '';
$*PARAMETER.var_name(~$/);
if $<name> {
if @BLOCK[0].symbol(~$/) {
$/.CURSOR.panic("Redeclaration of symbol ", ~$/);
if $twigil eq '' {
if $<name> {
if @BLOCK[0].symbol(~$/) {
$/.CURSOR.panic("Redeclaration of symbol ", ~$/);
}
@BLOCK[0].symbol(~$/, :scope($*SCOPE eq 'my' ?? 'lexical' !! 'package'));
}
@BLOCK[0].symbol(~$/, :scope($*SCOPE eq 'my' ?? 'lexical' !! 'package'));
}
elsif $twigil ne '!' && $twigil ne '.' && $twigil ne '*' {
$/.CURSOR.panic("Illegal to use $twigil twigil in signature");
}
}
}
Expand Down Expand Up @@ -1617,6 +1623,11 @@ method methodop($/) {
elsif $<quote> {
$past.name( $<quote>.ast );
}
elsif $<variable> {
$past.unshift($<variable>.ast);
$past.name('!dispatch_variable');
$past.pasttype('call');
}
make $past;
}

Expand Down Expand Up @@ -1904,12 +1915,25 @@ method infixish($/) {

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') );
my $sym := ~$<infixish>;
my $opsub := "&infix:<$metaop$sym>";
unless %*METAOPGEN{$opsub} {
if $metaop eq '!' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :name('!gen_not_metaop'), $sym,
:pasttype('call') )
);
}
if $metaop eq 'R' {
@BLOCK[0].loadinit.push(
PAST::Op.new( :name('!gen_reverse_metaop'), $sym,
:pasttype('call') )
);
}

%*METAOPGEN{$opsub} := 1;
}
make PAST::Op.new( :name($opsub), :pasttype('call') );
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -1034,7 +1034,7 @@ INIT {
token infixish {
| <OPER=infix> <![=]>
| <infix> <OPER=infix_postfix_meta_operator>
| <OPER=infix_prefix_meta_operator> <infix>
| <OPER=infix_prefix_meta_operator> <infixish>
}

token postfixish {
Expand Down Expand Up @@ -1093,6 +1093,7 @@ token privop {
token methodop {
[
| <longname>
| <?before '$' | '@' | '&' > <variable>
| <?before <[ ' " ]> >
<quote>
[ <?before '(' | '.(' | '\\'> || <.panic: "Quoted method name requires parenthesized arguments"> ]
Expand Down Expand Up @@ -1215,6 +1216,10 @@ token infix:sym<?? !!> {

# item_assignment is probably wrong, but I don't know how to do what is right...
token infix_prefix_meta_operator:sym<!> { <sym> <O('%item_assignment')> }
token infix_prefix_meta_operator:sym<R> { <sym> <O('%item_assignment')> }
token infix_prefix_meta_operator:sym<S> { <sym> <O('%item_assignment')> }
token infix_prefix_meta_operator:sym<X> { <sym> <O('%item_assignment')> }
token infix_prefix_meta_operator:sym<Z> { <sym> <O('%item_assignment')> }

token infix:sym<:=> {
<sym> <O('%item_assignment, :reducecheck<bindish_check>')>
Expand Down Expand Up @@ -1246,6 +1251,7 @@ token prefix:sym<not> { <sym> >> <O('%loose_unary')> }
token infix:sym<,> { <sym> <O('%comma')> }

token infix:sym<Z> { <sym> <O('%list_infix')> }
token infix:sym<X> { <sym> <O('%list_infix')> }

token infix:sym<...> { <sym> <O('%list_infix')> }
# token term:sym<...> { <sym> <args>? <O(|%list_prefix)> }
Expand Down
27 changes: 0 additions & 27 deletions src/builtins/assign.pir
Expand Up @@ -89,33 +89,6 @@ 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
69 changes: 69 additions & 0 deletions src/builtins/metaops.pir
@@ -0,0 +1,69 @@
=head1 NAME

src/builtins/metaops.pir - meta-op operations

=head1 Functions

=over 2

=cut

.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

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

# XXX -- we might want this to be a Perl6MultiSub
.sub '!reverse_metaop' :anon :outer('!gen_reverse_metaop')
.param pmc a
.param pmc b
$P0 = find_lex '$opname'
$S0 = $P0
$P0 = get_global $S0
$P1 = $P0(b, a)
.return ($P1)
.end

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
14 changes: 8 additions & 6 deletions src/cheats/parrot/Protoobject.pir
Expand Up @@ -98,24 +98,26 @@ Return a clone of the protoobject with a new WHENCE property set.
.namespace ['P6protoobject']
.sub '' :vtable('get_bool') :method
.const 'Sub' $P1 = '!FAIL'
$P0 = $P1('Use of type object as value')
$I0 = istrue $P0
.return ($I0)
# .const 'Sub' $P1 = '!FAIL'
# I don't think boolean context should warn, no? --moritz
# $P0 = $P1('Use of type object as value in boolean context')
## $I0 = istrue $P0
# .return ($I0)
.return (0)
.end

.namespace ['P6protoobject']
.sub '' :vtable('get_integer') :method
.const 'Sub' $P1 = '!FAIL'
$P0 = $P1('Use of type object as value')
$P0 = $P1('Use of type object as value in integer context')
$I0 = $P0
.return ($I0)
.end

.namespace ['P6protoobject']
.sub '' :vtable('get_number') :method
.const 'Sub' $P1 = '!FAIL'
$P0 = $P1('Use of type object as value')
$P0 = $P1('Use of type object as value in numeric context')
$N0 = $P0
.return ($N0)
.end
Expand Down
19 changes: 17 additions & 2 deletions src/core/operators.pm
Expand Up @@ -444,10 +444,25 @@ our multi sub infix:<Z>(Iterable $a-iterable, Iterable $b-iterable) {
}
}

multi sub infix_prefix_meta_operator:<!>($a, $b, $c) {
!(pir::get_hll_global__CS($a)($b, $c));
our multi sub infix:<X>(Iterable $a-iterable, Iterable $b-iterable) {
my $ai = $a-iterable.iterator;
my @b = $b-iterable.Seq;
gather loop {
my $a = $ai.get;
last if ($a ~~ EMPTY);
for @b -> $b {
take ($a, $b);
}
}
}

# Eliminate use of this one, but keep the pir around for
# the moment, as it may come in handy elsewhere.
#
# multi sub infix_prefix_meta_operator:<!>($a, $b, $c) {
# !(pir::get_hll_global__CS($a)($b, $c));
# }

# CHEAT: These should be automatically generated by the grammar,
# I think. But this is a quick fix to get some basic functionality
# working.
Expand Down
15 changes: 15 additions & 0 deletions src/glue/dispatch.pir
Expand Up @@ -285,6 +285,21 @@ Helper for handling calls of the form .Foo::bar.
.end
=item !dispatch_variable
Helper for handling calls of the form .$indirectthingy()
=cut
.sub '!dispatch_variable'
.param pmc invocant
.param pmc to_call
.param pmc pos_args :slurpy
.param pmc named_args :slurpy :named
.tailcall to_call(invocant, pos_args :flat, named_args :flat :named)
.end
=item !deferal_fail
Used by P6invocation to help us get soft-failure semantics when no deferal
Expand Down
3 changes: 3 additions & 0 deletions src/old/setting/Operators.pm
Expand Up @@ -369,4 +369,7 @@ multi sub infix:<< >= >>($a, Whatever $b) {
}
}

multi sub infix:<!===>($a, $b) {
!($a === $b);
}
# vim: ft=perl6
6 changes: 4 additions & 2 deletions t/spectest.data
Expand Up @@ -111,7 +111,7 @@ S02-whitespace_and_comments/one-pass-parsing.t
S02-whitespace_and_comments/pod-in-multi-line-exprs.t
S02-whitespace_and_comments/sub-block-parsing.t
S02-whitespace_and_comments/unicode-whitespace.t
# S02-whitespace_and_comments/unspace.t
S02-whitespace_and_comments/unspace.t
S03-junctions/associative.t
S03-junctions/autothreading.t
S03-junctions/boolean-context.t
Expand Down Expand Up @@ -144,9 +144,11 @@ S03-operators/list-quote-junction.t
S03-operators/misc.t
S03-operators/names.t
S03-operators/not.t
S03-operators/not-metaop.t
S03-operators/numeric-context.t
# S03-operators/p5arrow.t
S03-operators/precedence.t
S03-operators/r-metaop.t
S03-operators/range-basic.t
S03-operators/range.t
# S03-operators/reduce-le1arg.t
Expand Down Expand Up @@ -293,7 +295,7 @@ S06-signature/arity.t
S06-signature/closure-parameters.t
S06-signature/code.t
S06-signature/defaults.t
# S06-signature/errors.t
S06-signature/errors.t
# S06-signature/introspection.t
S06-signature/mixed-placeholders.t
S06-signature/named-parameters.t
Expand Down

0 comments on commit 8826895

Please sign in to comment.