Permalink
Browse files

export trait for constants

  • Loading branch information...
1 parent 962b9b1 commit bb9d84b4d6327aff6aeeec2d4f39a807809cf75d @moritz moritz committed Sep 4, 2012
Showing with 14 additions and 2 deletions.
  1. +7 −2 src/Perl6/Actions.pm
  2. +7 −0 src/core/traits.pm
@@ -2704,6 +2704,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) );
@@ -3153,8 +3158,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);
};
}
}
View
@@ -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 {

0 comments on commit bb9d84b

Please sign in to comment.