Package com.tonic.analysis.instruction
Class NewPrimitiveArrayInstruction
- java.lang.Object
-
- com.tonic.analysis.instruction.Instruction
-
- com.tonic.analysis.instruction.NewPrimitiveArrayInstruction
-
public class NewPrimitiveArrayInstruction extends Instruction
Represents the NEWARRAY instruction (0xBC).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNewPrimitiveArrayInstruction.ArrayTypeThe primitive element types NEWARRAY can allocate, each pairing an atype code with a description.
-
Constructor Summary
Constructors Constructor Description NewPrimitiveArrayInstruction(int opcode, int offset, int typeCode, int count)Constructs a NewPrimitiveArrayInstruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(AbstractBytecodeVisitor visitor)Accepts a visitor for bytecode analysis.NewPrimitiveArrayInstruction.ArrayTypegetArrayType()intgetCount()intgetLocalChange()Returns the change in local variables caused by this instruction.intgetStackChange()Returns the change in stack size caused by this instruction.intgetTypeCode()StringtoString()Returns a string representation of the instruction.voidwrite(DataOutputStream dos)Writes the NEWARRAY opcode and its operand to the DataOutputStream.-
Methods inherited from class com.tonic.analysis.instruction.Instruction
getLength, getOffset, getOpcode, setOffset
-
-
-
-
Constructor Detail
-
NewPrimitiveArrayInstruction
public NewPrimitiveArrayInstruction(int opcode, int offset, int typeCode, int count)Constructs a NewPrimitiveArrayInstruction.- Parameters:
opcode- The opcode of the instruction.offset- The bytecode offset of the instruction.typeCode- The type code of the array elements.count- The number of elements in the array.- Throws:
IllegalArgumentException- if the opcode is not NEWARRAY (0xBC)
-
-
Method Detail
-
getArrayType
public NewPrimitiveArrayInstruction.ArrayType getArrayType()
- Returns:
- the array type
-
getTypeCode
public int getTypeCode()
- Returns:
- the type code
-
getCount
public int getCount()
- Returns:
- the count
-
accept
public void accept(AbstractBytecodeVisitor visitor)
Description copied from class:InstructionAccepts a visitor for bytecode analysis.- Specified by:
acceptin classInstruction- Parameters:
visitor- The visitor to accept.
-
write
public void write(DataOutputStream dos) throws IOException
Writes the NEWARRAY opcode and its operand to the DataOutputStream.- Specified by:
writein classInstruction- Parameters:
dos- The DataOutputStream to write to.- Throws:
IOException- If an I/O error occurs.
-
getStackChange
public int getStackChange()
Returns the change in stack size caused by this instruction.- Specified by:
getStackChangein classInstruction- Returns:
- The stack size change: pops the element count and pushes the array reference (net 0).
-
getLocalChange
public int getLocalChange()
Returns the change in local variables caused by this instruction.- Specified by:
getLocalChangein classInstruction- Returns:
- The local variables size change (none).
-
toString
public String toString()
Returns a string representation of the instruction.- Overrides:
toStringin classInstruction- Returns:
- The mnemonic and array type of the instruction.
-
-