OSDN Git Service

update
[stigmata/stigmata-plugins.git] / opcodes / opcodes-1.0.0 / src / main / java / jp / sourceforge / stigmata / birthmarks / OpcodeExtractVisitor.java
1 package jp.sourceforge.stigmata.birthmarks;
2
3 /*
4  * $Id$
5  */
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 import jp.sourceforge.stigmata.Birthmark;
11 import jp.sourceforge.stigmata.BirthmarkContext;
12 import jp.sourceforge.stigmata.BirthmarkElement;
13
14 import org.objectweb.asm.ClassVisitor;
15 import org.objectweb.asm.MethodVisitor;
16
17 /**
18  *
19  *
20  * @author tamada
21  * @version $Revision$
22  */
23 public class OpcodeExtractVisitor extends BirthmarkExtractVisitor{
24     private List<Opcode> opcodeList = new ArrayList<Opcode>();
25     private BirthmarkElementBuilder builder;
26
27     public OpcodeExtractVisitor(ClassVisitor visitor, Birthmark birthmark, BirthmarkContext context, BirthmarkElementBuilder builder){
28         super(visitor, birthmark, context);
29         this.builder = builder;
30     }
31
32     public void visitEnd(){
33         BirthmarkElement[] elements = builder.buildElements(opcodeList, getContext());
34         for(BirthmarkElement element: elements){
35             addElement(element);
36         }
37     }
38
39     @Override
40     public MethodVisitor visitMethod(int arg0, String arg1, String arg2, String arg3, String[] arg4){
41         MethodVisitor visitor = super.visitMethod(arg0, arg1, arg2, arg3, arg4);
42         OpcodeExtractMethodVisitor opcodeVisitor = new OpcodeExtractMethodVisitor(visitor, opcodeList);
43
44         return opcodeVisitor;
45     }
46 }