/** * Throw an exception of the given type. */ protected Instruction throwException(Code code, Class type) { Instruction ins = code.anew().setType(type); code.dup(); code.invokespecial().setMethod(type, "<init>", void.class, null); code.athrow(); return ins; }
/** * Two MultiANewArray instructions are equal if they have the same * type and dimensions, or if the type and dimensions of either is unset. */ public boolean equalsInstruction(Instruction other) { if (other == this) return true; if (!(other instanceof MultiANewArrayInstruction)) return false; if (!super.equalsInstruction(other)) return false; MultiANewArrayInstruction ins = (MultiANewArrayInstruction) other; int dims = getDimensions(); int otherDims = ins.getDimensions(); return dims == -1 || otherDims == -1 || dims == otherDims; }
int getLength() { return super.getLength() + 1; }
public void enterClassInstruction(ClassInstruction obj) { _out.print(obj.getTypeIndex() + " <" + obj.getTypeName() + ">"); }
void read(Instruction other) { super.read(other); setType(((ClassInstruction) other).getTypeName()); }
public TypedInstruction setType(String type) { if (type == null) _index = 0; else { type = getProject().getNameCache().getInternalForm(type, false); _index = getPool().findClassEntry(type, true); } return this; }
public int getStackChange() { if (getOpcode() == Constants.NEW) return 1; return 0; }
/** * ClassInstructions are equal if the type they reference is the same or * unset and if their opcodes are equal. */ public boolean equalsInstruction(Instruction other) { if (other == this) return true; if (!super.equalsInstruction(other)) return false; String type = getTypeName(); String otherType = ((ClassInstruction) other).getTypeName(); return (type == null) || (otherType == null) || type.equals(otherType); }
case Constants.CHECKCAST: case Constants.INSTANCEOF: return new ClassInstruction(this, opcode); case Constants.NEWARRAY: return new NewArrayInstruction(this);
void read(Instruction other) { super.read(other); setType(((ClassInstruction) other).getTypeName()); }
public TypedInstruction setType(String type) { if (type == null) _index = 0; else { type = getProject().getNameCache().getInternalForm(type, false); _index = getPool().findClassEntry(type, true); } return this; }
public void enterClassInstruction(ClassInstruction obj) { _out.print(obj.getTypeIndex() + " <" + obj.getTypeName() + ">"); }
public int getStackChange() { if (getOpcode() == Constants.NEW) return 1; return 0; }
/** * ClassInstructions are equal if the type they reference is the same or * unset and if their opcodes are equal. */ public boolean equalsInstruction(Instruction other) { if (other == this) return true; if (!super.equalsInstruction(other)) return false; String type = getTypeName(); String otherType = ((ClassInstruction) other).getTypeName(); return (type == null) || (otherType == null) || type.equals(otherType); }
case Constants.CHECKCAST: case Constants.INSTANCEOF: return new ClassInstruction(this, opcode); case Constants.NEWARRAY: return new NewArrayInstruction(this);
/** * Helper method to add the code necessary to throw the given * exception type, sans message. */ private Instruction throwException(Code code, Class type) { Instruction ins = code.anew().setType(type); code.dup(); code.invokespecial().setMethod(type, "<init>", void.class, null); code.athrow(); return ins; }
public String getTypeName() { if (_index == 0) return null; ClassEntry entry = (ClassEntry) getPool().getEntry(_index); return getProject().getNameCache().getExternalForm(entry. getNameEntry().getValue(), false); }
int getLength() { return super.getLength() + 1; }
/** * Two MultiANewArray instructions are equal if they have the same * type and dimensions, or if the type and dimensions of either is unset. */ public boolean equalsInstruction(Instruction other) { if (other == this) return true; if (!(other instanceof MultiANewArrayInstruction)) return false; if (!super.equalsInstruction(other)) return false; MultiANewArrayInstruction ins = (MultiANewArrayInstruction) other; int dims = getDimensions(); int otherDims = ins.getDimensions(); return dims == -1 || otherDims == -1 || dims == otherDims; }
/** * Throw an exception of the given type. */ protected Instruction throwException(Code code, Class type) { Instruction ins = code.anew().setType(type); code.dup(); code.invokespecial().setMethod(type, "<init>", void.class, null); code.athrow(); return ins; }