Exemplo n.º 1
0
 @Override
 public void enterFacilityDecl(ResolveParser.FacilityDeclContext ctx) {
   VCAssertiveBlockBuilder block =
       new VCAssertiveBlockBuilder(g, moduleScope, "Facility_Inst=" + ctx.name.getText(), ctx);
   block.assume(g.getTrueExp());
   assertiveBlocks.push(block);
 }
Exemplo n.º 2
0
  @Override
  public void enterProcedureDecl(ResolveParser.ProcedureDeclContext ctx) {
    Scope s = symtab.getScope(ctx);
    try {
      List<ProgParameterSymbol> paramSyms = s.getSymbolsOfType(ProgParameterSymbol.class);

      currentProcOpSym =
          s.queryForOne(
              new OperationQuery(
                  null, ctx.name, Utils.apply(paramSyms, ProgParameterSymbol::getDeclaredType)));

      // This is the requires for the operation with some substutions made (see corrFnExp rule in
      // HH-diss)
      PExp corrFnExpRequires =
          perParameterCorrFnExpSubstitute(paramSyms, currentProcOpSym.getRequires());
      List<PExp> opParamAntecedents = new ArrayList<>();
      Utils.apply(paramSyms, opParamAntecedents, this::extractAssumptionsFromParameter);
      Set<PExp> l = getModuleLevelAssertionsOfType(ClauseType.REQUIRES);
      VCAssertiveBlockBuilder block =
          new VCAssertiveBlockBuilder(g, s, "Correct_Op_Hypo=" + ctx.name.getText(), ctx)
              .facilitySpecializations(facilitySpecFormalActualMappings)
              .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
              // TODO: constraints should be added on demand via NOTICE:...
              // .assume(getModuleLevelAssertionsOfType(ClauseType.CONSTRAINT))
              .assume(opParamAntecedents) // we assume correspondence for reprs here automatically
              .assume(corrFnExpRequires)
              .remember();
      assertiveBlocks.push(block);
    } catch (SymbolTableException e) {
      throw new RuntimeException(e); // this shouldn't happen now
    }
  }
Exemplo n.º 3
0
  @Override
  public void enterTypeImplInit(ResolveParser.TypeImplInitContext ctx) {
    Scope s = symtab.getScope(ctx.getParent());
    PExp convention = currentTypeReprSym.getConvention();
    PExp correspondence = currentTypeReprSym.getCorrespondence();
    PExp typeInitEnsures = g.getTrueExp();
    List<ModuleParameterSymbol> moduleParamSyms = getAllModuleParameterSyms();

    VCAssertiveBlockBuilder block =
        new VCAssertiveBlockBuilder(g, s, "T_Init_Hypo=" + currentTypeReprSym.getName(), ctx)
            .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
            .assume(
                getAssertionsFromModuleFormalParameters(
                    moduleParamSyms, this::extractAssumptionsFromParameter));

    assertiveBlocks.push(block);
  }
Exemplo n.º 4
0
  @Override
  public void enterTypeRepresentationDecl(ResolveParser.TypeRepresentationDeclContext ctx) {
    Scope s = symtab.getScope(ctx);
    currentTypeReprSym = null;
    try {
      currentTypeReprSym =
          moduleScope
              .queryForOne(new UnqualifiedNameQuery(ctx.name.getText()))
              .toProgReprTypeSymbol();
    } catch (SymbolTableException e) {
    }
    List<PExp> opParamAntecedents =
        getAssertionsFromModuleFormalParameters(
            getAllModuleParameterSyms(), this::extractAssumptionsFromParameter);

    VCAssertiveBlockBuilder block =
        new VCAssertiveBlockBuilder(g, s, "Well_Def_Corr_Hyp=" + ctx.name.getText(), ctx)
            .assume(opParamAntecedents)
            .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
            .assume(currentTypeReprSym.getConvention());
    assertiveBlocks.push(block);
  }
Exemplo n.º 5
0
  // TODO: Would be really cool if we could hover over a given and get information about where it
  // came from
  // "constraint for type Integer", etc.
  @Override
  public void enterOperationProcedureDecl(ResolveParser.OperationProcedureDeclContext ctx) {
    Scope s = symtab.getScope(ctx);
    List<ProgParameterSymbol> paramSyms = s.getSymbolsOfType(ProgParameterSymbol.class);

    // precondition[params 1..i <-- conc.X]
    PExp corrFnExpRequires =
        perParameterCorrFnExpSubstitute(paramSyms, tr.getMathExpASTFor(g, ctx.requiresClause()));

    VCAssertiveBlockBuilder block =
        new VCAssertiveBlockBuilder(g, s, "Proc_Decl_rule=" + ctx.name.getText(), ctx)
            .facilitySpecializations(facilitySpecFormalActualMappings)
            .assume(
                getAssertionsFromModuleFormalParameters(
                    getAllModuleParameterSyms(), this::extractAssumptionsFromParameter))
            .assume(
                getAssertionsFromFormalParameters(paramSyms, this::extractAssumptionsFromParameter))
            .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
            .assume(getModuleLevelAssertionsOfType(ClauseType.CONSTRAINT))
            .assume(corrFnExpRequires)
            .remember();

    assertiveBlocks.push(block);
  }