Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:rakudo/rakudo
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed May 14, 2009
2 parents c223b06 + fe54884 commit f7dbcce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
23 changes: 19 additions & 4 deletions src/builtins/guts.pir
Expand Up @@ -1046,19 +1046,34 @@ Sets the type constraint on the container.
.sub '!sub_trait'
.param pmc block
.param string type
.param string trait
.param string trait # XXX Eventually should not be name
.param pmc arg :optional
.param int has_arg :opt_flag

if has_arg goto have_arg
null arg
have_arg:

# XXX For now, handle special case traits.
$S0 = concat '!sub_trait_', trait
$P0 = find_name $S0
if null $P0 goto done
$P0(trait, block, arg)
done:
if null $P0 goto not_special
.tailcall $P0(trait, block, arg)
not_special:

# Look up the trait and dispatch.
$P0 = get_hll_global trait
if null $P0 goto err
$P1 = get_hll_global type
if has_arg goto with_arg
.tailcall $P1($P0, block)
with_arg:
.tailcall $P1($P0, block, arg)

err:
# XXX For now, until we hunt down all uses of non-existent traits, just
# warn.
'warn'('Use of non-existent trait.')
.end


Expand Down
32 changes: 17 additions & 15 deletions src/parser/actions.pm
Expand Up @@ -3104,21 +3104,23 @@ sub make_sigparam($var) {
sub add_optoken($block, $match) {
my $category := ~$match<category>;
my $name := $category ~ ':' ~ ~$match[0];
my $equiv := 'infix:+';
if $category eq 'prefix' { $equiv := 'prefix:+' }
elsif $category eq 'postfix' { $equiv := 'postfix:++' }
my $past := PAST::Op.new( :name('newtok'), :pasttype('callmethod'),
PAST::Op.new(
:inline(" %r = get_hll_global ['Perl6';'Grammar'], '$optable'")
),
$name,
PAST::Val.new( :value($equiv), :named('equiv') ),
);
my $sub := PAST::Compiler.compile(
PAST::Block.new( $past, :hll($?RAKUDO_HLL), :blocktype('declaration') )
);
$sub();
$block.loadinit().push($past);
if $category ne 'trait_auxiliary' {
my $equiv := 'infix:+';
if $category eq 'prefix' { $equiv := 'prefix:+' }
elsif $category eq 'postfix' { $equiv := 'postfix:++' }
my $past := PAST::Op.new( :name('newtok'), :pasttype('callmethod'),
PAST::Op.new(
:inline(" %r = get_hll_global ['Perl6';'Grammar'], '$optable'")
),
$name,
PAST::Val.new( :value($equiv), :named('equiv') ),
);
my $sub := PAST::Compiler.compile(
PAST::Block.new( $past, :hll($?RAKUDO_HLL), :blocktype('declaration') )
);
$sub();
$block.loadinit().push($past);
}
$name;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/grammar.pg
Expand Up @@ -873,7 +873,7 @@ token subshortname {
<category> <colonpair>+
}

token category { 'infix' | 'prefix' | 'postfix' }
token category { 'infix' | 'prefix' | 'postfix' | 'trait_auxiliary' }

## used internally to convert p6 opnames to internal ones
regex opname {
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Expand Up @@ -225,6 +225,7 @@ S06-multi/lexical-multis.t
S06-multi/proto.t
S06-multi/syntax.t
S06-multi/type-based.t
S06-operator-overloading/imported-subs.t
S06-operator-overloading/sub.t
S06-other/main.t
S06-other/main-eval.t
Expand Down

0 comments on commit f7dbcce

Please sign in to comment.