1 19 20 25 26 27 28 29 30 31 32 package soot.coffi; 33 import java.io.*; 34 62 abstract class Instruction implements Cloneable { 63 64 65 public static final String argsep = " "; 66 67 public static final String LOCALPREFIX = "local_"; 68 70 71 public byte code; 72 75 public int label; 76 79 public String name; 80 81 82 public Instruction next; 83 84 public Instruction prev; 85 86 public boolean labelled; 87 88 public boolean branches; 89 90 public boolean calls; 91 92 public boolean returns; 93 94 95 public Instruction[] succs; 96 97 int originalIndex; 98 99 102 public Instruction(byte c) { 103 code = c; 104 next = null; 105 branches = false; 106 calls = false; 107 returns = false; 108 } 109 110 protected Object clone() throws CloneNotSupportedException { 111 112 return super.clone(); 113 114 } 115 116 117 public String toString() 118 { 119 return label +": "+name + "[" + originalIndex + "]"; 120 } 121 122 133 public abstract int parse(byte bc[],int index); 134 135 143 public abstract int compile(byte bc[],int index); 144 145 150 public void offsetToPointer(ByteCode bc) { } 151 152 153 159 public int nextOffset(int curr) { return curr+1; } 160 161 168 public Instruction[] branchpoints(Instruction next) 169 { 170 175 return null; 176 } 177 178 184 public void markCPRefs(boolean[] refs) { } 185 186 191 public void redirectCPRefs(short redirect[]) { } 192 193 196 public int hashCode() { 197 return (new Integer (label)).hashCode(); 198 } 199 200 204 public boolean equals(Instruction i) { 205 return (this == i); 206 210 } 211 212 221 public static short getShort(byte bc[],int index) { 222 short s,bh,bl; 223 bh = (short)(bc[index]); bl = (short)(bc[index+1]); 224 s = (short)(((bh<<8)&0xff00) | (bl&0xff)); 225 return s; 227 } 228 237 public static int getInt(byte bc[],int index) { 238 int i,bhh,bhl,blh,bll; 239 bhh = (((int)(bc[index]))<<24)&0xff000000; 240 bhl = (((int)(bc[index+1]))<<16)&0xff0000; 241 blh = (((int)(bc[index+2]))<<8)&0xff00; 242 bll = ((int)(bc[index+3]))&0xff; 243 i = bhh | bhl | blh | bll; 244 return i; 245 } 246 247 256 public static int shortToBytes(short s,byte bc[],int index) { 257 bc[index++] = (byte)((s>>8)&0xff); 258 bc[index++] = (byte)(s&0xff); 259 return index; 260 } 261 262 271 public static int intToBytes(int s,byte bc[],int index) { 272 bc[index++] = (byte)((s>>24)&0xff); 273 bc[index++] = (byte)((s>>16)&0xff); 274 bc[index++] = (byte)((s>>8)&0xff); 275 bc[index++] = (byte)(s&0xff); 276 return index; 277 } 278 279 283 public String toString(cp_info constant_pool[]) { 284 int i = ((int)code)&0xff; 285 if (name==null) name = "null???=" + Integer.toString(i); 286 return name; 287 } 288 } 289 | Popular Tags |