@Override public String getDefPredString() { if (stitch == null) { return ""; } String result = stitch.toString(); return result; }
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 IProofObligationList caseATailUnaryExp(ATailUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getExp().apply(mainVisitor, question); if (!aF.createPTypeAssistant().isType(node.getExp().getType(), ASeq1SeqType.class)) { obligations.add(new NonEmptySeqObligation(node.getExp(), question, aF)); } return obligations; }
private void checkNumeric(SNumericBinaryExp node, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { node.getLeft().apply(rootVisitor, question.newConstraint(null)); node.getRight().apply(rootVisitor, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isNumeric(node.getLeft().getType())) { TypeCheckerErrors.report(3139, "Left hand of " + node.getOp() + " is not numeric", node.getLocation(), node); TypeCheckerErrors.detail("Actual", node.getLeft().getType()); node.getLeft().setType(AstFactory.newARealNumericBasicType(node.getLocation())); } if (!question.assistantFactory.createPTypeAssistant().isNumeric(node.getRight().getType())) { TypeCheckerErrors.report(3140, "Right hand of " + node.getOp() + " is not numeric", node.getLocation(), node); TypeCheckerErrors.detail("Actual", node.getRight().getType()); node.getRight().setType(AstFactory.newARealNumericBasicType(node.getLocation())); } }
private IProofObligationList handleNumericBinaryExpression(SNumericBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp[] leftRight = getLeftRight(node); PExp left = leftRight[LEFT]; PExp right = leftRight[RIGHT]; PType ltype = left.getType(); PType rtype = right.getType(); if (left.getLocation().getStartLine() == 2792) { System.out.println("fd"); } handleBinExpSubNode(question, obligations, left, ltype); handleBinExpSubNode(question, obligations, right , rtype); obligations.addAll(left.apply(mainVisitor, question)); obligations.addAll(right.apply(mainVisitor, question)); return obligations; }
throws AnalysisException super(root, POType.FUNC_APPLY, ctxt, root.getLocation(), af); preExp.setFunction(root.clone()); preExp.setArgs(cloneListPExp(args)); stitch = preExp.clone(); varExp.setType(root.getType().clone()); PExp pred = getApplyExp(varExp, cloneListPExp(args)); pred.setType(new ABooleanBasicType()); stitch = pred.clone(); valuetree.setPredicate(ctxt.getPredWithContext(pred));
public PExp caseAMapletPatternMaplet(AMapletPatternMaplet node) throws AnalysisException { AMapletExp maplet = new AMapletExp(); PExp from = node.getFrom().apply(this).clone(); maplet.setLeft(from); PExp to = node.getTo().apply(this).clone(); maplet.setRight(to); maplet.setType(AstFactory.newAMapMapType(null, from.getType().clone(), to.getType().clone())); return maplet; }
@Override public ILexLocation defaultPExp(PExp node) throws AnalysisException { return node.getLocation(); }
@Override public PType caseACardinalityUnaryExp(ACardinalityUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp exp = node.getExp(); question.qualifiers = null; if (!question.assistantFactory.createPTypeAssistant().isSet(exp.apply(THIS, question.newConstraint(null)))) { TypeCheckerErrors.report(3067, "Argument of 'card' is not a set", exp.getLocation(), exp); } node.setType(AstFactory.newANatNumericBasicType(node.getLocation())); return question.assistantFactory.createPTypeAssistant().possibleConstraint(question.constraint, node.getType(), node.getLocation()); }
public boolean isIntegerType(PExp exp) { PType type = exp.getType(); // Expressions like 1.0 are considered real literal expressions // of type NatOneNumericBasicType return (type instanceof ANatOneNumericBasicType || type instanceof ANatNumericBasicType || type instanceof AIntNumericBasicType) && !(exp instanceof ARealLiteralExp); }
public SExpIR handleQuantifier(PExp node, List<PMultipleBind> bindings, PExp predicate, SQuantifierExpIR quantifier, IRInfo question, String nodeStr) throws AnalysisException { LinkedList<SMultipleBindIR> bindingsCg = new LinkedList<SMultipleBindIR>(); for (PMultipleBind multipleBind : bindings) { SMultipleBindIR multipleBindCg = multipleBind.apply(question.getMultipleBindVisitor(), question); if (multipleBindCg != null) { bindingsCg.add(multipleBindCg); } } PType type = node.getType(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR predicateCg = predicate.apply(question.getExpVisitor(), question); quantifier.setType(typeCg); quantifier.setBindList(bindingsCg); quantifier.setPredicate(predicateCg); return quantifier; }
private void checkOrdered(SNumericBinaryExp node, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { node.getLeft().apply(rootVisitor, question.newConstraint(null)); node.getRight().apply(rootVisitor, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isOrdered(node.getLeft().getType(), node.getLocation())) { TypeCheckerErrors.report(3139, "Left hand of " + node.getOp() + " is not ordered", node.getLocation(), node); TypeCheckerErrors.detail("Actual", node.getLeft().getType()); node.getLeft().setType(AstFactory.newARealNumericBasicType(node.getLocation())); } if (!question.assistantFactory.createPTypeAssistant().isOrdered(node.getRight().getType(), node.getLocation())) { TypeCheckerErrors.report(3140, "Right hand of " + node.getOp() + " is not ordered", node.getLocation(), node); TypeCheckerErrors.detail("Actual", node.getRight().getType()); node.getRight().setType(AstFactory.newARealNumericBasicType(node.getLocation())); } }
if (exp.getType() != null && etype != null && rec) if (assistantFactory.getTypeComparator().isSubType(exp.getType(), etype)) po.setType(new ABooleanBasicType()); PExp s = oneType(true, e.clone(), fit.next().getType(), ait.next()); ne.setOp(new LexKeywordToken(VDMToken.NE, exp.getLocation())); ASeqEnumSeqExp empty = new ASeqEnumSeqExp(); empty.setMembers(new Vector<PExp>()); PExp s = oneType(true, m.clone(), stype.getSeqof().clone(), it.next().clone()); PType itype = AstFactory.newANatOneNumericBasicType(exp.getLocation()); PExp s = oneType(true, subseq.getFrom(), itype, subseq.getFtype()); ne.setOp(new LexKeywordToken(VDMToken.NE, exp.getLocation())); ASetEnumSetExp empty = new ASetEnumSetExp(); empty.setMembers(new Vector<PExp>()); PExp s = oneType(true, m.clone(), stype.getSetof(), it.next().clone()); PType itype = AstFactory.newAIntNumericBasicType(exp.getLocation()); PExp s = oneType(true, e.clone(), eit.next(), ait.next()); gt.setOp(new LexKeywordToken(VDMToken.GT, exp.getLocation())); gt.setRight(getIntLiteral(0));