Record Class IntInIntHandler

java.lang.Object
java.lang.Record
ghidra.pcode.emu.jit.alloc.IntInIntHandler
Record Components:
local - see local()
type - see type()
vn - see vn() (wrt. the sub variable)
byteShift - see byteShift()
All Implemented Interfaces:
SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>, VarHandler

public record IntInIntHandler(JvmLocal<Types.TInt,JitType.IntJitType> local, JitType.IntJitType type, Varnode vn, int byteShift) extends Record implements SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>
The handler for an int p-code variable stored in part of a JVM int.
  • Constructor Details

    • IntInIntHandler

      public IntInIntHandler(JvmLocal<Types.TInt,JitType.IntJitType> local, JitType.IntJitType type, Varnode vn, int byteShift)
      Creates an instance of a IntInIntHandler record class.
      Parameters:
      local - the value for the local record component
      type - the value for the type record component
      vn - the value for the vn record component
      byteShift - the value for the byteShift record component
  • Method Details

    • getConvToSub

      Description copied from interface: SubVarHandler
      Get the converter of multi-precision integers to the type of the sub variable.

      The converter need not worry about positioning or masking wrt. the sub variable. It should extract from the multi-precision integer the minimum number of legs needed to fill the sub variable, i.e., it need only consider the sub variable's size. This handler will then mask and position it within the containing variable for storage.

      Specified by:
      getConvToSub in interface SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>
      Returns:
      the converter
    • genLoadToStack

      public <TT extends Types.BPrim<?>, TJT extends JitType.SimpleJitType<TT, TJT>, N extends Emitter.Next> Emitter<Emitter.Ent<N,TT>> genLoadToStack(Emitter<N> em, JitCodeGenerator<?> gen, TJT type, Opnd.Ext ext)
      Description copied from interface: VarHandler
      Emit bytecode to load the varnode's value onto the JVM stack.
      Specified by:
      genLoadToStack in interface VarHandler
      Type Parameters:
      TT - the JVM type of the value to load onto the stack
      TJT - the p-code type of the value to load onto the stack
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      gen - the code generator
      type - the p-code type of the value expected on the JVM stack by the proceeding bytecode
      ext - the kind of extension to apply when adjusting from JVM size to varnode size
      Returns:
      the emitter typed with the resulting stack
    • genLoadLegToStack

      public <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genLoadLegToStack(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType type, int leg, Opnd.Ext ext)
      Description copied from interface: VarHandler
      Emit bytecode to load one leg of a multi-precision value from the varnode onto the JVM stack.
      Specified by:
      genLoadLegToStack in interface VarHandler
      Type Parameters:
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      gen - the code generator
      type - the p-code type of the complete multi-precision value
      leg - the index of the leg to load, 0 being least significant
      ext - the kind of extension to apply
      Returns:
      the emitter typed with the resulting stack, i.e., having the int leg pushed onto it
    • genLoadToBool

      public <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genLoadToBool(Emitter<N> em, JitCodeGenerator<?> gen)
      Description copied from interface: VarHandler
      Emit bytecode to load the varnode's value, interpreted as a boolean, as an integer onto the JVM stack.
      Specified by:
      genLoadToBool in interface VarHandler
      Type Parameters:
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      gen - the code generator
      Returns:
      the emitter typed with the resulting stack, i.e., having the int boolean pushed onto it
    • genStoreFromStack

      public <FT extends Types.BPrim<?>, FJT extends JitType.SimpleJitType<FT, FJT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, FT>> Emitter<N1> genStoreFromStack(Emitter<N0> em, JitCodeGenerator<?> gen, FJT type, Opnd.Ext ext, Scope scope)
      Description copied from interface: VarHandler
      Emit bytecode to store a value into a variable from the JVM stack.
      Specified by:
      genStoreFromStack in interface VarHandler
      Type Parameters:
      FT - the JVM type of the value on the stack
      FJT - the p-code type of the value on the stack
      N1 - the tail of the incoming stack
      N0 - the incoming stack having the value to store on top
      Parameters:
      em - the emitter typed with the incoming stack
      gen - the code generator
      type - the p-code type of the value on the stack
      ext - the kind of extension to apply
      scope - a scope for generating temporary local storage
      Returns:
      the emitter typed with the resulting stack, i.e., having popped the value
    • subpiece

      public VarHandler subpiece(Endian endian, int byteOffset, int maxByteSize)
      Description copied from interface: VarHandler
      Create a handler for a PcodeOp.SUBPIECE of a value.

      To implement subpiece, we could load the entire varnode and then extract the designated portion. Or, we could load only the designated portion, averting any code and execution cost of loading the un-designated portions. We accomplish this by re-writing the subpiece op and a load of the sub-varnode.

      Specified by:
      subpiece in interface VarHandler
      Parameters:
      endian - the endianness of the emulation target
      byteOffset - the number of least-significant bytes to remove
      maxByteSize - the maximum size of the resulting variable. In general, a subpiece should never exceed the size of the parent varnode, but if it does, this will truncate that excess.
      Returns:
      the resulting subpiece handler
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • local

      Returns the value of the local record component.
      Specified by:
      local in interface SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>
      Returns:
      the value of the local record component
    • type

      public JitType.IntJitType type()
      Returns the value of the type record component.
      Specified by:
      type in interface SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>
      Specified by:
      type in interface VarHandler
      Returns:
      the value of the type record component
    • vn

      public Varnode vn()
      Returns the value of the vn record component.
      Specified by:
      vn in interface VarHandler
      Returns:
      the value of the vn record component
    • byteShift

      public int byteShift()
      Returns the value of the byteShift record component.
      Specified by:
      byteShift in interface SubVarHandler<Types.TInt,JitType.IntJitType,Types.TInt,JitType.IntJitType>
      Returns:
      the value of the byteShift record component