Search in sources :

Example 16 with soot

use of soot in project soot by Sable.

the class VarAccess method emitStore.

/**
 * @ast method
 * @aspect GenericsCodegen
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/GenericsCodegen.jrag:86
 */
public soot.Value emitStore(Body b, soot.Value lvalue, soot.Value rvalue, ASTNode location) {
    Variable v = decl();
    if (v instanceof FieldDeclaration) {
        FieldDeclaration f = ((FieldDeclaration) v).erasedField();
        if (requiresAccessor()) {
            if (f.isStatic()) {
                ArrayList list = new ArrayList();
                list.add(rvalue);
                return asLocal(b, b.newStaticInvokeExpr(f.createAccessorWrite(fieldQualifierType().erasure()).sootRef(), list, this));
            } else {
                soot.Local base = base(b);
                ArrayList list = new ArrayList();
                list.add(base);
                list.add(asLocal(b, rvalue, lvalue.getType()));
                return asLocal(b, b.newStaticInvokeExpr(f.createAccessorWrite(fieldQualifierType().erasure()).sootRef(), list, this));
            }
        }
    }
    return refined_Expressions_VarAccess_emitStore(b, lvalue, rvalue, location);
}
Also used : soot(soot) ArrayList(java.util.ArrayList)

Example 17 with soot

use of soot in project soot by Sable.

the class Modifiers method addRuntimeVisibleAnnotationsAttribute.

/**
 * @ast method
 * @aspect AnnotationsCodegen
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/AnnotationsCodegen.jrag:110
 */
public void addRuntimeVisibleAnnotationsAttribute(Collection c) {
    Collection annotations = runtimeVisibleAnnotations();
    if (!annotations.isEmpty()) {
        soot.tagkit.VisibilityAnnotationTag tag = new soot.tagkit.VisibilityAnnotationTag(soot.tagkit.AnnotationConstants.RUNTIME_VISIBLE);
        for (Iterator iter = annotations.iterator(); iter.hasNext(); ) {
            Annotation annotation = (Annotation) iter.next();
            ArrayList elements = new ArrayList(1);
            annotation.appendAsAttributeTo(elements);
            tag.addAnnotation((soot.tagkit.AnnotationTag) elements.get(0));
        }
        c.add(tag);
    }
}
Also used : soot(soot) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Example 18 with soot

use of soot in project soot by Sable.

the class Modifiers method addSourceOnlyAnnotations.

/**
 * @ast method
 * @aspect AnnotationsCodegen
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/AnnotationsCodegen.jrag:83
 */
public void addSourceOnlyAnnotations(Collection c) {
    if (new soot.options.JBOptions(soot.PhaseOptions.v().getPhaseOptions("jb")).preserve_source_annotations()) {
        for (int i = 0; i < getNumModifier(); i++) {
            if (getModifier(i) instanceof Annotation) {
                Annotation a = (Annotation) getModifier(i);
                if (!a.isRuntimeVisible() && !a.isRuntimeInvisible()) {
                    soot.tagkit.VisibilityAnnotationTag tag = new soot.tagkit.VisibilityAnnotationTag(soot.tagkit.AnnotationConstants.SOURCE_VISIBLE);
                    ArrayList elements = new ArrayList(1);
                    a.appendAsAttributeTo(elements);
                    tag.addAnnotation((soot.tagkit.AnnotationTag) elements.get(0));
                    c.add(tag);
                }
            }
        }
    }
}
Also used : soot(soot) ArrayList(java.util.ArrayList)

Example 19 with soot

use of soot in project soot by Sable.

the class SuperConstructorAccess method eval.

/**
 * @ast method
 * @aspect GenericsCodegen
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/GenericsCodegen.jrag:255
 */
public soot.Value eval(Body b) {
    ConstructorDecl c = decl().erasedConstructor();
    // this
    Local base = b.emitThis(hostType());
    int index = 0;
    ArrayList list = new ArrayList();
    if (c.needsEnclosing()) {
        if (hasPrevExpr() && !prevExpr().isTypeAccess()) {
            list.add(asImmediate(b, prevExpr().eval(b)));
        } else {
            if (hostType().needsSuperEnclosing()) {
                soot.Type type = ((ClassDecl) hostType()).superclass().enclosingType().getSootType();
                if (hostType().needsEnclosing())
                    list.add(asImmediate(b, b.newParameterRef(type, 1, this)));
                else
                    list.add(asImmediate(b, b.newParameterRef(type, 0, this)));
            } else {
                list.add(emitThis(b, superConstructorQualifier(c.hostType().enclosingType())));
            }
        }
    }
    // args
    for (int i = 0; i < getNumArg(); i++) list.add(asImmediate(b, // MethodInvocationConversion
    getArg(i).type().emitCastTo(b, getArg(i), c.getParameter(i).type())));
    if (decl().isPrivate() && decl().hostType() != hostType()) {
        list.add(asImmediate(b, soot.jimple.NullConstant.v()));
        b.add(b.newInvokeStmt(b.newSpecialInvokeExpr(base, decl().erasedConstructor().createAccessor().sootRef(), list, this), this));
        return base;
    } else {
        return b.newSpecialInvokeExpr(base, c.sootRef(), list, this);
    }
}
Also used : soot(soot) ArrayList(java.util.ArrayList)

Aggregations

soot (soot)19 ArrayList (java.util.ArrayList)17 SourceFileTag (soot.tagkit.SourceFileTag)3 Collection (java.util.Collection)2 soot.jimple (soot.jimple)2