Java Code Examples for soot.jimple.InvokeExpr#getMethodRef()

The following examples show how to use soot.jimple.InvokeExpr#getMethodRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueTemplatePrinter.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void printInvokeExpr(InvokeExpr v) {
	p.openBlock();		
	
	String oldName = varName;
	SootMethodRef method = v.getMethodRef();
	SootMethod m = method.resolve();
		
	if(!m.isStatic()) {
		Local base= (Local)((InstanceInvokeExpr)v).getBase();
		p.println("Local base = localByName(b,\"" + base.getName()+ "\");");
	}		
	
	p.println("List<Type> parameterTypes = new LinkedList<Type>();");
	int i=0;
	for(Type t: (List<Type>)m.getParameterTypes()) {
		ttp.setVariableName("type"+i);
		t.apply(ttp);
		p.println("parameterTypes.add(type"+i+");");
		i++;
	}
	
	ttp.setVariableName("returnType");
	m.getReturnType().apply(ttp);
	
	p.print("SootMethodRef methodRef = ");
	p.printNoIndent("Scene.v().makeMethodRef(");
	String className = m.getDeclaringClass().getName();
	p.printNoIndent("Scene.v().getSootClass(\""+className+"\"),");
	p.printNoIndent("\""+m.getName()+"\",");
	p.printNoIndent("parameterTypes,");	
	p.printNoIndent("returnType,");
	p.printlnNoIndent(m.isStatic()+");");		
			
	printExpr(v, "base", "methodRef");

	varName = oldName;

	p.closeBlock();
}
 
Example 2
Source File: UseChecker.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void handleInvokeExpr(InvokeExpr ie, Stmt stmt)
{
	SootMethodRef m = ie.getMethodRef();

	if ( ie instanceof InstanceInvokeExpr )
	{
		InstanceInvokeExpr iie = (InstanceInvokeExpr)ie;
		iie.setBase(this.uv.visit(
			iie.getBase(),m.declaringClass().getType(), stmt));
	}

	for ( int i = 0; i < ie.getArgCount(); i++ )
		ie.setArg(i, this.uv.visit(
			ie.getArg(i), m.parameterType(i), stmt));
}