void PrintLineFor(StringBuilder sb, int pc, int? characterStartPos, int? characterEndPos)
{
var foundLocation = false;
if (characterStartPos != null && characterEndPos != null) {
if (this.sources != null) {
var fileName = this.FindFileName (pc);
var sourceFile = SourceFile.FindSource (this.sources, fileName);
if (sourceFile != null) {
var startPos = Position.CalculatePosition (sourceFile, characterStartPos.Value);
var endPos = Position.CalculatePosition (sourceFile, characterEndPos.Value);
var lines = Utils.ExtractRelevantSource (sourceFile.Content.Split ('\n'), startPos, endPos);
foreach (var line in lines) {
sb.AppendLine (line);
}
foundLocation = true;
}
}
}
if (!foundLocation) {
sb.AppendLine (String.Format (
"... unknown source location, program counter {0} ...",
pc)
);
}
}