public void SaveExtendedLineInfo(XsltInput input) { if (lineInfo.Start.Line == 0) { elemNameLi = endTagLi = null; return; } elemNameLi = new SourceLineInfo( lineInfo.Uri, lineInfo.Start.Line, lineInfo.Start.Pos + 1, // "<" lineInfo.Start.Line, lineInfo.Start.Pos + 1 + _elemNameLength ); if (!input.IsEmptyElement) { Debug.Assert(input.NodeType == XmlNodeType.EndElement); endTagLi = input.BuildLineInfo(); } else { Debug.Assert(input.NodeType == XmlNodeType.Element || input.NodeType == XmlNodeType.Attribute); endTagLi = new EmptyElementEndTag(lineInfo); } }
public CompilerError CreateError(ISourceLineInfo lineInfo, string res, params string[] args) { return(new CompilerError( lineInfo.Uri, lineInfo.StartLine, lineInfo.StartPos, /*errorNumber:*/ string.Empty, /*errorText:*/ XslTransformException.CreateMessage(res, args) )); }
public XslNodeEx(XslNodeType t, QilName name, object arg, ContextInfo ctxInfo, XslVersion xslVer) : base(t, name, arg, xslVer) { ElemNameLi = ctxInfo.elemNameLi; EndTagLi = ctxInfo.endTagLi; Debug.Assert(ElemNameLi != null && EndTagLi != null); }
public static void Validate(ISourceLineInfo lineInfo) { if (lineInfo.Start.Line != 0) { int line = lineInfo.Start.Line; } }
static void SetLineInfo(ISourceLineInfo model, XNode node, CodeGenerationOptions options) { model.SourceFile = options?.ApiXmlFile; if (node is IXmlLineInfo info && info.HasLineInfo()) { model.LineNumber = info.LineNumber; model.LinePosition = info.LinePosition; } }
public static void Validate(ISourceLineInfo lineInfo) { if (lineInfo.Start.Line == 0 || lineInfo.Start.Line == NoSourceMagicNumber) { Debug.Assert(lineInfo.Start.Line == lineInfo.End.Line); Debug.Assert(lineInfo.Start.Pos == 0 && lineInfo.End.Pos == 0); } else { Debug.Assert(0 < lineInfo.Start.Line && 0 < lineInfo.Start.Pos, "0 < start"); Debug.Assert(0 < lineInfo.End.Line && 0 < lineInfo.End.Pos , "0 < end"); Debug.Assert(lineInfo.Start.LessOrEqual(lineInfo.End), "start <= end"); } }
public static void Validate(ISourceLineInfo lineInfo) { if (lineInfo.StartLine == 0 || lineInfo.StartLine == NoSourceMagicNumber) { Debug.Assert(lineInfo.StartLine == lineInfo.EndLine); Debug.Assert(lineInfo.StartPos == 0 && lineInfo.EndPos == 0); } else { Debug.Assert(0 < lineInfo.StartLine && lineInfo.StartLine <= lineInfo.EndLine); if (lineInfo.StartLine == lineInfo.EndLine) { Debug.Assert(0 < lineInfo.StartPos && lineInfo.StartPos < lineInfo.EndPos); } else { Debug.Assert(0 < lineInfo.StartPos && 0 < lineInfo.EndPos); } } }
public static void Validate(ISourceLineInfo lineInfo) { if (lineInfo.Start.Line == 0 || lineInfo.Start.Line == NoSourceMagicNumber) { Debug.Assert(lineInfo.Start.Line == lineInfo.End.Line); Debug.Assert(lineInfo.Start.Pos == 0 && lineInfo.End.Pos == 0); } else { Debug.Assert(0 < lineInfo.Start.Line && 0 < lineInfo.Start.Pos, "0 < start"); Debug.Assert(0 < lineInfo.End.Line && 0 < lineInfo.End.Pos, "0 < end"); Debug.Assert(lineInfo.Start.LessOrEqual(lineInfo.End), "start <= end"); } }
internal XslLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { bool hasLineInfo = (bool)info.GetValue("hasLineInfo", typeof(bool)); if (hasLineInfo) { string uriString = (string)info.GetValue("Uri", typeof(string)); int startLine = (int)info.GetValue("StartLine", typeof(int)); int startPos = (int)info.GetValue("StartPos", typeof(int)); int endLine = (int)info.GetValue("EndLine", typeof(int)); int endPos = (int)info.GetValue("EndPos", typeof(int)); _lineInfo = new SourceLineInfo(uriString, startLine, startPos, endLine, endPos); } }
private static string AppendLineInfoMessage(string message, ISourceLineInfo lineInfo) { if (lineInfo != null) { string fileName = SourceLineInfo.GetFileName(lineInfo.Uri); string lineInfoMessage = CreateMessage(SR.Xml_ErrorFilePosition, fileName, lineInfo.Start.Line.ToString(CultureInfo.InvariantCulture), lineInfo.Start.Pos.ToString(CultureInfo.InvariantCulture)); if (lineInfoMessage != null && lineInfoMessage.Length > 0) { if (message.Length > 0 && !XmlCharType.Instance.IsWhiteSpace(message[message.Length - 1])) { message += " "; } message += lineInfoMessage; } } return(message); }
protected XslLoadException(SerializationInfo info, StreamingContext context) : base(info, context) { bool hasLineInfo = (bool)info.GetValue("hasLineInfo", typeof(bool)); if (hasLineInfo) { string fileName; int startLine, startPos, endLine, endPos; fileName = (string)info.GetValue("FileName", typeof(string)); startLine = (int)info.GetValue("StartLine", typeof(int)); startPos = (int)info.GetValue("StartPos", typeof(int)); endLine = (int)info.GetValue("EndLine", typeof(int)); endPos = (int)info.GetValue("EndPos", typeof(int)); lineInfo = new SourceLineInfo(fileName, startLine, startPos, endLine, endPos); } }
public void SaveExtendedLineInfo(XsltInput input) { elemNameLi = new SourceLineInfo( lineInfo.Uri, lineInfo.StartLine, lineInfo.StartPos + 1, // "<" lineInfo.StartLine, lineInfo.StartPos + 1 + elemNameLength ); if (!input.IsEmptyElement) { Debug.Assert(input.reader.NodeType == XmlNodeType.EndElement); endTagLi = input.BuildLineInfo(); } else { Debug.Assert(input.reader.NodeType == XmlNodeType.Element); endTagLi = new EmptyElementEndTag(lineInfo); } }
public void ReportWarning(ISourceLineInfo lineInfo, string res, params string[] args) { int warningLevel = 1; if (0 <= Settings.WarningLevel && Settings.WarningLevel < warningLevel) { // Ignore warning return; } CompilerError error = CreateError(lineInfo, res, args); if (Settings.TreatWarningsAsErrors) { error.ErrorText = XslTransformException.CreateMessage(SR.Xslt_WarningAsError, error.ErrorText); CompilerErrorColl.Add(error); } else { error.IsWarning = true; CompilerErrorColl.Add(error); } }
internal static string CreateMessage(ISourceLineInfo lineInfo, string res, params string[] args) { return(AppendLineInfoMessage(CreateMessage(res, args), lineInfo)); }
public void ReportError(ISourceLineInfo lineInfo, string res, params string[] args) { CompilerError error = CreateError(lineInfo, res, args); CompilerErrorColl.Add(error); }
private static XslNode SetLineInfo(XslNode node, ISourceLineInfo lineInfo) { Debug.Assert(node != null); node.SourceLine = lineInfo; return node; }
internal void SetSourceLineInfo(ISourceLineInfo lineInfo) { Debug.Assert(lineInfo == null || lineInfo.Uri != null); _lineInfo = lineInfo; }
internal static string CreateMessage(ISourceLineInfo lineInfo, string res, params string[] args) { return AppendLineInfoMessage(CreateMessage(res, args), lineInfo); }
public ContextInfo(XsltInput input) { lineInfo = input.BuildLineInfo(); elemNameLength = input.QualifiedName.Length; }
private static QilNode SetLineInfo(QilNode n, ISourceLineInfo lineInfo) { Debug.Assert(n.SourceLine == null); if (lineInfo != null) { SourceLineInfo.Validate(lineInfo); if (0 < lineInfo.Start.Line && lineInfo.Start.LessOrEqual(lineInfo.End)) { n.SourceLine = lineInfo; } } return n; }
internal XslLoadException(Exception inner, ISourceLineInfo lineInfo) : base(inner, Res.Xslt_CompileError2, null) { this.lineInfo = lineInfo; }
internal void SetSourceLineInfo(ISourceLineInfo lineInfo) { this.lineInfo = lineInfo; }
// Suppresses errors if FCB is enabled private List<XslNode> ParseUseAttributeSets(string useAttributeSets, ISourceLineInfo lineInfo) { List<XslNode> result = new List<XslNode>(); if (useAttributeSets != null && useAttributeSets.Length != 0) { compiler.EnterForwardsCompatible(); string[] qnames = XmlConvert.SplitString(useAttributeSets); for (int idx = 0; idx < qnames.Length; idx++) { AddInstruction(result, SetLineInfo(f.UseAttributeSet(CreateXPathQName(qnames[idx])), lineInfo)); } if (!compiler.ExitForwardsCompatible(input.ForwardCompatibility)) { // There were errors in the list, ignore the whole list result = new List<XslNode>(); } } return result; }
/// <summary> /// Begin generating code within a new method. /// </summary> public void MethodBegin(MethodInfo methInfo, ISourceLineInfo sourceInfo, bool initWriters) { this.methInfo = methInfo; this.ilgen = XmlILModule.DefineMethodBody(methInfo); this.lastSourceInfo = null; #if DEBUG if (XmlILTrace.IsEnabled) { this.numLocals = 0; this.symbols = new Hashtable(); this.lblNum = 0; this.sourceFile = null; this.writerDump = XmlILTrace.GetTraceWriter("dump.il"); this.writerDump.WriteLine(".method {0}()", methInfo.Name); this.writerDump.WriteLine("{"); } #endif if (this.isDebug) { DebugStartScope(); // DebugInfo: Sequence point just before generating code for this function if (sourceInfo != null) { MarkSequencePoint(sourceInfo); Emit(OpCodes.Nop); } } this.initWriters = false; if (initWriters) { EnsureWriter(); LoadQueryRuntime(); Call(XmlILMethods.GetOutput); Emit(OpCodes.Stloc, this.locXOut); } }
/// <summary> /// Correlate the current IL generation position with the current source position. /// </summary> public void DebugSequencePoint(ISourceLineInfo sourceInfo) { Debug.Assert(this.isDebug && this.lastSourceInfo != null); Debug.Assert(sourceInfo != null); Emit(OpCodes.Nop); MarkSequencePoint(sourceInfo); }
public void SaveExtendedLineInfo(XsltInput input) { if (lineInfo.Start.Line == 0) { elemNameLi = endTagLi = null; return; } elemNameLi = new SourceLineInfo( lineInfo.Uri, lineInfo.Start.Line, lineInfo.Start.Pos + 1, // "<" lineInfo.Start.Line, lineInfo.Start.Pos + 1 + elemNameLength ); if (!input.IsEmptyElement) { Debug.Assert(input.NodeType == XmlNodeType.EndElement); endTagLi = input.BuildLineInfo(); } else { Debug.Assert(input.NodeType == XmlNodeType.Element || input.NodeType == XmlNodeType.Attribute); endTagLi = new EmptyElementEndTag(lineInfo); } }
private void SetLineInfoCheck(QilNode n, ISourceLineInfo lineInfo) { // Prevent xsl:choose override xsl:when, etc. if (n.SourceLine == null) { SetLineInfo(n, lineInfo); } else { Debug.Assert(!IsDebug, "Attempt to override SourceLineInfo in debug mode"); } }
public EmptyElementEndTag(ISourceLineInfo elementTagLi) { this.elementTagLi = elementTagLi; }
internal XslLoadException(Exception inner, ISourceLineInfo lineInfo) : base(inner, SR.Xslt_CompileError2, null) { SetSourceLineInfo(lineInfo); }
protected XslLoadException (SerializationInfo info, StreamingContext context) : base(info, context) { bool hasLineInfo = (bool) info.GetValue("hasLineInfo", typeof(bool)); if (hasLineInfo) { string uriString; int startLine, startPos, endLine, endPos; uriString = (string) info.GetValue("Uri" , typeof(string )); startLine = (int) info.GetValue("StartLine" , typeof(int )); startPos = (int) info.GetValue("StartPos" , typeof(int )); endLine = (int) info.GetValue("EndLine" , typeof(int )); endPos = (int) info.GetValue("EndPos" , typeof(int )); lineInfo = new SourceLineInfo(uriString, startLine, startPos, endLine, endPos); } }
private static string AppendLineInfoMessage(string message, ISourceLineInfo lineInfo) { if (lineInfo != null) { string fileName = SourceLineInfo.GetFileName(lineInfo.Uri); string lineInfoMessage = CreateMessage(SR.Xml_ErrorFilePosition, fileName, lineInfo.Start.Line.ToString(CultureInfo.InvariantCulture), lineInfo.Start.Pos.ToString(CultureInfo.InvariantCulture)); if (lineInfoMessage != null && lineInfoMessage.Length > 0) { if (message.Length > 0 && !XmlCharType.Instance.IsWhiteSpace(message[message.Length - 1])) { message += " "; } message += lineInfoMessage; } } return message; }
public XslNodeEx(XslNodeType t, QilName name, object arg, ContextInfo ctxInfo, XslVersion xslVer) : base(t, name, arg, xslVer) { ElemNameLi = ctxInfo.elemNameLi; EndTagLi = ctxInfo.endTagLi; }
/// <summary> /// Correlate the current IL generation position with the current source position. /// </summary> public void DebugSequencePoint(ISourceLineInfo sourceInfo) { Debug.Assert(_isDebug && _lastSourceInfo != null); Debug.Assert(sourceInfo != null); // When emitting sequence points, be careful to always follow two rules: // 1. Never emit adjacent sequence points, as this messes up the debugger. We guarantee this by // always emitting a Nop before every sequence point. // 2. The runtime enforces a rule that BP sequence points can only appear at zero stack depth, // or if a NOP instruction is placed before them. We guarantee this by always emitting a Nop // before every sequence point. // <spec>http://devdiv/Documents/Whidbey/CLR/CurrentSpecs/Debugging%20and%20Profiling/JIT-Determined%20Sequence%20Points.doc</spec> Emit(OpCodes.Nop); MarkSequencePoint(sourceInfo); }
// Create ContextInfo based on existing line info (used during AST rewriting) internal ContextInfo(ISourceLineInfo lineinfo) { this.elemNameLi = lineinfo; this.endTagLi = lineinfo; this.lineInfo = lineinfo; }
private void MarkSequencePoint(ISourceLineInfo sourceInfo) { Debug.Assert(_module.EmitSymbols); // Do not emit adjacent 0xfeefee sequence points, as that slows down stepping in the debugger if (sourceInfo.IsNoSource && _lastSourceInfo != null && _lastSourceInfo.IsNoSource) { return; } string sourceFile = GetFileName(sourceInfo); #if DEBUG if (XmlILTrace.IsEnabled) { if (sourceInfo.IsNoSource) this.writerDump.WriteLine("//[no source]"); else { if (sourceFile != this.sourceFile) { this.sourceFile = sourceFile; this.writerDump.WriteLine("// Source File '{0}'", this.sourceFile); } this.writerDump.WriteLine("//[{0},{1} -- {2},{3}]", sourceInfo.Start.Line, sourceInfo.Start.Pos, sourceInfo.End.Line, sourceInfo.End.Pos); } } #endif //ISymbolDocumentWriter symDoc = this.module.AddSourceDocument(sourceFile); //this.ilgen.MarkSequencePoint(symDoc, sourceInfo.Start.Line, sourceInfo.Start.Pos, sourceInfo.End.Line, sourceInfo.End.Pos); _lastSourceInfo = sourceInfo; }
public QilNode Error(ISourceLineInfo lineInfo, string res, params string[] args) { return(Error(String(XslLoadException.CreateMessage(lineInfo, res, args)))); }
private QilNode WrapInSequencePoints(ISourceLineInfo before, QilNode expr, ISourceLineInfo after) { if (IsDebug) { return f.Sequence( SetLineInfo(f.Nop(f.Sequence()), before), expr, SetLineInfo(f.Nop(f.Sequence()), after) ); } return expr; }
public QilNode Error(ISourceLineInfo lineInfo, string res, params string[] args) { return Error(String(XslLoadException.CreateMessage(lineInfo, res, args))); }
public static void LogCodedWarning(int verbosity, LocalizedMessage message, ISourceLineInfo sourceInfo, params string [] args) => LogCodedWarning(verbosity, message, null, sourceInfo.SourceFile, sourceInfo.LineNumber, sourceInfo.LinePosition, args);
// SQLBUDT 278010: debugger does not work with network paths in uri format, like file://server/share/dir/file private string GetFileName(ISourceLineInfo sourceInfo) { string uriString = sourceInfo.Uri; if ((object)uriString == (object)_lastUriString) { return _lastFileName; } _lastUriString = uriString; _lastFileName = SourceLineInfo.GetFileName(uriString); return _lastFileName; }
private QilNode WrapLoopBody(ISourceLineInfo before, QilNode expr, ISourceLineInfo after) { Debug.Assert(_curLoop.IsFocusSet); if (IsDebug) { return _f.Sequence( SetLineInfo(InvokeOnCurrentNodeChanged(), before), expr, SetLineInfo(_f.Nop(_f.Sequence()), after) ); } return expr; }
/// <summary> /// Begin generating code within a new method. /// </summary> // SxS note: Using hardcoded "dump.il" is an SxS issue. Since we are doing this ONLY in debug builds // and only for tracing purposes and MakeVersionSafeName does not seem to be able to handle file // extensions correctly I decided to suppress the SxS message (as advised by SxS guys). public void MethodBegin(MethodBase methInfo, ISourceLineInfo sourceInfo, bool initWriters) { _methInfo = methInfo; _ilgen = XmlILModule.DefineMethodBody(methInfo); _lastSourceInfo = null; #if DEBUG if (XmlILTrace.IsEnabled) { this.numLocals = 0; this.symbols = new Hashtable(); this.lblNum = 0; this.sourceFile = null; this.writerDump = XmlILTrace.GetTraceWriter("dump.il"); this.writerDump.WriteLine(".method {0}()", methInfo.Name); this.writerDump.WriteLine("{"); } #endif if (_isDebug) { DebugStartScope(); // DebugInfo: Sequence point just before generating code for this function if (sourceInfo != null) { // Don't call DebugSequencePoint, as it puts Nop *before* the sequence point. That is // wrong in this case, because we need source line information to be emitted before any // IL instruction so that stepping into this function won't end up in the assembly window. // We still guarantee that: // 1. Two sequence points are never adjacent, since this is the 1st sequence point // 2. Stack depth is 0, since this is the very beginning of the method MarkSequencePoint(sourceInfo); Emit(OpCodes.Nop); } } else if (_module.EmitSymbols) { // For a retail build, put source information on methods only if (sourceInfo != null) { MarkSequencePoint(sourceInfo); // Set this.lastSourceInfo back to null to prevent generating additional sequence points // in this method. _lastSourceInfo = null; } } _initWriters = false; if (initWriters) { EnsureWriter(); LoadQueryRuntime(); Call(XmlILMethods.GetOutput); Emit(OpCodes.Stloc, _locXOut); } }