private PExp handlePrePost(PExp preexp, PExp postexp, List<AErrorCase> errs) { if (preexp != null) { // (preexp and postexp) AAndBooleanBinaryExp andExp = AstExpressionFactory.newAAndBooleanBinaryExp(preexp.clone(), postexp); return andExp; } else { return postexp; } }
public POForAllContext(PBind bind, PExp exp) { // Create new binding for "bind.pattern in set elems exp" bindings = new Vector<PMultipleBind>(); List<PPattern> pl = new ArrayList<PPattern>(); pl.add(bind.getPattern().clone()); AElementsUnaryExp elems = AstFactory.newAElementsUnaryExp(exp.getLocation(), exp.clone()); ASetMultipleBind msb = AstFactory.newASetMultipleBind(pl, elems); bindings.add(msb); }
@Override public PExp caseAMapSeqStateDesignator(AMapSeqStateDesignator node) throws AnalysisException { AApplyExp applyExp = new AApplyExp(); applyExp.setRoot(node.getMapseq().apply(this).clone()); List<PExp> args = new LinkedList<PExp>(); args.add(node.getExp().clone()); applyExp.setArgs(args); return applyExp; }
public PExp caseASetPattern(ASetPattern node) throws AnalysisException { ASetEnumSetExp set = new ASetEnumSetExp(); List<PExp> values = new Vector<PExp>(); for (PPattern p : node.getPlist()) { values.add(p.apply(this).clone()); } set.setMembers(values); return addPossibleType(set, node); }
public CasesExhaustiveObligation(ACasesExp exp, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(exp, POType.CASES_EXHAUSTIVE, ctxt, exp.getLocation(), assistantFactory); PExp initialExp = alt2Exp(exp.getCases().getFirst(), exp, assistantFactory); List<ACaseAlternative> initialCases = new LinkedList<ACaseAlternative>(exp.getCases()); initialCases.remove(0); PExp pred = recOnExp(exp.clone(), initialCases, initialExp, assistantFactory); stitch = pred.clone(); valuetree.setPredicate(ctxt.getPredWithContext(pred)); }
public NonEmptySetObligation(PExp exp, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(exp, POType.NON_EMPTY_SET, ctxt, exp.getLocation(), af); // exp <> {} ASetEnumSetExp setExp = new ASetEnumSetExp(); setExp.setMembers(new LinkedList<PExp>()); // empty list ANotEqualBinaryExp notEqualsExp = AstExpressionFactory.newANotEqualBinaryExp(exp.clone(), setExp); stitch = notEqualsExp; valuetree.setPredicate(ctxt.getPredWithContext(notEqualsExp)); } }
private PExp invDefs(SClassDefinition def) { PExp root = null; for (PDefinition d : assistantFactory.createSClassDefinitionAssistant().getInvDefs(def.clone())) { AClassInvariantDefinition cid = (AClassInvariantDefinition) d; root = makeAnd(root, cid.getExpression().clone()); } return root; }
/** * Just produce one is_(<expression>, <type>) node. */ private PExp addIs(PExp exp, PType type) { AIsExp isExp = new AIsExp(); isExp.setBasicType(type); isExp.setType(new ABooleanBasicType()); isExp.setTest(exp.clone()); return isExp; } }
public SetMembershipObligation(PPattern pattern, PExp set, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(set, POType.SET_MEMBER, ctxt, set.getLocation(), af); AInSetBinaryExp inSetExp = AstExpressionFactory.newAInSetBinaryExp(patternToExp(pattern), set.clone()); stitch = inSetExp; valuetree.setPredicate(ctxt.getPredWithContext(inSetExp)); } }
public PExp caseAConcatenationPattern(AConcatenationPattern node) throws AnalysisException { ASeqConcatBinaryExp conc = new ASeqConcatBinaryExp(); conc.setLeft(node.getLeft().apply(this).clone()); conc.setOp(new LexKeywordToken(VDMToken.CONCATENATE, null)); conc.setRight(node.getRight().apply(this).clone()); return addPossibleType(conc, node); }
public PExp caseAUnionPattern(AUnionPattern node) throws AnalysisException { ASetUnionBinaryExp union = new ASetUnionBinaryExp(); union.setLeft(node.getLeft().apply(this).clone()); union.setOp(new LexKeywordToken(VDMToken.UNION, null)); union.setRight(node.getRight().apply(this).clone()); return addPossibleType(union, node); }
public OperationPostConditionObligation(AExplicitOperationDefinition op, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(op, POType.OP_POST_CONDITION, ctxt, op.getLocation(), af); PExp pred = buildExp(op.getPrecondition(), op.getPostcondition().clone(), null); stitch = pred; valuetree.setPredicate(ctxt.getPredWithContext(pred)); }
public SeqMembershipObligation(PPattern pattern, PExp seq, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(seq, POType.SEQ_MEMBER, ctxt, seq.getLocation(), af); AElementsUnaryExp elems = AstFactory.newAElementsUnaryExp(seq.getLocation(), seq.clone()); AInSetBinaryExp inSetExp = AstExpressionFactory.newAInSetBinaryExp(patternToExp(pattern), elems); stitch = inSetExp; valuetree.setPredicate(ctxt.getPredWithContext(inSetExp)); } }
public OperationPostConditionObligation(AImplicitOperationDefinition op, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(op, POType.OP_POST_CONDITION, ctxt, op.getLocation(), af); stitch = buildExp(op.getPrecondition(), op.getPostcondition().clone(), op.clone().getErrors()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
private AValueDefinition buildValueDef(PExp exp, String name) { AValueDefinition valDef = new AValueDefinition(); valDef.setType(exp.getType().clone()); valDef.setExpression(exp.clone()); AIdentifierPattern pattern = new AIdentifierPattern(); pattern.setName(new LexNameToken(null, name, null)); valDef.setPattern(pattern); return valDef; }