@Override public void exitOperationProcedureDecl(ResolveParser.OperationProcedureDeclContext ctx) { Scope s = symtab.getScope(ctx); VCAssertiveBlockBuilder block = assertiveBlocks.pop(); List<ProgParameterSymbol> paramSyms = s.getSymbolsOfType(ProgParameterSymbol.class); PExp corrFnExpEnsures = perParameterCorrFnExpSubstitute( paramSyms, tr.getMathExpASTFor( g, ctx.ensuresClause())); // postcondition[params 1..i <-- corr_fn_exp] corrFnExpEnsures = corrFnExpEnsures.withVCInfo(ctx.getStart(), "Ensures clause of " + ctx.name.getText()); Token loc = ctx.ensuresClause() != null ? ctx.ensuresClause().getStart() : ctx.getStart(); List<PExp> paramConsequents = new ArrayList<>(); Utils.apply(paramSyms, paramConsequents, this::extractConsequentsFromParameter); // add verification statements to the assertive context/block block.stats(Utils.collect(VCRuleBackedStat.class, ctx.stmt(), stats)); // add any additional confirms from the parameters, etc for (ProgParameterSymbol p : paramSyms) { confirmParameterConsequentsForBlock(block, p); // modfies 'block' with additional confims! } // TODO: Tomorrow look at the verification statements in the assertive context for // int_do_nothing, then block.finalConfirm(corrFnExpEnsures); outputFile.addAssertiveBlock(block.build()); }
@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()); }