summaryrefslogtreecommitdiff
path: root/Source/VCGeneration/ConditionGeneration.cs
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2010-11-01 21:56:14 +0000
committerGravatar rustanleino <unknown>2010-11-01 21:56:14 +0000
commit31f5a7c20e25225e4b9dca95e60e955402f64df6 (patch)
treea8b2a54790d1e1900ed0a7ea8d00bd6faa7ce31f /Source/VCGeneration/ConditionGeneration.cs
parent1219dc1f931e17918d3a1bfe580149b21493a0c4 (diff)
Dafny: a partial first crack at a Dafny model-viewer provider, including captureState mark-ups in the Boogie code generated from Dafny
Diffstat (limited to 'Source/VCGeneration/ConditionGeneration.cs')
-rw-r--r--Source/VCGeneration/ConditionGeneration.cs40
1 files changed, 21 insertions, 19 deletions
diff --git a/Source/VCGeneration/ConditionGeneration.cs b/Source/VCGeneration/ConditionGeneration.cs
index 927868b5..031f0f18 100644
--- a/Source/VCGeneration/ConditionGeneration.cs
+++ b/Source/VCGeneration/ConditionGeneration.cs
@@ -210,10 +210,7 @@ namespace Microsoft.Boogie {
Contract.Assert(mvstates.Arity == 1);
foreach (Variable v in MvInfo.AllVariables) {
- var fn = m.TryGetFunc(v.Name);
- if (fn != null && fn.Arity == 0) {
- m.InitialState.AddBinding(v.Name, fn.GetConstant());
- }
+ m.InitialState.AddBinding(v.Name, GetModelValue(m, v));
}
var states = new List<int>();
@@ -239,21 +236,7 @@ namespace Microsoft.Boogie {
if (e is IdentifierExpr) {
IdentifierExpr ide = (IdentifierExpr)e;
-
- // first, get the unique name
- string uniqueName;
- VCExprVar vvar = Context.BoogieExprTranslator.TryLookupVariable(ide.Decl);
- if (vvar == null) {
- uniqueName = ide.Decl.Name;
- } else {
- uniqueName = Context.Lookup(vvar);
- }
-
- var f = m.TryGetFunc(uniqueName);
- if (f == null) {
- f = m.MkFunc(uniqueName, 0);
- }
- elt = f.GetConstant();
+ elt = GetModelValue(m, ide.Decl);
} else if (e is LiteralExpr) {
LiteralExpr lit = (LiteralExpr)e;
elt = m.MkElement(lit.Val.ToString());
@@ -272,6 +255,25 @@ namespace Microsoft.Boogie {
return m;
}
+ private Model.Element GetModelValue(Model m, Variable v) {
+ Model.Element elt;
+ // first, get the unique name
+ string uniqueName;
+ VCExprVar vvar = Context.BoogieExprTranslator.TryLookupVariable(v);
+ if (vvar == null) {
+ uniqueName = v.Name;
+ } else {
+ uniqueName = Context.Lookup(vvar);
+ }
+
+ var f = m.TryGetFunc(uniqueName);
+ if (f == null) {
+ f = m.MkFunc(uniqueName, 0);
+ }
+ elt = f.GetConstant();
+ return elt;
+ }
+
public abstract int GetLocation();
}