Package ghidra.pcode.emu.jit.analysis

# Interface JitType

All Known Subinterfaces:
  `JitType.SimpleJitType`

All Known Implementing Classes:
  `JitType.DoubleJitType`, `JitType.FloatJitType`, `JitType.IntJitType`, `JitType.LongJitType`, `JitType.MpFloatJitType`, `JitType.MpIntJitType`

public interface JitType
The p-code type of an operand.

A type is an integer of floating-point value of a specific size in bytes. All values and variables in p-code are just bit vectors. The operators interpret those vectors according to a `JitTypeBehavior`. While types only technically belong to the operands, we also talk about values, variables, and varnodes being assigned types, so that we can allocate suitable JVM locals.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static enum`
  `JitType.DoubleJitType`
  The p-code type for floating-point of size 8, i.e., that fits in a JVM double.
  `static enum`
  `JitType.FloatJitType`
  The p-code type for floating-point of size 4, i.e., that fits in a JVM float.
  `static final record`
  `JitType.IntJitType`
  The p-code types for integers of size 1 through 4, i.e., that fit in a JVM int.
  `static final record`
  `JitType.LongJitType`
  The p-code types for integers of size 5 through 8, i.e., that fit in a JVM long.
  `static final record`
  `JitType.MpFloatJitType`
  WIP: The p-code types for floats of size other than 4 and 8
  `static final record`
  `JitType.MpIntJitType`
  The p-code types for integers of size 9 and greater.
  `static interface`
  `JitType.SimpleJitType`
  A p-code type that can be represented in a single JVM variable.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static int`
  `compare(JitType t1, JitType t2)`
  Compare two types by preference.
  `JitType`
  `ext()`
  Extend this p-code type to the p-code type that fills its entire host JVM type.
  `static JitType`
  `forJavaType(Class<?> cls)`
  Identify the p-code type that is exactly represented by the given JVM type.
  `List<? extends JitType.SimpleJitType>`
  `legTypes()`
  Get the p-code type that describes the part of the variable in each leg
  `String`
  `nm()`
  Part of the name of a JVM local variable allocated for this type
  `int`
  `pref()`
  The preference for this type.
  `int`
  `size()`
  The size of this type

- ## Method Details

  - ### compare

    static int compare(JitType t1, JitType t2)
    Compare two types by preference. The type with the more preferred behavior then smaller size is preferred.
    Parameters:
      `t1` - the first type
      `t2` - the second type
    Returns:
      as in `Comparator.compare(Object, Object)`

  - ### forJavaType

    static JitType forJavaType(Class<?> cls)
    Identify the p-code type that is exactly represented by the given JVM type.

    This is used during Direct userop invocation to convert the arguments and return value.

    Parameters:
      `cls` - the primitive class (not boxed)
    Returns:
      the p-code type
    See Also:
      - `JitDataFlowUseropLibrary`

  - ### pref

    int pref()
    The preference for this type. Smaller is more preferred.
    Returns:
      the preference

  - ### nm

    String nm()
    Part of the name of a JVM local variable allocated for this type
    Returns:
      the "type" part of a JVM local's name

  - ### size

    int size()
    The size of this type
    Returns:
      the size in bytes

  - ### ext

    JitType ext()
    Extend this p-code type to the p-code type that fills its entire host JVM type.

    This is useful, e.g., when multiplying two `int3` values using `imul` that the result might be an `int4` and so may need additional conversion.

    Returns:
      the extended type

  - ### legTypes

    List<? extends JitType.SimpleJitType> legTypes()
    Get the p-code type that describes the part of the variable in each leg

    Each whole leg will have the type `JitType.IntJitType.I4`, and the partial leg, if applicable, will have its appropriate smaller integer type.

    Returns:
      the list of types, each fitting in a JVM int, in big-endian order.