void FixFieldCtorCalls(Blocks blocks) { if (blocks.Method.Name != ".ctor") { return; } var instrsToRemove = new List <int>(); foreach (var block in blocks.MethodBlocks.GetAllBlocks()) { var instrs = block.Instructions; for (int i = 0; i < instrs.Count; i++) { var stfld = instrs[i]; if (stfld.OpCode.Code != Code.Stfld) { continue; } var field = stfld.Operand as IField; if (field == null) { continue; } if (!structFieldsToFix.Find(field)) { continue; } var instrs2 = ToInstructionList(instrs); var instrPushes = DotNetUtils.GetArgPushes(instrs2, i); if (instrPushes == null || instrPushes.Count != 2) { continue; } block.Remove(i, 1); block.Remove(instrs2.IndexOf(instrPushes[1]), 1); block.Remove(instrs2.IndexOf(instrPushes[0]), 1); i -= 3; } } }
public static IList <object> GetArgValues(IList <Instruction> instrs, int index) { return(GetArgValues(DotNetUtils.GetArgPushes(instrs, index))); }