Mono.Cecil.Mdb.MdbReader.ReadScopes C# (CSharp) Method

ReadScopes() static private method

static private ReadScopes ( MethodEntry entry, MethodDebugInformation info ) : Mono.Cecil.Cil.ScopeDebugInformation[]
entry Mono.CompilerServices.SymbolWriter.MethodEntry
info Mono.Cecil.Cil.MethodDebugInformation
return Mono.Cecil.Cil.ScopeDebugInformation[]
        static ScopeDebugInformation[] ReadScopes(MethodEntry entry, MethodDebugInformation info)
        {
            var blocks = entry.GetCodeBlocks ();
            var scopes = new ScopeDebugInformation [blocks.Length + 1];

            info.scope = scopes [0] = new ScopeDebugInformation {
                Start = new InstructionOffset (0),
                End = new InstructionOffset (info.code_size),
            };

            foreach (var block in blocks) {
                if (block.BlockType != CodeBlockEntry.Type.Lexical && block.BlockType != CodeBlockEntry.Type.CompilerGenerated)
                    continue;

                var scope = new ScopeDebugInformation ();
                scope.Start = new InstructionOffset (block.StartOffset);
                scope.End = new InstructionOffset (block.EndOffset);

                scopes [block.Index + 1] = scope;

                if (!AddScope (info.scope.Scopes, scope))
                    info.scope.Scopes.Add (scope);
            }

            return scopes;
        }

Usage Example

Esempio n. 1
0
        public void Read(MethodBody body, InstructionMapper mapper)
        {
            MetadataToken method_token = body.Method.MetadataToken;
            MethodEntry   entry        = this.symbol_file.GetMethodByToken(method_token.ToInt32());

            if (entry != null)
            {
                Scope[] scopes = MdbReader.ReadScopes(entry, body, mapper);
                this.ReadLineNumbers(entry, mapper);
                MdbReader.ReadLocalVariables(entry, body, scopes);
            }
        }