@Override public Boolean defaultSSeqType(SSeqType type, AAccessSpecifierAccessSpecifier accessSpecifier) throws AnalysisException { return type.getSeqof().apply(this, accessSpecifier); }
@Override public Integer defaultSSeqType(SSeqType type) throws AnalysisException { SSeqType stype = type; return stype.getEmpty() ? 0 : stype.getSeqof().apply(THIS); // hashCode(stype.getSeqof()); }
@Override public void defaultSSeqType(SSeqType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } type.getSeqof().apply(THIS); }
@Override public PType defaultSSeqType(SSeqType type, Context ctxt) throws AnalysisException { return AstFactory.newASeqSeqType(type.getLocation(), type.getSeqof().apply(this, ctxt)); }
@Override public PType defaultSSeqType(SSeqType type, Newquestion question) throws AnalysisException { return AstFactory.newASeqSeqType(type.getLocation(), af.createPTypeAssistant().polymorph(type.getSeqof(), question.pname, question.actualType)); }
@Override public List<PDefinition> caseASeqPattern(ASeqPattern pattern, NewQuestion question) throws AnalysisException { List<PDefinition> defs = new Vector<PDefinition>(); if (!af.createPTypeAssistant().isSeq(question.ptype)) { TypeCheckerErrors.report(3203, "Sequence pattern is matched against " + question.ptype, pattern.getLocation(), pattern); } else { PType elem = af.createPTypeAssistant().getSeq(question.ptype).getSeqof(); for (PPattern p : pattern.getPlist()) { defs.addAll(af.createPPatternAssistant().getDefinitions(p, elem, question.scope)); } } return defs; }
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(); }
public PType seqApply(AApplyObjectDesignator node, SSeqType seq, Environment env, NameScope scope, boolean unique, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(unique, 3252, "Sequence application must have one argument", node.getLocation(), node); return AstFactory.newAUnknownType(node.getLocation()); } PType argtype = node.getArgs().get(0).apply(rootVisitor, new TypeCheckInfo(question.assistantFactory, env, scope)); if (!env.af.createPTypeAssistant().isNumeric(argtype)) { TypeCheckerErrors.concern(unique, 3253, "Sequence argument is not numeric", node.getLocation(), node); TypeCheckerErrors.detail(unique, "Type", argtype); } return seq.getSeqof(); }
@Override protected Value convertValueTo(PType to, Context ctxt, Set<PType> done) throws AnalysisException { // We can't use the isSeq method as it plucks out one sequence // value from a union. We need to try all union members. So we // only test for pure SeqTypes. if (to instanceof SSeqType) { if (to instanceof ASeq1SeqType && values.isEmpty()) { abort(4084, "Cannot convert empty sequence to seq1", ctxt); } SSeqType seqto = (SSeqType) to; ValueList nl = new ValueList(); for (Value v : values) { nl.add(v.convertValueTo(seqto.getSeqof(), ctxt)); } return new SeqValue(nl); } else { return super.convertValueTo(to, ctxt, done); } }
@Override public PType defaultSSeqType(SSeqType type, Newquestion question) throws AnalysisException { if (type.getResolved()) { return type; } else { type.setResolved(true); } try { type.setSeqof(af.createPTypeAssistant().typeResolve(type.getSeqof(), question.root, question.rootVisitor, question.question)); if (question.root != null) { question.root.setInfinite(false); // Could be empty } return type; } catch (TypeCheckException e) { type.apply(af.getTypeUnresolver()); throw e; } }
@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()); }
@Override public PType caseAHeadUnaryExp(AHeadUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp exp = node.getExp(); question.qualifiers = null; PType etype = exp.apply(THIS, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isSeq(etype)) { TypeCheckerErrors.report(3104, "Argument to 'hd' is not a sequence", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } node.setType(question.assistantFactory.createPTypeAssistant().getSeq(etype).getSeqof()); return node.getType(); }
@Override public SSeqType caseAUnionType(AUnionType type) throws AnalysisException { // return AUnionTypeAssistantTC.getSeq(type); if (!type.getSeqDone()) { type.setSeqDone(true); // Mark early to avoid recursion. // type.setSeqType(PTypeAssistantTC.getSeq(AstFactory.newAUnknownType(type.getLocation()))); type.setSeqType(af.createPTypeAssistant().getSeq(AstFactory.newAUnknownType(type.getLocation()))); PTypeSet set = new PTypeSet(af); for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isSeq(t)) { set.add(t.apply(THIS).getSeqof()); } } type.setSeqType(set.isEmpty() ? null : AstFactory.newASeqSeqType(type.getLocation(), set.getType(type.getLocation()))); } return type.getSeqType(); }
stype = AstFactory.newASeqSeqType(node.getLocation(), stype.getSeqof()); lrconstraint = question.newConstraint(stype); lof instanceof ASeq1SeqType || rof instanceof ASeq1SeqType; lof = ((SSeqType) lof).getSeqof(); rof = ((SSeqType) rof).getSeqof(); PTypeSet ts = new PTypeSet(question.assistantFactory); ts.add(lof);
@Override public PType caseADistConcatUnaryExp(ADistConcatUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp exp = node.getExp(); question.qualifiers = null; TypeCheckInfo expConstraint = question; if (question.constraint != null) { PType stype = AstFactory.newASeqSeqType(node.getLocation(), question.constraint); expConstraint = question.newConstraint(stype); } PType result = exp.apply(THIS, expConstraint); if (question.assistantFactory.createPTypeAssistant().isSeq(result)) { PType inner = question.assistantFactory.createPTypeAssistant().getSeq(result).getSeqof(); if (question.assistantFactory.createPTypeAssistant().isSeq(inner)) { node.setType(question.assistantFactory.createPTypeAssistant().getSeq(inner)); return node.getType(); } } TypeCheckerErrors.report(3075, "Argument of 'conc' is not a seq of seq", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); }
@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(); }
result = st.getSeqof(); PType ptype = question.assistantFactory.createPMultipleBindAssistant().getPossibleType(node);
seq.add(UpdatableValue.factory(ur.listeners, node.getSeqType().getSeqof())); } else
rt = question.assistantFactory.createPTypeAssistant().getSeq(rt).getSeqof(); } else
} else result.add(node.getSeqType().getSeqof());