1 package alt.jiapi.util; 2 3 import alt.jiapi.reflect.Instruction; 4 import alt.jiapi.reflect.InstructionList; 5 import alt.jiapi.reflect.Signature; 6 import alt.jiapi.reflect.instruction.FieldAccess; 7 import alt.jiapi.reflect.instruction.Invocation; 8 9 31 public class HotSpot { 32 private Instruction startIns; 33 private Instruction endIns; 34 private InstructionList il; 35 36 42 public HotSpot(InstructionList il, Instruction ins) { 43 this(il, ins, ins); 44 } 45 46 53 public HotSpot(InstructionList il, Instruction start, Instruction end) { 54 this.il = il; 55 this.startIns = start; 56 this.endIns = end; 57 } 58 59 68 public InstructionList getInstructionList() { 69 int i1 = il.indexOf(startIns); 70 int i2 = il.indexOf(endIns); 71 72 return il.createView(i1, i2 + 1); 73 } 74 75 76 88 public InstructionList getArgumentList() { 89 int i1 = il.indexOf(startIns); 90 int i2 = il.indexOf(endIns); 91 92 return il.createView(i1, i2); 93 } 94 95 96 104 public Instruction getHotSpotInstruction() { 105 return endIns; 106 } 107 108 127 public String getName() { 128 if (endIns instanceof Invocation) { 129 Invocation inv = (Invocation)endIns; 130 StringBuffer sb = new StringBuffer (); 131 if (!"<init>".equals(inv.getMethodName())) { 132 sb.append(inv.getReturnType()); 133 sb.append(' '); 134 } 135 136 sb.append(inv.getClassName()); 137 sb.append('.'); 138 sb.append(inv.getMethodName()); 139 sb.append('('); 140 141 String [] params = inv.getParameterTypes(); 142 for (int i = 0; i < params.length; i++) { 143 sb.append(params[i]); 144 if (i < params.length - 1) { 145 sb.append(','); 146 } 147 } 148 sb.append(')'); 149 150 return sb.toString(); 151 } 152 else if (endIns instanceof FieldAccess) { 153 FieldAccess fa = (FieldAccess)endIns; 154 return fa.getClassName() + "." + fa.getFieldName(); 155 } 156 157 return ""; } 159 } 160 | Popular Tags |