/// <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); }
/// <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(nameof(span)); } MarkSequencePoint(document, span.StartLine, span.StartColumn, span.EndLine, span.EndColumn); }
/// <summary> /// Emits a sequence point, and sets the SourceSpan property. /// </summary> /// <param name="generator"> The IL generator used to emit the sequence point. </param> /// <param name="span"> The source code span. </param> public void MarkSequencePoint(ILGenerator generator, SourceCodeSpan span) { if (span == null) throw new ArgumentNullException("span"); if (this.DebugDocument != null) generator.MarkSequencePoint(this.DebugDocument, span); this.SourceSpan = span; }
/// <summary> /// Creates a new FunctionMethodGenerator instance. /// </summary> /// <param name="scope"> The function scope. </param> /// <param name="functionName"> The name of the function. </param> /// <param name="declarationType"> Indicates how the function was declared. </param> /// <param name="arguments"> The names and default values of the arguments. </param> /// <param name="bodyText"> The source code of the function. </param> /// <param name="body"> The root of the abstract syntax tree for the body of the function. </param> /// <param name="scriptPath"> The URL or file system path that the script was sourced from. </param> /// <param name="span"> The extent of the function in the source code. </param> /// <param name="options"> Options that influence the compiler. </param> public FunctionMethodGenerator(DeclarativeScope scope, string functionName, FunctionDeclarationType declarationType, IList <FunctionArgument> arguments, string bodyText, Statement body, string scriptPath, SourceCodeSpan span, CompilerOptions options) : base(scope, new DummyScriptSource(scriptPath), options) { this.Name = functionName; this.DeclarationType = declarationType; this.Arguments = arguments; this.BodyRoot = body; this.BodyText = bodyText; Validate(span.StartLine, scriptPath); }
/// <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(nameof(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()); }