/** * Checks if all parameters and return value of a method have primitive types. * * @param mtd Method. * @return boolean True if all parameters and return value are of primitive type, otherwise false. */ private static boolean isAllPrimitiveTypes(IMethod mtd) { if (!mtd.getReturnType().isPrimitiveType()) return false; for (int i = (mtd.isStatic() ? 0 : 1); i < mtd.getNumberOfParameters(); i++) { if (!mtd.getParameterType(i).isPrimitiveType()) return false; } return true; }
/** * Get astubx style method signature. {FullyQualifiedEnclosingType}: {UnqualifiedMethodReturnType} * {methodName} ([{UnqualifiedArgumentType}*]) * * @param mtd Method reference. * @return String Method signature. */ // TODO: handle generics and inner classes private static String getSignature(IMethod mtd) { String classType = mtd.getDeclaringClass().getName().toString().replaceAll("/", "\\.").substring(1); classType = classType.replaceAll("\\$", "\\."); // handle inner class String returnType = mtd.isInit() ? null : getSimpleTypeName(mtd.getReturnType()); String strArgTypes = ""; int argi = mtd.isStatic() ? 0 : 1; // Skip 'this' parameter for (; argi < mtd.getNumberOfParameters(); argi++) { strArgTypes += getSimpleTypeName(mtd.getParameterType(argi)); if (argi < mtd.getNumberOfParameters() - 1) strArgTypes += ", "; } return classType + ":" + (returnType == null ? "void " : returnType + " ") + mtd.getName().toString() + "(" + strArgTypes + ")"; } /**
String sign = ""; if (mtd.getNumberOfParameters() > (mtd.isStatic() ? 0 : 1)) {
method.isStatic() ? 1 : 2; // 1-indexed; v1 is 'this' for non-static methods LOG(DEBUG, "DEBUG", "param value numbers : " + firstParamIndex + " ... " + numParam); while (!nodeQueue.isEmpty()) {
@Override public int getNumberOfParameters() { return getMethod().isStatic()? 0: 1; }
@Override public int getNumberOfParameters() { return getMethod().isStatic()? 0: 1; }
/** * Get the ssa-number for a parameter to an IMethod. * * @see com.ibm.wala.util.ssa.ParameterAccessor */ private static int ssaFor(IMethod inCallTo, int paramNo) { assert (paramNo >= 0); assert (paramNo < inCallTo.getNumberOfParameters()); if (inCallTo.isStatic()) { return paramNo + 1; } else { return paramNo + 1; // TODO 2 or 1? } }
/** * Get the ssa-number for a parameter to an IMethod. * * @see com.ibm.wala.util.ssa.ParameterAccessor */ private static int ssaFor(IMethod inCallTo, int paramNo) { assert (paramNo >= 0); assert (paramNo < inCallTo.getNumberOfParameters()); if (inCallTo.isStatic()) { return paramNo + 1; } else { return paramNo + 1; // TODO 2 or 1? } }
public static ParameterState createDefault(IMethod m) { ParameterState p = new ParameterState(); if (!m.isStatic()) { // set this pointer to NOT_NULL p.setState(0, State.NOT_NULL); } return p; }
public static ParameterState createDefault(IMethod m) { ParameterState p = new ParameterState(); if (!m.isStatic()) { // set this pointer to NOT_NULL p.setState(0, State.NOT_NULL); } return p; }
@Override public PointerKey getPointerKeyForLocal(CGNode node, int valueNumber) { if (!node.getMethod().isStatic() && valueNumber == 1) { return delegate.getFilteredPointerKeyForLocal(node, valueNumber, getFilter(node)); } else { return delegate.getPointerKeyForLocal(node, valueNumber); } }
@Override public TypeReference[] getParameterTypes(int i) { assert i == 0; if (getMethod().isStatic()) { return new TypeReference[0]; } else { return new TypeReference[] { getMethod().getDeclaringClass().getReference() }; } }
@Override public TypeReference[] getParameterTypes(int i) { assert i == 0; if (getMethod().isStatic()) { return new TypeReference[0]; } else { return new TypeReference[] { getMethod().getDeclaringClass().getReference() }; } }
@Override public PointerKey getPointerKeyForLocal(CGNode node, int valueNumber) { if (!node.getMethod().isStatic() && valueNumber == 1) { return delegate.getFilteredPointerKeyForLocal(node, valueNumber, getFilter(node)); } else { return delegate.getPointerKeyForLocal(node, valueNumber); } }
/** * @return the receiver class for this method. */ private IClass getReceiverClass(IMethod method) { TypeReference formalType = method.getParameterType(0); IClass C = cha.lookupClass(formalType); if (method.isStatic()) { Assertions.UNREACHABLE("asked for receiver of static method " + method); } if (C == null) { Assertions.UNREACHABLE("no class found for " + formalType + " recv of " + method); } return C; }
/** * @return the receiver class for this method. */ private IClass getReceiverClass(IMethod method) { TypeReference formalType = method.getParameterType(0); IClass C = cha.lookupClass(formalType); if (method.isStatic()) { Assertions.UNREACHABLE("asked for receiver of static method " + method); } if (C == null) { Assertions.UNREACHABLE("no class found for " + formalType + " recv of " + method); } return C; }
@Override public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m){ CallSiteReference site = makeSite(0); if (site == null) { return null; } int functionVn = getMethod().isStatic()? -1: makeArgument(m, 0); int paramVns[] = new int[Math.min(0, getNumberOfParameters() - 1)]; for (int j = 0; j < paramVns.length; j++) { paramVns[j] = makeArgument(m, j + 1); } return ((ScriptFakeRoot) m).addDirectCall(functionVn, paramVns, site); } }
@Override public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m){ CallSiteReference site = makeSite(0); if (site == null) { return null; } int functionVn = getMethod().isStatic()? -1: makeArgument(m, 0); int paramVns[] = new int[Math.min(0, getNumberOfParameters() - 1)]; for (int j = 0; j < paramVns.length; j++) { paramVns[j] = makeArgument(m, j + 1); } return ((ScriptFakeRoot) m).addDirectCall(functionVn, paramVns, site); } }
/** * @return the receiver class for this method. */ private IClass getReceiverClass(IMethod method) { TypeReference formalType = method.getParameterType(0); IClass C = getClassHierarchy().lookupClass(formalType); if (method.isStatic()) { Assertions.UNREACHABLE("asked for receiver of static method " + method); } if (C == null) { Assertions.UNREACHABLE("no class found for " + formalType + " recv of " + method); } return C; }
/** * @return the receiver class for this method. */ private IClass getReceiverClass(IMethod method) { TypeReference formalType = method.getParameterType(0); IClass C = getClassHierarchy().lookupClass(formalType); if (method.isStatic()) { Assertions.UNREACHABLE("asked for receiver of static method " + method); } if (C == null) { Assertions.UNREACHABLE("no class found for " + formalType + " recv of " + method); } return C; }