1 package jp.sourceforge.stigmata.birthmarks.wsp;
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collections;
10 import java.util.Iterator;
11 import java.util.List;
13 import org.objectweb.asm.Label;
17 * @author Haruaki Tamada
20 public class Opcode implements Serializable{
21 private static final long serialVersionUID = -2349834745416345564L;
23 public static enum Category{
24 NORMAL, BRANCH, OBJECT, INVOKE, TARGETER,
28 private int argumentCount;
30 private Category category;
31 private List<Label> labels = new ArrayList<Label>();
33 public Opcode(Opcode opcode){
34 this(opcode.getOpcode(), opcode.getName(), opcode.getArgumentCount(), opcode.getAct(), opcode.getCategory());
37 public Opcode(int opcode, String name, int argumentCount, int act, String category){
38 this(opcode, name, argumentCount, act, Category.valueOf(category));
41 public Opcode(int opcode, String name, int argumentCount, int act, Category category){
44 this.argumentCount = argumentCount;
46 this.category = category;
49 public int getOpcode(){
53 public String getName(){
57 public int getArgumentCount(){
61 public void addLabel(Label label){
62 if(category != Category.BRANCH){
63 throw new IllegalStateException("this method allows only branch category");
68 public void setLabels(Label[] labelArray){
69 if(category != Category.BRANCH){
70 throw new IllegalStateException("this method allows only branch category");
72 for(Label label: labelArray){
77 public Iterator<Label> labels(){
78 return Collections.unmodifiableList(labels).iterator();
81 public void setAct(int act){
82 if(category != Category.OBJECT && category != Category.INVOKE){
83 throw new IllegalStateException("setAct can be called only object and invoke category.");
92 public Category getCategory(){