Package: LetBeExistsObligation

LetBeExistsObligation

nameinstructionbranchcomplexitylinemethod
LetBeExistsObligation(ALetBeStExp, IPOContextStack, IPogAssistantFactory)
M: 0 C: 59
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
LetBeExistsObligation(ALetBeStStm, IPOContextStack, IPogAssistantFactory)
M: 0 C: 59
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 13
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (C) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.pog.obligation;
25:
26: import java.util.List;
27: import java.util.Vector;
28:
29: import org.overture.ast.analysis.AnalysisException;
30: import org.overture.ast.expressions.ABooleanConstExp;
31: import org.overture.ast.expressions.AExistsExp;
32: import org.overture.ast.expressions.ALetBeStExp;
33: import org.overture.ast.lex.LexBooleanToken;
34: import org.overture.ast.patterns.PMultipleBind;
35: import org.overture.ast.statements.ALetBeStStm;
36: import org.overture.pog.pub.IPOContextStack;
37: import org.overture.pog.pub.IPogAssistantFactory;
38: import org.overture.pog.pub.POType;
39:
40: public class LetBeExistsObligation extends ProofObligation
41: {
42:         private static final long serialVersionUID = 4190499967249305830L;
43:
44:         public LetBeExistsObligation(ALetBeStExp exp, IPOContextStack ctxt,
45:                         IPogAssistantFactory af) throws AnalysisException
46:         {
47:                 super(exp, POType.LET_BE_EXISTS, ctxt, exp.getBind().getLocation(), af);
48:
49:                 /**
50:                  * let <binds> be st <predicate> in <exp> produces exists <binds> & <predicate>
51:                  */
52:
53:                 AExistsExp exists = new AExistsExp();
54:                 List<PMultipleBind> bindList = new Vector<PMultipleBind>();
55:                 bindList.add(exp.getBind().clone());
56:                 exists.setBindList(bindList);
57:
58:•                if (exp.getSuchThat() != null)
59:                 {
60:                         exists.setPredicate(exp.getSuchThat().clone());
61:                 } else
62:                 {
63:                         // we just use true since we cannot have
64:                         // exists by itself
65:                         ABooleanConstExp replacementNothing_exp = new ABooleanConstExp();
66:                         replacementNothing_exp.setValue(new LexBooleanToken(true, null));
67:
68:                         exists.setPredicate(replacementNothing_exp);
69:                 }
70:
71:                 stitch = exists;
72:                 valuetree.setPredicate(ctxt.getPredWithContext(exists));
73:         }
74:
75:         public LetBeExistsObligation(ALetBeStStm stmt, IPOContextStack ctxt,
76:                         IPogAssistantFactory af) throws AnalysisException
77:         {
78:                 super(stmt, POType.LET_BE_EXISTS, ctxt, stmt.getBind().getLocation(), af);
79:
80:                 AExistsExp exists = new AExistsExp();
81:                 List<PMultipleBind> bindList = new Vector<PMultipleBind>();
82:                 bindList.add(stmt.getBind().clone());
83:                 exists.setBindList(bindList);
84:
85:•                if (stmt.getSuchThat() != null)
86:                 {
87:                         exists.setPredicate(stmt.getSuchThat().clone());
88:                 } else
89:                 {
90:                         // we just use true since we cannot have
91:                         // exists by itself
92:                         ABooleanConstExp replacementNothing_exp = new ABooleanConstExp();
93:                         replacementNothing_exp.setValue(new LexBooleanToken(true, null));
94:
95:                         exists.setPredicate(replacementNothing_exp);
96:                 }
97:                 stitch = exists;
98:                 valuetree.setPredicate(ctxt.getPredWithContext(exists));
99:         }
100: }