Skip to content

Commit 6633624

Browse files
committed
[js] Treat static similiar to contvars.
1 parent c45a1c2 commit 6633624

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/vm/js/Compiler.nqp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,23 +1522,26 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
15221522
$*BLOCK.add_js_lexical($*BLOCK.add_mangled_var($node));
15231523
}
15241524
}
1525-
elsif $node.decl eq 'var' || $node.decl eq 'contvar' {
1525+
elsif $node.decl eq 'var' || $node.decl eq 'contvar' || $node.decl eq 'static' {
15261526
$*BLOCK.add_variable($node);
15271527

15281528
if !self.is_dynamic_var($*BLOCK, $node) {
15291529
my $mangled_name := $*BLOCK.add_mangled_var($node);
15301530
if $node.decl eq 'contvar' {
15311531
$*BLOCK.add_js_lexical_with_value($mangled_name, "nqp.op.clone({self.value_as_js($node.value)})");
15321532
}
1533+
elsif $node.decl eq 'static' {
1534+
$*BLOCK.add_js_lexical_with_value($mangled_name, self.value_as_js($node.value));
1535+
}
15331536
else {
15341537
$*BLOCK.add_js_lexical($mangled_name);
15351538
}
15361539
}
15371540
}
1538-
elsif $node.decl eq 'static' {
1539-
$*BLOCK.add_variable($node);
1540-
$*BLOCK.add_static_variable($node);
1541-
}
1541+
# elsif $node.decl eq 'static' {
1542+
# $*BLOCK.add_variable($node);
1543+
# $*BLOCK.add_static_variable($node);
1544+
# }
15421545
elsif $node.decl eq 'param' {
15431546
$*BLOCK.add_variable($node);
15441547
if $node.scope eq 'local' || $node.scope eq 'lexical' {
@@ -1682,6 +1685,9 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
16821685
elsif $var.decl eq 'contvar' {
16831686
self.stored_result(Chunk.new($T_OBJ, "({$*CTX}[{quote_string($var.name)}] = nqp.op.clone({self.value_as_js($var.value)}))", []), :$want);
16841687
}
1688+
elsif $var.decl eq 'static' {
1689+
self.stored_result(Chunk.new($T_OBJ, "({$*CTX}[{quote_string($var.name)}] = {self.value_as_js($var.value)})", []), :$want);
1690+
}
16851691
else {
16861692
if $*BLOCK.ctx_for_var($var) -> $ctx {
16871693
Chunk.new($type, "$ctx[{quote_string($var.name)}]", [], :node($var));

0 commit comments

Comments
 (0)