public void EndNode(AstNode node) { if (nodeStack.Pop() != node) { throw new InvalidOperationException(); } var startLocation = startLocations.Pop(); // code mappings if (currentMemberMapping != null) { var ranges = node.Annotation <List <ILRange> >(); if (ranges != null && ranges.Count > 0) { // add all ranges foreach (var range in ranges) { currentMemberMapping.MemberCodeMappings.Add( new SourceCodeMapping { ILInstructionOffset = range, StartLocation = startLocation, EndLocation = output.Location, MemberMapping = currentMemberMapping }); } } } if (node.Annotation <MemberMapping>() != null) { output.AddDebuggerMemberMapping(currentMemberMapping); currentMemberMapping = parentMemberMappings.Pop(); } }
public void AddDebuggerMemberMapping(MemberMapping memberMapping) { DebuggerMemberMappings.Add(memberMapping); output.AddDebuggerMemberMapping(memberMapping); }
void ITextOutput.AddDebuggerMemberMapping(MemberMapping memberMapping) => _inner.AddDebuggerMemberMapping(memberMapping);
void DisassembleMethodInternal(MethodDefinition method) { // .method public hidebysig specialname // instance default class [mscorlib]System.IO.TextWriter get_BaseWriter () cil managed // //emit flags WriteEnum(method.Attributes & MethodAttributes.MemberAccessMask, methodVisibility); WriteFlags(method.Attributes & ~MethodAttributes.MemberAccessMask, methodAttributeFlags); if (method.IsCompilerControlled) { output.Write("privatescope "); } if ((method.Attributes & MethodAttributes.PInvokeImpl) == MethodAttributes.PInvokeImpl) { output.Write("pinvokeimpl"); if (method.HasPInvokeInfo && method.PInvokeInfo != null) { PInvokeInfo info = method.PInvokeInfo; output.Write("(\"" + NRefactory.CSharp.CSharpOutputVisitor.ConvertString(info.Module.Name) + "\""); if (!string.IsNullOrEmpty(info.EntryPoint) && info.EntryPoint != method.Name) { output.Write(" as \"" + NRefactory.CSharp.CSharpOutputVisitor.ConvertString(info.EntryPoint) + "\""); } if (info.IsNoMangle) { output.Write(" nomangle"); } if (info.IsCharSetAnsi) { output.Write(" ansi"); } else if (info.IsCharSetAuto) { output.Write(" autochar"); } else if (info.IsCharSetUnicode) { output.Write(" unicode"); } if (info.SupportsLastError) { output.Write(" lasterr"); } if (info.IsCallConvCdecl) { output.Write(" cdecl"); } else if (info.IsCallConvFastcall) { output.Write(" fastcall"); } else if (info.IsCallConvStdCall) { output.Write(" stdcall"); } else if (info.IsCallConvThiscall) { output.Write(" thiscall"); } else if (info.IsCallConvWinapi) { output.Write(" winapi"); } output.Write(')'); } output.Write(' '); } output.WriteLine(); output.Indent(); if (method.ExplicitThis) { output.Write("instance explicit "); } else if (method.HasThis) { output.Write("instance "); } //call convention WriteEnum(method.CallingConvention & (MethodCallingConvention)0x1f, callingConvention); //return type method.ReturnType.WriteTo(output); output.Write(' '); if (method.MethodReturnType.HasMarshalInfo) { WriteMarshalInfo(method.MethodReturnType.MarshalInfo); } if (method.IsCompilerControlled) { output.Write(DisassemblerHelpers.Escape(method.Name + "$PST" + method.MetadataToken.ToInt32().ToString("X8"))); } else { output.Write(DisassemblerHelpers.Escape(method.Name)); } WriteTypeParameters(output, method); //( params ) output.Write(" ("); if (method.HasParameters) { output.WriteLine(); output.Indent(); WriteParameters(method.Parameters); output.Unindent(); } output.Write(") "); //cil managed WriteEnum(method.ImplAttributes & MethodImplAttributes.CodeTypeMask, methodCodeType); if ((method.ImplAttributes & MethodImplAttributes.ManagedMask) == MethodImplAttributes.Managed) { output.Write("managed "); } else { output.Write("unmanaged "); } WriteFlags(method.ImplAttributes & ~(MethodImplAttributes.CodeTypeMask | MethodImplAttributes.ManagedMask), methodImpl); output.Unindent(); OpenBlock(defaultCollapsed: isInType); WriteAttributes(method.CustomAttributes); if (method.HasOverrides) { foreach (var methodOverride in method.Overrides) { output.Write(".override method "); methodOverride.WriteTo(output); output.WriteLine(); } } foreach (var p in method.Parameters) { WriteParameterAttributes(p); } WriteSecurityDeclarations(method); if (method.HasBody) { // create IL code mappings - used in debugger MemberMapping methodMapping = new MemberMapping(method); methodBodyDisassembler.Disassemble(method.Body, methodMapping); output.AddDebuggerMemberMapping(methodMapping); } CloseBlock("end of method " + DisassemblerHelpers.Escape(method.DeclaringType.Name) + "::" + DisassemblerHelpers.Escape(method.Name)); }