コード例 #1
0
  private List<PExp> extractConsequentsFromParameter(ProgParameterSymbol p) {
    List<PExp> result = new ArrayList<>();
    PExp incParamExp = new PSymbolBuilder(p.asPSymbol()).incoming(true).build();
    PExp paramExp = new PSymbolBuilder(p.asPSymbol()).incoming(false).build();

    if (p.getDeclaredType() instanceof ProgNamedType) {
      ProgNamedType t = (ProgNamedType) p.getDeclaredType();
      PExp exemplar = new PSymbolBuilder(t.getExemplarName()).mathClssfctn(t.toMath()).build();

      if (t instanceof PTRepresentation) {
        ProgReprTypeSymbol repr = ((PTRepresentation) t).getReprTypeSymbol();

        PExp convention = repr.getConvention();
        PExp corrFnExp = repr.getCorrespondence();
        result.add(convention.substitute(t.getExemplarAsPSymbol(), paramExp));
      }
      if (p.getMode() == ParameterMode.PRESERVES || p.getMode() == ParameterMode.RESTORES) {
        PExp equalsExp =
            g.formEquals(paramExp, incParamExp)
                .withVCInfo(
                    p.getDefiningTree().getStart(),
                    "Ensure parameter " + p.getName() + " is restored");
        result.add(equalsExp);
      } else if (p.getMode() == ParameterMode.CLEARS) {
        PExp init =
            ((ProgNamedType) p.getDeclaredType())
                .getInitializationEnsures()
                .substitute(exemplar, paramExp);
        result.add(init);
      }
    }
    return result;
  }
コード例 #2
0
  private void confirmParameterConsequentsForBlock(
      VCAssertiveBlockBuilder block, ProgParameterSymbol p) {
    PExp incParamExp = new PSymbolBuilder(p.asPSymbol()).incoming(true).build();
    PExp paramExp = new PSymbolBuilder(p.asPSymbol()).incoming(false).build();

    if (p.getDeclaredType() instanceof ProgNamedType) {
      ProgNamedType t = (ProgNamedType) p.getDeclaredType();
      PExp exemplar = new PSymbolBuilder(t.getExemplarName()).mathClssfctn(t.toMath()).build();

      if (t instanceof PTRepresentation) {
        ProgReprTypeSymbol repr = ((PTRepresentation) t).getReprTypeSymbol();

        PExp convention = repr.getConvention();
        PExp corrFnExp = repr.getCorrespondence();
        // if we're doing this its going to be on a procedure decl or op-proc decl, so just
        // say block.definingTree
        PExp newConvention =
            convention
                .substitute(t.getExemplarAsPSymbol(), paramExp)
                .withVCInfo(block.definingTree.getStart(), "Convention for " + t.getName());
        block.confirm(block.definingTree, newConvention);
      }
      if (p.getMode() == ParameterMode.PRESERVES || p.getMode() == ParameterMode.RESTORES) {
        PExp equalsExp =
            g.formEquals(paramExp, incParamExp)
                .withVCInfo(
                    block.definingTree.getStart(),
                    "Ensure parameter " + p.getName() + " is restored");
        block.confirm(block.definingTree, equalsExp);
      } else if (p.getMode() == ParameterMode.CLEARS) {
        PExp init =
            ((ProgNamedType) p.getDeclaredType())
                .getInitializationEnsures()
                .substitute(exemplar, paramExp);
        // result.add(init);
      }
    }
  }