public override void DebugEnd(AstNode node, TextLocation?end)
        {
            var state = debugStack.Pop();

            if (currentMemberMapping != null)
            {
                foreach (var range in ILRange.OrderAndJoin(GetILRanges(state)))
                {
                    currentMemberMapping.MemberCodeMappings.Add(
                        new SourceCodeMapping {
                        ILInstructionOffset = range,
                        StartLocation       = state.StartLocation,
                        EndLocation         = end ?? output.Location,
                        MemberMapping       = currentMemberMapping
                    });
                }
            }
            else if (multiMappings != null)
            {
                foreach (var mm in multiMappings)
                {
                    foreach (var range in ILRange.OrderAndJoin(mm.Item2))
                    {
                        mm.Item1.MemberCodeMappings.Add(
                            new SourceCodeMapping {
                            ILInstructionOffset = range,
                            StartLocation       = state.StartLocation,
                            EndLocation         = end ?? output.Location,
                            MemberMapping       = mm.Item1
                        });
                    }
                }
            }
        }
        public override void EndNode(AstNode node)
        {
            base.EndNode(node);
            if (node is EntityDeclaration && node.Annotation <MemberReference>() != null)
            {
                MemberLocations[XmlDocKeyProvider.GetKey(node.Annotation <MemberReference>())] = node.StartLocation;
            }

            // code mappings
            var ranges = node.Annotation <List <ILRange> >();

            if (symbolsStack.Count > 0 && ranges != null && ranges.Count > 0)
            {
                symbolsStack.Peek().SequencePoints.Add(
                    new SequencePoint()
                {
                    ILRanges      = ILRange.OrderAndJoin(ranges).ToArray(),
                    StartLocation = node.StartLocation,
                    EndLocation   = node.EndLocation
                });
            }

            if (node.Annotation <MethodDebugSymbols>() != null)
            {
                var symbols = symbolsStack.Pop();
                symbols.SequencePoints = symbols.SequencePoints.OrderBy(s => s.ILOffset).ToList();
                symbols.StartLocation  = node.StartLocation;
                symbols.EndLocation    = node.EndLocation;
                DebugSymbols[XmlDocKeyProvider.GetKey(symbols.CecilMethod)] = symbols;
            }
        }
Beispiel #3
0
        public override void EndNode(AstNode node)
        {
            if (nodeStack.Pop() != node)
            {
                throw new InvalidOperationException();
            }

            var startLocation = startLocations.Pop();

            // code mappings
            var ranges = node.Annotation <List <ILRange> >();

            if (symbolsStack.Count > 0 && ranges != null && ranges.Count > 0)
            {
                // Ignore the newline which was printed at the end of the statement
                TextLocation endLocation = (node is Statement) ? (lastEndOfLine ?? output.Location) : output.Location;
                symbolsStack.Peek().SequencePoints.Add(
                    new SequencePoint()
                {
                    ILRanges      = ILRange.OrderAndJoin(ranges).ToArray(),
                    StartLocation = startLocation,
                    EndLocation   = endLocation
                });
            }

            if (node.Annotation <MethodDebugSymbols>() != null)
            {
                symbolsStack.Peek().EndLocation = output.Location;
                output.AddDebugSymbols(symbolsStack.Pop());
            }
        }
Beispiel #4
0
        public int[] ToArray(List <ILRange> currentList, bool isMatch)
        {
            if (currentList == null)
            {
                currentList = new List <ILRange>();
            }

            // add inverted
            currentList.AddRange(InvertedList);

            if (isMatch)
            {
                // if the current list contains the last mapping, add also the last gap
                var lastInverted = InvertedList.LastOrDefault();
                if (!lastInverted.IsDefault && lastInverted.From == currentList[currentList.Count - 1].To)
                {
                    currentList.Add(lastInverted);
                }
            }

            // set the output
            var resultList = new List <int>();

            foreach (var element in ILRange.OrderAndJoin(currentList))
            {
                resultList.Add((int)element.From);
                resultList.Add((int)element.To);
            }

            return(resultList.ToArray());
        }
Beispiel #5
0
 public static ILExpression WithILRangesAndJoin(this ILExpression expr, IEnumerable <ILRange> ilranges1, IEnumerable <ILRange> ilranges2)
 {
     expr.WithILRanges(ilranges1, ilranges2);
     if (ilranges1 != null || ilranges2 != null)
     {
         ILRange.OrderAndJoin(expr.ILRanges);
     }
     return(expr);
 }
Beispiel #6
0
 public static ILExpression WithILRangesAndJoin(this ILExpression expr, IEnumerable <ILRange> ilranges)
 {
     if (ilranges != null)
     {
         expr.ILRanges.AddRange(ilranges);
         ILRange.OrderAndJoin(expr.ILRanges);
     }
     return(expr);
 }
        public static AstNode CreateHidden(IEnumerable <ILRange> ilRanges, AstNode stmt)
        {
            var list = ILRange.OrderAndJoin(ilRanges);

            if (list.Count == 0)
            {
                return(stmt);
            }
            if (stmt == null)
            {
                stmt = new EmptyStatement();
            }
            stmt.AddAnnotation(list);
            return(stmt);
        }
Beispiel #8
0
        public override void DebugEnd(AstNode node, TextPosition?end)
        {
            var state = debugStack.Pop();

            if (currentMemberMapping != null)
            {
                foreach (var range in ILRange.OrderAndJoin(GetILRanges(state)))
                {
                    currentMemberMapping.MemberCodeMappings.Add(new SourceCodeMapping(range, state.StartLocation, end ?? output.Location, currentMemberMapping));
                }
            }
            else if (multiMappings != null)
            {
                foreach (var mm in multiMappings)
                {
                    foreach (var range in ILRange.OrderAndJoin(mm.Item2))
                    {
                        mm.Item1.MemberCodeMappings.Add(new SourceCodeMapping(range, state.StartLocation, end ?? output.Location, mm.Item1));
                    }
                }
            }
        }