Skip to content

Commit

Permalink
export trait for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Sep 9, 2012
1 parent 1374a97 commit f488677
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog
Expand Up @@ -5,6 +5,7 @@ New in 2012.09
+ support for indirect type names in routine and type declarations
+ compiler now built with QAST-based NQP, which generates better code, thus
making the compiler a little faster
+ support for "is export" traits on constants

New in 2012.08
+ tclc implemented
Expand Down
9 changes: 7 additions & 2 deletions src/Perl6/Actions.pm
Expand Up @@ -2697,6 +2697,11 @@ class Perl6::Actions is HLL::Actions {
$*W.install_package($/, [$name], ($*SCOPE || 'our'),
'constant', $*PACKAGE, $*W.cur_lexpad(), $value);
}
$*W.ex-handle($/, {
for $<trait> -> $t {
($t.ast)($value, :SYMBOL($name));
}
});

# Evaluate to the constant.
make QAST::WVal.new( :value($value) );
Expand Down Expand Up @@ -3146,8 +3151,8 @@ class Perl6::Actions is HLL::Actions {
my %arg;
%arg{~$<longname>} := @trait_arg ?? @trait_arg[0] !!
$*W.find_symbol(['Bool', 'True']);
make -> $declarand {
$*W.apply_trait($/, '&trait_mod:<is>', $declarand, |%arg);
make -> $declarand, *%additional {
$*W.apply_trait($/, '&trait_mod:<is>', $declarand, |%arg, |%additional);
};
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/core/traits.pm
Expand Up @@ -124,6 +124,13 @@ multi trait_mod:<is>(Mu:U \type, :$export!) {
'DEFAULT');
EXPORT_SYMBOL($exp_name, @tags, type);
}
# for constants
multi trait_mod:<is>(Mu \sym, :$export!, :$SYMBOL!) {
my @tags = 'ALL', ($export ~~ Pair ?? $export.key !!
$export ~~ Positional ?? @($export)>>.key !!
'DEFAULT');
EXPORT_SYMBOL($SYMBOL, @tags, sym);
}

multi trait_mod:<is>(Mu:D $docee, :$docs!) {
$docee does role {
Expand Down

0 comments on commit f488677

Please sign in to comment.