TechTrader Bytecode Toolkit

com.techtrader.modules.tools.bytecode
Class CmpInstruction

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

public class CmpInstruction
extends Instruction

An instruction comparing two stack values that varies depending on the value type.

Author:
Abe White

Fields inherited from class com.techtrader.modules.tools.bytecode.Instruction
_byteIndex, _opcode, _opcodeTypes, _owner
 
Constructor Summary
protected CmpInstruction(Code owner)
           
protected CmpInstruction(Code owner, int opcode, Class type, int nan)
           
 
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)
          Two cmp instructions are equal if the type and NaN value they reference is equal or the type of either instruction is unset.
 int getNaNValue()
          Get the number that will be placed on the stack if this instruction is of type float or double and one of the operands is NaN.
 int getStackChange()
          Return the number of stack positions this instruction pushes or pops during its execution.
 Class getType()
          Get the type of value to operate on; this is one of: float, double, long.
 String getTypeName()
          Get the type of value to operate on; this is one of: float, double, long.
 void setNaNValue(int nan)
          Set the number that will be placed on the stack if this instruction is of type float or double and one of the operands is NaN.
 CmpInstruction setType(Class type)
          Set the type of value to operate on; primitives that have no direct support (byte, char, boolean, int) will be conerted to long.class.
 CmpInstruction setTypeName(String name)
          Set the type to load 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

CmpInstruction

protected CmpInstruction(Code owner)

CmpInstruction

protected CmpInstruction(Code owner,
                         int opcode,
                         Class type,
                         int nan)
Method Detail

getType

public Class getType()
Get the type of value to operate on; this is one of: float, double, long.

getTypeName

public String getTypeName()
Get the type of value to operate on; this is one of: float, double, long.

setType

public CmpInstruction setType(Class type)
Set the type of value to operate on; primitives that have no direct support (byte, char, boolean, int) will be conerted to long.class.
Returns:
this Instruction, for method chaining

setTypeName

public CmpInstruction setTypeName(String name)
Set the type to load by name.
Returns:
this Instruction, for method chaining
See Also:
setType(java.lang.Class)

getNaNValue

public int getNaNValue()
Get the number that will be placed on the stack if this instruction is of type float or double and one of the operands is NaN. The return value will be either 1 or -1.

setNaNValue

public void setNaNValue(int nan)
Set the number that will be placed on the stack if this instruction is of type float or double and one of the operands is NaN. The value must be either 1 or -1.

equals

public boolean equals(Object other)
Two cmp instructions are equal if the type and NaN value they reference is equal or the type of either instruction 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

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

copy

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

TechTrader Bytecode Toolkit