예제 #1
0
        private void FixupBranchAndSwitch(ILProcessorInstruction oldInstruction, ILProcessorInstruction newInstruction)
        {
            //Fix up any branch or switch instructions
            foreach (var inst in _instructions)
            {
                switch (inst)
                {
                case OperandInstruction <ILProcessorInstruction> branchInstruction
                    when branchInstruction.Operand == oldInstruction:
                    branchInstruction.Operand = newInstruction;
                    break;

                case OperandInstruction <IReadOnlyList <ILProcessorInstruction> > switchInstruction
                    when switchInstruction.Operand.Contains(oldInstruction):
                    switchInstruction.Operand = switchInstruction.Operand
                                                .Select(i => i != oldInstruction ? i : newInstruction)
                                                .ToList();

                    break;
                }
            }
        }