All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opalj.br.instructions.ExplicitLocalVariableIndex.scala Maven / Gradle / Ivy

The newest version!
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj
package br
package instructions

/**
 * Trait that can be mixed in if the local variable index of a load or store instruction
 * ((a,i,l,...)load/store_X) is not predefined as part of the instruction.
 *
 * @author Michael Eichberg
 */
trait ExplicitLocalVariableIndex extends Instruction {

    def lvIndex: Int

    final def isIsomorphic(thisPC: PC, otherPC: PC)(implicit code: Code): Boolean = {
        val other = code.instructions(otherPC)

        (this eq other) || (
            other.opcode == this.opcode &&
            other.asInstanceOf[ExplicitLocalVariableIndex].lvIndex == this.lvIndex
        )
    }

    final def indexOfNextInstruction(currentPC: Int)(implicit code: Code): Int = {
        indexOfNextInstruction(currentPC, code.isModifiedByWide(currentPC))
    }

    final def indexOfNextInstruction(currentPC: PC, modifiedByWide: Boolean): Int = {
        if (modifiedByWide)
            currentPC + 3
        else
            currentPC + 2
    }

}

object ExplicitLocalVariableIndex {

    def unapply(i: ExplicitLocalVariableIndex): Some[Int] = Some(i.lvIndex)

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy