Record Class JitTypeModel.Contest

java.lang.Object
java.lang.Record
ghidra.pcode.emu.jit.analysis.JitTypeModel.Contest
Record Components:
counts - the initial count for each candidate (should just be empty)
Enclosing class:
JitTypeModel

protected static record JitTypeModel.Contest(Map<JitTypeBehavior,Integer> counts) extends Record
A contest to determine a type assignment
  • Constructor Details

    • Contest

      public Contest()
      Start a new contest
    • Contest

      protected Contest(Map<JitTypeBehavior,Integer> counts)
      Creates an instance of a Contest record class.
      Parameters:
      counts - the value for the counts record component
  • Method Details

    • vote

      public void vote(JitTypeBehavior candidate)
      Cast a vote for the given candidate
      Parameters:
      candidate - the candidate type
    • compareCandidateEntries

      public static int compareCandidateEntries(Map.Entry<JitTypeBehavior,Integer> ent1, Map.Entry<JitTypeBehavior,Integer> ent2)
      Compare the votes between two candidates, and select the winner

      The winner() method seeks the "max" candidate, so the vote counts are compared in the usual fashion. We need to invert the comparison of the types, though. JitTypeBehavior.INTEGER has a lower ordinal than JitTypeBehavior.FLOAT, but we want to ensure int is preferred, so we reverse that comparison.

      Parameters:
      ent1 - the first candidate-vote entry
      ent2 - the second candidate-vote entry
      Returns:
      -1 if the second wins, 1 if the first wins. 0 should never result, unless we're comparing a candidate with itself.
    • winner

      public JitTypeBehavior winner()
      Compute the winner of the contest
      Returns:
      the winner, or JitTypeBehavior.ANY if there are no entries
    • 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.
    • counts

      public Map<JitTypeBehavior,Integer> counts()
      Returns the value of the counts record component.
      Returns:
      the value of the counts record component