Record Class FieldForVarnode

java.lang.Object
java.lang.Record
ghidra.pcode.emu.jit.gen.FieldForVarnode
Record Components:
vn - the varnode to pre-construct
All Implemented Interfaces:
FieldReq, StaticFieldReq

public record FieldForVarnode(Varnode vn) extends Record implements StaticFieldReq
A field request for a pre-constructed varnode

These are used to invoke userops using the Standard strategy.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a FieldForVarnode record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    generateClinitCode(JitCodeGenerator gen, org.objectweb.asm.ClassVisitor cv, org.objectweb.asm.MethodVisitor sv)
    Emit the field declaration and its initialization bytecode
    void
    generateLoadCode(JitCodeGenerator gen, org.objectweb.asm.MethodVisitor rv)
    Emit code to load the field onto the JVM stack
    final int
    Returns a hash code value for this object.
    Derive a suitable name for the field
    final String
    Returns a string representation of this record class.
    vn()
    Returns the value of the vn record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FieldForVarnode

      public FieldForVarnode(Varnode vn)
      Creates an instance of a FieldForVarnode record class.
      Parameters:
      vn - the value for the vn record component
  • Method Details

    • name

      public String name()
      Description copied from interface: FieldReq
      Derive a suitable name for the field
      Specified by:
      name in interface FieldReq
      Returns:
      the name
    • generateClinitCode

      public void generateClinitCode(JitCodeGenerator gen, org.objectweb.asm.ClassVisitor cv, org.objectweb.asm.MethodVisitor sv)
      Emit the field declaration and its initialization bytecode

      The declaration is emitted into the class definition, and the initialization code is emitted into the class initializer.

      Consider the varnode (ram:00400000,4). The code is equivalent to:

       private static final Varnode VARNODE_ram_400000_4 = createVarnode(ADDRESS_FACTORY, "ram", 0x400000, 4);
       
      Specified by:
      generateClinitCode in interface StaticFieldReq
      Parameters:
      gen - the code generator
      cv - the visitor for the class definition
      sv - the visitor for the class (static) initializer
    • generateLoadCode

      public void generateLoadCode(JitCodeGenerator gen, org.objectweb.asm.MethodVisitor rv)
      Emit code to load the field onto the JVM stack

      To clarify, this does not load a varnode's current value onto the JVM stack. That is done by VarGen. This loads a ref to the Varnode instance. Also, it's not precisely the same instance as given, but a re-construction of it as a plain Varnode, i.e., just the (space,offset,size) triple.

      Specified by:
      generateLoadCode in interface FieldReq
      Parameters:
      gen - the code generator
      rv - the visitor often for the run method, but could be the static initializer or constructor
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • vn

      public Varnode vn()
      Returns the value of the vn record component.
      Returns:
      the value of the vn record component