Java 类soot.jimple.NewMultiArrayExpr 实例源码

项目:JAADAS    文件:ValueTemplatePrinter.java   
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    p.openBlock();
    String oldName = varName; 

    ttp.setVariableName("arrayType");
    v.getType().apply(ttp);

    p.println("List<IntConstant> sizes = new LinkedList<IntConstant>();");
    int i=0;
    for(Value s: v.getSizes()) {
        this.suggestVariableName("size"+i);
        s.apply(this);
        i++;

        p.println("sizes.add(sizes"+i+");");
    }

    p.println("Value "+oldName+" = Jimple.v().newNewMultiArrayExpr(arrayType, sizes);");
    varName = oldName;
    p.closeBlock();
}
项目:JAADAS    文件:DavaBody.java   
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);
}
项目:JAADAS    文件:NullnessAnalysis.java   
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);
    }
}
项目:JAADAS    文件:ExprVisitor.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr nmae) {
    constantV.setOrigStmt(origStmt);
    // get array dimensions
    if (nmae.getSizeCount() > 255) {
        throw new RuntimeException("number of dimensions is too high (> 255) for the filled-new-array* opcodes: " + nmae.getSizeCount());
    }
    short dimensions = (short) nmae.getSizeCount();
    // get array base type
    ArrayType arrayType = ArrayType.v(nmae.getBaseType().baseType, dimensions);
    BuilderReference arrayTypeItem = DexPrinter.toTypeReference
            (arrayType, stmtV.getBelongingFile());
    // get the dimension size registers
    List<Register> dimensionSizeRegs = new ArrayList<Register>();
    for (int i = 0; i < dimensions; i++) {
        Value currentDimensionSize = nmae.getSize(i);
        Register currentReg = regAlloc.asImmediate(currentDimensionSize, constantV);
        dimensionSizeRegs.add(currentReg);
    }
    // create filled-new-array instruction, depending on the dimension sizes
    if (dimensions <= 5) {
        Register[] paddedRegs = pad35cRegs(dimensionSizeRegs);
           stmtV.addInsn(new Insn35c(Opcode.FILLED_NEW_ARRAY, dimensions, paddedRegs[0],
                   paddedRegs[1], paddedRegs[2], paddedRegs[3], paddedRegs[4], arrayTypeItem),
                   null);
    } else {
           stmtV.addInsn(new Insn3rc(Opcode.FILLED_NEW_ARRAY_RANGE, dimensionSizeRegs, dimensions,
                   arrayTypeItem), null);
    } // check for > 255 is done already
    // move the resulting array into the destination register
       stmtV.addInsn(new Insn11x(Opcode.MOVE_RESULT_OBJECT, destinationReg), origStmt);
}
项目:JAADAS    文件:UnitThrowAnalysis.java   
public void caseNewMultiArrayExpr(NewMultiArrayExpr expr) {
    result = result.add(mgr.RESOLVE_CLASS_ERRORS);
    for (int i = 0; i < expr.getSizeCount(); i++) {
    Value count = expr.getSize(i);
    if ((! (count instanceof IntConstant)) ||
        (((IntConstant) count).lessThan(INT_CONSTANT_ZERO)
                              .equals(INT_CONSTANT_ZERO))) {
        result = result.add(mgr.NEGATIVE_ARRAY_SIZE_EXCEPTION);
    }
    result = result.add(mightThrow(count));
    }
}
项目:petablox    文件:DomArrDimension.java   
@Override
public void visit(Value e) {
    if (e instanceof NewMultiArrayExpr) {
        MAXZ = ((NewMultiArrayExpr) e).getSizes().size();
        fill();
    }
}
项目:petablox    文件:RelNewMutliArrSize.java   
@Override
public void visit(Value e) { 
    if (e instanceof NewMultiArrayExpr) {
        NewMultiArrayExpr nmae = (NewMultiArrayExpr) e;
        for (int i = 0; i < nmae.getSizeCount(); i++) {
            add(nmae, i, nmae.getSize(i));
        }
    }
}
项目:petablox    文件:RelNewMutliArrExpr.java   
@Override
public void visit(Value e) { 
    if (e instanceof NewMultiArrayExpr) {
        NewMultiArrayExpr nmae = (NewMultiArrayExpr) e;
        add(e, e.getType(), nmae.getSizeCount());
    }
}
项目:jgs    文件:AnnotationValueSwitch.java   
/**
 * DOC
 * 
 * @see soot.jimple.ExprSwitch#caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr)
 */
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    for (int i = 0; i < v.getSizeCount(); i++) {
        v.getSize(i).apply(this);
    }
}
项目:jgs    文件:AnnotationValueSwitch.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    rightElement = RightElement.NEW_ARRAY;
    logger.finest("New Multiarray expression identified: " + callingStmt.toString());
    if (actualContext == StmtContext.ASSIGNRIGHT) {
        new InternalAnalyzerException();
    }
}
项目:vasco    文件:PointsToGraph.java   
/**
 * Assigns a root variable to a new object at a given allocation site.
 */
public void assignNew(Local lhs, AnyNewExpr allocSite) {

    // If creating a new string or class, re-use the constant site
    if (allocSite != SUMMARY_NODE) {
        if (allocSite.getType().equals(STRING_CONST.getType())) {
            allocSite = STRING_SITE;
        } else if (allocSite.getType().equals(CLASS_CONST.getType())) {
            allocSite = CLASS_SITE;
        }
    }

    // We do not handle multi-dimensional arrays in this version
    if (allocSite instanceof NewMultiArrayExpr) {
        allocSite = SUMMARY_NODE;
    }

    // Create this node in the heap, if it doesn't already exist
    newNode(allocSite, false);

    // Assign LHS to the new node
    Set<AnyNewExpr> target = new HashSet<AnyNewExpr>();
    target.add(allocSite);
    roots.put(lhs, Collections.unmodifiableSet(target));

    // Ensure reachability.
    gc();
}
项目:FuzzDroid    文件:JimpleExprVisitorImpl.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    throw new RuntimeException("todo");

}
项目:boomerang    文件:BackwardFlowFunctions.java   
private boolean isAllocationSite(Value val) {
  return (val instanceof StringConstant || val instanceof NewExpr || val instanceof NewArrayExpr || val instanceof NewMultiArrayExpr);
}
项目:JAADAS    文件:DavaBody.java   
private void javafy_newmultiarray_expr(ValueBox vb) {
    NewMultiArrayExpr nmae = (NewMultiArrayExpr) vb.getValue();
    for (int i = 0; i < nmae.getSizeCount(); i++)
        javafy(nmae.getSizeBox(i));
    vb.setValue(new DNewMultiArrayExpr(nmae.getBaseType(), nmae .getSizes()));
}
项目:bixie    文件:SootValueSwitch.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr arg0) {
    throw new RuntimeException("Must be handeled in SootStmtSwitch");
}
项目:bixie    文件:AssignmentTranslation.java   
public static void translateAssignment(SootStmtSwitch ss, Value lhs,
        Value rhs, Unit statement) {

    ProgramFactory pf = GlobalsCache.v().getPf();
    SootValueSwitch valueswitch = ss.getValueSwitch();

    if (rhs instanceof InvokeExpr) {
        InvokeExpr ivk = (InvokeExpr) rhs;
        InvokeTranslation
                .translateInvokeAssignment(ss, lhs, ivk, statement);
        return;
    }
    valueswitch.isLeftHandSide = true;
    lhs.apply(valueswitch);
    valueswitch.isLeftHandSide = false;
    Expression left = valueswitch.getExpression();

    Expression right;
    if (rhs instanceof NewExpr) {
        right = ss.createAllocatedVariable(((NewExpr) rhs).getBaseType());
    } else if (rhs instanceof NewArrayExpr) {
        NewArrayExpr nae = (NewArrayExpr) rhs;
        right = ss.createAllocatedVariable(nae.getType());
        nae.getSize().apply(valueswitch);
        Expression sizeexp = valueswitch.getExpression();
        // add the size expression.
        ss.addStatement(GlobalsCache.v().setArraySizeStatement(right,
                sizeexp));
    } else if (rhs instanceof NewMultiArrayExpr) {
        NewMultiArrayExpr nmae = (NewMultiArrayExpr) rhs;
        for (int i = 0; i < nmae.getSizeCount(); i++) {
            nmae.getSize(i).apply(valueswitch);
            // Expression sizeexp = valueswitch.getExpression();
            // TODO
            Log.debug("Mulit-arrays are not implemented!");
        }
        right = GlobalsCache.v().makeFreshGlobal(
                SootPrelude.v().getReferenceType(), true, true);
    } else if (rhs instanceof StringConstant) {
        StringConstant str = (StringConstant) rhs;

        // right = stringConstantMap.get(str);
        right = ss.createAllocatedVariable(rhs.getType());

        Expression[] indices = { right };
        // assign the size of the string to the appropriate field in the
        // $stringSizeHeapVariable array.
        translateAssignment(
                ss,
                SootPrelude.v().getStringSizeHeapVariable(),
                pf.mkArrayStoreExpression(SootPrelude.v()
                        .getStringSizeHeapVariable().getType(), SootPrelude
                        .v().getStringSizeHeapVariable(), indices, pf
                        .mkIntLiteral(Integer.toString(str.value.length()))));
    } else {
        rhs.apply(valueswitch);
        right = valueswitch.getExpression();
    }

    translateAssignment(ss, left, right);
}
项目:petablox    文件:FGStmtSwitch.java   
/** A new multi array statement */
protected void caseNewMultiArrayStmt( Local dest, NewMultiArrayExpr e ) {}
项目:petablox    文件:FGStmtSwitch.java   
public final void caseAssignStmt( AssignStmt s ) {
statement = s;
Value lhs = s.getLeftOp();
Value rhs = s.getRightOp();
if( ! (lhs.getType() instanceof RefType)
    &&  ! (lhs.getType() instanceof ArrayType) ) {
    if( rhs instanceof InvokeExpr ) {
        caseInvokeStmt( null, (InvokeExpr) rhs );
        return;
    }
    caseUninterestingStmt( s );
    return;
}
if( rhs instanceof InvokeExpr ) {
    caseInvokeStmt( (Local) lhs, (InvokeExpr) rhs );
    return;
}
if( lhs instanceof Local ) {
    if( rhs instanceof Local ) {
        caseCopyStmt( (Local) lhs, rhs );
    } else if( rhs instanceof InstanceFieldRef ) {
        caseLoadStmt( (Local) lhs, (InstanceFieldRef) rhs );
    } else if( rhs instanceof ArrayRef ) {
        caseArrayLoadStmt( (Local) lhs, (ArrayRef) rhs );
    } else if( rhs instanceof StaticFieldRef ) {
        caseGlobalLoadStmt( (Local) lhs, (StaticFieldRef) rhs );
    } else if( rhs instanceof NewExpr ) {
        caseNewStmt( (Local) lhs, (NewExpr) rhs );
    } else if( rhs instanceof NewArrayExpr ) {
        caseNewArrayStmt( (Local) lhs, (NewArrayExpr) rhs );
    } else if( rhs instanceof NewMultiArrayExpr ) {
        caseNewMultiArrayStmt( (Local) lhs, (NewMultiArrayExpr) rhs );
    } else if( rhs instanceof CastExpr ) {
        CastExpr r = (CastExpr) rhs;
        Value rv = r.getOp();
        caseCastStmt( (Local) lhs, rv, r );
    } else if( rhs instanceof Constant ) {
        caseCopyStmt( (Local) lhs, rhs );
    } else if( rhs instanceof PhiExpr ) {
        casePhiStmt( (Local) lhs, (PhiExpr) rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof InstanceFieldRef ) {
    if( rhs instanceof Local || rhs instanceof Constant) {
        caseStoreStmt( (InstanceFieldRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof ArrayRef ) {
    if( rhs instanceof Local || rhs instanceof Constant ) {
        caseArrayStoreStmt( (ArrayRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof StaticFieldRef ) {
    if( rhs instanceof Local || rhs instanceof Constant ) {
    caseGlobalStoreStmt( (StaticFieldRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else throw new RuntimeException( "unhandled stmt "+s );
  }
项目:jar2bpl    文件:SootValueSwitch.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr arg0) {
    throw new RuntimeException("Must be handeled in SootStmtSwitch");
}
项目:jar2bpl    文件:AssignmentTranslation.java   
public static void translateAssignment(SootStmtSwitch ss, Value lhs,
        Value rhs, Unit statement) {

    ProgramFactory pf = GlobalsCache.v().getPf();
    SootValueSwitch valueswitch = ss.getValueSwitch();

    if (rhs instanceof InvokeExpr) {
        InvokeExpr ivk = (InvokeExpr) rhs;
        InvokeTranslation
                .translateInvokeAssignment(ss, lhs, ivk, statement);
        return;
    }
    valueswitch.isLeftHandSide = true;
    lhs.apply(valueswitch);
    valueswitch.isLeftHandSide = false;
    Expression left = valueswitch.getExpression();

    Expression right;
    if (rhs instanceof NewExpr) {
        right = ss.createAllocatedVariable(((NewExpr) rhs).getBaseType());
    } else if (rhs instanceof NewArrayExpr) {
        NewArrayExpr nae = (NewArrayExpr) rhs;
        right = ss.createAllocatedVariable(nae.getType());
        nae.getSize().apply(valueswitch);
        Expression sizeexp = valueswitch.getExpression();
        // add the size expression.
        ss.addStatement(GlobalsCache.v().setArraySizeStatement(right,
                sizeexp));
    } else if (rhs instanceof NewMultiArrayExpr) {
        NewMultiArrayExpr nmae = (NewMultiArrayExpr) rhs;
        for (int i = 0; i < nmae.getSizeCount(); i++) {
            nmae.getSize(i).apply(valueswitch);
            // Expression sizeexp = valueswitch.getExpression();
            // TODO
            Log.error("Mulit-arrays are not implemented!");
        }
        right = GlobalsCache.v().makeFreshGlobal(
                SootPrelude.v().getReferenceType(), true, true);
    } else if (rhs instanceof StringConstant) {
        StringConstant str = (StringConstant) rhs;

        // right = stringConstantMap.get(str);
        right = ss.createAllocatedVariable(rhs.getType());

        Expression[] indices = { right };
        // assign the size of the string to the appropriate field in the
        // $stringSizeHeapVariable array.
        translateAssignment(
                ss,
                SootPrelude.v().getStringSizeHeapVariable(),
                pf.mkArrayStoreExpression(SootPrelude.v()
                        .getStringSizeHeapVariable().getType(), SootPrelude
                        .v().getStringSizeHeapVariable(), indices, pf
                        .mkIntLiteral(Integer.toString(str.value.length()))));
    } else {
        rhs.apply(valueswitch);
        right = valueswitch.getExpression();
    }

    translateAssignment(ss, left, right);
}
项目:jgs    文件:SecurityConstraintValueWriteSwitch.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    throwInvalidWriteException(v);
}
项目:jgs    文件:SecurityConstraintValueReadSwitch.java   
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    throwIllegalNewArrayException(v);
}
项目:jgs    文件:SecurityLevelValueWriteSwitch.java   
/**
 * The method should update the <em>security level</em> of an expression
 * with type {@link NewMultiArrayExpr}, but it is not possible to update the
 * level of such an expression.
 * 
 * @param v
 *            The expression for which the <em>security level</em> should be
 *            updated.
 * @see soot.jimple.ExprSwitch#caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr)
 * @throws InvalidSwitchException
 *             Always, because the update is not possible.
 */
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    throw new SwitchException(getMsg("exception.analysis.switch.update_error",
                                     this.getClass().getSimpleName(),
                                     v.getClass().getSimpleName(),
                                     v.toString(),
                                     getSourceLine()));
}
项目:jgs    文件:SecurityLevelValueReadSwitch.java   
/**
 * Looks up the <em>security level</em> for the given new expression and
 * stores the level in {@link SecurityLevelValueReadSwitch#level}. For a
 * {@link NewMultiArrayExpr} this is the weakest available
 * <em>security level</em>.
 * 
 * @param v
 *            The new expression for which the <em>security level</em>
 *            should be looked up.
 * @see soot.jimple.ExprSwitch#caseNewMultiArrayExpr(soot.jimple.NewMultiArrayExpr)
 */
@Override
public void caseNewMultiArrayExpr(NewMultiArrayExpr v) {
    this.level = getWeakestSecurityLevel();
}