1 19 20 25 26 27 28 29 30 package soot.baf.internal; 31 32 import soot.*; 33 import soot.jimple.*; 34 import soot.baf.*; 35 import soot.util.*; 36 import java.util.*; 37 38 public class BIncInst extends AbstractInst implements IncInst 39 { 40 ValueBox localBox; 41 ValueBox defLocalBox; 42 List useBoxes; 43 Constant mConstant; 44 List mDefBoxes; 45 46 private class LinkedBafLocalBox extends BafLocalBox 47 { 48 ValueBox otherBox = null; 49 50 private LinkedBafLocalBox(Value v) 51 { 52 super(v); 53 } 54 55 public void setOtherBox(ValueBox otherBox) 56 { 57 this.otherBox = otherBox; 58 } 59 60 public Value getValue() 61 { 62 Value toReturn = super.getValue(); 63 64 return toReturn; 65 } 66 67 public void setValue(Value v) 68 { 69 super.setValue(v); 70 71 if(otherBox != null) 72 { 73 if(otherBox.getValue() != v) 74 otherBox.setValue(v); 75 } 76 } 77 } 78 79 public BIncInst(Local local, Constant constant) 80 { 81 mConstant = constant; 82 83 localBox = new BafLocalBox(local); 84 85 useBoxes = new ArrayList(); 86 useBoxes.add(localBox); 87 useBoxes = Collections.unmodifiableList(useBoxes); 88 89 defLocalBox = new BafLocalBox(local); 90 91 94 mDefBoxes = new ArrayList(); 95 mDefBoxes.add(defLocalBox); 96 mDefBoxes = Collections.unmodifiableList(mDefBoxes); 97 98 } 99 100 public int getInCount() 101 { 102 return 0; 103 } 104 105 public Object clone() 106 { 107 return new BIncInst( getLocal(), getConstant()); 108 } 109 110 public int getInMachineCount() 111 { 112 return 0; 113 } 114 115 public int getOutCount() 116 { 117 return 0; 118 } 119 120 public int getOutMachineCount() 121 { 122 return 0; 123 } 124 125 126 127 128 public Constant getConstant() 129 { 130 return mConstant; 131 } 132 133 public void setConstant(Constant aConstant) 134 { 135 mConstant = aConstant; 136 } 137 138 139 140 final public String getName() { return "inc.i"; } 141 final String getParameters() 142 { return " "+ localBox.getValue().toString(); } 143 protected void getParameters(UnitPrinter up ) { 144 up.literal(" "); 145 localBox.toString(up); 146 } 147 148 public void apply(Switch sw) 149 { 150 ((InstSwitch) sw).caseIncInst(this); 151 } 152 153 public void setLocal(Local l) 154 { 155 localBox.setValue(l); 156 } 157 158 public Local getLocal() 159 { 160 return (Local) localBox.getValue(); 161 } 162 163 public List getUseBoxes() 164 { 165 return useBoxes; 166 } 167 168 public List getDefBoxes() 169 { 170 return mDefBoxes; 171 } 172 173 174 public String toString() 175 { 176 return "inc.i" + " " +getLocal() + " " + getConstant() ; 177 } 178 179 public void toString( UnitPrinter up ) { 180 up.literal( "inc.i" ); 181 up.literal( " " ); 182 localBox.toString( up ); 183 up.literal( " " ); 184 up.constant( mConstant ); 185 } 186 187 188 } 189 | Popular Tags |