@Override public PExp getContextNode(PExp stitch) { for (Substitution sub : subs) { try { stitch = stitch.clone().apply(af.getVarSubVisitor(), sub); } catch (AnalysisException e) { e.printStackTrace(); } } return stitch; }
public OpPostConditionContext(AExplicitFunctionDefinition postDef, ACallStm stm, SOperationDefinitionBase calledOp, IPogAssistantFactory af, IPOContextStack ctxt) { super(ctxt); this.gen = ctxt.getGenerator(); this.subs = new LinkedList<Substitution>(); this.forall_exp = getChangedVarsExp(postDef, calledOp); PExp inv = buildInvExp(calledOp, af); this.pred = spellCondition(postDef, af, stm.getArgs(), inv); this.visitor = af.getVarSubVisitor(); }
public OpPostConditionContext(AExplicitFunctionDefinition postDef, AApplyExp exp, SOperationDefinitionBase calledOp, IPogAssistantFactory af, IPOContextStack ctxt) { super(ctxt); this.visitor = af.getVarSubVisitor(); this.gen = ctxt.getGenerator(); this.subs = new LinkedList<Substitution>(); this.forall_exp = getChangedVarsExp(postDef, calledOp); PExp inv = buildInvExp(calledOp, af); this.pred = spellCondition(postDef, af, exp.getArgs(), inv); }
private PExp rewritePost(PExp post_exp, List<Substitution> subs, IPogAssistantFactory af) { if (post_exp instanceof APostOpExp) { // post-expression bodies are wrapped in a PostOpExp for some reason... post_exp = ((APostOpExp) post_exp).getPostexpression(); } for (Substitution sub : subs) { try { post_exp = post_exp.clone().apply(af.getVarSubVisitor(), sub); } catch (AnalysisException e) { e.printStackTrace(); } } return post_exp; }
public OperationCallObligation(ACallStm stm, SOperationDefinitionBase def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(stm, POType.OP_CALL, ctxt, stm.getLocation(), af); // cannot quote pre-cond so we spell it out with rewritten arguments List<Substitution> subs = new LinkedList<Substitution>(); for (int i = 0; i < stm.getArgs().size(); i++) { PPattern orig = def.getPredef().getParamPatternList().get(0).get(i); ILexNameToken origName = af.createPPatternAssistant().getAllVariableNames(orig).get(0).clone(); PExp new_exp = stm.getArgs().get(0); subs.add(new Substitution(origName, new_exp)); } PExp pre_exp = def.getPrecondition().clone(); for (Substitution sub : subs) { pre_exp = pre_exp.clone().apply(af.getVarSubVisitor(), sub); } stitch = pre_exp; valuetree.setPredicate(ctxt.getPredWithContext(pre_exp)); }
public AssignmentContext(AAssignmentStm node, IPogAssistantFactory af, IPOContextStack ctxt) throws AnalysisException { super(ctxt); String hash = node.getTarget().apply(af.getStateDesignatorNameGetter()); t = null; for (ILexNameToken n : last_vars.keySet()) { if (n.getName().equals(hash)) { t = last_vars.get(n).getName().clone(); break; } } if (t == null) { t = new LexNameToken("", hash, null); } subLast = new Substitution(new LexNameToken("", hash, null), node.getExp().clone()); sub = new Substitution(t, node.getExp().clone()); this.visitor = af.getVarSubVisitor(); }
public StateInvariantObligation(AAtomicStm atom, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(atom, POType.STATE_INV, ctxt, atom.getLocation(), af); assistantFactory = af; PExp invApplyExp = makeInvApplyExp(atom); PExp invApplyExpForSub = invApplyExp.clone(); List<Substitution> subs = new LinkedList<Substitution>(); for (AAssignmentStm asgn : atom.getAssignments()) { String hash = asgn.getTarget().apply(af.getStateDesignatorNameGetter()); subs.add(new Substitution(hash, asgn.getExp().clone())); } IVariableSubVisitor varSubVisitor = af.getVarSubVisitor(); for (Substitution sub : subs) { invApplyExpForSub = invApplyExpForSub.apply(varSubVisitor, sub); } stitch = AstExpressionFactory.newAImpliesBooleanBinaryExp(invApplyExp, invApplyExpForSub); valuetree.setPredicate(stitch); }
if (ivdef.getInitialized()) question.push(new AssignmentContext((AInstanceVariableDefinition) pdef, assistantFactory.getVarSubVisitor(), question));
hash = ass.getTarget().apply(af.getStateDesignatorNameGetter()); Substitution sub = new Substitution(new LexNameToken("", hash, null), ass.getExp().clone()); PExp new_invs = old_invs.clone().apply(af.getVarSubVisitor(), sub);