Esempio n. 1
0
        /// <summary>
        /// Reads the source code within the given span.
        /// </summary>
        /// <param name="span"> The start and end positions within the source code. </param>
        /// <returns> The source code within the given span. </returns>
        internal string ReadSpan(Compiler.SourceCodeSpan span)
        {
            if (span == null)
            {
                throw new ArgumentNullException("span");
            }

            int  line = 1, column = 1;
            var  reader     = this.GetReader();
            var  spanText   = new System.Text.StringBuilder();
            bool insideSpan = false;

            while (true)
            {
                // Detect the start and end of the span.
                if (insideSpan == false)
                {
                    // Check for the start of the span.
                    if (line == span.StartLine && column == span.StartColumn)
                    {
                        insideSpan = true;
                    }
                }
                if (insideSpan == true)
                {
                    // Check for the end of the span.
                    if (line == span.EndLine && column == span.EndColumn)
                    {
                        break;
                    }
                }

                // Read the next character.
                int c = reader.Read();
                if (c == -1)
                {
                    break;
                }

                // Collect text
                if (insideSpan == true)
                {
                    spanText.Append((char)c);
                }

                // Update the line and column count.
                if (c == '\r' || c == '\n')
                {
                    if (c == '\r' && reader.Peek() == '\n')
                    {
                        reader.Read();
                    }
                    line++;
                    column = 1;
                }
                else
                {
                    column++;
                }
            }

            return(spanText.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Marks a sequence point in the Microsoft intermediate language (MSIL) stream.
 /// </summary>
 /// <param name="document"> The document for which the sequence point is being defined. </param>
 /// <param name="span"> The start and end positions which define the sequence point. </param>
 public void MarkSequencePoint(System.Diagnostics.SymbolStore.ISymbolDocumentWriter document, SourceCodeSpan span)
 {
     if (span == null)
     {
         throw new ArgumentNullException("span");
     }
     MarkSequencePoint(document, span.StartLine, span.StartColumn, span.EndLine, span.EndColumn);
 }