Search in sources :

Example 1 with SourceLnPosTag

use of soot.tagkit.SourceLnPosTag in project soot by Sable.

the class Attribute method addTag.

public void addTag(Tag t) {
    if (t instanceof LineNumberTag) {
        int lnNum = (new Integer(((LineNumberTag) t).toString())).intValue();
        javaStartLn(lnNum);
        javaEndLn(lnNum);
    } else if (t instanceof JimpleLineNumberTag) {
        JimpleLineNumberTag jlnTag = (JimpleLineNumberTag) t;
        jimpleStartLn(jlnTag.getStartLineNumber());
        jimpleEndLn(jlnTag.getEndLineNumber());
    } else if (t instanceof SourceLnPosTag) {
        SourceLnPosTag jlnTag = (SourceLnPosTag) t;
        javaStartLn(jlnTag.startLn());
        javaEndLn(jlnTag.endLn());
        javaStartPos(jlnTag.startPos());
        javaEndPos(jlnTag.endPos());
    } else if (t instanceof LinkTag) {
        LinkTag lt = (LinkTag) t;
        Host h = lt.getLink();
        LinkAttribute link = new LinkAttribute(lt.getInfo(), getJimpleLnOfHost(h), getJavaLnOfHost(h), lt.getClassName(), lt.getAnalysisType());
        addLink(link);
    } else if (t instanceof StringTag) {
        StringTag st = (StringTag) t;
        StringAttribute string = new StringAttribute(formatForXML(st.getInfo()), st.getAnalysisType());
        addText(string);
    } else if (t instanceof PositionTag) {
        PositionTag pt = (PositionTag) t;
        jimpleStartPos(pt.getStartOffset());
        jimpleEndPos(pt.getEndOffset());
    } else if (t instanceof ColorTag) {
        ColorTag ct = (ColorTag) t;
        ColorAttribute ca = new ColorAttribute(ct.getRed(), ct.getGreen(), ct.getBlue(), ct.isForeground(), ct.getAnalysisType());
        // color(ca);
        addColor(ca);
    } else /*else if (t instanceof SourcePositionTag){
        }
        else if (t instanceof SourceLineNumberTag){
        }*/
    {
        // System.out.println("t is: "+t.getClass());
        StringAttribute sa = new StringAttribute(t.toString(), t.getName());
        addText(sa);
    }
}
Also used : SourceLnPosTag(soot.tagkit.SourceLnPosTag) StringTag(soot.tagkit.StringTag) LinkTag(soot.tagkit.LinkTag) ColorTag(soot.tagkit.ColorTag) PositionTag(soot.tagkit.PositionTag) Host(soot.tagkit.Host) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag) LineNumberTag(soot.tagkit.LineNumberTag) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag)

Example 2 with SourceLnPosTag

use of soot.tagkit.SourceLnPosTag in project soot by Sable.

the class ExceptionChecker method checkInvokeExpr.

protected void checkInvokeExpr(Body b, InvokeExpr ie, Stmt s) {
    if (ie instanceof InstanceInvokeExpr && ((InstanceInvokeExpr) ie).getBase().getType() instanceof ArrayType && ie.getMethodRef().name().equals("clone") && ie.getMethodRef().parameterTypes().size() == 0)
        // the call is to the clone() method of an array type, which
        return;
    // is defined not to throw any exceptions; if we left this to
    // normal resolution we'd get the method in Object which does
    // throw CloneNotSupportedException
    List exceptions = ie instanceof InterfaceInvokeExpr ? // the method in supertypes.
    getExceptionSpec(ie.getMethodRef().declaringClass(), ie.getMethodRef().getSubSignature()) : // Otherwise, we just do normal resolution.
    ie.getMethod().getExceptionsUnsafe();
    if (exceptions == null)
        return;
    Iterator it = exceptions.iterator();
    while (it.hasNext()) {
        SootClass sc = (SootClass) it.next();
        if (isThrowDeclared(b, sc) || isExceptionCaught(b, s, sc.getType()))
            continue;
        if (reporter != null) {
            if (s instanceof InvokeStmt) {
                reporter.reportError(new ExceptionCheckerError(b.getMethod(), sc, s, (SourceLnPosTag) s.getTag("SourceLnPosTag")));
            } else if (s instanceof AssignStmt) {
                reporter.reportError(new ExceptionCheckerError(b.getMethod(), sc, s, (SourceLnPosTag) ((AssignStmt) s).getRightOpBox().getTag("SourceLnPosTag")));
            }
        }
    }
}
Also used : ArrayType(soot.ArrayType) SourceLnPosTag(soot.tagkit.SourceLnPosTag) InvokeStmt(soot.jimple.InvokeStmt) AssignStmt(soot.jimple.AssignStmt) Iterator(java.util.Iterator) InstanceInvokeExpr(soot.jimple.InstanceInvokeExpr) InterfaceInvokeExpr(soot.jimple.InterfaceInvokeExpr) List(java.util.List) SootClass(soot.SootClass)

Aggregations

SourceLnPosTag (soot.tagkit.SourceLnPosTag)2 Iterator (java.util.Iterator)1 List (java.util.List)1 ArrayType (soot.ArrayType)1 SootClass (soot.SootClass)1 AssignStmt (soot.jimple.AssignStmt)1 InstanceInvokeExpr (soot.jimple.InstanceInvokeExpr)1 InterfaceInvokeExpr (soot.jimple.InterfaceInvokeExpr)1 InvokeStmt (soot.jimple.InvokeStmt)1 ColorTag (soot.tagkit.ColorTag)1 Host (soot.tagkit.Host)1 JimpleLineNumberTag (soot.tagkit.JimpleLineNumberTag)1 LineNumberTag (soot.tagkit.LineNumberTag)1 LinkTag (soot.tagkit.LinkTag)1 PositionTag (soot.tagkit.PositionTag)1 StringTag (soot.tagkit.StringTag)1