summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar MichalMoskal <unknown>2010-12-10 01:35:27 +0000
committerGravatar MichalMoskal <unknown>2010-12-10 01:35:27 +0000
commitc78b9efc4d974dded811e1964cf4459fc22f3aec (patch)
treee4ba4ad1d01bb44568b0b9097f78607b3912fc5c
parentc06446c8cc5f1ffe12b24d3ae192c2a17cd1ee01 (diff)
Add ToString() overrides to help in debugging
-rw-r--r--Source/Core/AbsyCmd.cs11
-rw-r--r--Source/Model/Model.cs18
2 files changed, 29 insertions, 0 deletions
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<string>() != null);
+ System.IO.StringWriter buffer = new System.IO.StringWriter();
+ using (TokenTextWriter stream = new TokenTextWriter("<buffer>", 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