Exemplo n.º 1
0
        List <ILSpan> GetUnusedILSpans(List <ILSpan> list)
        {
            uint codeSize = (uint)Method.Body.GetCodeSize();

            list = ILSpan.OrderAndCompact(list);
            var res = new List <ILSpan>();

            if (list.Count == 0)
            {
                if (codeSize > 0)
                {
                    res.Add(new ILSpan(0, codeSize));
                }
                return(res);
            }
            uint prevEnd = 0;

            for (int i = 0; i < list.Count; i++)
            {
                var span = list[i];
                Debug.Assert(span.Start >= prevEnd);
                uint length = span.Start - prevEnd;
                if (length > 0)
                {
                    res.Add(new ILSpan(prevEnd, length));
                }
                prevEnd = span.End;
            }
            Debug.Assert(prevEnd <= codeSize);
            if (prevEnd < codeSize)
            {
                res.Add(new ILSpan(prevEnd, codeSize - prevEnd));
            }
            return(res);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="span">Scope span</param>
 /// <param name="scopes">Child scopes</param>
 /// <param name="locals">Locals</param>
 /// <param name="imports">Imports</param>
 /// <param name="constants">Constants</param>
 public MethodDebugScope(ILSpan span, MethodDebugScope[] scopes, SourceLocal[] locals, ImportInfo[] imports, MethodDebugConstant[] constants)
 {
     Span      = span;
     Scopes    = scopes ?? throw new ArgumentNullException(nameof(scopes));
     Locals    = locals ?? throw new ArgumentNullException(nameof(locals));
     Imports   = imports ?? throw new ArgumentNullException(nameof(imports));
     Constants = constants ?? throw new ArgumentNullException(nameof(constants));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets step ranges
        /// </summary>
        /// <param name="sourceILSpans">Source statement spans</param>
        /// <returns></returns>
        public ILSpan[] GetRanges(ILSpan[] sourceILSpans)
        {
            var list = new List <ILSpan>(sourceILSpans.Length + GetUnusedILSpans().Length + 1);

            list.AddRange(sourceILSpans);
            list.AddRange(GetUnusedILSpans());
            return(ILSpan.OrderAndCompactList(list).ToArray());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="decompilerSettingsVersion">Decompiler settings version number. This version number should get incremented when the settings change.</param>
 /// <param name="stateMachineKind">State machine kind</param>
 /// <param name="method">Method</param>
 /// <param name="kickoffMethod">Kickoff method or null</param>
 public MethodDebugInfoBuilder(int decompilerSettingsVersion, StateMachineKind stateMachineKind, MethodDef method, MethodDef?kickoffMethod)
 {
     this.decompilerSettingsVersion = decompilerSettingsVersion;
     this.stateMachineKind          = stateMachineKind;
     this.method        = method ?? throw new ArgumentNullException(nameof(method));
     this.kickoffMethod = kickoffMethod;
     statements         = new List <SourceStatement>();
     Scope      = new MethodDebugScopeBuilder();
     Scope.Span = ILSpan.FromBounds(0, (uint)method.Body.GetCodeSize());
     if (method == kickoffMethod)
     {
         throw new ArgumentException();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ilSpan">IL span</param>
 /// <param name="textSpan">Text span</param>
 public SourceStatement(ILSpan ilSpan, TextSpan textSpan)
 {
     this.ilSpan   = ilSpan;
     this.textSpan = textSpan;
 }