@Override public Integer defaultSSeqType(SSeqType type) throws AnalysisException { SSeqType stype = type; return stype.getEmpty() ? 0 : stype.getSeqof().apply(THIS); // hashCode(stype.getSeqof()); }
public PType sequenceApply(AApplyExp node, boolean isSimple, SSeqType seq, TypeCheckInfo question) { if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(isSimple, 3055, "Sequence selector must have one argument", node.getLocation(), node); } else if (!question.assistantFactory.createPTypeAssistant().isNumeric(node.getArgtypes().get(0))) { TypeCheckerErrors.concern(isSimple, 3056, "Sequence application argument must be numeric", node.getLocation(), node); } else if (seq.getEmpty()) { TypeCheckerErrors.concern(isSimple, 3268, "Empty sequence cannot be applied", node.getLocation(), node); } return seq.getSeqof(); }
@Override public PType caseAIndicesUnaryExp(AIndicesUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp exp = node.getExp(); question.qualifiers = null; PType etype = exp.apply(THIS, question.newConstraint(null)); boolean empty = false; if (!question.assistantFactory.createPTypeAssistant().isSeq(etype)) { TypeCheckerErrors.report(3109, "Argument to 'inds' is not a sequence", node.getLocation(), node); TypeCheckerErrors.detail("Actual type", etype); } else { empty = question.assistantFactory.createPTypeAssistant().getSeq(etype).getEmpty(); } node.setType(AstFactory.newASetSetType(node.getLocation(), AstFactory.newANatOneNumericBasicType(node.getLocation()))); ((ASetSetType)node.getType()).setEmpty(empty); return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }
@Override public PType caseAElementsUnaryExp(AElementsUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp etype = node.getExp(); question.qualifiers = null; TypeCheckInfo argConstraint = question; if (question.constraint != null && question.assistantFactory.createPTypeAssistant().isSet(question.constraint)) { PType stype = question.assistantFactory.createPTypeAssistant().getSet(question.constraint).getSetof(); stype = AstFactory.newASeqSeqType(node.getLocation(), stype); argConstraint = question.newConstraint(stype); } PType arg = etype.apply(THIS, argConstraint); if (!question.assistantFactory.createPTypeAssistant().isSeq(arg)) { TypeCheckerErrors.report(3085, "Argument of 'elems' is not a sequence", node.getLocation(), node); node.setType(AstFactory.newASetSetType(node.getLocation(), AstFactory.newAUnknownType(node.getLocation()))); return node.getType(); } SSeqType seq = question.assistantFactory.createPTypeAssistant().getSeq(arg); node.setType(seq.getEmpty() ? AstFactory.newASetSetType(node.getLocation()) : AstFactory.newASetSetType(node.getLocation(), seq.getSeqof())); return node.getType(); }
if (!st.getEmpty())