Skip to content

Commit

Permalink
[pmc2c] support RETURN(PMC* const ...) and (INTVAL pos>>32)
Browse files Browse the repository at this point in the history
const is no variable name.
allow full expressions as return value, not just names.

just skip ptr dereferences /^\**/. Note that the * return syntax is flawed,
as we should support both cases, return *ptr; and return ptr;
But we get away with it as we return only return (decl)*ptr and return (decl*)ptr;
  • Loading branch information
Reini Urban committed Jun 9, 2014
1 parent f1a375c commit 1265f5d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Parrot/Pmc2c/PCCMETHOD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sub rewrite_RETURNs {
my $signature_re = qr/
(RETURN #method name
\s* #optional whitespace
\( ([^\(]*) \) #returns ( stuff ... )
\( ([^\(]*) \) #returns ( type... var)
;?) #optional semicolon
/sx;

Expand Down Expand Up @@ -227,6 +227,7 @@ END
return $result;
}

# This doesn't handle "const PMC *var", but "PMC *const var"
sub parse_p_args_string {
my ($parameters) = @_;
my $linear_args = [];
Expand All @@ -241,12 +242,16 @@ sub parse_p_args_string {

my ( $type, $name, $rest ) = split /\s+/, trim($x), 3;

# 'PMC *const ret'
if ($rest and $rest !~ /^:/) { # handle const volatile or such
$type .= " ".$name;
($name, $rest) = split /\s+/, trim($rest), 2;
}

die "invalid PCC arg '$x': did you forget to specify a type?\n"
unless defined $name;

if ($name =~ /\**([a-zA-Z_]\w*)/) {
$name = $1;
}
$name =~ s/^\*//g;

my $arg = {
type => convert_type_string_to_reg_type($type),
Expand Down

0 comments on commit 1265f5d

Please sign in to comment.