}
public void caseIdentityStmt(IdentityStmt s) {
assignment(s);
}
private void assignment(DefinitionStmt s) {
Variable right = translateExpr(s.getRightOp());
if (s.getLeftOp() instanceof ArrayRef) {
// A[X] = B
ArrayRef array = (ArrayRef)s.getLeftOp();
if (((ArrayType)array.getBase().getType()).getElementType() instanceof RefLikeType) {
Variable left = context.getLocal(((Local)array.getBase()).getName());
cfg.addStatement(new ArrayWriteStm(left, right, context.getCurrentOrigin()));
// also write possible strings we can get from converting the argument using toString()
cfg.addStatement(addStringStatement(new ArrayWriteStringStm(left, null, context.getCurrentOrigin()), s.getRightOpBox()));
} else {
// ignore..
}
} else if (s.getLeftOp() instanceof FieldRef) {
// A.field = B
SootField sootField = ((FieldRef)s.getLeftOp()).getField();
Variable field = context.getField(sootField);
checkTypeAnnotation(context.getFieldSchemaType(sootField), right);
cfg.startBranch();
cfg.addStatement(new VarStm(field, right, context.getCurrentOrigin()));
cfg.useBranch();
cfg.useBranch(); // <-- second branch is empty for weak update
cfg.endBranch();
} else if (s.getLeftOp() instanceof Local) {
// var = B
Variable left = context.getLocal(((Local)s.getLeftOp()).getName());
cfg.addStatement(new VarStm(left, right, context.getCurrentOrigin()));
} else {
throw new RuntimeException("Unexpected assignment to " + s.getLeftOp().getClass());
}