private void EmitError(IObjectWithLocations node, ErrorCode code) { if (this.errors.ContainsKey(node)) { return; } this.errors.Add(node, new ErrorNode() { Node = node, Code = code }); }
public void EmitSourceContext(IObjectWithLocations element) { if (element is IEmptyStatement) { return; } var tok = element.Token(); string fileName = null; int lineNumber = 0; if (this.PdbReader != null) { var slocs = this.PdbReader.GetClosestPrimarySourceLocationsFor(element.Locations); foreach (var sloc in slocs) { fileName = sloc.Document.Location; lineNumber = sloc.StartLine; this.lastSourceLocation = sloc; break; } if (fileName != null) { var attrib = new Bpl.QKeyValue(tok, "sourceLine", new List <object> { Bpl.Expr.Literal((int)lineNumber) }, null); attrib = new Bpl.QKeyValue(tok, "sourceFile", new List <object> { fileName }, attrib); attrib = new Bpl.QKeyValue(tok, "first", new List <object>(), attrib); this.StmtBuilder.Add( new Bpl.AssertCmd(tok, Bpl.Expr.True, attrib) ); } } }
public static Bpl.IToken Token(this IObjectWithLocations objectWithLocations) { //TODO: use objectWithLocations.Locations! Bpl.IToken tok = Bpl.Token.NoToken; return(tok); }
private static IEnumerable <IPrimarySourceLocation> GetValidLocations(this IObjectWithLocations locatable, PdbReader pdb) { return(from l in pdb.GetPrimarySourceLocationsFor(locatable.Locations) where l.Length != 0 select l); }
private static IPrimarySourceLocation GetValidLocation(this IObjectWithLocations locatable, PdbReader pdb) { return(pdb == null ? null : locatable.GetValidLocations(pdb).FirstOrDefault()); }
private static SourceCodeLocation Of(this IObjectWithLocations locatable, PdbReader pdb) { IPrimarySourceLocation location = locatable.GetValidLocation(pdb); return(location != null?location.ToSourceCodeLocation() : SourceCodeLocation.None); }