public FieldReference ConsumeArgFieldRef(Instruction fieldRefInstruction) { return(ConsumeArgFieldRefBuilder(fieldRefInstruction).Build()); FieldRefBuilder ConsumeArgFieldRefBuilder(Instruction instruction) { if (instruction.OpCode.FlowControl != FlowControl.Call || !(instruction.Operand is MethodReference method)) { throw UnexpectedInstruction(instruction, "a method call"); } switch (method.FullName) { case "System.Void InlineIL.FieldRef::.ctor(InlineIL.TypeRef,System.String)": case "InlineIL.FieldRef InlineIL.FieldRef::Field(InlineIL.TypeRef,System.String)": { var args = _il.GetArgumentPushInstructionsInSameBasicBlock(instruction); var typeRef = ConsumeArgTypeRef(args[0]); var fieldName = ConsumeArgString(args[1]); var builder = new FieldRefBuilder(typeRef, fieldName); _il.Remove(instruction); return(builder); } default: throw UnexpectedInstruction(instruction, "a field reference"); } } }
public FieldReference ConsumeArgFieldRef(Instruction fieldRefInstruction) { return(ConsumeArgFieldRefBuilder(fieldRefInstruction).Build()); FieldRefBuilder ConsumeArgFieldRefBuilder(Instruction instruction) { if (instruction.OpCode != OpCodes.Newobj || !(instruction.Operand is MethodReference ctor) || ctor.FullName != "System.Void InlineIL.FieldRef::.ctor(InlineIL.TypeRef,System.String)") { throw UnexpectedInstruction(instruction, "newobj FieldRef"); } var args = _il.GetArgumentPushInstructionsInSameBasicBlock(instruction); var typeRef = ConsumeArgTypeRef(args[0]); var fieldName = ConsumeArgString(args[1]); var builder = new FieldRefBuilder(typeRef, fieldName); _il.Remove(instruction); return(builder); } }