OSDN Git Service

change kgram format
[stigmata/stigmata-plugins.git] / kgram / src / main / java / jp / sourceforge / stigmata / birthmarks / kgram / OpcodeExtractionMethodVisitor.java
1 package jp.sourceforge.stigmata.birthmarks.kgram;
2
3 import java.util.List;
4
5 import org.objectweb.asm.Label;
6 import org.objectweb.asm.MethodVisitor;
7 import org.objectweb.asm.Opcodes;
8
9 /**
10  * 
11  * @author Haruaki TAMADA
12  */
13 public class OpcodeExtractionMethodVisitor extends MethodVisitor{
14     private List<Integer> opcodes;
15
16     public OpcodeExtractionMethodVisitor(MethodVisitor visitor,
17                                          List<Integer> opcodes){
18         super(Opcodes.ASM4, visitor);
19         this.opcodes = opcodes;
20     }
21
22     @Override
23     public void visitFieldInsn(int opcode, String owner,
24                                String name, String desc){
25         opcodes.add(opcode);
26         super.visitFieldInsn(opcode, owner, name, desc);
27     }
28
29     @Override
30     public void visitIincInsn(int var, int increment){
31         opcodes.add(Opcodes.IINC);
32         super.visitIincInsn(var, increment);
33     }
34
35     @Override
36     public void visitInsn(int opcode){
37         opcodes.add(opcode);
38         super.visitInsn(opcode);
39     }
40
41     @Override
42     public void visitIntInsn(int opcode, int operand){
43         opcodes.add(opcode);
44         super.visitIntInsn(opcode, operand);
45     }
46
47     @Override
48     public void visitJumpInsn(int opcode, Label label){
49         opcodes.add(opcode);
50         super.visitJumpInsn(opcode, label);
51     }
52
53     @Override
54     public void visitLdcInsn(Object value){
55         opcodes.add(Opcodes.LDC);
56         super.visitLdcInsn(value);
57     }
58
59     @Override
60     public void visitLookupSwitchInsn(Label defaultHandle, int[] keys,
61                                       Label[] labels){
62         opcodes.add(Opcodes.LOOKUPSWITCH);
63         super.visitLookupSwitchInsn(defaultHandle, keys, labels);
64     }
65
66     @Override
67     public void visitMethodInsn(int opcode, String owner,
68                                 String name, String desc){
69         opcodes.add(opcode);
70         super.visitMethodInsn(opcode, owner, name, desc);
71     }
72
73     @Override
74     public void visitMultiANewArrayInsn(String desc, int dims){
75         opcodes.add(Opcodes.MULTIANEWARRAY);
76         super.visitMultiANewArrayInsn(desc, dims);
77     }
78
79     @Override
80     public void visitTableSwitchInsn(int min, int max,
81                                      Label defaultLabel, Label... labels){
82         opcodes.add(Opcodes.TABLESWITCH);
83         super.visitTableSwitchInsn(min, max, defaultLabel, labels);
84     }
85
86     @Override
87     public void visitTypeInsn(int opcode, String desc){
88         opcodes.add(opcode);
89         super.visitTypeInsn(opcode, desc);
90     }
91
92     @Override
93     public void visitVarInsn(int opcode, int var){
94         opcodes.add(opcode);
95         super.visitVarInsn(opcode, var);
96     }
97 }