/* BSD 2-Clause License - see OPAL/LICENSE for details. */ package org.opalj package issues import scala.xml.Node import play.api.libs.json.Json import play.api.libs.json.JsValue import play.api.libs.json.JsNull import org.opalj.collection.mutable.Locals import org.opalj.br.PC import org.opalj.br.Code import org.opalj.br.instructions.SimpleConditionalBranchInstruction import org.opalj.br.instructions.CompoundConditionalBranchInstruction import org.opalj.br.instructions.StackManagementInstruction import org.opalj.br.instructions.IINC class Operands( val code: Code, val pc: PC, val operands: List[_ <: AnyRef], val localVariables: Locals[_ <: AnyRef] ) extends IssueDetails with CodeComprehension { def toXHTML(basicInfoOnly: Boolean): Node = { val detailsNodes = instruction match { case cbi: SimpleConditionalBranchInstruction[_] => val condition = if (cbi.operandCount == 1) List( { operands.head } , { cbi.operator } ) else List( { operands.tail.head } , { cbi.operator } , { operands.head } ) if :: condition case cbi: CompoundConditionalBranchInstruction => Seq( switch , { operands.head } , (case values: { cbi.caseValues.mkString(", ") } ) ) case smi: StackManagementInstruction => val representation = { smi.mnemonic } :: (operands.map(op => { op } )) representation case IINC(lvIndex, constValue) => val representation = List( iinc , ( { localVariables(lvIndex) } { constValue } ) ) representation case instruction => val operandsCount = instruction.numberOfPoppedOperands { x => throw new UnknownError() } val parametersNode = operands.take(operandsCount).reverse.map { op => { op } } List( { instruction.mnemonic } , ({ parametersNode }) ) }