1 19 20 package edu.umd.cs.findbugs.ba; 21 22 public class ReturnPath { 23 26 public static final int TOP = 0; 27 30 public static final int EXIT = 1; 31 34 public static final int UE = 2; 35 38 public static final int EXIT_UE = 3; 39 42 public static final int RETURNS = 4; 43 44 private int kind; 45 46 public ReturnPath(int kind) { 47 this.kind = kind; 48 } 49 50 public int getKind() { 51 return kind; 52 } 53 54 public void setKind(int kind) { 55 this.kind = kind; 56 } 57 58 public void copyFrom(ReturnPath other) { 59 this.kind = other.kind; 60 } 61 62 public boolean sameAs(ReturnPath other) { 63 return this.kind == other.kind; 64 } 65 66 private static final int[][] mergeMatrix = { 67 {TOP, }, {EXIT, EXIT, }, {UE, EXIT_UE, UE, }, {EXIT_UE, EXIT_UE, EXIT_UE, EXIT_UE, }, {RETURNS, RETURNS, RETURNS, RETURNS, RETURNS}, }; 74 75 public void mergeWith(ReturnPath other) { 76 int max = Math.max(this.kind, other.kind); 77 int min = Math.min(this.kind, other.kind); 78 this.kind = mergeMatrix[max][min]; 79 } 80 81 @Override 82 public String toString() { 83 switch (kind) { 84 case TOP: 85 return "[TOP]"; 86 case EXIT: 87 return "[EXIT]"; 88 case UE: 89 return "[UE]"; 90 case EXIT_UE: 91 return "[EXIT_UE]"; 92 case RETURNS: 93 return "[RETURNS]"; 94 default: 95 throw new IllegalStateException (); 96 } 97 } 98 } 99 100 | Popular Tags |