public abstract class AbstractASMBackend
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected org.objectweb.asm.ClassVisitor |
cv |
protected int |
javaVersion |
protected SootClass |
sc |
Constructor and Description |
---|
AbstractASMBackend(SootClass sc,
int javaVersion)
Creates a new ASM backend
|
Modifier and Type | Method and Description |
---|---|
protected void |
generateAnnotationElems(org.objectweb.asm.AnnotationVisitor av,
java.util.Collection<AnnotationElem> elements,
boolean addName)
Emits the bytecode for the values of an annotation
|
protected void |
generateAnnotations(java.lang.Object visitor,
Host host)
Emits the bytecode for all annotations of a class, field or method
|
protected void |
generateAttributes()
Emits the bytecode for all attributes of the class
|
protected void |
generateAttributes(org.objectweb.asm.FieldVisitor fv,
SootField f)
Emits the bytecode for all attributes of a field
|
protected void |
generateAttributes(org.objectweb.asm.MethodVisitor mv,
SootMethod m)
Emits the bytecode for all attributes of a method
|
protected void |
generateByteCode()
Emits the bytecode for the complete class
|
void |
generateClassFile(java.io.OutputStream os)
Outputs the bytecode generated as a class file
|
protected void |
generateClassHeader()
Emits the bytecode for the class itself, including its signature
|
protected void |
generateFields()
Emits the bytecode for all fields of the class
|
protected void |
generateInnerClassReferences()
Emits the bytecode for all references to inner classes if present
|
protected abstract void |
generateMethodBody(org.objectweb.asm.MethodVisitor mv,
SootMethod method)
Emits the bytecode for the body of a single method
Has to be implemented by subclasses to suit their needs
|
protected void |
generateMethods()
Emits the bytecode for all methods of the class
|
protected void |
generateOuterClassReference()
Emits the bytecode for a reference to an outer class if necessary
|
void |
generateTextualRepresentation(java.io.PrintWriter pw)
Outputs the bytecode generated as a textual representation
|
protected BafBody |
getBafBody(SootMethod method)
Gets the baf body for the given SootMethod.
|
protected int |
getMinJavaVersion(SootMethod sm)
Determines the minimum Java version required for the bytecode of the given SootMethod
Subclasses should override this method to suit their needs, otherwise Java 1.7 is assumed for compatibility with invokeDynamic
|
protected static int |
getModifiers(int modVal,
Host host)
Utility method to get the access modifiers of a Host
|
protected org.objectweb.asm.ClassVisitor cv
protected SootClass sc
protected int javaVersion
public AbstractASMBackend(SootClass sc, int javaVersion)
sc
- The SootClass that is to be converted into bytecodejavaVersion
- A particular Java version enforced by the user, may be 0 for automatic detection, must not be lower than necessary for all features usedprotected BafBody getBafBody(SootMethod method)
method
- The method for which to obtain a baf bodyprotected int getMinJavaVersion(SootMethod sm)
sm
- The SootMethod the minimum Java version is to be determined forpublic void generateClassFile(java.io.OutputStream os)
os
- The OutputStream the class file is written topublic void generateTextualRepresentation(java.io.PrintWriter pw)
pw
- The PrintWriter the textual representation is written toprotected void generateByteCode()
protected void generateMethods()
protected void generateFields()
protected void generateInnerClassReferences()
protected void generateAttributes()
protected void generateAttributes(org.objectweb.asm.FieldVisitor fv, SootField f)
fv
- The FieldVisitor to emit the bytecode tof
- The SootField the bytecode is to be emitted forprotected void generateAttributes(org.objectweb.asm.MethodVisitor mv, SootMethod m)
fv
- The MethodVisitor to emit the bytecode tof
- The SootMethod the bytecode is to be emitted forprotected void generateAnnotations(java.lang.Object visitor, Host host)
visitor
- A ClassVisitor, FieldVisitor or MethodVisitor to emit the bytecode tohost
- A Host (SootClass, SootField or SootMethod) the bytecode is to be emitted for, has to match the visitorprotected void generateAnnotationElems(org.objectweb.asm.AnnotationVisitor av, java.util.Collection<AnnotationElem> elements, boolean addName)
av
- The AnnotationVisitor to emit the bytecode toelements
- A collection of AnnatiotionElem that are the values of the annotationaddName
- True, if the name of the annotation has to be added, false otherwise (should be false only in recursive calls!)protected void generateOuterClassReference()
protected void generateClassHeader()
protected static int getModifiers(int modVal, Host host)
modVal
- The bitset representation of the Host's modifiershost
- The Host (SootClass, SootField or SootMethod) the modifiers are to be retrieved fromprotected abstract void generateMethodBody(org.objectweb.asm.MethodVisitor mv, SootMethod method)
mv
- The MethodVisitor to emit the bytecode tomethod
- The SootMethod the bytecode is to be emitted for