Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix wrong Parrot::Pmc2c::Method::decl
Failed when not in first line (s///m missing)
  • Loading branch information
Reini Urban committed Dec 12, 2012
1 parent cbe8900 commit f204cf8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Parrot/Pmc2c/Method.pm
Expand Up @@ -260,34 +260,34 @@ sub decl {
# SHIM UNUSED(arg) in body
my $body = $self->body;
my (%unused, $cnt);
if ($body->{data} and $body !~ /^\s*#if/m) {
while ($body->{data} =~ /^\s*UNUSED\((\w+)\)/m) {
if ($body->{data} and $body->{data} !~ /^\s*#if/m) {
while ($body->{data} =~ /^\s*UNUSED\((\w+)\);?\n/m) {
my $key = $1;
$cnt++;
if ($cnt > 6) {
warn "Internal Error: UNUSED($key) detection recursion in $pmcname METHOD $meth\n"
.$args."\n"
.$body."\n";
# This happens when the $body->{data} =~ s/// lines below do not remove the line
warn "Internal Error: UNUSED($key) detection recursion in $pmcname.$meth($args)\n"
.$body->{data}."\n";
last;
}
if ($key eq 'INTERP' or $key eq 'interp') {
$unused{INTERP}++;
$self->{interp_unused} = 1;
$body->{data} =~ s/^\s*UNUSED\($key\);?\n//;
$body->{data} =~ s/^\s*UNUSED\($key\);?\n//m;
warn "Replace UNUSED(interp) with UNUSED(INTERP) in $pmcname METHOD $meth\n"
if $key eq 'interp'
and $self->{parent_name} ne 'Null'
and $body->{data} !~ /^\s*$/;
} elsif ($body->{data} =~ /^\s*UNUSED\(SELF\)/m) {
$unused{SELF}++;
$self->{pmc_unused} = 1;
$body->{data} =~ s/^\s*UNUSED\(SELF\);?\n//;
$body->{data} =~ s/^\s*UNUSED\(SELF\);?\n//m;
} elsif ($args =~ s/, (\w+ \*?$key)/, SHIM($1)/) {
$unused{$key}++;
$body->{data} =~ s/^\s*UNUSED\($key\);?\n//;
$body->{data} =~ s/^\s*UNUSED\($key\);?\n//m;
$self->{parameters} =~ s/(\w+ \*?$key)/SHIM($1)/;
} else {
$body->{data} =~ s|^(\s*)UNUSED\($key\);?\n|$1/**/UNUSED\($key\)\n|;
$body->{data} =~ s|^(\s*)UNUSED\($key\);?\n|$1/**/UNUSED\($key\)\n|m;
$unused{$key}++;
warn "Did not SHIM UNUSED($key) in $pmcname METHOD $meth\n";
last;
Expand Down

0 comments on commit f204cf8

Please sign in to comment.