Package ghidra.pcode.emu.jit.analysis
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
A contest to determine a type assignment
-
Constructor Summary
ConstructorsModifierConstructorDescriptionContest()Start a new contestprotectedContest(Map<JitTypeBehavior, Integer> counts) Creates an instance of aContestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareCandidateEntries(Map.Entry<JitTypeBehavior, Integer> ent1, Map.Entry<JitTypeBehavior, Integer> ent2) Compare the votes between two candidates, and select the winnercounts()Returns the value of thecountsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.voidvote(JitTypeBehavior candidate) Cast a vote for the given candidatewinner()Compute the winner of the contest
-
Constructor Details
-
Contest
public Contest()Start a new contest -
Contest
Creates an instance of aContestrecord class.- Parameters:
counts- the value for thecountsrecord component
-
-
Method Details
-
vote
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 winnerThe
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.INTEGERhas a lower ordinal thanJitTypeBehavior.FLOAT, but we want to ensure int is preferred, so we reverse that comparison.- Parameters:
ent1- the first candidate-vote entryent2- 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
Compute the winner of the contest- Returns:
- the winner, or
JitTypeBehavior.ANYif there are no entries
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
counts
Returns the value of thecountsrecord component.- Returns:
- the value of the
countsrecord component
-