private void PrintResultHelper(object result) { if (result is bool) { buffer.Write((bool)result ? "True" : "False"); } else if (result is Stringish || result is long || result is double) { buffer.Write("{0}", HttpUtility.HtmlEncode(result)); } else if (result is byte[]) { buffer.Write("{0} bytes of Unspeakable Horror", ((byte[])result).Length); } else if (result is Template) { buffer.Write("Template {"); foreach (var attr in ((Template)result).GetAttributeNames()) { buffer.Write(" {0}", attr); } buffer.Write(" }"); } else if (result is Frame) { var frame_result = (Frame)result; if (result_seen.ContainsKey(frame_result)) { buffer.Write("<a href='#{0}'>Frame {0}</a>", frame_result.Id); return; } if (filter_lib && frame_result.Container == frame_result && frame_result.SourceReference is BasicSourceReference && ((BasicSourceReference)frame_result.SourceReference).FileName != "web") { buffer.Write("<p>Library {0} (not shown)</p>", ((BasicSourceReference)frame_result.SourceReference).FileName); return; } result_seen[frame_result] = true; buffer.Write("<p>Frame {0}</p><table id='{0}' title='{0}'>", frame_result.Id); foreach (var attr_name in frame_result.GetAttributeNames()) { var type = frame_result[attr_name].GetType(); buffer.Write("<tr class='{1}' title='{1}'><td>{0}</td><td>", attr_name, typeof(Future).IsAssignableFrom(type) ? "Comp" : SupportFunctions.NameForType(type)); PrintResultHelper(frame_result[attr_name]); buffer.Write("</td></tr>"); } buffer.Write("</table>"); } else if (result is Future) { buffer.Write("Unfinished computation"); } else { buffer.Write("Unknown value of type {0}.", SupportFunctions.NameForType(result.GetType())); } }