Skip to content

Commit

Permalink
Don't emit variable declarations for placeholders.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 14, 2010
1 parent 6c97fe1 commit 4afd745
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/Perl6/Actions.pm
Expand Up @@ -848,7 +848,12 @@ method declarator($/) {
my $list := PAST::Op.new( :pasttype('call'), :name('&infix:<,>') );
my $decls := $<signature>.ast.get_declarations;
for @($decls) {
$list.push(declare_variable($/, $_, $_<sigil>, $_<twigil>, $_<desigilname>, $_<traits>));
if $_.isa(PAST::Var) {
$list.push(declare_variable($/, $_, $_<sigil>, $_<twigil>, $_<desigilname>, $_<traits>));
}
else {
$list.push($_);
}
}
$list<signature_from_declarator> := $<signature>.ast;
make $list;
Expand Down Expand Up @@ -2597,8 +2602,10 @@ sub add_signature($block, $sig_obj, $lazy) {
$block[0].push(PAST::Var.new( :name('call_sig'), :scope('parameter'), :call_sig(1) ));
my $decls := $sig_obj.get_declarations();
for @($decls) {
$_.isdecl(1);
$block.symbol( $_.name, :scope('lexical') );
if $_.isa(PAST::Var) {
$_.isdecl(1);
$block.symbol( $_.name, :scope('lexical') );
}
}
$block[0].push($decls);
$block[0].push(PAST::Op.new(
Expand Down
11 changes: 10 additions & 1 deletion src/Perl6/Compiler/Signature.pm
Expand Up @@ -130,7 +130,7 @@ method get_declarations() {
my @entries := self.entries;
for @entries {
# If the parameter has a name, add it.
if $_.var_name {
if pir::length($_.var_name) > 1 {
my $var := PAST::Var.new(
:name($_.var_name),
:scope('lexical'),
Expand All @@ -142,6 +142,15 @@ method get_declarations() {
$var<traits> := $_.traits;
$result.push($var);
}
elsif pir::length($_.var_name) == 1 {
# A placeholder, but could be being used in a declaration, so emit
# a Whatever.
my @name := Perl6::Grammar::parse_name('Whatever');
$result.push(PAST::Op.new(
:pasttype('callmethod'), :name('new'), :lvalue(1),
PAST::Var.new( :name(@name.pop), :namespace(@name), :scope('package') )
));
}

# If there are captured type variables, need variables for those too.
if $_.type_captures {
Expand Down

0 comments on commit 4afd745

Please sign in to comment.