Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some tweaks to handle has &!foo and has &.foo. Resolves RT#64650 and …
…RT#64270.
  • Loading branch information
jnthn committed May 20, 2009
1 parent 60f709d commit ba0b2be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/builtins/guts.pir
Expand Up @@ -802,15 +802,21 @@ and C<type>.
.param int has_itype :opt_flag
.param pmc attr :slurpy :named

# twigil handling
# twigil handling (for has &!foo, we just get name as !foo)
.local int offset
.local string twigil
twigil = substr name, 1, 1
offset = 1
$S0 = substr name, 0, 1
if $S0 != '!' goto offset_done
offset = 0
offset_done:
twigil = substr name, offset, 1
if twigil == '.' goto twigil_public
if twigil == '!' goto twigil_done
substr name, 1, 0, '!'
substr name, offset, 0, '!'
goto twigil_done
twigil_public:
substr name, 1, 1, '!'
substr name, offset, 1, '!'
twigil_done:

$P0 = metaclass.'attributes'()
Expand Down
8 changes: 6 additions & 2 deletions src/parser/actions.pm
Expand Up @@ -1654,7 +1654,11 @@ method scope_declarator($/) {
# accessor method for it in the block (class/grammar/role)
if $var<twigil> eq '.' {
my $method := PAST::Block.new( :blocktype('method') );
$method.name( substr($var.name(), 2) );
if $var<sigil> eq '&' {
$method.name( substr($var.name(), 1) );
} else {
$method.name( substr($var.name(), 2) );
}
my $value := PAST::Var.new( :name($var.name()) );
my $readtype := trait_readtype( $var<traitlist> ) || 'readonly';
if $readtype eq 'CONFLICT' {
Expand Down Expand Up @@ -1977,7 +1981,7 @@ method variable($/, $key) {
}

$var := PAST::Var.new( :name($varname), :node($/) );
$var<sigil> := $sigil;
$var<sigil> := ~$<sigil>;
if $twigil { $var<twigil> := $twigil; }

# If namespace qualified or has a '*' twigil, it's a package var.
Expand Down

0 comments on commit ba0b2be

Please sign in to comment.