@Override public SExpIR caseATupleExp(ATupleExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); LinkedList<PExp> args = node.getArgs(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); ATupleExpIR tupleExp = new ATupleExpIR(); tupleExp.setType(typeCg); for (PExp exp : args) { SExpIR expCg = exp.apply(question.getExpVisitor(), question); if (expCg != null) { tupleExp.getArgs().add(expCg); } else { return null; } } return tupleExp; }
@Override public PType caseATupleExp(ATupleExp node, TypeCheckInfo question) throws AnalysisException { node.setTypes(new LinkedList<PType>()); List<PType> types = node.getTypes(); List<PType> elemConstraints = null; if (question.constraint != null && question.assistantFactory.createPTypeAssistant().isProduct(question.constraint)) { elemConstraints = question.assistantFactory.createPTypeAssistant().getProduct(question.constraint).getTypes(); if (elemConstraints.size() != node.getArgs().size()) { elemConstraints = null; } } int i = 0; for (PExp arg : node.getArgs()) { question.qualifiers = null; if (elemConstraints == null) { types.add(arg.apply(THIS, question.newConstraint(null))); } else { types.add(arg.apply(THIS, question.newConstraint(elemConstraints.get(i++)))); } } node.setType(AstFactory.newAProductType(node.getLocation(), types)); return question.assistantFactory.createPTypeAssistant().possibleConstraint(question.constraint, node.getType(), node.getLocation()); }