本文整理汇总了Java中soot.jimple.NewExpr类的典型用法代码示例。如果您正苦于以下问题:Java NewExpr类的具体用法?Java NewExpr怎么用?Java NewExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NewExpr类属于soot.jimple包,在下文中一共展示了NewExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flowThrough
import soot.jimple.NewExpr; //导入依赖的package包/类
protected void flowThrough(HashMap<Local,Set<NewExpr>> in, Unit unit,
HashMap<Local,Set<NewExpr>> out)
{
Stmt s = (Stmt) unit;
out.clear();
out.putAll(in);
if (s instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt) s;
Value lhs = ds.getLeftOp();
Value rhs = ds.getRightOp();
if (lhs instanceof Local) {
HashSet<NewExpr> lv = new HashSet<NewExpr>();
out.put((Local) lhs, lv);
if (rhs instanceof NewExpr) {
lv.add((NewExpr) rhs);
} else if (rhs instanceof Local) {
lv.addAll(in.get(rhs));
} else lv.add(UNKNOWN);
}
}
}
示例2: jimplify
import soot.jimple.NewExpr; //导入依赖的package包/类
public void jimplify (DexBody body) {
Instruction21c i = (Instruction21c)instruction;
int dest = i.getRegisterA();
String className = dottedClassName(((TypeReference)(i.getReference())).toString());
RefType type = RefType.v(className);
NewExpr n = Jimple.v().newNewExpr(type);
assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), n);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
int op = (int)instruction.getOpcode().value;
//DalvikTyper.v().captureAssign((JAssignStmt)assign, op); // TODO: ref. type may be null!
DalvikTyper.v().setType(assign.getLeftOpBox(), type, false);
}
}
示例3: javafy_expr
import soot.jimple.NewExpr; //导入依赖的package包/类
private void javafy_expr(ValueBox vb) {
Expr e = (Expr) vb.getValue();
if (e instanceof BinopExpr)
javafy_binop_expr(vb);
else if (e instanceof UnopExpr)
javafy_unop_expr(vb);
else if (e instanceof CastExpr)
javafy_cast_expr(vb);
else if (e instanceof NewArrayExpr)
javafy_newarray_expr(vb);
else if (e instanceof NewMultiArrayExpr)
javafy_newmultiarray_expr(vb);
else if (e instanceof InstanceOfExpr)
javafy_instanceof_expr(vb);
else if (e instanceof InvokeExpr)
javafy_invoke_expr(vb);
else if (e instanceof NewExpr)
javafy_new_expr(vb);
}
示例4: javafy_new_expr
import soot.jimple.NewExpr; //导入依赖的package包/类
private void javafy_new_expr(ValueBox vb) {
NewExpr ne = (NewExpr) vb.getValue();
String className = ne.getBaseType().getSootClass().toString();
String packageName = ne.getBaseType().getSootClass().getJavaPackageName();
String classPackageName = packageName;
if (className.lastIndexOf('.') > 0) {// 0 doesnt make sense
classPackageName = className.substring(0, className.lastIndexOf('.'));
}
if(!packageName.equals(classPackageName))
throw new DecompilationException("Unable to retrieve package name for identifier. Please report to developer.");
addToImportList(className);
}
示例5: h2t
import soot.jimple.NewExpr; //导入依赖的package包/类
Type h2t(Unit h) {
if(h instanceof JAssignStmt){
JAssignStmt j = (JAssignStmt)h;
if(SootUtilities.isNewStmt(j)){
NewExpr ne = (NewExpr)j.rightBox.getValue();
return ne.getType();
}else if(SootUtilities.isNewArrayStmt(j)){
NewArrayExpr nae = (NewArrayExpr)j.rightBox.getValue();
return nae.getType();
}else if(SootUtilities.isNewMultiArrayStmt(j)){
JNewMultiArrayExpr jnmae = (JNewMultiArrayExpr)j.rightBox.getValue();
return jnmae.getType();
}
}
return null;
}
示例6: h2t
import soot.jimple.NewExpr; //导入依赖的package包/类
Type h2t(Unit h) {
if(h instanceof JAssignStmt){
JAssignStmt j = (JAssignStmt)h;
if(SootUtilities.isNewStmt(j)){
NewExpr ne = (NewExpr)j.rightBox.getValue();
return ne.getType();
}else if(SootUtilities.isNewArrayStmt(j)){
NewArrayExpr nae = (NewArrayExpr)j.rightBox.getValue();
return nae.getType();
}else if(SootUtilities.isNewMultiArrayStmt(j)){
JNewMultiArrayExpr jnmae = (JNewMultiArrayExpr)j.rightBox.getValue();
return jnmae.getType();
}
}
return null;
}
示例7: performMapping
import soot.jimple.NewExpr; //导入依赖的package包/类
private void performMapping(SootMethod meth, Map<Integer,String> anonymClasses) {
if(!meth.isConcrete())
return;
for(Unit u : meth.retrieveActiveBody().getUnits()){
Stmt stmt = (Stmt) u;
if(!(stmt instanceof AssignStmt))
continue;
Value rightOp = ((AssignStmt) stmt).getRightOp();
if(!(rightOp instanceof NewExpr))
continue;
String className = rightOp.getType().toString();
int lineNum = this.sourceInfo.stmtLineNum(stmt);
String anonymClassName = anonymClasses.get(lineNum);
if(anonymClassName == null)
continue;
String prevBinding = bcClNameToSrcClName.put(className, anonymClassName);
System.out.println("binding " + className + " " + anonymClassName);
if(prevBinding != null){
System.out.println("Multiple anonymous classes in the same line " + anonymClassName);
bcClNameToSrcClName.put(className, null);
}
}
}
示例8: analyse
import soot.jimple.NewExpr; //导入依赖的package包/类
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass();
if (type.hasTag(HostnameVerifierTag.NAME)) {
HostnameVerifierTag tag = (HostnameVerifierTag) type.getTag(HostnameVerifierTag.NAME);
vulnerabilities.add(new Vulnerability(method, VulnerabilityType.INIT_HOSTNAME_VERIFIER, tag.getState()));
}
}
});
}
}
}
示例9: analyse
import soot.jimple.NewExpr; //导入依赖的package包/类
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass();
if (type.hasTag(TrustManagerTag.NAME)) {
TrustManagerTag tag = (TrustManagerTag) type.getTag(TrustManagerTag.NAME);
vulnerabilities.add(new Vulnerability(method, VulnerabilityType.INIT_TRUST_MANAGER, tag.getState()));
}
}
});
}
}
}
示例10: methodIsAndroidStub
import soot.jimple.NewExpr; //导入依赖的package包/类
/**
* Checks whether the given method is a library stub method
* @param method The method to check
* @return True if the given method is an Android library stub, false
* otherwise
*/
private boolean methodIsAndroidStub(SootMethod method) {
if (!(Options.v().src_prec() == Options.src_prec_apk
&& method.getDeclaringClass().isLibraryClass()
&& SystemClassHandler.isClassInSystemPackage(
method.getDeclaringClass().getName())))
return false;
// Check whether there is only a single throw statement
for (Unit u : method.getActiveBody().getUnits()) {
if (u instanceof DefinitionStmt) {
DefinitionStmt defStmt = (DefinitionStmt) u;
if (!(defStmt.getRightOp() instanceof ThisRef)
&& !(defStmt.getRightOp() instanceof ParameterRef)
&& !(defStmt.getRightOp() instanceof NewExpr))
return false;
}
else if (u instanceof InvokeStmt) {
InvokeStmt stmt = (InvokeStmt) u;
// Check for exception constructor invocations
SootMethod callee = stmt.getInvokeExpr().getMethod();
if (!callee.getSubSignature().equals("void <init>(java.lang.String)"))
// Check for super class constructor invocation
if (!(method.getDeclaringClass().hasSuperclass()
&& callee.getDeclaringClass() == method.getDeclaringClass().getSuperclass()
&& callee.getName().equals("<init>")))
return false;
}
else if (!(u instanceof ThrowStmt))
return false;
}
return true;
}
示例11: caseNewExpr
import soot.jimple.NewExpr; //导入依赖的package包/类
public void caseNewExpr(NewExpr v) {
String oldName = varName;
suggestVariableName("type");
String typeName = varName;
ttp.setVariableName(varName);
v.getType().apply(ttp);
p.println("Value "+oldName+" = Jimple.v().newNewExpr("+typeName+");");
varName = oldName;
}
示例12: handleRefTypeAssignment
import soot.jimple.NewExpr; //导入依赖的package包/类
private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo out) {
Value left = assignStmt.getLeftOp();
Value right = assignStmt.getRightOp();
//unbox casted value
if(right instanceof JCastExpr) {
JCastExpr castExpr = (JCastExpr) right;
right = castExpr.getOp();
}
//if we have a definition (assignment) statement to a ref-like type, handle it,
if ( isAlwaysNonNull(right)
|| right instanceof NewExpr || right instanceof NewArrayExpr
|| right instanceof NewMultiArrayExpr || right instanceof ThisRef
|| right instanceof StringConstant || right instanceof ClassConstant
|| right instanceof CaughtExceptionRef) {
//if we assign new... or @this, the result is non-null
out.put(left,NON_NULL);
} else if(right==NullConstant.v()) {
//if we assign null, well, it's null
out.put(left, NULL);
} else if(left instanceof Local && right instanceof Local) {
out.put(left, out.get(right));
} else {
out.put(left, TOP);
}
}
示例13: merge
import soot.jimple.NewExpr; //导入依赖的package包/类
protected void merge(HashMap<Local,Set<NewExpr>> in1, HashMap<Local,Set<NewExpr>> in2, HashMap<Local,Set<NewExpr>> o)
{
for (Local l : locals) {
Set<NewExpr> l1 = in1.get(l), l2 = in2.get(l);
Set<NewExpr> out = o.get(l);
out.clear();
if (l1.contains(UNKNOWN) || l2.contains(UNKNOWN)) {
out.add(UNKNOWN);
} else {
out.addAll(l1); out.addAll(l2);
}
}
}
示例14: entryInitialFlow
import soot.jimple.NewExpr; //导入依赖的package包/类
protected HashMap<Local,Set<NewExpr>> entryInitialFlow()
{
HashMap<Local,Set<NewExpr>> m = new HashMap<Local,Set<NewExpr>>();
for (Local l : (Collection<Local>) locals) {
HashSet<NewExpr> s = new HashSet<NewExpr>();
s.add(UNKNOWN);
m.put(l, s);
}
return m;
}
示例15: newInitialFlow
import soot.jimple.NewExpr; //导入依赖的package包/类
protected HashMap<Local,Set<NewExpr>> newInitialFlow()
{
HashMap<Local,Set<NewExpr>> m = new HashMap<Local,Set<NewExpr>>();
for (Local l : (Collection<Local>) locals) {
HashSet<NewExpr> s = new HashSet<NewExpr>();
m.put(l, s);
}
return m;
}