public virtual string ToDotString()
{
#if COMPACT
throw new NotImplementedException("The current platform does not provide RuntimeHelpers.GetHashCode(object).");
#else
StringBuilder builder = new StringBuilder();
builder.Append("digraph G {\n");
builder.Append("rankdir=LR;\n");
HashSet<PredictionContext> visited = new HashSet<PredictionContext>();
Stack<PredictionContext> workList = new Stack<PredictionContext>();
workList.Push(Context);
visited.Add(Context);
while (workList.Count > 0)
{
PredictionContext current = workList.Pop();
for (int i = 0; i < current.Size; i++)
{
builder.Append(" s").Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(current));
builder.Append("->");
builder.Append("s").Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(current.GetParent(i)));
builder.Append("[label=\"").Append(current.GetReturnState(i)).Append("\"];\n");
if (visited.Add(current.GetParent(i)))
{
workList.Push(current.GetParent(i));
}
}
}
builder.Append("}\n");
return builder.ToString();
#endif
}