public override void Visit(Model.Bytecode.BranchInstruction instruction) { // placeholder for target as a nop Cecil.Cil.Instruction cilIns = processor.Create(GetCilBranchOpcode(instruction), processor.Create(Cecil.Cil.OpCodes.Nop)); Result = new List <Mono.Cecil.Cil.Instruction>() { cilIns }; }
private Mono.Cecil.Cil.OpCode GetCilBranchOpcode(Model.Bytecode.BranchInstruction instruction) { switch (instruction.Operation) { case AnalysisNet.Bytecode.BranchOperation.Branch: return(Mono.Cecil.Cil.OpCodes.Br); case AnalysisNet.Bytecode.BranchOperation.Eq: return(Mono.Cecil.Cil.OpCodes.Beq); case AnalysisNet.Bytecode.BranchOperation.False: return(Mono.Cecil.Cil.OpCodes.Brfalse); case AnalysisNet.Bytecode.BranchOperation.Ge: if (instruction.UnsignedOperands) { return(Mono.Cecil.Cil.OpCodes.Bge_Un); } else { return(Mono.Cecil.Cil.OpCodes.Bge); } case AnalysisNet.Bytecode.BranchOperation.Gt: if (instruction.UnsignedOperands) { return(Mono.Cecil.Cil.OpCodes.Bgt_Un); } else { return(Mono.Cecil.Cil.OpCodes.Bgt); } case AnalysisNet.Bytecode.BranchOperation.Le: if (instruction.UnsignedOperands) { return(Mono.Cecil.Cil.OpCodes.Ble_Un); } else { return(Mono.Cecil.Cil.OpCodes.Ble); } case AnalysisNet.Bytecode.BranchOperation.Leave: return(Mono.Cecil.Cil.OpCodes.Leave); case AnalysisNet.Bytecode.BranchOperation.Lt: if (instruction.UnsignedOperands) { return(Mono.Cecil.Cil.OpCodes.Blt_Un); } else { return(Mono.Cecil.Cil.OpCodes.Blt); } case AnalysisNet.Bytecode.BranchOperation.Neq: return(Mono.Cecil.Cil.OpCodes.Bne_Un); case AnalysisNet.Bytecode.BranchOperation.True: return(Mono.Cecil.Cil.OpCodes.Brtrue); default: throw new NotImplementedException(); } }