Ejemplo n.º 1
0
 // The only way I'm current aware of a local requires clause getting changed
 // is by passing a locally defined type  to an operation (something of type
 // PTRepresentation). This method won't do anything otherwise.
 @NotNull
 private PExp perParameterCorrFnExpSubstitute(
     @NotNull List<ProgParameterSymbol> params, @Nullable PExp requiresOrEnsures) {
   List<PExp> result = new ArrayList<>();
   PExp resultingClause = requiresOrEnsures;
   for (ProgParameterSymbol p : params) {
     if (p.getDeclaredType() instanceof PTRepresentation) {
       ProgReprTypeSymbol repr = ((PTRepresentation) p.getDeclaredType()).getReprTypeSymbol();
       PExp corrFnExp = repr.getCorrespondence();
       // distribute conc.X into the clause passed
       Map<PExp, PExp> concReplMapping = new HashMap<>();
       concReplMapping.put(repr.exemplarAsPSymbol(), repr.conceptualExemplarAsPSymbol());
       concReplMapping.put(repr.exemplarAsPSymbol(true), repr.conceptualExemplarAsPSymbol(true));
       resultingClause = resultingClause.substitute(concReplMapping);
     }
   }
   return resultingClause == null ? g.getTrueExp() : resultingClause;
 }
Ejemplo n.º 2
0
 @Override
 public void exitTypeImplInit(ResolveParser.TypeImplInitContext ctx) {
   PExp typeInitEnsures = g.getTrueExp();
   PExp convention = currentTypeReprSym.getConvention();
   PExp correspondence = currentTypeReprSym.getCorrespondence();
   if (currentTypeReprSym.getDefinition() != null) {
     typeInitEnsures =
         currentTypeReprSym.getDefinition().getProgramType().getInitializationEnsures();
   }
   VCAssertiveBlockBuilder block = assertiveBlocks.pop();
   PExp newInitEnsures =
       typeInitEnsures.substitute(
           currentTypeReprSym.exemplarAsPSymbol(),
           currentTypeReprSym.conceptualExemplarAsPSymbol());
   // block.stats(Utils.collect(VCRuleBackedStat.class, ctx.stmt(), stats));
   // block.confirm(convention);  //order here is important
   block.assume(correspondence);
   throw new UnsupportedOperationException("re-institute the final confirm for this dan");
   // block.finalConfirm(newInitEnsures, "Initialization-ensures clause of " +
   // currentTypeReprSym.getName());
   // outputFile.addAssertiveBlock(block.build());
 }
Ejemplo n.º 3
0
  @Override
  public void exitTypeRepresentationDecl(ResolveParser.TypeRepresentationDeclContext ctx) {
    PExp constraint = g.getTrueExp();
    PExp correspondence = g.getTrueExp();
    if (currentTypeReprSym == null) return;
    correspondence = currentTypeReprSym.getCorrespondence();

    if (currentTypeReprSym.getDefinition() != null) {
      constraint = currentTypeReprSym.getDefinition().getProgramType().getConstraint();
    }
    VCAssertiveBlockBuilder block = assertiveBlocks.pop();
    PExp newConstraint =
        constraint.substitute(
            currentTypeReprSym.exemplarAsPSymbol(),
            currentTypeReprSym.conceptualExemplarAsPSymbol());
    newConstraint =
        newConstraint.withVCInfo(ctx.getStart(), "Constraint for type: " + ctx.name.getText());
    block.assume(correspondence.splitIntoConjuncts());
    // throw new UnsupportedOperationException("re-institute the final confirm for this dan");
    block.finalConfirm(newConstraint);
    outputFile.addAssertiveBlock(block.build());
  }