Class ByteCodeForm
- java.lang.Object
-
- org.apache.commons.compress.harmony.unpack200.bytecode.forms.ByteCodeForm
-
- Direct Known Subclasses:
ByteForm,IincForm,LabelForm,LocalForm,NoArgumentForm,ReferenceForm,ShortForm,VariableInstructionForm
public abstract class ByteCodeForm extends java.lang.Object
Abstract byte code form.
-
-
Field Summary
Fields Modifier and Type Field Description protected static ByteCodeForm[]byteCodeArrayprotected static java.util.Map<java.lang.String,ByteCodeForm>byteCodesByNameprotected static booleanWIDENED
-
Constructor Summary
Constructors Constructor Description ByteCodeForm(int opcode, java.lang.String name)Constructs a new instance with the specified opcode and name.ByteCodeForm(int opcode, java.lang.String name, int[] rewrite)Constructs a new instance with the specified opcode, name, operandType and rewrite.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcalculateOperandPosition()intfirstOperandIndex()voidfixUpByteCodeTargets(ByteCode byteCode, CodeAttribute codeAttribute)The ByteCodeForm knows how to fix up a bytecode if it needs to be fixed up because it holds a Label bytecode.static ByteCodeFormget(int opcode)Gets a ByteCodeForm.java.lang.StringgetName()Gets the name.intgetOpcode()Gets the opcode.int[]getRewrite()Gets the rewrite array.int[]getRewriteCopy()Gets a copy of the rewrite array.booleanhasMultipleByteCodes()This method will answer true if the receiver is a multi-bytecode instruction (such as aload0_putfield_super); otherwise, it will answer false.booleanhasNoOperand()Tests whether this instance has an operand.booleannestedMustStartClassPool()intoperandLength()Gets the operand length.abstract voidsetByteCodeOperands(ByteCode byteCode, OperandManager operandManager, int codeLength)Sets the rewrite of the byteCode.java.lang.StringtoString()
-
-
-
Field Detail
-
WIDENED
protected static final boolean WIDENED
- See Also:
- Constant Field Values
-
byteCodeArray
protected static final ByteCodeForm[] byteCodeArray
-
byteCodesByName
protected static final java.util.Map<java.lang.String,ByteCodeForm> byteCodesByName
-
-
Constructor Detail
-
ByteCodeForm
public ByteCodeForm(int opcode, java.lang.String name)
Constructs a new instance with the specified opcode and name. Assume no rewrite.- Parameters:
opcode- index corresponding to the opcode's value.name- printable name of the opcode.
-
ByteCodeForm
public ByteCodeForm(int opcode, java.lang.String name, int[] rewrite)
Constructs a new instance with the specified opcode, name, operandType and rewrite.- Parameters:
opcode- index corresponding to the opcode's value.name- String printable name of the opcode.rewrite- Operand positions (which will later be rewritten in ByteCodes) are indicated by -1.
-
-
Method Detail
-
get
public static ByteCodeForm get(int opcode)
Gets a ByteCodeForm.- Parameters:
opcode- opcode index.- Returns:
- the matching ByteCodeForm at the given opcode.
-
calculateOperandPosition
protected void calculateOperandPosition()
-
firstOperandIndex
public int firstOperandIndex()
-
fixUpByteCodeTargets
public void fixUpByteCodeTargets(ByteCode byteCode, CodeAttribute codeAttribute)
The ByteCodeForm knows how to fix up a bytecode if it needs to be fixed up because it holds a Label bytecode.- Parameters:
byteCode- a ByteCode to be fixed upcodeAttribute- a CodeAttribute used to determine how the ByteCode should be fixed up.
-
getName
public java.lang.String getName()
Gets the name.- Returns:
- the name.
-
getOpcode
public int getOpcode()
Gets the opcode.- Returns:
- the opcode.
-
getRewrite
public int[] getRewrite()
Gets the rewrite array.- Returns:
- the rewrite array.
-
getRewriteCopy
public int[] getRewriteCopy()
Gets a copy of the rewrite array.- Returns:
- a copy of the rewrite array.
-
hasMultipleByteCodes
public boolean hasMultipleByteCodes()
This method will answer true if the receiver is a multi-bytecode instruction (such as aload0_putfield_super); otherwise, it will answer false.- Returns:
- boolean true if multibytecode, false otherwise
-
hasNoOperand
public boolean hasNoOperand()
Tests whether this instance has an operand.- Returns:
- whether this instance has an operand.
-
nestedMustStartClassPool
public boolean nestedMustStartClassPool()
-
operandLength
public int operandLength()
Gets the operand length.- Returns:
- the operand length.
-
setByteCodeOperands
public abstract void setByteCodeOperands(ByteCode byteCode, OperandManager operandManager, int codeLength) throws Pack200Exception
Sets the rewrite of the byteCode.- Parameters:
byteCode- ByteCode to be updated (!)operandManager- OperandTable from which to draw infocodeLength- Length of bytes (excluding this bytecode) from the beginning of the method. Used in calculating padding for some variable-length bytecodes (such as lookupswitch, tableswitch).- Throws:
Pack200Exception- if a type is not supported or an index not in the range [0,Integer.MAX_VALUE].
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-