public NonEmptySeqObligation(PExp exp, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(exp, POType.NON_EMPTY_SEQ, ctxt, exp.getLocation(), af); // exp <> [] ASeqEnumSeqExp seqExp = new ASeqEnumSeqExp(); seqExp.setMembers(new LinkedList<PExp>()); // empty list seqExp.setType(AstFactory.newASeqSeqType(null, new AUnknownType())); ANotEqualBinaryExp notEqualsExp = AstExpressionFactory.newANotEqualBinaryExp(exp.clone(), seqExp); stitch = notEqualsExp; valuetree.setPredicate(ctxt.getPredWithContext(notEqualsExp)); } }
@Override public PType caseASeqEnumSeqExp(ASeqEnumSeqExp node, TypeCheckInfo question) throws AnalysisException { PTypeSet ts = new PTypeSet(question.assistantFactory); node.setTypes(new LinkedList<PType>()); List<PType> types = node.getTypes(); TypeCheckInfo elemConstraint = question; if (question.constraint != null && question.assistantFactory.createPTypeAssistant().isSeq(question.constraint)) { PType stype = question.assistantFactory.createPTypeAssistant().getSeq(question.constraint).getSeqof(); elemConstraint = question.newConstraint(stype); } for (PExp ex : node.getMembers()) { question.qualifiers = null; PType mt = ex.apply(THIS, elemConstraint); ts.add(mt); types.add(mt); } node.setType(ts.isEmpty() ? AstFactory.newASeqSeqType(node.getLocation()) : AstFactory.newASeq1SeqType(node.getLocation(), ts.getType(node.getLocation()))); return question.assistantFactory.createPTypeAssistant().possibleConstraint(question.constraint, node.getType(), node.getLocation()); }