summaryrefslogtreecommitdiff
path: root/Source/ModelViewer/DataModel.cs
diff options
context:
space:
mode:
authorGravatar MichalMoskal <unknown>2010-10-12 01:18:57 +0000
committerGravatar MichalMoskal <unknown>2010-10-12 01:18:57 +0000
commit15e2fa869e98fdd7900a422aa78bb034d39bfe37 (patch)
treeb69460614f7c0f1788e3d5a69287725aa4ea3095 /Source/ModelViewer/DataModel.cs
parent45fb2f73118bf4010ad08757122d829c76e676d3 (diff)
Put in proper namespace, move files around.
Diffstat (limited to 'Source/ModelViewer/DataModel.cs')
-rw-r--r--Source/ModelViewer/DataModel.cs82
1 files changed, 82 insertions, 0 deletions
diff --git a/Source/ModelViewer/DataModel.cs b/Source/ModelViewer/DataModel.cs
new file mode 100644
index 00000000..f2250e0f
--- /dev/null
+++ b/Source/ModelViewer/DataModel.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Microsoft.Boogie.ModelViewer
+{
+ public interface IDisplayNode
+ {
+ string Name { get; }
+ IEnumerable<string> Values { get; }
+ bool Expandable { get; }
+ IEnumerable<IDisplayNode> Expand();
+ object ViewSync { get; set; }
+ }
+
+ public class StateNode : IDisplayNode
+ {
+ protected Model.CapturedState state;
+
+ public StateNode(Model.CapturedState s)
+ {
+ state = s;
+ }
+
+ public virtual string Name
+ {
+ get { return "State"; }
+ }
+
+ public virtual IEnumerable<string> Values
+ {
+ get { yield return state.Name; }
+ }
+
+ public virtual bool Expandable { get { return state.VariableCount != 0; } }
+
+ public virtual IEnumerable<IDisplayNode> Expand()
+ {
+ foreach (var v in state.Variables) {
+ yield return new ElementNode(v, state.TryGet(v));
+ }
+ }
+
+ public object ViewSync { get; set; }
+ }
+
+ public class ElementNode : IDisplayNode
+ {
+ protected Model.Element elt;
+ protected string name;
+
+ public ElementNode(string name, Model.Element elt)
+ {
+ this.name = name;
+ this.elt = elt;
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ }
+
+ public virtual IEnumerable<string> Values
+ {
+ get
+ {
+ if (!(elt is Model.Uninterpreted))
+ yield return elt.ToString();
+ foreach (var tupl in elt.Names) {
+ if (tupl.Func.Arity == 0)
+ yield return tupl.Func.Name;
+ }
+ }
+ }
+
+ public virtual bool Expandable { get { return false; } }
+ public virtual IEnumerable<IDisplayNode> Expand() { yield break; }
+
+ public object ViewSync { get; set; }
+ }
+}