001package daikon;
002
003import java.io.Serializable;
004import org.checkerframework.checker.lock.qual.GuardSatisfied;
005import org.checkerframework.dataflow.qual.Pure;
006import org.checkerframework.dataflow.qual.SideEffectFree;
007
008/**
009 * Used when no VarComparability information is available (in the {@code .dtrace} file). Every
010 * variable is considered comparable to every other variable.
011 */
012public final class VarComparabilityNone extends VarComparability implements Serializable {
013  static final long serialVersionUID = 20020122L;
014
015  // There is only one VarComparabilityNone object.
016  public static final VarComparabilityNone it = new VarComparabilityNone();
017
018  private VarComparabilityNone() {}
019
020  static VarComparabilityNone parse(String rep, ProglangType vartype) {
021    return it;
022  }
023
024  @Override
025  public VarComparability makeAlias() {
026    return it;
027  }
028
029  @Override
030  public VarComparability elementType(@GuardSatisfied VarComparabilityNone this) {
031    return it;
032  }
033
034  @Override
035  public VarComparability indexType(@GuardSatisfied VarComparabilityNone this, int dim) {
036    return it;
037  }
038
039  @Override
040  public VarComparability string_length_type() {
041    return it;
042  }
043
044  @Pure
045  @Override
046  public int hashCode(@GuardSatisfied VarComparabilityNone this) {
047    return 0;
048  }
049
050  @Override
051  public boolean alwaysComparable(@GuardSatisfied VarComparabilityNone this) {
052    return true;
053  }
054
055  /**
056   * The best we can do without comparability info is to check if the representation types in the
057   * data trace file are the same. This lets us compare integers to longs, but not integers to
058   * arrays.
059   */
060  @Pure
061  static boolean comparable(
062      @GuardSatisfied VarComparabilityNone vcomp1, @GuardSatisfied VarComparabilityNone vcomp2) {
063    return true;
064  }
065
066  @SideEffectFree
067  @Override
068  public String toString(@GuardSatisfied VarComparabilityNone this) {
069    return "no-comparability";
070  }
071}