Beispiel #1
0
    def save_xrefs(self, path, fname, fid):
        xrefroot = UX.get_xml_header('global-xrefs', 'global-xrefs')
        xrefsnode = ET.Element('global-xrefs')
        xrefroot.append(xrefsnode)
        cxrefsnode = ET.Element('compinfo-xrefs')
        vxrefsnode = ET.Element('varinfo-xrefs')
        xrefsnode.extend([cxrefsnode, vxrefsnode])

        if fid in self.ckey2gckey:
            for ckey in sorted(self.ckey2gckey[fid]):
                xref = ET.Element('cxref')
                xref.set('ckey', str(ckey))
                xref.set('gckey', str(self.ckey2gckey[fid][ckey]))
                cxrefsnode.append(xref)

        if fid in self.vid2gvid:
            for vid in sorted(self.vid2gvid[fid]):
                xref = ET.Element('vxref')
                xref.set('vid', str(vid))
                xref.set('gvid', str(self.vid2gvid[fid][vid]))
                vxrefsnode.append(xref)

        xreffilename = UF.get_cxreffile_filename(path, fname)
        xreffile = open(xreffilename, 'w')
        xreffile.write(UX.doc_to_pretty(ET.ElementTree(xrefroot)))
 def _savefile(self,filename,fid,result):
     filename = UF.get_global_invs_filename(self.capp.getpath(),filename,self.objectname)
     root = UX.get_xml_header(filename,'global-invariants')
     ggnode = ET.Element('global-invariants')
     root.append(ggnode)
     for gvid in result:
         (lb,ub) = result[gvid]
         if lb == ub:
             vname = self.initializers[gvid][1]
             vid = self.capp.indexmanager.get_vid(fid,gvid)
             gnode = ET.Element('global-invariant')
             ggnode.append(gnode)
             fnode = ET.Element('fact')
             fnode.set('tag','non-relational')
             gnode.append(fnode)
             ppnode = ET.Element('program-vals')
             fnode.append(ppnode)
             pnode = ET.Element('pval')
             ppnode.append(pnode)
             lnode = ET.Element('lhost')
             pnode.append(lnode)
             vnode = ET.Element('var')
             vnode.set('vid',str(vid))
             vnode.set('vname',vname)
             lnode.append(vnode)
             rnode = ET.Element('nr-value')
             rnode.set('tag','range')
             rnode.set('value',str(lb))
             fnode.append(rnode)
     print('Saving ' + filename)
     with open(filename,'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(root)))
Beispiel #3
0
def _save_contracts_file_aux(path, filename, cnode):
    filedir = os.path.dirname(filename)
    if not os.path.isdir(filedir):
        os.makedirs(filedir)
    root = UX.get_xml_header('cfile', 'cfile')
    root.append(cnode)
    with open(filename, 'w') as fp:
        fp.write(UX.doc_to_pretty(ET.ElementTree(root)))
Beispiel #4
0
 def save_user_assumptions(self, userdata, assumptions):
     path = self.capp.path
     xroot = UX.get_xml_header('cfile', 'cfile')
     xnode = ET.Element('cfile')
     xroot.append(xnode)
     userdata.write_xml(xnode, assumptions)
     filename = UF.get_cfile_usr_filename(path, self.name)
     with open(filename, 'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(xroot)))
Beispiel #5
0
 def save_declarations(self):
     path = self.capp.path
     xroot = UX.get_xml_header('cfile', 'cfile')
     xnode = ET.Element('cfile')
     xroot.append(xnode)
     self.declarations.write_xml(xnode)
     filename = UF.get_cfile_dictionaryname(path, self.name)
     with open(filename, 'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(xroot)))
Beispiel #6
0
 def save_global_compinfos(self):
     path = self.capp.path
     xroot = UX.get_xml_header('globals','globals')
     xnode = ET.Element('globals')
     xroot.append(xnode)
     self.declarations.write_xml(xnode)
     filename = UF.get_global_definitions_filename(path)
     with open(filename,'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(xroot)))
Beispiel #7
0
def save_global_xml_contract(path, cnode):
    filename = os.path.join(path, 'globaldefs.xml')
    root = UX.get_xml_header('codehawk-contract-file',
                             'codehawk-contract-file')
    root.append(cnode)
    if os.path.isfile(filename):
        create_backup_file(filename)
    with open(filename, 'w') as fp:
        fp.write(UX.doc_to_pretty(ET.ElementTree(root)))
Beispiel #8
0
 def save_interface_dictionary(self):
     path = self.capp.path
     xroot = UX.get_xml_header('interface-dictionary',
                               'interface-dictionary')
     xnode = ET.Element('interface-dictionary')
     xroot.append(xnode)
     self.interfacedictionary.write_xml(xnode)
     filename = UF.get_cfile_interface_dictionaryname(path, self.name)
     with open(filename, 'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(xroot)))
Beispiel #9
0
 def save_xml_file(self, tgtpath):
     tgtroot = UX.get_xml_header('target_files', 'c-files')
     cfilesnode = ET.Element('c-files')
     tgtroot.append(cfilesnode)
     for name in sorted(self.files):
         xcfile = ET.Element('c-file')
         xcfile.set('name', name)
         xcfile.set('id', str(self.files[name]))
         cfilesnode.append(xcfile)
     cfilesnode.set('file-count', str(len(self.files)))
     tgtfilename = os.path.join(tgtpath, 'target_files.xml')
     with open(tgtfilename, 'w') as fp:
         fp.write(UX.doc_to_pretty(ET.ElementTree(tgtroot)))
Beispiel #10
0
def save_pod_file(path, cfilename, fname, cnode):
    filename = get_pod_filename(path, cfilename, fname)
    header = UX.get_xml_header(filename, 'pod')
    header.append(cnode)
    with open(filename, 'w') as fp:
        fp.write(UX.doc_to_pretty(ET.ElementTree(header)))
Beispiel #11
0
def save_api(path, cfilename, fname, xnode):
    filename = get_api_filename(path, cfilename, fname)
    header = UX.get_xml_header(filename, 'api')
    header.append(xnode)
    with open(filename, 'w') as fp:
        fp.write(UX.doc_to_pretty(ET.ElementTree(header)))
Beispiel #12
0
def save_cfile_interface_dictionary(path, cfilename, xnode):
    filename = get_cfile_interface_dictionaryname(path, cfilename)
    header = UX.get_xml_header(filename, 'interfacedictionary')
    header.append(xnode)
    with open(filename, 'w') as fp:
        fp.write(UX.doc_to_pretty(ET.ElementTree(header)))