TechTrader Bytecode Toolkit

com.techtrader.modules.tools.bytecode
Class ConvertInstruction

java.lang.Object
  |
  +--com.techtrader.modules.tools.bytecode.Instruction
        |
        +--com.techtrader.modules.tools.bytecode.ConvertInstruction

public class ConvertInstruction
extends Instruction

Represents one of the conversion opcodes defined in the Constants interface for converting between primitive types. Changing the types of the instruction will automatically update the underlying opcode. If converting from one type to the same type will result in a NOP. Note that the result of conversions not supported directly by the JVM (i.e. char to double) is undefined.

Author:
Abe White

Fields inherited from class com.techtrader.modules.tools.bytecode.Instruction
_byteIndex, _opcode, _opcodeTypes, _owner
 
Constructor Summary
protected ConvertInstruction(Code owner)
           
protected ConvertInstruction(Code owner, int opcode, Class from, Class to)
           
 
Method Summary
 void acceptVisit(BCVisitor visit)
          Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this object.
protected  void copy(Instruction orig)
           
 boolean equals(Object other)
          ConvertInstructions are equal if they convert between the same types, or the types of either is unset.
 Class getFromType()
          Get the type of being converted from; will be one of: int, float, double, long.
 String getFromTypeName()
          Get the type of being converted from; will be one of: int, float, double, long.
 int getStackChange()
          Return the number of stack positions this instruction pushes or pops during its execution.
 Class getToType()
          Get the type being converted to; will be one of: int, float, double, long, byte, char, short.
 String getToTypeName()
          Get the type being converted to; will be one of: int, float, double, long, byte, char, short.
 ConvertInstruction setFromType(Class type)
          Set the type to convert from.
 ConvertInstruction setFromTypeName(String name)
          Set the type to convert from by name.
 ConvertInstruction setToType(Class type)
          Set the type to convert to.
 ConvertInstruction setToTypeName(String name)
          Set the type to convert to by name.
 
Methods inherited from class com.techtrader.modules.tools.bytecode.Instruction
getByteIndex, getLength, getName, getOpCode, getOwner, invalidate, readData, setByteIndex, setOpCode, writeData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertInstruction

protected ConvertInstruction(Code owner)

ConvertInstruction

protected ConvertInstruction(Code owner,
                             int opcode,
                             Class from,
                             Class to)
Method Detail

getFromType

public Class getFromType()
Get the type of being converted from; will be one of: int, float, double, long. If the type has not been set, this method will return null.

getFromTypeName

public String getFromTypeName()
Get the type of being converted from; will be one of: int, float, double, long. If the type has not been set, this method will return null.

setFromType

public ConvertInstruction setFromType(Class type)
Set the type to convert from. Types without direct support are demoted to int.class.
Returns:
this Instruction, for method chaining

setFromTypeName

public ConvertInstruction setFromTypeName(String name)
Set the type to convert from by name.
Returns:
this Instruction, for method chaining
See Also:
setFromType(java.lang.Class)

getToType

public Class getToType()
Get the type being converted to; will be one of: int, float, double, long, byte, char, short. If the type has not been set, this method will return null.

getToTypeName

public String getToTypeName()
Get the type being converted to; will be one of: int, float, double, long, byte, char, short. If the type has not been set, this method will return null.

setToType

public ConvertInstruction setToType(Class type)
Set the type to convert to. Types without direct support are demoted to int.class.
Returns:
this Instruction, for method chaining

setToTypeName

public ConvertInstruction setToTypeName(String name)
Set the type to convert to by name.
Returns:
this Instruction, for method chaining
See Also:
setToType(java.lang.Class)

equals

public boolean equals(Object other)
ConvertInstructions are equal if they convert between the same types, or the types of either is unset.
Overrides:
equals in class Instruction

getStackChange

public int getStackChange()
Description copied from class: Instruction
Return the number of stack positions this instruction pushes or pops during its execution.
Overrides:
getStackChange in class Instruction
Tags copied from class: Instruction
Returns:
0 if the stack is not affected by this instruction, a positive number if it pushes onto the stack, and a negative number if it pops from the stack

copy

protected void copy(Instruction orig)
Overrides:
copy in class Instruction

acceptVisit

public void acceptVisit(BCVisitor visit)
Description copied from interface: VisitAcceptor
Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this object.
Overrides:
acceptVisit in class Instruction

TechTrader Bytecode Toolkit