@@ -523,10 +523,10 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
523
523
if $ desired == $ T_NUM {
524
524
if $ got == $ T_INT {
525
525
# we store both as a javascript number, and 32bit integers fit into doubles
526
- return Chunk. new ($ T_NUM , $ chunk . expr, [ $ chunk ] );
526
+ return Chunk. new ($ T_NUM , $ chunk . expr, $ chunk );
527
527
}
528
528
if $ got == $ T_BOOL {
529
- return Chunk. new ($ T_NUM , " ({ $ chunk . expr} ? 1 : 0)" , [ $ chunk ] );
529
+ return Chunk. new ($ T_NUM , " ({ $ chunk . expr} ? 1 : 0)" , $ chunk );
530
530
}
531
531
if $ got == $ T_STR {
532
532
my $ tmp := $ * BLOCK . add_tmp();
@@ -536,68 +536,68 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
536
536
537
537
if $ desired == $ T_INT {
538
538
if $ got == $ T_STR {
539
- return Chunk. new ($ T_INT , " parseInt({ $ chunk . expr} )" , [ $ chunk ] );
539
+ return Chunk. new ($ T_INT , " parseInt({ $ chunk . expr} )" , $ chunk );
540
540
}
541
541
if $ got == $ T_NUM {
542
- return Chunk. new ($ T_INT , " ({ $ chunk . expr} |0)" , [ $ chunk ] );
542
+ return Chunk. new ($ T_INT , " ({ $ chunk . expr} |0)" , $ chunk );
543
543
}
544
544
if $ got == $ T_BOOL {
545
- return Chunk. new ($ T_INT , " ({ $ chunk . expr} ? 1 : 0)" , [ $ chunk ] );
545
+ return Chunk. new ($ T_INT , " ({ $ chunk . expr} ? 1 : 0)" , $ chunk );
546
546
}
547
547
}
548
548
549
549
if $ got == $ T_OBJ {
550
550
if $ desired == $ T_BOOL {
551
- return Chunk. new ($ desired , " { $ chunk . expr} .\$\$decont($ * CTX ).\$\$toBool($ * CTX )" , [ $ chunk ] );
551
+ return Chunk. new ($ desired , " { $ chunk . expr} .\$\$decont($ * CTX ).\$\$toBool($ * CTX )" , $ chunk );
552
552
}
553
553
my % convert ;
554
554
% convert {$ T_STR } := ' toStr' ;
555
555
% convert {$ T_NUM } := ' toNum' ;
556
556
% convert {$ T_INT } := ' toInt' ;
557
- return Chunk. new ($ desired , ' nqp.' ~ % convert {$ desired } ~ ' (' ~ $ chunk . expr ~ " , { $ * CTX } )" , [ $ chunk ] );
557
+ return Chunk. new ($ desired , ' nqp.' ~ % convert {$ desired } ~ ' (' ~ $ chunk . expr ~ " , { $ * CTX } )" , $ chunk );
558
558
}
559
559
560
560
if $ desired == $ T_STR {
561
561
if $ got == $ T_INT || $ got == $ T_NUM {
562
- return Chunk. new ($ T_STR , $ chunk . expr ~ ' .toString()' , [ $ chunk ] );
562
+ return Chunk. new ($ T_STR , $ chunk . expr ~ ' .toString()' , $ chunk );
563
563
}
564
564
if $ got == $ T_BOOL {
565
- return Chunk. new ($ T_STR , " ({ $ chunk . expr} ? '1' : '0')" , [ $ chunk ] );
565
+ return Chunk. new ($ T_STR , " ({ $ chunk . expr} ? '1' : '0')" , $ chunk );
566
566
}
567
567
}
568
568
569
569
if $ desired == $ T_OBJ {
570
570
if $ got == $ T_BOOL {
571
- $ chunk := Chunk. new ($ T_INT , " ({ $ chunk . expr} ? 1 : 0)" , [ $ chunk ] );
571
+ $ chunk := Chunk. new ($ T_INT , " ({ $ chunk . expr} ? 1 : 0)" , $ chunk );
572
572
$ got := $ T_INT ;
573
573
}
574
574
elsif $ got == $ T_VOID {
575
575
# TODO think what's the correct thing here
576
- return Chunk. new ($ T_OBJ , " nqp.Null" , [ $ chunk ] );
576
+ return Chunk. new ($ T_OBJ , " nqp.Null" , $ chunk );
577
577
}
578
578
579
579
if $ * HLL eq ' nqp' {
580
580
if $ got == $ T_NUM || $ got == $ T_STR {
581
581
return $ chunk ;
582
582
}
583
583
elsif $ got == $ T_INT {
584
- return Chunk. new ($ T_OBJ , " new nqp.NQPInt({ $ chunk . expr} )" , [ $ chunk ] );
584
+ return Chunk. new ($ T_OBJ , " new nqp.NQPInt({ $ chunk . expr} )" , $ chunk );
585
585
}
586
586
}
587
587
else {
588
588
my % convert ;
589
589
% convert {$ T_INT } := ' intToObj' ;
590
590
% convert {$ T_NUM } := ' numToObj' ;
591
591
% convert {$ T_STR } := ' strToObj' ;
592
- return Chunk. new ($ T_OBJ , " nqp.{ % convert {$ got }} ({ quote_string($ * HLL )} , { $ chunk . expr} )" , [ $ chunk ] );
592
+ return Chunk. new ($ T_OBJ , " nqp.{ % convert {$ got }} ({ quote_string($ * HLL )} , { $ chunk . expr} )" , $ chunk );
593
593
}
594
594
}
595
595
596
596
if $ desired == $ T_BOOL {
597
597
if $ got == $ T_INT || $ got == $ T_NUM {
598
- return Chunk. new ($ T_BOOL , $ chunk . expr, [ $ chunk ] );
598
+ return Chunk. new ($ T_BOOL , $ chunk . expr, $ chunk );
599
599
} elsif $ got == $ T_STR {
600
- return Chunk. new ($ T_BOOL , " ({ $ chunk . expr} && { $ chunk . expr} !== nqp.null_s)" , [ $ chunk ] );
600
+ return Chunk. new ($ T_BOOL , " ({ $ chunk . expr} && { $ chunk . expr} !== nqp.null_s)" , $ chunk );
601
601
}
602
602
}
603
603
@@ -805,12 +805,15 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
805
805
self . chunk_sequence($ want , @ chunks , : $ result_child , : $ node );
806
806
}
807
807
808
- proto method cpsify_chunk ($ chunk ) { * }
809
- multi method cpsify_chunk (ChunkCPS $ chunk ) { $ chunk }
810
- multi method cpsify_chunk (Chunk $ chunk ) {
811
- my $ ret := self . chunk_sequence($ chunk . type, $ chunk . setup, : expr($ chunk . expr), : node($ chunk . node));
812
- $ ret ;
813
- }
808
+ # proto method cpsify_chunk($chunk) { * }
809
+ # multi method cpsify_chunk(ChunkCPS $chunk) { $chunk }
810
+ # multi method cpsify_chunk(Chunk $chunk) {
811
+ # my $ret := self.chunk_sequence($chunk.type, $chunk.setup, :expr($chunk.expr), :node($chunk.node));
812
+ # $ret;
813
+ # }
814
+
815
+ method cpsify_chunk ($ chunk ) { $ chunk }
816
+ # TODO restore CPS
814
817
815
818
multi method as_js (QAST ::Block $ node , : $ want , : $ cps ) {
816
819
my $ outer := try $ * BLOCK ;
@@ -1710,15 +1713,15 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1710
1713
if $ * BINDVAL {
1711
1714
my $ bindval := self . as_js_clear_bindval($ * BINDVAL , : want($ type ), : $ cps );
1712
1715
if $ var . decl eq ' var' {
1713
- self . stored_result(Chunk. new ($ type , " ({ $ * CTX } [{ quote_string($ var . name )} ] = { $ bindval . expr} )" , [ $ bindval ] ), : $ want );
1716
+ self . stored_result(Chunk. new ($ type , " ({ $ * CTX } [{ quote_string($ var . name )} ] = { $ bindval . expr} )" , $ bindval ), : $ want );
1714
1717
}
1715
1718
else {
1716
1719
if $ * BLOCK . ctx_for_var($ var ) -> $ ctx {
1717
- self . stored_result(Chunk. new ($ type , " ({ $ ctx } [{ quote_string($ var . name )} ] = { $ bindval . expr} )" , [ $ bindval ] ), : $ want );
1720
+ self . stored_result(Chunk. new ($ type , " ({ $ ctx } [{ quote_string($ var . name )} ] = { $ bindval . expr} )" , $ bindval ), : $ want );
1718
1721
}
1719
1722
else {
1720
1723
# nqp::die("we can't find ctx for {$var.name}");
1721
- self . stored_result(Chunk. new ($ type , " { $ * CTX } .bind({ quote_string($ var . name )} , { $ bindval . expr} )" , [ $ bindval ] ), : $ want );
1724
+ self . stored_result(Chunk. new ($ type , " { $ * CTX } .bind({ quote_string($ var . name )} , { $ bindval . expr} )" , $ bindval ), : $ want );
1722
1725
}
1723
1726
}
1724
1727
}
@@ -1925,7 +1928,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1925
1928
Chunk. new ($ T_OBJ , $ bindval . expr, [$ self , $ bindval , " { $ self . expr} .\$\$bindattr\${ $ hint } ({ $ bindval . expr} );\n " ]);
1926
1929
}
1927
1930
else {
1928
- Chunk. new ($ T_OBJ , " { $ self . expr} .\$\$getattr\${ $ hint } ()" , [ $ self ] );
1931
+ Chunk. new ($ T_OBJ , " { $ self . expr} .\$\$getattr\${ $ hint } ()" , $ self );
1929
1932
}
1930
1933
}
1931
1934
else {
@@ -1935,15 +1938,15 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
1935
1938
Chunk. new ($ type , $ bindval . expr, [$ self , $ bindval , " $ attr = { $ bindval . expr} ;\n " ]);
1936
1939
}
1937
1940
else {
1938
- Chunk. new ($ type , $ attr , [ $ self ] );
1941
+ Chunk. new ($ type , $ attr , $ self );
1939
1942
}
1940
1943
}
1941
1944
}
1942
1945
}
1943
1946
elsif $ var . scope eq ' contextual' {
1944
1947
if $ * BINDVAL {
1945
1948
my $ bindval := self . as_js_clear_bindval($ * BINDVAL , : want($ T_OBJ ), : $ cps );
1946
- self . stored_result(Chunk. new ($ T_OBJ , " { $ * CTX } .bindDynamic({ quote_string($ var . name )} ,{ $ bindval . expr} )" , [ $ bindval ] ), : $ want );
1949
+ self . stored_result(Chunk. new ($ T_OBJ , " { $ * CTX } .bindDynamic({ quote_string($ var . name )} ,{ $ bindval . expr} )" , $ bindval ), : $ want );
1947
1950
}
1948
1951
else {
1949
1952
Chunk. new ($ T_OBJ , " { $ * CTX } .lookupDynamic({ quote_string($ var . name )} )" );
0 commit comments