Example #1
0
        private void ReadAsyncMethodBody(AsyncMethodBodyDebugInformation async_method)
        {
            if (async_method.catch_handler.Offset > -1)
            {
                async_method.catch_handler = new InstructionOffset(GetInstruction(async_method.catch_handler.Offset));
            }
            InstructionOffset instructionOffset;

            if (!async_method.yields.IsNullOrEmpty())
            {
                for (int i = 0; i < async_method.yields.Count; i++)
                {
                    Collection <InstructionOffset> yields = async_method.yields;
                    int index = i;
                    instructionOffset = async_method.yields[i];
                    yields[index]     = new InstructionOffset(GetInstruction(instructionOffset.Offset));
                }
            }
            if (!async_method.resumes.IsNullOrEmpty())
            {
                for (int j = 0; j < async_method.resumes.Count; j++)
                {
                    Collection <InstructionOffset> resumes = async_method.resumes;
                    int index2 = j;
                    instructionOffset = async_method.resumes[j];
                    resumes[index2]   = new InstructionOffset(GetInstruction(instructionOffset.Offset));
                }
            }
        }
Example #2
0
        public SequencePoint(Instruction instruction, Document document)
        {
            if (document == null)
                throw new ArgumentNullException ("document");

            this.offset = new InstructionOffset (instruction);
            this.document = document;
        }
Example #3
0
        internal SequencePoint(int offset, Document document)
        {
            if (document == null)
                throw new ArgumentNullException ("document");

            this.offset = new InstructionOffset (offset);
            this.document = document;
        }
Example #4
0
 public SequencePoint(Instruction instruction, Document document)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     offset        = new InstructionOffset(instruction);
     this.document = document;
 }
Example #5
0
 internal SequencePoint(int offset, Document document)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     this.offset   = new InstructionOffset(offset);
     this.document = document;
 }
Example #6
0
 public ScopeDebugInformation(Instruction start, Instruction end)
     : this()
 {
     if (start == null)
     {
         throw new ArgumentNullException("start");
     }
     this.start = new InstructionOffset(start);
     if (end != null)
     {
         this.end = new InstructionOffset(end);
     }
 }
Example #7
0
        private void ReadScope(ScopeDebugInformation scope)
        {
            InstructionOffset instructionOffset = scope.Start;
            Instruction       instruction       = GetInstruction(instructionOffset.Offset);

            if (instruction != null)
            {
                scope.Start = new InstructionOffset(instruction);
            }
            instructionOffset = scope.End;
            Instruction       instruction2 = GetInstruction(instructionOffset.Offset);
            InstructionOffset end;

            if (instruction2 == null)
            {
                instructionOffset = default(InstructionOffset);
                end = instructionOffset;
            }
            else
            {
                end = new InstructionOffset(instruction2);
            }
            scope.End = end;
            if (!scope.variables.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.variables.Count; i++)
                {
                    VariableDebugInformation variableDebugInformation = scope.variables[i];
                    VariableDefinition       variable = GetVariable(variableDebugInformation.Index);
                    if (variable != null)
                    {
                        variableDebugInformation.index = new VariableIndex(variable);
                    }
                }
            }
            if (!scope.scopes.IsNullOrEmpty())
            {
                ReadScopes(scope.scopes);
            }
        }
Example #8
0
        InstructionOffset ResolveInstructionOffset(InstructionOffset inputOffset, ref InstructionOffsetCache cache)
        {
            if (inputOffset.IsResolved)
            {
                return(inputOffset);
            }

            int offset = inputOffset.Offset;

            if (cache.Offset == offset)
            {
                return(new InstructionOffset(cache.Instruction));
            }

            if (cache.Offset > offset)
            {
                // This should be rare - we're resolving offset pointing to a place before the current cache position
                // resolve by walking the instructions from start and don't cache the result.
                int size = 0;
                for (int i = 0; i < items.Length; i++)
                {
                    // The array can be larger than the actual size, in which case its padded with nulls at the end
                    // so when we reach null, treat it as an end of the IL.
                    if (items [i] == null)
                    {
                        return(new InstructionOffset(i == 0 ? items [0] : items [i - 1]));
                    }

                    if (size == offset)
                    {
                        return(new InstructionOffset(items [i]));
                    }

                    if (size > offset)
                    {
                        return(new InstructionOffset(i == 0 ? items [0] : items [i - 1]));
                    }

                    size += items [i].GetSize();
                }

                // Offset is larger than the size of the body - so it points after the end
                return(new InstructionOffset());
            }
            else
            {
                // The offset points after the current cache position - so continue counting and update the cache
                int size = cache.Offset;
                for (int i = cache.Index; i < items.Length; i++)
                {
                    cache.Index  = i;
                    cache.Offset = size;

                    var item = items [i];

                    // Allow for trailing null values in the case of
                    // instructions.Size < instructions.Capacity
                    if (item == null)
                    {
                        return(new InstructionOffset(i == 0 ? items [0] : items [i - 1]));
                    }

                    cache.Instruction = item;

                    if (cache.Offset == offset)
                    {
                        return(new InstructionOffset(cache.Instruction));
                    }

                    if (cache.Offset > offset)
                    {
                        return(new InstructionOffset(i == 0 ? items [0] : items [i - 1]));
                    }

                    size += item.GetSize();
                }

                return(new InstructionOffset());
            }
        }
Example #9
0
 public StateMachineScope(Instruction start, Instruction end)
 {
     this.start = new InstructionOffset(start);
     this.end   = end != null ? new InstructionOffset(end) : new InstructionOffset();
 }
Example #10
0
 internal StateMachineScope(int start, int end)
 {
     this.start = new InstructionOffset(start);
     this.end   = new InstructionOffset(end);
 }
Example #11
0
 public AsyncMethodBodyDebugInformation()
     : base(KindIdentifier)
 {
     this.catch_handler = new InstructionOffset(-1);
 }
Example #12
0
 internal AsyncMethodBodyDebugInformation(int catchHandler)
     : base(KindIdentifier)
 {
     this.catch_handler = new InstructionOffset(catchHandler);
 }
Example #13
0
 public StateMachineScopeDebugInformation(Instruction start, Instruction end)
     : base(KindIdentifier)
 {
     this.start = new InstructionOffset(start);
     this.end   = end != null ? new InstructionOffset(end) : new InstructionOffset();
 }
Example #14
0
 internal StateMachineScopeDebugInformation(int start, int end)
     : base(KindIdentifier)
 {
     this.start = new InstructionOffset(start);
     this.end   = new InstructionOffset(end);
 }
Example #15
0
 internal StateMachineScopeDebugInformation(int start, int end)
     : base(KindIdentifier)
 {
     this.start = new InstructionOffset (start);
     this.end = new InstructionOffset (end);
 }
Example #16
0
 public StateMachineScopeDebugInformation(Instruction start, Instruction end)
     : base(KindIdentifier)
 {
     this.start = new InstructionOffset (start);
     this.end = new InstructionOffset (end);
 }
Example #17
0
        public ScopeDebugInformation(Instruction start, Instruction end)
            : this()
        {
            if (start == null)
                throw new ArgumentNullException ("start");

            this.start = new InstructionOffset (start);

            if (end != null)
                this.end = new InstructionOffset (end);
        }
Example #18
0
 internal AsyncMethodBodyDebugInformation(int catchHandler)
     : base(KindIdentifier)
 {
     this.catch_handler = new InstructionOffset (catchHandler);
 }
Example #19
0
        InstructionOffset ResolveInstructionOffset(InstructionOffset inputOffset, ref InstructionOffsetCache cache)
        {
            if (inputOffset.IsResolved)
            {
                return(inputOffset);
            }

            int offset = inputOffset.Offset;

            if (cache.Offset == offset)
            {
                return(new InstructionOffset(cache.Instruction));
            }

            if (cache.Offset > offset)
            {
                // This should be rare - we're resolving offset pointing to a place before the current cache position
                // resolve by walking the instructions from start and don't cache the result.
                int size = 0;
                for (int i = 0; i < items.Length; i++)
                {
                    if (size == offset)
                    {
                        return(new InstructionOffset(items [i]));
                    }

                    if (size > offset)
                    {
                        return(new InstructionOffset(items [i - 1]));
                    }

                    size += items [i].GetSize();
                }

                // Offset is larger than the size of the body - so it points after the end
                return(new InstructionOffset());
            }
            else
            {
                // The offset points after the current cache position - so continue counting and update the cache
                int size = cache.Offset;
                for (int i = cache.Index; i < items.Length; i++)
                {
                    cache.Index       = i;
                    cache.Offset      = size;
                    cache.Instruction = items [i];

                    if (cache.Offset == offset)
                    {
                        return(new InstructionOffset(cache.Instruction));
                    }

                    if (cache.Offset > offset)
                    {
                        return(new InstructionOffset(items [i - 1]));
                    }

                    size += items [i].GetSize();
                }

                return(new InstructionOffset());
            }
        }
 public AsyncMethodBodyDebugInformation(Instruction catchHandler)
     : base(KindIdentifier)
 {
     catch_handler = new InstructionOffset(catchHandler);
 }