Пример #1
0
def parse_sail_to_pvs(project_name, only_print):
    project_info = data[project_name]
    sail_src_path = helper.preprocess_path(project_info['sail_src_path'])
    sail_src_files = project_info['sail_src_files']
    lem_src_files = project_info['lem_src_files']
    lem_embedded_lib = project_info['lem_embedded_lib']
    lem_object_name = project_info['lem_object_name']
    target_dir = helper.preprocess_path(project_info['target_dir'])
    lem_flags = project_info['lem_flags']
    lem_source_libs = data['lem_source_libs']
    if not os.path.exists(target_dir):
        os.mkdir(target_dir)
    sail_to_lem_cmd = construct_sail_to_lem_cmd(sail_src_files, lem_flags,
                                                lem_embedded_lib,
                                                lem_object_name)
    lem_to_ocaml_cmd = construct_from_lem_cmd('ocaml', sail_src_path,
                                              target_dir, lem_src_files,
                                              lem_source_libs)
    lem_to_pvs_cmd = construct_from_lem_cmd('pvs', sail_src_path, target_dir,
                                            lem_src_files, lem_source_libs)
    cmd = 'cd ' + sail_src_path + '; '
    cmd += sail_to_lem_cmd + '; '
    cmd += 'cd ' + helper.dir_path + '; '
    cmd += lem_to_ocaml_cmd + '; '
    cmd += lem_to_pvs_cmd + '; '
    cmd += 'cd ' + target_dir + '; '
    cmd += 'rm -f *_aux.pvs; cd ..'
    print(cmd)
    if not only_print:
        helper.execute_command(cmd)
        rewriteFiles.rewrite_files(target_dir, '')
Пример #2
0
def construct_from_lem_cmd(target_language, sail_src_path, target_dir,
                           lem_src_files, lem_extra_libs):
    lem_executable = helper.preprocess_path(data['lem_executable'])
    cmd = lem_executable + ' -' + target_language + ' -outdir ' + target_dir
    cmd += ' ' + helper.add_prefix('-lib',
                                   helper.preprocess_path(lem_extra_libs))
    cmd += ' ' + helper.build_file_path(sail_src_path, lem_src_files)
    return cmd
Пример #3
0
def update_library_data(pvs_lib_name):
    lib_data = data[pvs_lib_name]
    verifyPVSLib(pvs_lib_name)
    pvs_lib_path = helper.preprocess_path(lib_data["library_path"])
    lib_data["library_path"] = pvs_lib_path
    mlSrcFiles = lib_data[tags[T_MLSrcFile]]
    for index, itemName in enumerate(mlSrcFiles):
        if not '.ml' in itemName:
            lib_data[tags[T_MLSrcFile]].clear()
            itemName = helper.preprocess_path(itemName)
            fileNames = [
                f for f in listdir(itemName)
                if isfile(join(itemName, f)) and f.endswith('.ml')
            ]
            for f in fileNames:
                ml_src_file = helper.preprocess_path(join(itemName, f))
                verifySrcFile(ml_src_file)
                lib_data[tags[T_MLSrcFile]].append(ml_src_file)
        else:
            ml_src_file = helper.preprocess_path(itemName)
            lib_data[tags[T_MLSrcFile]][index] = ml_src_file
    constr_externals(pvs_lib_name)
Пример #4
0
def constr_externals(name):
    lib_data = data[name]
    external_mls = lib_data[tags[T_ExtML]]
    external_cmds = lib_data[tags[T_ExtCmd]]
    for index, ext_ml in enumerate(external_mls):
        if not ext_ml.startswith('#mod_use'):
            ext_ml = helper.preprocess_path(ext_ml)
            lib_data[tags[T_ExtML]][index] = '#mod_use \"' + ext_ml + '\";;'
    for index, ext_cmd in enumerate(external_cmds):
        if not ext_cmd.startswith('#load') and not ext_cmd.startswith(
                '#require'):
            if '.cma' in ext_cmd:
                lib_data[tags[T_ExtCmd]][index] = '#load \"' + ext_cmd + '\";;'
            elif '.' not in ext_cmd:
                lib_data[
                    tags[T_ExtCmd]][index] = '#require \"' + ext_cmd + '\";;'
    lib_data[tags[T_ExtCmd]] = external_cmds
    lib_data[tags[T_ExtML]] = external_mls
Пример #5
0
def parse_library_to_pvs(library_name, only_print):
    lem_executable = helper.preprocess_path(data['lem_executable'])
    lem_library_data = data[library_name]
    pvs_library_path = os.path.join(helper.dir_path,
                                    lem_library_data['pvs_library_name'])
    if os.path.exists(pvs_library_path):
        shutil.rmtree(pvs_library_path)
    os.mkdir(pvs_library_path)
    cmd = 'cd ' + lem_library_data['library_path'] + '; '
    cmd += lem_executable + ' -pvs -outdir ' + pvs_library_path + ' '
    cmd += lem_library_data['lem_flags'] + ' '
    cmd += lem_library_data['lem_src_files'] + '; '
    cmd += 'cd ' + pvs_library_path + '; '
    cmd += 'rm -f *_aux.pvs; '
    print(cmd)
    if not only_print:
        helper.execute_command(cmd)
        rewriteFiles.rewrite_files(pvs_library_path,
                                   lem_library_data['special_prefix'])
        cmd = 'cp -f ./pvs_aux/* ' + pvs_library_path
        helper.execute_command(cmd)