Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
the first obvious changes towards lowering lexicalref
  • Loading branch information
timo committed Jul 27, 2015
1 parent ed945eb commit cbe2eca
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -629,17 +629,19 @@ my class BlockVarOptimizer {
nqp::iscclass(nqp::const::CCLASS_ALPHABETIC, $name, 1);
}

# Also must not lexicalref it.
my int $ref'd := 0;
if %!usages_flat{$name} {
for %!usages_flat{$name} {
if $_.scope eq 'lexicalref' {
$ref'd := 1;
last;
# Also must not lexicalref it - except if it's a native var.
if nqp::objprimspec($qast.returns) == 0 {
my int $ref'd := 0;
if %!usages_flat{$name} {
for %!usages_flat{$name} {
if $_.scope eq 'lexicalref' {
$ref'd := 1;
last;
}
}
}
next if $ref'd;
}
next if $ref'd;

# Seems good; lower it. Note we need to retain a lexical in
# case of binder failover to generate errors.
Expand All @@ -650,8 +652,13 @@ my class BlockVarOptimizer {
$qast.scope('local');
if %!usages_flat{$name} {
for %!usages_flat{$name} {
$_.scope('local');
if $_.scope eq 'lexical' {
$_.scope('local');
} else {
$_.scope('localref');
}
$_.name($new_name);
$_.returns($qast.returns);
}
}
}
Expand Down

0 comments on commit cbe2eca

Please sign in to comment.