public string VisitFun(FunType f) { if (f.arrows.Count == 0) { return("? -> ?"); } StringBuilder sb = new StringBuilder(); int?num = ctr.Visit(f); if (num.HasValue) { sb.Append("#").Append(num.Value); } else { int newNum = ctr.Push(f); int i = 0; ISet <string> seen = new HashSet <string>(); foreach (var e in f.arrows) { DataType from = e.Key; string sArrow = $"{from.Accept(this)} -> {e.Value.Accept(this)}"; if (!seen.Contains(sArrow)) { if (i != 0) { if (this.multiline) { sb.Append("\n| "); } else { sb.Append(" | "); } } sb.Append(sArrow); seen.Add(sArrow); } i++; } if (ctr.isUsed(f)) { sb.Append("=#").Append(newNum).Append(": "); } ctr.Pop(f); } return(sb.ToString()); }
public override bool Equals(object other) { if (other is FunType) { FunType fo = (FunType)other; return(fo.Table.Path.Equals(Table.Path) || object.ReferenceEquals(this, other)); } else { return(false); } }