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;
31 private Category category;
32 private List<Label> labels = new ArrayList<Label>();
34 public Opcode(Opcode opcode){
35 this(opcode.getOpcode(), opcode.getName(), opcode.getArgumentCount(), opcode.getAct(), opcode.getCategory());
38 public Opcode(int opcode, String name, int argumentCount, int act, String category){
39 this(opcode, name, argumentCount, act, Category.valueOf(category));
42 public Opcode(int opcode, String name, int argumentCount, int act, Category category){
45 this.argumentCount = argumentCount;
47 this.category = category;
50 Opcode(int opcode, String name, int argumentCount, int act, Category category, int weight){
51 this(opcode, name, argumentCount, act, category);
55 public int getOpcode(){
59 public String getName(){
63 public int getArgumentCount(){
67 public void addLabel(Label label){
68 if(category != Category.BRANCH){
69 throw new IllegalStateException("this method allows only branch category");
74 public void setLabels(Label[] labelArray){
75 if(category != Category.BRANCH){
76 throw new IllegalStateException("this method allows only branch category");
78 for(Label label: labelArray){
83 public Iterator<Label> labels(){
84 return Collections.unmodifiableList(labels).iterator();
87 public void setAct(int act){
88 if(category != Category.OBJECT && category != Category.INVOKE){
89 throw new IllegalStateException("setAct can be called only object and invoke category.");
98 public Category getCategory(){
102 public void setWeight(int weight){
103 this.weight = weight;
106 public int getWeight(){