Ejemplo n.º 1
0
  public TupleSelectObligation(PExp exp, PType type, IPOContextStack ctxt, IPogAssistantFactory af)
      throws AnalysisException {
    // not is_(exp, type)
    super(exp, POType.TUPLE_SELECT, ctxt, exp.getLocation(), af);

    ANotUnaryExp notExp = new ANotUnaryExp();
    AIsExp isExp = new AIsExp();

    isExp.setTest(exp.clone());
    isExp.setBasicType(
        type.clone()); // Do we need the type definition instead? If so, the visitor must provide
    // it.

    notExp.setExp(isExp);

    stitch = notExp;
    valuetree.setPredicate(ctxt.getPredWithContext(stitch));
  }
Ejemplo n.º 2
0
  public List<QualifiedDefinition> caseAIsExp(AIsExp node, TypeCheckInfo question)
      throws AnalysisException {
    List<QualifiedDefinition> result = new Vector<QualifiedDefinition>();

    if (node.getTest() instanceof AVariableExp) {
      AVariableExp exp = (AVariableExp) node.getTest();
      PDefinition existing = question.env.findName(exp.getName(), NameScope.NAMESANDSTATE);

      if (existing != null && existing.getNameScope().matches(NameScope.NAMES)) {
        if (node.getBasicType() != null) {
          result.add(new QualifiedDefinition(existing, node.getBasicType()));
        } else if (node.getTypeName() != null) {
          if (node.getTypedef() == null) {
            PDefinition typedef =
                question.env.findType(node.getTypeName(), node.getLocation().getModule());
            node.setTypedef(typedef.clone());
          }

          if (node.getTypedef() != null) {
            result.add(new QualifiedDefinition(existing, node.getTypedef().getType()));
          }
        }
      }
    }

    return result;
  }