From c78b9efc4d974dded811e1964cf4459fc22f3aec Mon Sep 17 00:00:00 2001 From: MichalMoskal Date: Fri, 10 Dec 2010 01:35:27 +0000 Subject: Add ToString() overrides to help in debugging --- Source/Core/AbsyCmd.cs | 11 +++++++++++ Source/Model/Model.cs | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Source/Core/AbsyCmd.cs b/Source/Core/AbsyCmd.cs index 125e33f6..363578e5 100644 --- a/Source/Core/AbsyCmd.cs +++ b/Source/Core/AbsyCmd.cs @@ -1018,6 +1018,17 @@ namespace Microsoft.Boogie { kv.Typecheck(tc); } } + + [Pure] + public override string ToString() + { + Contract.Ensures(Contract.Result() != null); + System.IO.StringWriter buffer = new System.IO.StringWriter(); + using (TokenTextWriter stream = new TokenTextWriter("", buffer, false)) { + this.Emit(stream, 0); + } + return buffer.ToString(); + } } public class CommentCmd : Cmd // just a convenience for debugging diff --git a/Source/Model/Model.cs b/Source/Model/Model.cs index c04be448..9aeb5440 100644 --- a/Source/Model/Model.cs +++ b/Source/Model/Model.cs @@ -7,6 +7,7 @@ using System; using System.Linq; using System.Collections.Generic; +using System.Text; namespace Microsoft.Boogie { @@ -93,6 +94,11 @@ namespace Microsoft.Boogie internal Func(Model p, string n, int a) { Model = p; Name = n; Arity = a; } + public override string ToString() + { + return string.Format("{0}/{1}", Name, Arity); + } + public void SetConstant(Element res) { if (Arity != 0 || apps.Count > 0) @@ -204,6 +210,18 @@ namespace Microsoft.Boogie Func = func; Result = res; } + + public override string ToString() + { + var res = new StringBuilder(); + res.Append(Func.Name).Append("("); + for (int i = 0; i < Args.Length; ++i) { + if (i != 0) res.Append(", "); + res.Append(Args[i]); + } + res.Append(" -> ").Append(Result); + return res.ToString(); + } } #endregion -- cgit v1.2.3