soot.jimple.CaughtExceptionRef Java Examples

The following examples show how to use soot.jimple.CaughtExceptionRef. 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: ConstraintCollector.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
public void caseIdentityStmt(IdentityStmt stmt) {
	Value l = stmt.getLeftOp();
	Value r = stmt.getRightOp();

	if (l instanceof Local) {
		TypeVariable left = resolver.typeVariable((Local) l);

		if (!(r instanceof CaughtExceptionRef)) {
			TypeVariable right = resolver.typeVariable(r.getType());
			right.addParent(left);
		} else {
			List<RefType> exceptionTypes = TrapManager.getExceptionTypesOf(stmt, stmtBody);
			Iterator<RefType> typeIt = exceptionTypes.iterator();

			while (typeIt.hasNext()) {
				Type t = typeIt.next();

				resolver.typeVariable(t).addParent(left);
			}

			if (uses) {
				left.addParent(resolver.typeVariable(RefType.v("java.lang.Throwable")));
			}
		}
	}
}
 
Example #2
Source File: StmtVisitor.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void caseIdentityStmt(IdentityStmt stmt) {
	Value lhs = stmt.getLeftOp();
	Value rhs = stmt.getRightOp();
	if (rhs instanceof CaughtExceptionRef) {
		// save the caught exception with move-exception
		Register localReg = regAlloc.asLocal(lhs);
		
           addInsn(new Insn11x(Opcode.MOVE_EXCEPTION, localReg), stmt);

           this.insnRegisterMap.put(insns.get(insns.size() - 1), LocalRegisterAssignmentInformation.v(localReg, (Local)lhs));
	} else if (rhs instanceof ThisRef || rhs instanceof ParameterRef) {
		/* 
		 * do not save the ThisRef or ParameterRef in a local, because it always has a parameter register already.
		 * at least use the local for further reference in the statements
		 */
		Local localForThis = (Local) lhs;
		regAlloc.asParameter(belongingMethod, localForThis);
		
		parameterInstructionsList.add(LocalRegisterAssignmentInformation.v(regAlloc.asLocal(localForThis).clone(), localForThis));
	} else {
		throw new Error("unknown Value as right-hand side of IdentityStmt: " + rhs);
	}
}
 
Example #3
Source File: DavaBody.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
/**
 *  Construct an empty DavaBody 
 */

DavaBody(SootMethod m) {
	super(m);

	pMap = new HashMap<Integer, Value>();
	consumedConditions = new HashSet<Object>();
	thisLocals = new HashSet<Object>();
	synchronizedBlockFacts = new IterableSet<ExceptionNode>();
	exceptionFacts = new IterableSet<ExceptionNode>();
	monitorFacts = new IterableSet<AugmentedStmt>();
	importList = new IterableSet<String>();
	//packagesUsed = new IterableSet();
	caughtrefs = new LinkedList<CaughtExceptionRef>();

	controlLocal = null;
	constructorExpr = null;
}
 
Example #4
Source File: AsmMethodSource.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
private void convertLabel(LabelNode ln) {
	if (!trapHandlers.containsKey(ln))
		return;
	StackFrame frame = getFrame(ln);
	Operand[] out = frame.out();
	Operand opr;
	if (out == null) {
		CaughtExceptionRef ref = Jimple.v().newCaughtExceptionRef();
		Local stack = newStackLocal();
		DefinitionStmt as = Jimple.v().newIdentityStmt(stack, ref);
		opr = new Operand(ln, ref);
		opr.stack = stack;
		frame.out(opr);
		setUnit(ln, as);
	} else {
		opr = out[0];
	}
	push(opr);
}
 
Example #5
Source File: NullnessAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
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);
	}
}
 
Example #6
Source File: ValueTemplatePrinter.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void caseCaughtExceptionRef(CaughtExceptionRef v) {
	p.println("Value "+varName+" = Jimple.v().newCaughtExceptionRef();");
}
 
Example #7
Source File: DavaBody.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public List<CaughtExceptionRef> get_CaughtRefs() {
	return caughtrefs;
}
 
Example #8
Source File: UnitThrowAnalysis.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void caseCaughtExceptionRef(CaughtExceptionRef v) {
}