public MethodWriter(ClassDataItem.EncodedMethod encodedMethod, Method m, boolean isStatic, ConstPool cp) { this.encodedMethod = encodedMethod; this.parameterSize = m.getParameterTypes().length; this.cp = cp; this.method = m; this.isStatic = isStatic; }
public String[] getArgs() { return method.getParameterTypes(); }
static int countArgs(Method t) { int i = 0; for (String arg : t.getParameterTypes()) { char type = arg.charAt(0); if (type == 'J' || type == 'D') { i += 2; } else { i += 1; } } return i; }
public static int methodIns(Method m, boolean isStatic) { int a = isStatic ? 0 : 1; for (String t : m.getParameterTypes()) { switch (t.charAt(0)) { case 'J': case 'D': a += 2; break; default: a += 1; break; } } return a; }
static int countParameterRegisters(Method m, boolean isStatic) { int a = isStatic ? 0 : 1; for (String t : m.getParameterTypes()) { switch (t.charAt(0)) { case 'J': case 'D': a += 2; break; default: a += 1; break; } } return a; }
M(Method method, int totals, int ins, boolean isStatic) { this.locals = totals - ins; this.total = totals; String paramTypes[] = method.getParameterTypes(); paramNames = new String[paramTypes.length]; map = new int[ins]; int start = 0; if (!isStatic) { map[start] = -1; start++; } for (int i = 0; i < paramTypes.length; i++) { char t = paramTypes[i].charAt(0); map[start++] = i; if (t == 'J' || t == 'D') { map[start++] = i; } } } }
public CodeWriter(ClassDataItem.EncodedMethod encodedMethod, CodeItem codeItem, Method owner, boolean isStatic, ConstPool cp) { this.encodedMethod = encodedMethod; this.codeItem = codeItem; this.owner = owner; int in_reg_size = 0; if (!isStatic) { in_reg_size++; } for (String s : owner.getParameterTypes()) { switch (s.charAt(0)) { case 'J': case 'D': in_reg_size += 2; break; default: in_reg_size++; break; } } this.in_reg_size = in_reg_size; this.cp = cp; }
public static int reg2ParamIdx(Method m, int reg, int locals, boolean isStatic) { int x = reg - locals; if (x < 0) { return -1; } int a = isStatic ? 0 : 1; String[] parameterTypes = m.getParameterTypes(); for (int i = 0, parameterTypesLength = parameterTypes.length; i < parameterTypesLength; i++) { if (x == a) { return i; } String t = parameterTypes[i]; switch (t.charAt(0)) { case 'J': case 'D': a += 2; break; default: a += 1; break; } } return -1; }
@SuppressWarnings("unchecked") @Override public DexAnnotationAble visitParameterAnnotation(final int index) { if (parameterAnns == null) { parameterAnns = new List[method.getParameterTypes().length]; } return new DexAnnotationAble() { @Override public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { List<DexAnnotationNode> pas = parameterAnns[index]; if (pas == null) { pas = new ArrayList<DexAnnotationNode>(5); parameterAnns[index] = pas; } DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); pas.add(annotation); return annotation; } }; }
private ProtoIdItem uniqProto(Method method) { return uniqProto(method.getParameterTypes(), method.getReturnType()); }
codeItem.debugInfo.parameterNames=new StringIdItem[owner.getParameterTypes().length];
/** * @param isStatic * @param method */ public Dex2IrAdapter(boolean isStatic, Method method) { super(); IrMethod irMethod = new IrMethod(); irMethod.args = method.getParameterTypes(); irMethod.ret = method.getReturnType(); irMethod.owner = method.getOwner(); irMethod.name = method.getName(); irMethod.isStatic = isStatic; this.irMethod = irMethod; this.list = irMethod.stmts; this.irMethod = irMethod; this.method = method; this.isStatic = isStatic; }
public static String v(Method m) { return String.format("new Method(%s,%s,%s,%s)", v(m.getOwner()), v(m.getName()), v(m.getParameterTypes()), v(m.getReturnType())); } public static String v(Proto m) {
i++; for (String t : method.getParameterTypes()) { ps.add(locals[args[i]]); if (t.equals("J") || t.equals("D")) { case INVOKE_VIRTUAL_RANGE: case INVOKE_VIRTUAL: invoke = nInvokeVirtual(vs, method.getOwner(), method.getName(), method.getParameterTypes(), method.getReturnType()); break; case INVOKE_SUPER: case INVOKE_DIRECT: invoke = nInvokeSpecial(vs, method.getOwner(), method.getName(), method.getParameterTypes(), method.getReturnType()); break; case INVOKE_STATIC_RANGE: case INVOKE_STATIC: invoke = nInvokeStatic(vs, method.getOwner(), method.getName(), method.getParameterTypes(), method.getReturnType()); break; case INVOKE_INTERFACE_RANGE: case INVOKE_INTERFACE: invoke = nInvokeInterface(vs, method.getOwner(), method.getName(), method.getParameterTypes(), method.getReturnType()); break;
String type = method.getParameterTypes()[i]; String debugName = parameterNames == null ? null : i < parameterNames.size() ? parameterNames.get(i) : null; if (debugName != null) {
dcv.visitConstStmt(Op.CONST_4, 0, 0); if (t.getParameterTypes().length == 0) { dcv.visitConstStmt(Op.CONST_4, 1, 0); } else { dcv.visitConstStmt(Op.CONST, 1, t.getParameterTypes().length); dcv.visitTypeStmt(Op.NEW_ARRAY, 1, 1, "[Ljava/lang/Object;"); for (int i = 0; i < t.getParameterTypes().length; i++) { char type = t.getParameterTypes()[i].charAt(0); dcv.visitConstStmt(Op.CONST, 2, i); box(type, argStart, 3, dcv);
case INVOKE_VIRTUAL: invoke = nInvokeVirtual(vs, method.getOwner(), method.getName(), method .getParameterTypes(), method.getReturnType()); break; case INVOKE_DIRECT: invoke = nInvokeSpecial(vs, method.getOwner(), method.getName(), method .getParameterTypes(), method.getReturnType()); break; case INVOKE_STATIC: invoke = nInvokeStatic(vs, method.getOwner(), method.getName(), method .getParameterTypes(), method.getReturnType()); break; case INVOKE_INTERFACE: invoke = nInvokeInterface(vs, method.getOwner(), method.getName(), method .getParameterTypes(), method.getReturnType()); break;
@Override public void visitRegister(int total) { Local[] locals = new Local[total]; this.locals = locals; this.tmpLocal = new Local(total); for (int i = 0; i < locals.length; i++) { locals[i] = new Local(i); } int nextReg = total - countParameterRegisters(method, isStatic); int nextReg0 = nextReg; if (!isStatic) {// is not static x(Stmts.nIdentity(locals[nextReg], Exprs.nThisRef(method.getOwner()))); nextReg++; } String[] args = method.getParameterTypes(); for (int i = 0; i < args.length; i++) { String t = args[i]; x(Stmts.nIdentity(locals[nextReg], Exprs.nParameterRef(t, i))); nextReg++; if (t.equals("J") || t.equals("D")) { nextReg++; } } // simple fix for issue 219, init all tmp register to 0 at the start of insn. for (int i = 0; i < nextReg0; i++) { x(Stmts.nAssign(locals[i], nInt(0))); } x(Stmts.nAssign(tmpLocal, nInt(0))); }
String[] parameterTypes = t.getParameterTypes(); for (int i1 = 0; i1 < parameterTypes.length; i1++) { String argType = parameterTypes[i1];
if (mapTo != null) { final Method t = new Method( method.getOwner(), buildMethodAName(method.getName()), method.getParameterTypes(), method .getReturnType() );