@@ -36,13 +36,16 @@ class JAST::Class is JAST::Node {
36
36
nqp :: push (@ dumped , " + super $ ! super" );
37
37
nqp :: push (@ dumped , " + filename $ ! filename" );
38
38
nqp :: push (@ dumped , " + serialized $ ! serialized" ) unless nqp ::isnull_s($ ! serialized );
39
+ nqp :: push (@ dumped , " " );
39
40
for @ ! fields {
40
41
$ _ . dump(@ dumped );
42
+ nqp :: push (@ dumped , " " );
41
43
}
42
44
for @ ! methods {
43
45
$ _ . dump(@ dumped );
46
+ nqp :: push (@ dumped , " " );
44
47
}
45
- return @ dumped ;
48
+ return join ( " \n " , @ dumped ) ~ " \n " ;
46
49
}
47
50
}
48
51
@@ -241,7 +244,7 @@ class JAST::Instruction is JAST::Node {
241
244
?? $ _ . name
242
245
!! ~ $ _ )
243
246
}
244
- nqp :: push (@ dumped , " $ ! op " ~ nqp :: join (" " , @ processed ))
247
+ nqp :: push (@ dumped , opcode2name( $ ! op ) ~ " " ~ nqp :: join (" " , @ processed ))
245
248
}
246
249
}
247
250
@@ -270,7 +273,7 @@ class JAST::InvokeDynamic is JAST::Node {
270
273
}
271
274
272
275
method dump (@ dumped ) {
273
- my @ op_dump := [opname2code( ' invokedynamic' ) , $ ! name ];
276
+ my @ op_dump := [' invokedynamic' , $ ! name ];
274
277
nqp :: push (@ op_dump , ' (' ~ join (' ' , @ ! arg_types ) ~ ' )' ~ $ ! ret_type );
275
278
nqp :: push (@ op_dump , $ ! bsm_type );
276
279
nqp :: push (@ op_dump , $ ! bsm_name );
@@ -610,4 +613,216 @@ sub opname2code($name) {
610
613
else {
611
614
nqp ::die(" Opcode '$ name ' not recognized" );
612
615
}
616
+ };
617
+ my % name2opmap := nqp ::hash(
618
+ 0x00 , ' nop' ,
619
+ 0x01 , ' aconst_null' ,
620
+ 0x02 , ' iconst_m1' ,
621
+ 0x03 , ' iconst_0' ,
622
+ 0x04 , ' iconst_1' ,
623
+ 0x05 , ' iconst_2' ,
624
+ 0x06 , ' iconst_3' ,
625
+ 0x07 , ' iconst_4' ,
626
+ 0x08 , ' iconst_5' ,
627
+ 0x09 , ' lconst_0' ,
628
+ 0x0a , ' lconst_1' ,
629
+ 0x0b , ' fconst_0' ,
630
+ 0x0c , ' fconst_1' ,
631
+ 0x0d , ' fconst_2' ,
632
+ 0x0e , ' dconst_0' ,
633
+ 0x0f , ' dconst_1' ,
634
+ 0x10 , ' bipush' ,
635
+ 0x11 , ' sipush' ,
636
+ 0x12 , ' ldc' ,
637
+ 0x13 , ' ldc_w' ,
638
+ 0x14 , ' ldc2_w' ,
639
+ 0x15 , ' iload' ,
640
+ 0x16 , ' lload' ,
641
+ 0x17 , ' fload' ,
642
+ 0x18 , ' dload' ,
643
+ 0x19 , ' aload' ,
644
+ 0x1a , ' iload_0' ,
645
+ 0x1b , ' iload_1' ,
646
+ 0x1c , ' iload_2' ,
647
+ 0x1d , ' iload_3' ,
648
+ 0x1e , ' lload_0' ,
649
+ 0x1f , ' lload_1' ,
650
+ 0x20 , ' lload_2' ,
651
+ 0x21 , ' lload_3' ,
652
+ 0x22 , ' fload_0' ,
653
+ 0x23 , ' fload_1' ,
654
+ 0x24 , ' fload_2' ,
655
+ 0x25 , ' fload_3' ,
656
+ 0x26 , ' dload_0' ,
657
+ 0x27 , ' dload_1' ,
658
+ 0x28 , ' dload_2' ,
659
+ 0x29 , ' dload_3' ,
660
+ 0x2a , ' aload_0' ,
661
+ 0x2b , ' aload_1' ,
662
+ 0x2c , ' aload_2' ,
663
+ 0x2d , ' aload_3' ,
664
+ 0x2e , ' iaload' ,
665
+ 0x2f , ' laload' ,
666
+ 0x30 , ' faload' ,
667
+ 0x31 , ' daload' ,
668
+ 0x32 , ' aaload' ,
669
+ 0x33 , ' baload' ,
670
+ 0x34 , ' caload' ,
671
+ 0x35 , ' saload' ,
672
+ 0x36 , ' istore' ,
673
+ 0x37 , ' lstore' ,
674
+ 0x38 , ' fstore' ,
675
+ 0x39 , ' dstore' ,
676
+ 0x3a , ' astore' ,
677
+ 0x3b , ' istore_0' ,
678
+ 0x3c , ' istore_1' ,
679
+ 0x3d , ' istore_2' ,
680
+ 0x3e , ' istore_3' ,
681
+ 0x3f , ' lstore_0' ,
682
+ 0x40 , ' lstore_1' ,
683
+ 0x41 , ' lstore_2' ,
684
+ 0x42 , ' lstore_3' ,
685
+ 0x43 , ' fstore_0' ,
686
+ 0x44 , ' fstore_1' ,
687
+ 0x45 , ' fstore_2' ,
688
+ 0x46 , ' fstore_3' ,
689
+ 0x47 , ' dstore_0' ,
690
+ 0x48 , ' dstore_1' ,
691
+ 0x49 , ' dstore_2' ,
692
+ 0x4a , ' dstore_3' ,
693
+ 0x4b , ' astore_0' ,
694
+ 0x4c , ' astore_1' ,
695
+ 0x4d , ' astore_2' ,
696
+ 0x4e , ' astore_3' ,
697
+ 0x4f , ' iastore' ,
698
+ 0x50 , ' lastore' ,
699
+ 0x51 , ' fastore' ,
700
+ 0x52 , ' dastore' ,
701
+ 0x53 , ' aastore' ,
702
+ 0x54 , ' bastore' ,
703
+ 0x55 , ' castore' ,
704
+ 0x56 , ' sastore' ,
705
+ 0x57 , ' pop' ,
706
+ 0x58 , ' pop2' ,
707
+ 0x59 , ' dup' ,
708
+ 0x5a , ' dup_x1' ,
709
+ 0x5b , ' dup_x2' ,
710
+ 0x5c , ' dup2' ,
711
+ 0x5d , ' dup2_x1' ,
712
+ 0x5e , ' dup2_x2' ,
713
+ 0x5f , ' swap' ,
714
+ 0x60 , ' iadd' ,
715
+ 0x61 , ' ladd' ,
716
+ 0x62 , ' fadd' ,
717
+ 0x63 , ' dadd' ,
718
+ 0x64 , ' isub' ,
719
+ 0x65 , ' lsub' ,
720
+ 0x66 , ' fsub' ,
721
+ 0x67 , ' dsub' ,
722
+ 0x68 , ' imul' ,
723
+ 0x69 , ' lmul' ,
724
+ 0x6a , ' fmul' ,
725
+ 0x6b , ' dmul' ,
726
+ 0x6c , ' idiv' ,
727
+ 0x6d , ' ldiv' ,
728
+ 0x6e , ' fdiv' ,
729
+ 0x6f , ' ddiv' ,
730
+ 0x70 , ' irem' ,
731
+ 0x71 , ' lrem' ,
732
+ 0x72 , ' frem' ,
733
+ 0x73 , ' drem' ,
734
+ 0x74 , ' ineg' ,
735
+ 0x75 , ' lneg' ,
736
+ 0x76 , ' fneg' ,
737
+ 0x77 , ' dneg' ,
738
+ 0x78 , ' ishl' ,
739
+ 0x79 , ' lshl' ,
740
+ 0x7a , ' ishr' ,
741
+ 0x7b , ' lshr' ,
742
+ 0x7c , ' iushr' ,
743
+ 0x7d , ' lushr' ,
744
+ 0x7e , ' iand' ,
745
+ 0x7f , ' land' ,
746
+ 0x80 , ' ior' ,
747
+ 0x81 , ' lor' ,
748
+ 0x82 , ' ixor' ,
749
+ 0x83 , ' lxor' ,
750
+ 0x84 , ' iinc' ,
751
+ 0x85 , ' i2l' ,
752
+ 0x86 , ' i2f' ,
753
+ 0x87 , ' i2d' ,
754
+ 0x88 , ' l2i' ,
755
+ 0x89 , ' l2f' ,
756
+ 0x8a , ' l2d' ,
757
+ 0x8b , ' f2i' ,
758
+ 0x8c , ' f2l' ,
759
+ 0x8d , ' f2d' ,
760
+ 0x8e , ' d2i' ,
761
+ 0x8f , ' d2l' ,
762
+ 0x90 , ' d2f' ,
763
+ 0x91 , ' i2b' ,
764
+ 0x92 , ' i2c' ,
765
+ 0x93 , ' i2s' ,
766
+ 0x94 , ' lcmp' ,
767
+ 0x95 , ' fcmpl' ,
768
+ 0x96 , ' fcmpg' ,
769
+ 0x97 , ' dcmpl' ,
770
+ 0x98 , ' dcmpg' ,
771
+ 0x99 , ' ifeq' ,
772
+ 0x9a , ' ifne' ,
773
+ 0x9b , ' iflt' ,
774
+ 0x9c , ' ifge' ,
775
+ 0x9d , ' ifgt' ,
776
+ 0x9e , ' ifle' ,
777
+ 0x9f , ' if_icmpeq' ,
778
+ 0xa0 , ' if_icmpne' ,
779
+ 0xa1 , ' if_icmplt' ,
780
+ 0xa2 , ' if_icmpge' ,
781
+ 0xa3 , ' if_icmpgt' ,
782
+ 0xa4 , ' if_icmple' ,
783
+ 0xa5 , ' if_acmpeq' ,
784
+ 0xa6 , ' if_acmpne' ,
785
+ 0xa7 , ' goto' ,
786
+ 0xa8 , ' jsr' ,
787
+ 0xa9 , ' ret' ,
788
+ 0xaa , ' tableswitch' ,
789
+ 0xab , ' lookupswitch' ,
790
+ 0xac , ' ireturn' ,
791
+ 0xad , ' lreturn' ,
792
+ 0xae , ' freturn' ,
793
+ 0xaf , ' dreturn' ,
794
+ 0xb0 , ' areturn' ,
795
+ 0xb1 , ' return' ,
796
+ 0xb2 , ' getstatic' ,
797
+ 0xb3 , ' putstatic' ,
798
+ 0xb4 , ' getfield' ,
799
+ 0xb5 , ' putfield' ,
800
+ 0xb6 , ' invokevirtual' ,
801
+ 0xb7 , ' invokespecial' ,
802
+ 0xb8 , ' invokestatic' ,
803
+ 0xb9 , ' invokeinterface' ,
804
+ 0xba , ' invokedynamic' ,
805
+ 0xbb , ' new' ,
806
+ 0xbc , ' newarray' ,
807
+ 0xbd , ' anewarray' ,
808
+ 0xbe , ' arraylength' ,
809
+ 0xbf , ' athrow' ,
810
+ 0xc0 , ' checkcast' ,
811
+ 0xc1 , ' instanceof' ,
812
+ 0xc2 , ' monitorenter' ,
813
+ 0xc3 , ' monitorexit' ,
814
+ 0xc4 , ' wide' ,
815
+ 0xc5 , ' multianewarray' ,
816
+ 0xc6 , ' ifnull' ,
817
+ 0xc7 , ' ifnonnull' ,
818
+ 0xc8 , ' goto_w' ,
819
+ 0xc9 , ' jsr_w'
820
+ );
821
+ sub opcode2name ($ code ) {
822
+ if nqp ::existskey(% name2opmap , $ code ) {
823
+ return % name2opmap {$ code };
824
+ }
825
+ else {
826
+ nqp ::die(" Opcode '$ code ' not recognized" );
827
+ }
613
828
}
0 commit comments