Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make use of PseudoStash poison lowers.
Not trying to do any of them yet, but this will be needed before we
safely can.
  • Loading branch information
jnthn committed Apr 11, 2014
1 parent 806c867 commit 5bc6b91
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -25,6 +25,7 @@ my class Symbols {
# Some interesting symbols.
has $!Mu;
has $!Any;
has $!PseudoStash;

# Constructs a new instance of the symbols handling class.
method new($compunit) {
Expand All @@ -41,8 +42,9 @@ my class Symbols {
nqp::die("Optimizer could not find UNIT");
}
nqp::push(@!block_stack, $!UNIT);
$!Mu := self.find_lexical('Mu');
$!Any := self.find_lexical('Any');
$!Mu := self.find_lexical('Mu');
$!Any := self.find_lexical('Any');
$!PseudoStash := self.find_lexical('PseudoStash');
nqp::pop(@!block_stack);
}

Expand All @@ -58,10 +60,11 @@ my class Symbols {
}

# Accessors for interesting symbols/scopes.
method GLOBALish() { $!GLOBALish }
method UNIT() { $!UNIT }
method Mu() { $!Mu }
method Any() { $!Any }
method GLOBALish() { $!GLOBALish }
method UNIT() { $!UNIT }
method Mu() { $!Mu }
method Any() { $!Any }
method PseudoStash() { $!PseudoStash }

# The following function is a nearly 1:1 copy of World.find_symbol.
# Finds a symbol that has a known value at compile time from the
Expand Down Expand Up @@ -1170,6 +1173,11 @@ class Perl6::Optimizer {
self.poison_var_lowering();
QRegex::Optimizer.new().optimize($visit, $!symbols.top_block, |%!adverbs);
}
elsif nqp::istype($visit, QAST::WVal) {
if $visit.value =:= $!symbols.PseudoStash {
self.poison_var_lowering();
}
}
}
$i := $first ?? $n !! $i + 1;
}
Expand Down

0 comments on commit 5bc6b91

Please sign in to comment.