Package soot.baf

Class BafASMBackend


  • public class BafASMBackend
    extends AbstractASMBackend
    Concrete ASM based bytecode generation backend for the BAF intermediate representation
    Author:
    Tobias Hamann, Florian Kuebler, Dominik Helm, Lukas Sommer, Alex Bertram, Andreas Dann
    • Field Detail

      • branchTargetLabels

        protected final Map<Unit,​org.objectweb.asm.Label> branchTargetLabels
    • Constructor Detail

      • BafASMBackend

        public BafASMBackend​(SootClass sc,
                             int javaVersion)
        Creates a new BafASMBackend with a given enforced java version
        Parameters:
        sc - The SootClass the bytecode is to be generated for
        javaVersion - A particular Java version enforced by the user, may be 0 for automatic detection, must not be lower than necessary for all features used
    • Method Detail

      • getBranchTargetLabel

        protected org.objectweb.asm.Label getBranchTargetLabel​(Unit target)
        Returns the ASM Label for a given Unit that is the target of a branch or jump
        Parameters:
        target - The unit that is the branch target
        Returns:
        The Label that specifies this unit
      • getMinJavaVersion

        protected int getMinJavaVersion​(SootMethod method)
        Description copied from class: AbstractASMBackend
        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
        Overrides:
        getMinJavaVersion in class AbstractASMBackend
        Parameters:
        method - The SootMethod the minimum Java version is to be determined for
        Returns:
        The minimum Java version required for the given SootMethod
      • generateMethodBody

        protected void generateMethodBody​(org.objectweb.asm.MethodVisitor mv,
                                          SootMethod method)
        Description copied from class: AbstractASMBackend
        Emits the bytecode for the body of a single method Has to be implemented by subclasses to suit their needs
        Specified by:
        generateMethodBody in class AbstractASMBackend
        Parameters:
        mv - The MethodVisitor to emit the bytecode to
        method - The SootMethod the bytecode is to be emitted for
      • generateTagsForUnit

        protected void generateTagsForUnit​(org.objectweb.asm.MethodVisitor mv,
                                           Unit u)
        Writes out the information stored in tags associated with the given unit
        Parameters:
        mv - The method visitor for writing out the bytecode
        u - The unit for which to write out the tags
      • generateInstruction

        protected void generateInstruction​(org.objectweb.asm.MethodVisitor mv,
                                           Inst inst)
        Emits the bytecode for a single Baf instruction
        Parameters:
        mv - The ASM MethodVisitor the bytecode is to be emitted to
        inst - The Baf instruction to be converted into bytecode