Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

export trait for constants

  • Loading branch information...
commit bb9d84b4d6327aff6aeeec2d4f39a807809cf75d 1 parent 962b9b1
Moritz Lenz authored September 04, 2012
9  src/Perl6/Actions.pm
@@ -2704,6 +2704,11 @@ class Perl6::Actions is HLL::Actions {
2704 2704
             $*W.install_package($/, [$name], ($*SCOPE || 'our'),
2705 2705
                 'constant', $*PACKAGE, $*W.cur_lexpad(), $value);
2706 2706
         }
  2707
+        $*W.ex-handle($/, {
  2708
+            for $<trait> -> $t {
  2709
+                ($t.ast)($value, :SYMBOL($name));
  2710
+            }
  2711
+        });
2707 2712
 
2708 2713
         # Evaluate to the constant.
2709 2714
         make QAST::WVal.new( :value($value) );
@@ -3153,8 +3158,8 @@ class Perl6::Actions is HLL::Actions {
3153 3158
                 my %arg;
3154 3159
                 %arg{~$<longname>} := @trait_arg ?? @trait_arg[0] !!
3155 3160
                     $*W.find_symbol(['Bool', 'True']);
3156  
-                make -> $declarand {
3157  
-                    $*W.apply_trait($/, '&trait_mod:<is>', $declarand, |%arg);
  3161
+                make -> $declarand, *%additional {
  3162
+                    $*W.apply_trait($/, '&trait_mod:<is>', $declarand, |%arg, |%additional);
3158 3163
                 };
3159 3164
             }
3160 3165
         }
7  src/core/traits.pm
@@ -124,6 +124,13 @@ multi trait_mod:<is>(Mu:U \type, :$export!) {
124 124
                        'DEFAULT');
125 125
     EXPORT_SYMBOL($exp_name, @tags, type);
126 126
 }
  127
+# for constants
  128
+multi trait_mod:<is>(Mu \sym, :$export!, :$SYMBOL!) {
  129
+    my @tags = 'ALL', ($export ~~ Pair ?? $export.key !!
  130
+                    $export ~~ Positional ?? @($export)>>.key !!
  131
+                    'DEFAULT');
  132
+    EXPORT_SYMBOL($SYMBOL, @tags, sym);
  133
+}
127 134
 
128 135
 multi trait_mod:<is>(Mu:D $docee, :$docs!) {
129 136
     $docee does role {

0 notes on commit bb9d84b

Please sign in to comment.
Something went wrong with that request. Please try again.