Exemple #1
0
    def collect_post_assumes(self):
        """For all call sites collect postconditions from callee's contracts and add as assume."""

        self._get_spos()
        if self.spos is None:
            raise UF.CHCError('No supporting proof obligations found for ' +
                              str(self.cfun.name) + ' in file ' +
                              str(self.cfile.name))
        self.spos.collect_post_assumes()
Exemple #2
0
 def _get_spos(self, force=False):
     if self.spos is None or force:
         xnode = UF.get_spo_xnode(self.capp.path, self.cfile.name,
                                  self.cfun.name)
         if not xnode is None:
             self.spos = CFunctionSPOs(self, xnode)
         else:
             raise UF.CHCError('Unable to load spos for ' + self.cfun.name +
                               ' in file ' + self.cfile.name)
Exemple #3
0
 def report_preconditions(self):
     lines = []
     try:
         if len(self.preconditions) == 1:
             return ('  ' + self.name + ': ' +
                     self.preconditions.values()[0].pretty())
         elif len(self.preconditions) > 1:
             lines.append('  ' + self.name)
             pclines = []
             for pc in self.preconditions.values():
                 pclines.append('     ' + pc.pretty())
             lines = lines + sorted(pclines)
             return '\n'.join(lines)
         return ''
     except UF.CHCError as e:
         msg = ('Error in contract function: ' + self.name + ' in file: ' +
                self.cfilecontracts.cfile.name + ': ' + str(e))
         raise UF.CHCError(msg)
 def report_preconditions(self):
     lines = []
     try:
         if len(self.preconditions) == 1:
             return "  " + self.name + ": " + self.preconditions.values(
             )[0].pretty()
         elif len(self.preconditions) > 1:
             lines.append("  " + self.name)
             pclines = []
             for pc in self.preconditions.values():
                 pclines.append("     " + pc.pretty())
             lines = lines + sorted(pclines)
             return "\n".join(lines)
         return ""
     except UF.CHCError as e:
         msg = ("Error in contract function: " + self.name + " in file: " +
                self.cfilecontracts.cfile.name + ": " + str(e))
         raise UF.CHCError(msg)
Exemple #5
0
 def get_constant(self):
     try:
         return int(self.tags[1])
     except ValueError as e:
         raise UF.CHCError(str(e))