/* BSD 2-Clause License - see OPAL/LICENSE for details. */ package org.opalj package issues import play.api.libs.json.JsNull import play.api.libs.json.Json import play.api.libs.json.JsValue import scala.xml.Node import org.opalj.br.Code import org.opalj.br.PC import org.opalj.br.instructions.CompoundConditionalBranchInstruction import org.opalj.br.instructions.IINC import org.opalj.br.instructions.SimpleConditionalBranchInstruction import org.opalj.br.instructions.StackManagementInstruction import org.opalj.collection.mutable.Locals 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}) ) }