1 19 20 25 26 package soot.jimple.toolkits.annotation.arraycheck; 27 28 class IntValueContainer 29 { 30 private static final int BOT = 0; 31 private static final int TOP = 1; 32 private static final int INT = 2; 33 34 private int type; 35 private int value; 36 37 public IntValueContainer() 38 { 39 this.type = BOT; 40 } 41 42 public IntValueContainer(int v) 43 { 44 this.type = INT; 45 this.value = v; 46 } 47 48 public boolean isBottom() 49 { 50 return (this.type == BOT); 51 } 52 53 public boolean isTop() 54 { 55 return (this.type == TOP); 56 } 57 58 public boolean isInteger() 59 { 60 return this.type == INT; 61 } 62 63 public int getValue() 64 { 65 if (this.type != INT) 66 throw new RuntimeException ("IntValueContainer: not integer type"); 67 68 return this.value; 69 } 70 71 public void setTop() 72 { 73 this.type = TOP; 74 } 75 76 public void setValue(int v) 77 { 78 this.type = INT; 79 this.value = v; 80 } 81 82 public void setBottom() 83 { 84 this.type = BOT; 85 } 86 87 public String toString() 88 { 89 if (type == BOT) 90 return "[B]"; 91 else 92 if (type == TOP) 93 return "[T]"; 94 else 95 return "["+value+"]"; 96 } 97 98 public boolean equals(Object other) 99 { 100 if (!(other instanceof IntValueContainer)) 101 return false; 102 103 IntValueContainer otherv = (IntValueContainer)other; 104 105 if ((this.type == INT) && (otherv.type == INT)) 106 return (this.value == otherv.value); 107 else 108 return (this.type == otherv.type) ; 109 } 110 111 public IntValueContainer dup() 112 { 113 IntValueContainer other = new IntValueContainer(); 114 other.type = this.type; 115 other.value = this.value; 116 117 return other; 118 } 119 } 120 121 | Popular Tags |