Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix $!foo params inside roles.
  • Loading branch information
jnthn committed Sep 8, 2013
1 parent f01be2c commit cdc323d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.nqp
Expand Up @@ -3371,8 +3371,8 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
}
elsif $twigil eq '!' {
%*PARAM_INFO<bind_attr> := 1;
%*PARAM_INFO<attr_package> := $*PACKAGE;
%*PARAM_INFO<bind_attr> := 1;
%*PARAM_INFO<attr_package> := $*W.find_symbol(['$?CLASS']);
}
elsif $twigil eq '.' {
%*PARAM_INFO<bind_accessor> := 1;
Expand Down
19 changes: 15 additions & 4 deletions src/Perl6/Metamodel/BOOTSTRAP.nqp
Expand Up @@ -434,18 +434,28 @@ BEGIN {
Parameter.HOW.add_attribute(Parameter, BOOTSTRAPATTR.new(:name<$!container_descriptor>, :type(Mu), :package(Parameter)));
Parameter.HOW.add_attribute(Parameter, BOOTSTRAPATTR.new(:name<$!attr_package>, :type(Mu), :package(Parameter)));
Parameter.HOW.add_method(Parameter, 'is_generic', nqp::getstaticcode(sub ($self) {
# If nonimnal type is generic, so are we.
# If nonimnal type or attr_package is generic, so are we.
my $type := nqp::getattr($self, Parameter, '$!nominal_type');
nqp::p6bool($type.HOW.archetypes.generic)
my $ap := nqp::getattr($self, Parameter, '$!attr_package');
nqp::p6bool($type.HOW.archetypes.generic ||
(!nqp::isnull($ap) && $ap.HOW.archetypes.generic))
}));
Parameter.HOW.add_method(Parameter, 'instantiate_generic', nqp::getstaticcode(sub ($self, $type_environment) {
# Clone with the type instantiated.
my $SIG_ELEM_NOMINAL_GENERIC := 524288;
my $ins := nqp::clone($self);
my $type := nqp::getattr($self, Parameter, '$!nominal_type');
my $cd := nqp::getattr($self, Parameter, '$!container_descriptor');
my $ins_type := $type.HOW.instantiate_generic($type, $type_environment);
my $ins_cd := nqp::isnull($cd) ?? $cd !! $cd.instantiate_generic($type_environment);
my $ap := nqp::getattr($self, Parameter, '$!attr_package');
my $ins_type := $type;
my $ins_cd := $cd;
if $type.HOW.archetypes.generic {
$ins_type := $type.HOW.instantiate_generic($type, $type_environment);
$ins_cd := nqp::isnull($cd) ?? $cd !! $cd.instantiate_generic($type_environment);
}
my $ins_ap := !nqp::isnull($ap) && $ap.HOW.archetypes.generic
?? $ap.HOW.instantiate_generic($ap, $type_environment)
!! $ap;
unless $ins_type.HOW.archetypes.generic {
my $flags := nqp::getattr_i($ins, Parameter, '$!flags');
if $flags +& $SIG_ELEM_NOMINAL_GENERIC {
Expand All @@ -455,6 +465,7 @@ BEGIN {
}
nqp::bindattr($ins, Parameter, '$!nominal_type', $ins_type);
nqp::bindattr($ins, Parameter, '$!container_descriptor', $ins_cd);
nqp::bindattr($ins, Parameter, '$!attr_package', $ins_ap);
$ins
}));
Parameter.HOW.add_method(Parameter, 'set_rw', nqp::getstaticcode(sub ($self) {
Expand Down

0 comments on commit cdc323d

Please sign in to comment.