Skip to content

Commit

Permalink
[js] Have a static variable be shadowed by a normal more inner one.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed May 16, 2016
1 parent 2364f08 commit 1adeaba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vm/js/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,24 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
nqp::existskey(%!static_variables, $name);
}

method has_local_variable($name) {
nqp::existskey(%!variables, $name);
}

method get_static_variable($name) {
%!static_variables{$name};
}

method lookup_static_variable($var) {
my $info := self;
return nqp::null if $var.scope ne 'lexical' && $var.scope ne 'typevar';
return nqp::null() if $var.scope ne 'lexical' && $var.scope ne 'typevar';
while $info {
if $info.has_local_static_variable($var.name) {
return $info.get_static_variable($var.name);
}
if $info.has_local_variable($var.name) {
return nqp::null();
}
$info := $info.outer;
}
nqp::null();
Expand Down

0 comments on commit 1adeaba

Please sign in to comment.