Record Class JvmLocal<T extends Types.BPrim<?>,JT extends JitType.SimpleJitType<T,JT>>

java.lang.Object
java.lang.Record
ghidra.pcode.emu.jit.alloc.JvmLocal<T,JT>
Type Parameters:
T - the JVM type of this local
JT - the p-code type of this local
Record Components:
local - the declared local this wraps
type - a type for this local
vn - the varnode whose value this local holds
opnd - this local as an operand

public record JvmLocal<T extends Types.BPrim<?>,JT extends JitType.SimpleJitType<T,JT>>(Local<T extends Types.BPrim<?>> local, JT extends JitType.SimpleJitType<T,JT> type, Varnode vn, SimpleOpnd<T extends Types.BPrim<?>,JT extends JitType.SimpleJitType<T,JT>> opnd) extends Record
An allocated JVM local
  • Constructor Details

    • JvmLocal

      public JvmLocal(Local<T> local, JT type, Varnode vn, SimpleOpnd<T,JT> opnd)
      Creates an instance of a JvmLocal 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
      opnd - the value for the opnd record component
  • Method Details

    • of

      public static <T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>> JvmLocal<T,JT> of(Local<T> local, JT type, Varnode vn)
      Create a JvmLocal with the given local, type, and varnode
      Type Parameters:
      T - the JVM type of the local
      JT - the p-code type of the local
      Parameters:
      local - the local
      type - the p-code type of the local
      vn - the varnode to assign to the local
      Returns:
      the new local (wrapper)
    • name

      public String name()
      Get the name of the wrapped local
      Returns:
      the name
    • castOf

      public <TT extends Types.BPrim<?>, TJT extends JitType.SimpleJitType<TT, TJT>> JvmLocal<TT,TJT> castOf(TJT type)
      Cast this local to satisfy checkers when a type variable is known to be of a given type

      This will verify at runtime that the types are in fact identical.

      Type Parameters:
      TT - the "to" JVM type
      TJT - the "to" p-code type
      Parameters:
      type - the "to" p-code type
      Returns:
      this local as the given type
    • genInit

      public <N extends Emitter.Next> Emitter<N> genInit(Emitter<N> em, JitCodeGenerator<?> gen)
      Emit bytecode into the class constructor needed to access the varnode's actual value from the underlying PcodeExecutorState.
      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 incoming stack
    • 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)
      Emit bytecode to load this local's value onto the JVM stack as the given type
      Type Parameters:
      TT - the desired JVM type
      TJT - the desired p-code type
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      gen - the code generator
      type - the desired p-code type
      ext - the kind of extension to apply
      Returns:
      the emitter typed with the resulting stack, i.e., having pushed the value
    • 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)
      Emit bytecode to store the value on the JVM stack into the local
      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 with the value 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
    • genBirthCode

      public <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<N> genBirthCode(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen)
      Emit bytecode to bring this varnode into scope.

      This will copy the value from the state into the local variable.

      Type Parameters:
      THIS - the type of the compiled passage
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      localThis - a handle to the local holding the this reference
      gen - the code generator
      Returns:
      the emitter typed with the incoming stack
    • genRetireCode

      public <THIS extends JitCompiledPassage, N extends Emitter.Next> Emitter<N> genRetireCode(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen)
      Emit bytecode to take this varnode out of scope.

      This will copy the value from the local variable into the state.

      Type Parameters:
      THIS - the type of the compiled passage
      N - the incoming stack
      Parameters:
      em - the emitter typed with the incoming stack
      localThis - a handle to the local holding the this reference
      gen - the code generator
      Returns:
      the emitter typed with the incoming stack
    • maxPrimAddr

      public Address maxPrimAddr()
      Returns the maximum address that would be occupied by the full primitive type.
      Returns:
      the maximum address that would be occupied by the full primitive type
    • 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.
    • local

      public Local<T> local()
      Returns the value of the local record component.
      Returns:
      the value of the local record component
    • type

      public JT type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • vn

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

      public SimpleOpnd<T,JT> opnd()
      Returns the value of the opnd record component.
      Returns:
      the value of the opnd record component