use of soot.ArrayType in project soot by Sable.
the class Walker method outAMultiNewExpr.
public void outAMultiNewExpr(AMultiNewExpr node) {
LinkedList arrayDesc = node.getArrayDescriptor();
int descCnt = arrayDesc.size();
List sizes = new LinkedList();
Iterator it = arrayDesc.iterator();
while (it.hasNext()) {
AArrayDescriptor o = (AArrayDescriptor) it.next();
if (o.getImmediate() != null)
sizes.add(0, mProductions.removeLast());
else
break;
}
Type type = (Type) mProductions.removeLast();
ArrayType arrayType = ArrayType.v(type, descCnt);
mProductions.addLast(Jimple.v().newNewMultiArrayExpr(arrayType, sizes));
}
use of soot.ArrayType in project soot by Sable.
the class MethodNodeFactory method caseNewMultiArrayExpr.
@Override
public final void caseNewMultiArrayExpr(NewMultiArrayExpr nmae) {
ArrayType type = (ArrayType) nmae.getType();
AllocNode prevAn = pag.makeAllocNode(new Pair<Expr, Integer>(nmae, new Integer(type.numDimensions)), type, method);
VarNode prevVn = pag.makeLocalVarNode(prevAn, prevAn.getType(), method);
mpag.addInternalEdge(prevAn, prevVn);
setResult(prevAn);
while (true) {
Type t = type.getElementType();
if (!(t instanceof ArrayType))
break;
type = (ArrayType) t;
AllocNode an = pag.makeAllocNode(new Pair<Expr, Integer>(nmae, new Integer(type.numDimensions)), type, method);
VarNode vn = pag.makeLocalVarNode(an, an.getType(), method);
mpag.addInternalEdge(an, vn);
mpag.addInternalEdge(vn, pag.makeFieldRefNode(prevVn, ArrayElement.v()));
prevAn = an;
prevVn = vn;
}
}
use of soot.ArrayType in project soot by Sable.
the class DemandCSPointsTo method getCallTargetsForType.
protected Set<SootMethod> getCallTargetsForType(Type type, NumberedString methodStr, Type receiverType, Set<SootMethod> possibleTargets) {
if (!pag.getTypeManager().castNeverFails(type, receiverType))
return Collections.<SootMethod>emptySet();
if (type instanceof AnySubType) {
AnySubType any = (AnySubType) type;
RefType refType = any.getBase();
if (pag.getTypeManager().getFastHierarchy().canStoreType(receiverType, refType) || pag.getTypeManager().getFastHierarchy().canStoreType(refType, receiverType)) {
return possibleTargets;
} else {
return Collections.<SootMethod>emptySet();
}
}
if (type instanceof ArrayType) {
// we'll invoke the java.lang.Object method in this
// case
// Assert.chk(varNodeType.toString().equals("java.lang.Object"));
type = Scene.v().getSootClass("java.lang.Object").getType();
}
RefType refType = (RefType) type;
SootMethod targetMethod = null;
targetMethod = VirtualCalls.v().resolveNonSpecial(refType, methodStr);
return Collections.<SootMethod>singleton(targetMethod);
}
use of soot.ArrayType in project soot by Sable.
the class SparkLibraryHelper method caseArrayType.
/**
* A new local array will be created and connected to
* {@link SparkLibraryHelper#node} of type {@link ArrayType}. For this new
* local an allocation edge to a new array of its declared type will be
* added. If the {@link ArrayType#getElementType()} is still an array an
* allocation to a new array of this element type will be made and stored
* until the element type is a {@link RefType}. If this is the case an
* allocation to {@link AnySubType} of {@link ArrayType#baseType} will be
* made.
*/
@Override
public void caseArrayType(ArrayType type) {
Node array = node;
for (Type t = type; t instanceof ArrayType; t = ((ArrayType) t).getElementType()) {
ArrayType at = (ArrayType) t;
if (at.baseType instanceof RefType) {
// var tmpArray;
LocalVarNode localArray = pag.makeLocalVarNode(new Object(), t, method);
// x = tmpArray;
pag.addEdge(localArray, array);
// new T[]
AllocNode newArray = pag.makeAllocNode(new Object(), at, method);
// tmpArray = new T[]
pag.addEdge(newArray, localArray);
// tmpArray[i]
FieldRefNode arrayRef = pag.makeFieldRefNode(localArray, ArrayElement.v());
// var tmp
LocalVarNode local = pag.makeLocalVarNode(new Object(), at.getElementType(), method);
// tmpArray[i] = tmp
pag.addEdge(local, arrayRef);
// x = tmp
array = local;
if (at.numDimensions == 1) {
// new T()
AllocNode alloc = pag.makeAllocNode(new Object(), AnySubType.v((RefType) at.baseType), method);
// tmp = new T()
pag.addEdge(alloc, local);
}
}
}
}
Aggregations