@@ -201,6 +201,20 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
201
201
method ctx (* @ value ) { $ ! ctx := @ value [0 ] if @ value ;$ ! ctx }
202
202
method params () { @ ! params }
203
203
method variables () { @ ! variables }
204
+
205
+ method is_dynamic_var ($ var ) {
206
+ # HACK due to a nqp misdesign we need a HACK
207
+ # TODO Make nqp mark dynamic variables explicitly
208
+ my $ name := $ var . name ;
209
+ if nqp :: chars ($ name ) > 2 {
210
+ my str $ sigil := nqp :: substr ($ name , 0 , 1 );
211
+ my str $ twigil := nqp :: substr ($ name , 1 , 1 );
212
+ if $ twigil eq ' *' {
213
+ return 1 ;
214
+ }
215
+ }
216
+ return 0 ;
217
+ }
204
218
}
205
219
206
220
method is_valid_js_identifier ($ identifier ) {
@@ -342,7 +356,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
342
356
}
343
357
344
358
my sub set_variable ($ var , $ value ) {
345
- if self . is_dynamic_var($ var ) {
359
+ if $ * BLOCK . is_dynamic_var($ var ) {
346
360
@ setup . push (" { $ * CTX } [{ quote_string($ var . name )} ] = $ value ;\n " );
347
361
}
348
362
else {
@@ -382,7 +396,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
382
396
383
397
set_variable($ _ , $ value );
384
398
}
385
- elsif self . is_dynamic_var($ _ ) {
399
+ elsif $ * BLOCK . is_dynamic_var($ _ ) {
386
400
my $ tmp := self . unique_var(' param' );
387
401
@ sig . push ($ tmp );
388
402
@@ -1122,7 +1136,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1122
1136
if $ * BLOCK . lookup_static_variable($ var ) -> $ static {
1123
1137
$ value := self . value_as_js($ static . value );
1124
1138
}
1125
- elsif self . is_dynamic_var($ var ) {
1139
+ elsif $ * BLOCK . is_dynamic_var($ var ) {
1126
1140
$ value := " { $ * CTX } .lookup({ quote_string($ var . name )} )" ;
1127
1141
}
1128
1142
else {
@@ -1438,20 +1452,6 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1438
1452
self . as_js($ node , : $ want , : $ cps );
1439
1453
}
1440
1454
1441
- method is_dynamic_var ($ var ) {
1442
- # HACK due to a nqp misdesign we need a HACK
1443
- # TODO Make nqp mark dynamic variables explicitly
1444
- my $ name := $ var . name ;
1445
- if nqp :: chars ($ name ) > 2 {
1446
- my str $ sigil := nqp :: substr ($ name , 0 , 1 );
1447
- my str $ twigil := nqp :: substr ($ name , 1 , 1 );
1448
- if $ twigil eq ' *' {
1449
- return 1 ;
1450
- }
1451
- }
1452
- return 0 ;
1453
- }
1454
-
1455
1455
method atpos ($ array , $ index , : $ node ) {
1456
1456
my $ array_chunk := self . as_js($ array , : want($ T_OBJ ));
1457
1457
my $ index_chunk := self . as_js($ index , : want($ T_INT ));
@@ -1530,7 +1530,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1530
1530
self . compile_var_as_js_var($ var , : $ cps );
1531
1531
}
1532
1532
elsif self . var_is_lexicalish($ var ) {
1533
- if self . is_dynamic_var($ var ) {
1533
+ if $ * BLOCK . is_dynamic_var($ var ) {
1534
1534
self . compile_var_as_part_of_ctx($ var , : $ cps );
1535
1535
}
1536
1536
else {
0 commit comments