mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-03 21:09:11 +00:00 
			
		
		
		
	Reorganizing the code
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
		
							parent
							
								
									8b70f0b833
								
							
						
					
					
						commit
						d8cd3fc3ab
					
				
					 36 changed files with 261 additions and 429 deletions
				
			
		
							
								
								
									
										162
									
								
								mk_make.py
									
										
									
									
									
								
							
							
						
						
									
										162
									
								
								mk_make.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,5 +1,12 @@
 | 
			
		|||
import os
 | 
			
		||||
import glob
 | 
			
		||||
############################################
 | 
			
		||||
# Copyright (c) 2012 Microsoft Corporation
 | 
			
		||||
# 
 | 
			
		||||
# Scripts for generate Makefiles and Visual 
 | 
			
		||||
# Studio project files.
 | 
			
		||||
#
 | 
			
		||||
# Author: Leonardo de Moura (leonardo)
 | 
			
		||||
############################################
 | 
			
		||||
from mk_util import *
 | 
			
		||||
 | 
			
		||||
BUILD_DIR='build-test'
 | 
			
		||||
SRC_DIR='src'
 | 
			
		||||
| 
						 | 
				
			
			@ -9,153 +16,9 @@ VS_COMMON_OPTIONS='WIN32;_WINDOWS;ASYNC_COMMANDS'
 | 
			
		|||
VS_DBG_OPTIONS='Z3DEBUG;_TRACE;_DEBUG'
 | 
			
		||||
VS_RELEASE_OPTIONS='NDEBUG;_EXTERNAL_RELEASE'
 | 
			
		||||
 | 
			
		||||
def is_debug(mode):
 | 
			
		||||
    return mode == 'Debug'
 | 
			
		||||
 | 
			
		||||
def is_x64(platform):
 | 
			
		||||
    return platform == 'x64'
 | 
			
		||||
 | 
			
		||||
def mk_dir(d):
 | 
			
		||||
    if not os.path.exists(d):
 | 
			
		||||
        os.makedirs(d)
 | 
			
		||||
 | 
			
		||||
# Initialization
 | 
			
		||||
mk_dir(BUILD_DIR)
 | 
			
		||||
 | 
			
		||||
def module_src_dir(name):
 | 
			
		||||
    return '%s%s%s' % (SRC_DIR, os.sep, name)
 | 
			
		||||
 | 
			
		||||
def module_build_dir(name):
 | 
			
		||||
    return '%s%s%s' % (BUILD_DIR, os.sep, name)
 | 
			
		||||
 | 
			
		||||
def vs_header(f):
 | 
			
		||||
    f.write(
 | 
			
		||||
'<?xml version="1.0" encoding="utf-8"?>\n'
 | 
			
		||||
'<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
 | 
			
		||||
 | 
			
		||||
GUI = 0
 | 
			
		||||
Name2GUI = {}
 | 
			
		||||
 | 
			
		||||
def vs_project_configurations(f, name):
 | 
			
		||||
    global GUI, Name2GUI
 | 
			
		||||
    f.write('  <ItemGroup Label="ProjectConfigurations">\n')
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('    <ProjectConfiguration Include="%s|%s">\n' % (mode, platform))
 | 
			
		||||
            f.write('      <Configuration>%s</Configuration>\n' % mode)
 | 
			
		||||
            f.write('      <Platform>%s</Platform>\n' % platform)
 | 
			
		||||
            f.write('    </ProjectConfiguration>\n')
 | 
			
		||||
    f.write('  </ItemGroup>\n')
 | 
			
		||||
 | 
			
		||||
    f.write('   <PropertyGroup Label="Globals">\n')
 | 
			
		||||
    f.write('    <ProjectGuid>{00000000-0000-0000-000--%s}</ProjectGuid>\n' % GUI)
 | 
			
		||||
    f.write('    <ProjectName>%s</ProjectName>\n' % name)
 | 
			
		||||
    f.write('    <Keyword>Win32Proj</Keyword>\n')
 | 
			
		||||
    f.write('  </PropertyGroup>\n')
 | 
			
		||||
    f.write('  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
 | 
			
		||||
    Name2GUI[name] = GUI
 | 
			
		||||
    GUI = GUI + 1
 | 
			
		||||
 | 
			
		||||
def vs_lib_configurations(f, name):
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('  <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'" Label="Configuration">\n' % (mode, platform))
 | 
			
		||||
            f.write('    <ConfigurationType>StaticLibrary</ConfigurationType>\n')
 | 
			
		||||
            f.write('    <CharacterSet>Unicode</CharacterSet>\n')
 | 
			
		||||
            f.write('    <UseOfMfc>false</UseOfMfc>\n')
 | 
			
		||||
            f.write('  </PropertyGroup>\n')
 | 
			
		||||
 | 
			
		||||
    f.write('  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n')
 | 
			
		||||
    f.write('  <ImportGroup Label="ExtensionSettings">\n')
 | 
			
		||||
    f.write('   </ImportGroup>\n')
 | 
			
		||||
    f.write('   <ImportGroup Label="PropertySheets">\n')
 | 
			
		||||
    f.write('    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists(\'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props\')" Label="LocalAppDataPlatform" />  </ImportGroup>\n')
 | 
			
		||||
    f.write('  <PropertyGroup Label="UserMacros" />\n')
 | 
			
		||||
 | 
			
		||||
    f.write('  <PropertyGroup>\n')
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('    <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>\n' % 
 | 
			
		||||
                        (mode, platform))
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('    <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">$(SolutionDir)$(Configuration)\</OutDir>\n' % (mode, platform))
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('    <TargetName Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">%s</TargetName>\n' % (mode, platform, name))
 | 
			
		||||
            f.write('    <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">.lib</TargetExt>\n' % (mode, platform))
 | 
			
		||||
    f.write('  </PropertyGroup>\n')
 | 
			
		||||
 | 
			
		||||
def vs_compilation_options(f, name, deps):
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('  <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">\n' % (mode, platform))
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('    <Midl>\n')
 | 
			
		||||
                f.write('      <TargetEnvironment>X64</TargetEnvironment>\n')
 | 
			
		||||
                f.write('    </Midl>\n')
 | 
			
		||||
            f.write('    <ClCompile>\n')
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                f.write('      <Optimization>Disabled</Optimization>\n')
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('      <Optimization>Full</Optimization>\n')
 | 
			
		||||
            options = VS_COMMON_OPTIONS
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                options = "%s;%s" % (options, VS_DBG_OPTIONS)
 | 
			
		||||
            else:
 | 
			
		||||
                options = "%s;%s" % (options, VS_RELEASE_OPTIONS)
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                options = "%s;_AMD64_" % options
 | 
			
		||||
            f.write('      <PreprocessorDefinitions>%s;%%(PreprocessorDefinitions)</PreprocessorDefinitions>\n' % options)
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                f.write('      <MinimalRebuild>true</MinimalRebuild>\n')
 | 
			
		||||
                f.write('      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
 | 
			
		||||
                f.write('      <WarningLevel>Level3</WarningLevel>\n')
 | 
			
		||||
            f.write('      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
 | 
			
		||||
            f.write('      <OpenMPSupport>true</OpenMPSupport>\n')
 | 
			
		||||
            f.write('      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n')
 | 
			
		||||
            f.write('      <AdditionalIncludeDirectories>')
 | 
			
		||||
            f.write('..\..\src\%s' % name)
 | 
			
		||||
            for dep in deps:
 | 
			
		||||
                f.write(';..\..\src\%s' % dep)
 | 
			
		||||
            f.write('</AdditionalIncludeDirectories>\n')
 | 
			
		||||
            f.write('    </ClCompile>\n')
 | 
			
		||||
            f.write('    <Link>\n')
 | 
			
		||||
            f.write('      <OutputFile>$(OutDir)%s.lib</OutputFile>\n' % name)
 | 
			
		||||
            f.write('      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('      <TargetMachine>MachineX64</TargetMachine>\n')
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('      <TargetMachine>MachineX86</TargetMachine>\n')
 | 
			
		||||
            f.write('    </Link>\n')
 | 
			
		||||
            f.write('  </ItemDefinitionGroup>\n')
 | 
			
		||||
 | 
			
		||||
def add_vs_cpps(f, name):
 | 
			
		||||
    f.write('  <ItemGroup>\n')
 | 
			
		||||
    srcs = module_src_dir(name)
 | 
			
		||||
    for cppfile in glob.glob(os.path.join(srcs, '*.cpp')):
 | 
			
		||||
       f.write('    <ClCompile Include="..%s..%s%s" />\n' % (os.sep, os.sep, cppfile))
 | 
			
		||||
    f.write('  </ItemGroup>\n')
 | 
			
		||||
 | 
			
		||||
def vs_footer(f):
 | 
			
		||||
    f.write(
 | 
			
		||||
'  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n'
 | 
			
		||||
'  <ImportGroup Label="ExtensionTargets">\n'
 | 
			
		||||
'  </ImportGroup>\n'
 | 
			
		||||
'</Project>\n')
 | 
			
		||||
   
 | 
			
		||||
def add_lib(name, deps):
 | 
			
		||||
    module_dir = module_build_dir(name)
 | 
			
		||||
    mk_dir(module_dir)
 | 
			
		||||
 | 
			
		||||
    vs_proj = open('%s%s%s.vcxproj' % (module_dir, os.sep, name), 'w')
 | 
			
		||||
    vs_header(vs_proj)
 | 
			
		||||
    vs_project_configurations(vs_proj, name)
 | 
			
		||||
    vs_lib_configurations(vs_proj, name)
 | 
			
		||||
    vs_compilation_options(vs_proj, name, deps)
 | 
			
		||||
    add_vs_cpps(vs_proj, name)
 | 
			
		||||
    vs_footer(vs_proj)
 | 
			
		||||
 | 
			
		||||
add_lib('util', [])
 | 
			
		||||
add_lib('polynomial', ['util'])
 | 
			
		||||
add_lib('sat', ['util', 'sat_core'])
 | 
			
		||||
| 
						 | 
				
			
			@ -163,6 +26,11 @@ add_lib('nlsat', ['util', 'sat_core', 'polynomial'])
 | 
			
		|||
add_lib('subpaving', ['util'])
 | 
			
		||||
add_lib('ast', ['util', 'polynomial'])
 | 
			
		||||
add_lib('rewriter', ['util', 'ast', 'polynomial'])
 | 
			
		||||
add_lib('model', ['util', 'ast', 'rewriter'])
 | 
			
		||||
# Simplifier module will be deleted in the future.
 | 
			
		||||
# It has been replaced with rewriter module.
 | 
			
		||||
add_lib('simplifier', ['util', 'ast', 'rewriter'])
 | 
			
		||||
# Model module should not depend on simplifier module. 
 | 
			
		||||
# We must replace all occurrences of simplifier with rewriter.
 | 
			
		||||
add_lib('model', ['util', 'ast', 'rewriter', 'simplifier'])
 | 
			
		||||
add_lib('tactic', ['util', 'ast'])
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										155
									
								
								mk_util.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								mk_util.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,155 @@
 | 
			
		|||
############################################
 | 
			
		||||
# Copyright (c) 2012 Microsoft Corporation
 | 
			
		||||
# 
 | 
			
		||||
# Auxiliary scripts for generate Makefiles and Visual 
 | 
			
		||||
# Studio project files.
 | 
			
		||||
#
 | 
			
		||||
# Author: Leonardo de Moura (leonardo)
 | 
			
		||||
############################################
 | 
			
		||||
import os
 | 
			
		||||
import glob
 | 
			
		||||
 | 
			
		||||
def is_debug(mode):
 | 
			
		||||
    return mode == 'Debug'
 | 
			
		||||
 | 
			
		||||
def is_x64(platform):
 | 
			
		||||
    return platform == 'x64'
 | 
			
		||||
 | 
			
		||||
def mk_dir(d):
 | 
			
		||||
    if not os.path.exists(d):
 | 
			
		||||
        os.makedirs(d)
 | 
			
		||||
 | 
			
		||||
def module_src_dir(name):
 | 
			
		||||
    return '%s%s%s' % (SRC_DIR, os.sep, name)
 | 
			
		||||
 | 
			
		||||
def module_build_dir(name):
 | 
			
		||||
    return '%s%s%s' % (BUILD_DIR, os.sep, name)
 | 
			
		||||
 | 
			
		||||
def vs_header(f):
 | 
			
		||||
    f.write(
 | 
			
		||||
'<?xml version="1.0" encoding="utf-8"?>\n'
 | 
			
		||||
'<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
 | 
			
		||||
 | 
			
		||||
GUI = 0
 | 
			
		||||
Name2GUI = {}
 | 
			
		||||
 | 
			
		||||
def vs_project_configurations(f, name):
 | 
			
		||||
    global GUI, Name2GUI
 | 
			
		||||
    f.write('  <ItemGroup Label="ProjectConfigurations">\n')
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('    <ProjectConfiguration Include="%s|%s">\n' % (mode, platform))
 | 
			
		||||
            f.write('      <Configuration>%s</Configuration>\n' % mode)
 | 
			
		||||
            f.write('      <Platform>%s</Platform>\n' % platform)
 | 
			
		||||
            f.write('    </ProjectConfiguration>\n')
 | 
			
		||||
    f.write('  </ItemGroup>\n')
 | 
			
		||||
 | 
			
		||||
    f.write('   <PropertyGroup Label="Globals">\n')
 | 
			
		||||
    f.write('    <ProjectGuid>{00000000-0000-0000-000--%s}</ProjectGuid>\n' % GUI)
 | 
			
		||||
    f.write('    <ProjectName>%s</ProjectName>\n' % name)
 | 
			
		||||
    f.write('    <Keyword>Win32Proj</Keyword>\n')
 | 
			
		||||
    f.write('  </PropertyGroup>\n')
 | 
			
		||||
    f.write('  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
 | 
			
		||||
    Name2GUI[name] = GUI
 | 
			
		||||
    GUI = GUI + 1
 | 
			
		||||
 | 
			
		||||
def vs_lib_configurations(f, name):
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('  <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'" Label="Configuration">\n' % (mode, platform))
 | 
			
		||||
            f.write('    <ConfigurationType>StaticLibrary</ConfigurationType>\n')
 | 
			
		||||
            f.write('    <CharacterSet>Unicode</CharacterSet>\n')
 | 
			
		||||
            f.write('    <UseOfMfc>false</UseOfMfc>\n')
 | 
			
		||||
            f.write('  </PropertyGroup>\n')
 | 
			
		||||
 | 
			
		||||
    f.write('  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n')
 | 
			
		||||
    f.write('  <ImportGroup Label="ExtensionSettings">\n')
 | 
			
		||||
    f.write('   </ImportGroup>\n')
 | 
			
		||||
    f.write('   <ImportGroup Label="PropertySheets">\n')
 | 
			
		||||
    f.write('    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists(\'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props\')" Label="LocalAppDataPlatform" />  </ImportGroup>\n')
 | 
			
		||||
    f.write('  <PropertyGroup Label="UserMacros" />\n')
 | 
			
		||||
 | 
			
		||||
    f.write('  <PropertyGroup>\n')
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('    <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>\n' % 
 | 
			
		||||
                        (mode, platform))
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('    <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">$(SolutionDir)$(Configuration)\</OutDir>\n' % (mode, platform))
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('    <TargetName Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">%s</TargetName>\n' % (mode, platform, name))
 | 
			
		||||
            f.write('    <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">.lib</TargetExt>\n' % (mode, platform))
 | 
			
		||||
    f.write('  </PropertyGroup>\n')
 | 
			
		||||
 | 
			
		||||
def vs_compilation_options(f, name, deps):
 | 
			
		||||
    for mode in MODES:
 | 
			
		||||
        for platform in PLATFORMS:
 | 
			
		||||
            f.write('  <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'%s|%s\'">\n' % (mode, platform))
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('    <Midl>\n')
 | 
			
		||||
                f.write('      <TargetEnvironment>X64</TargetEnvironment>\n')
 | 
			
		||||
                f.write('    </Midl>\n')
 | 
			
		||||
            f.write('    <ClCompile>\n')
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                f.write('      <Optimization>Disabled</Optimization>\n')
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('      <Optimization>Full</Optimization>\n')
 | 
			
		||||
            options = VS_COMMON_OPTIONS
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                options = "%s;%s" % (options, VS_DBG_OPTIONS)
 | 
			
		||||
            else:
 | 
			
		||||
                options = "%s;%s" % (options, VS_RELEASE_OPTIONS)
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                options = "%s;_AMD64_" % options
 | 
			
		||||
            f.write('      <PreprocessorDefinitions>%s;%%(PreprocessorDefinitions)</PreprocessorDefinitions>\n' % options)
 | 
			
		||||
            if is_debug(mode):
 | 
			
		||||
                f.write('      <MinimalRebuild>true</MinimalRebuild>\n')
 | 
			
		||||
                f.write('      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
 | 
			
		||||
                f.write('      <WarningLevel>Level3</WarningLevel>\n')
 | 
			
		||||
            f.write('      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
 | 
			
		||||
            f.write('      <OpenMPSupport>true</OpenMPSupport>\n')
 | 
			
		||||
            f.write('      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n')
 | 
			
		||||
            f.write('      <AdditionalIncludeDirectories>')
 | 
			
		||||
            f.write('..\..\src\%s' % name)
 | 
			
		||||
            for dep in deps:
 | 
			
		||||
                f.write(';..\..\src\%s' % dep)
 | 
			
		||||
            f.write('</AdditionalIncludeDirectories>\n')
 | 
			
		||||
            f.write('    </ClCompile>\n')
 | 
			
		||||
            f.write('    <Link>\n')
 | 
			
		||||
            f.write('      <OutputFile>$(OutDir)%s.lib</OutputFile>\n' % name)
 | 
			
		||||
            f.write('      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
 | 
			
		||||
            if is_x64(platform):
 | 
			
		||||
                f.write('      <TargetMachine>MachineX64</TargetMachine>\n')
 | 
			
		||||
            else:
 | 
			
		||||
                f.write('      <TargetMachine>MachineX86</TargetMachine>\n')
 | 
			
		||||
            f.write('    </Link>\n')
 | 
			
		||||
            f.write('  </ItemDefinitionGroup>\n')
 | 
			
		||||
 | 
			
		||||
def add_vs_cpps(f, name):
 | 
			
		||||
    f.write('  <ItemGroup>\n')
 | 
			
		||||
    srcs = module_src_dir(name)
 | 
			
		||||
    for cppfile in glob.glob(os.path.join(srcs, '*.cpp')):
 | 
			
		||||
       f.write('    <ClCompile Include="..%s..%s%s" />\n' % (os.sep, os.sep, cppfile))
 | 
			
		||||
    f.write('  </ItemGroup>\n')
 | 
			
		||||
 | 
			
		||||
def vs_footer(f):
 | 
			
		||||
    f.write(
 | 
			
		||||
'  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n'
 | 
			
		||||
'  <ImportGroup Label="ExtensionTargets">\n'
 | 
			
		||||
'  </ImportGroup>\n'
 | 
			
		||||
'</Project>\n')
 | 
			
		||||
   
 | 
			
		||||
def add_lib(name, deps):
 | 
			
		||||
    module_dir = module_build_dir(name)
 | 
			
		||||
    mk_dir(module_dir)
 | 
			
		||||
 | 
			
		||||
    vs_proj = open('%s%s%s.vcxproj' % (module_dir, os.sep, name), 'w')
 | 
			
		||||
    vs_header(vs_proj)
 | 
			
		||||
    vs_project_configurations(vs_proj, name)
 | 
			
		||||
    vs_lib_configurations(vs_proj, name)
 | 
			
		||||
    vs_compilation_options(vs_proj, name, deps)
 | 
			
		||||
    add_vs_cpps(vs_proj, name)
 | 
			
		||||
    vs_footer(vs_proj)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ Revision History:
 | 
			
		|||
#include"ast_pp.h"
 | 
			
		||||
#include"ast_ll_pp.h"
 | 
			
		||||
#include"var_subst.h"
 | 
			
		||||
#include"front_end_params.h"
 | 
			
		||||
#include"array_decl_plugin.h"
 | 
			
		||||
#include"well_sorted.h"
 | 
			
		||||
#include"used_symbols.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,76 +0,0 @@
 | 
			
		|||
/*++
 | 
			
		||||
Copyright (c) 2011 Microsoft Corporation
 | 
			
		||||
 | 
			
		||||
Module Name:
 | 
			
		||||
 | 
			
		||||
    model_evaluator_params.cpp
 | 
			
		||||
 | 
			
		||||
Abstract:
 | 
			
		||||
 | 
			
		||||
    New parameter setting support for rewriter. 
 | 
			
		||||
 | 
			
		||||
Author:
 | 
			
		||||
 | 
			
		||||
    Leonardo (leonardo) 2011-04-22
 | 
			
		||||
 | 
			
		||||
Notes:
 | 
			
		||||
 | 
			
		||||
--*/
 | 
			
		||||
#include"model_evaluator_params.h"
 | 
			
		||||
 | 
			
		||||
model_evaluator_params::model_evaluator_params() {
 | 
			
		||||
    reset();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void model_evaluator_params::reset() {
 | 
			
		||||
    m_model_completion = false;
 | 
			
		||||
    m_cache            = true;
 | 
			
		||||
    m_max_steps        = UINT_MAX;
 | 
			
		||||
    m_max_memory       = UINT_MAX;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define PARAM(name) param_names.push_back(name)
 | 
			
		||||
 | 
			
		||||
void model_evaluator_params::get_params(svector<char const *> & param_names) const {
 | 
			
		||||
    PARAM(":model-completion");
 | 
			
		||||
    PARAM(":cache");
 | 
			
		||||
    PARAM(":max-steps");
 | 
			
		||||
    PARAM(":max-memory");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define DESCR(NAME, DR) if (strcmp(name, NAME) == 0) return DR 
 | 
			
		||||
 | 
			
		||||
char const * model_evaluator_params::get_param_descr(char const * name) const {
 | 
			
		||||
    DESCR(":model-completion", "(default: false) assigns an interpretation to symbols that are not intepreted by the model.");
 | 
			
		||||
    DESCR(":cache", "(default: true) cache intermediate results.");
 | 
			
		||||
    DESCR(":max-steps", "(default: infty) maximum number of steps.");
 | 
			
		||||
    DESCR(":max-memory", "(default: infty) maximum amount of memory in megabytes.");
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define RBOOL(NAME) if (strcmp(name, NAME) == 0) return CPK_BOOL
 | 
			
		||||
#define RUINT(NAME) if (strcmp(name, NAME) == 0) return CPK_UINT
 | 
			
		||||
 | 
			
		||||
param_kind model_evaluator_params::get_param_kind(char const * name) const {
 | 
			
		||||
    RBOOL(":model-completion");
 | 
			
		||||
    RBOOL(":cache");
 | 
			
		||||
    RUINT(":max-steps");
 | 
			
		||||
    RUINT(":max-memory");
 | 
			
		||||
    return CPK_INVALID;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define SET(NAME, FIELD) if (strcmp(name, NAME) == 0) { FIELD = value; return true; }
 | 
			
		||||
 | 
			
		||||
bool model_evaluator_params::set_bool_param(char const * name, bool value) {
 | 
			
		||||
    SET(":model-completion", m_model_completion);
 | 
			
		||||
    SET(":cache", m_cache);
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool model_evaluator_params::set_uint_param(char const * name, unsigned value) {
 | 
			
		||||
    SET(":max-steps", m_max_steps);
 | 
			
		||||
    SET(":max-memory", m_max_memory);
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ Revision History:
 | 
			
		|||
#include"ast_pp.h"
 | 
			
		||||
#include"ast_ll_pp.h"
 | 
			
		||||
#include"var_subst.h"
 | 
			
		||||
#include"front_end_params.h"
 | 
			
		||||
#include"array_decl_plugin.h"
 | 
			
		||||
#include"well_sorted.h"
 | 
			
		||||
#include"used_symbols.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/*++
 | 
			
		||||
Copyright (c) 2006 Microsoft Corporation
 | 
			
		||||
 | 
			
		||||
Module Name:
 | 
			
		||||
 | 
			
		||||
    value.cpp
 | 
			
		||||
 | 
			
		||||
Abstract:
 | 
			
		||||
 | 
			
		||||
    <abstract>
 | 
			
		||||
 | 
			
		||||
Author:
 | 
			
		||||
 | 
			
		||||
    Leonardo de Moura (leonardo) 2007-08-17.
 | 
			
		||||
 | 
			
		||||
Revision History:
 | 
			
		||||
 | 
			
		||||
--*/
 | 
			
		||||
#include"value.h"
 | 
			
		||||
 | 
			
		||||
void bool_value::display(std::ostream & out) const {
 | 
			
		||||
    out << (m_value ? "true" : "false");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned bool_value::hash() const {
 | 
			
		||||
    return m_value ? 1 : 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool bool_value::operator==(const value & other) const {
 | 
			
		||||
    const bool_value * o = dynamic_cast<const bool_value*>(&other);
 | 
			
		||||
    return o && m_value == o->m_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
basic_factory::basic_factory(ast_manager & m):
 | 
			
		||||
    value_factory(symbol("basic"), m),
 | 
			
		||||
    m_bool(m) {
 | 
			
		||||
    m_bool  = m.mk_type(m.get_basic_family_id(), BOOL_SORT);
 | 
			
		||||
    m_true  = alloc(bool_value, true, m_bool.get());
 | 
			
		||||
    m_false = alloc(bool_value, false, m_bool.get());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,162 +0,0 @@
 | 
			
		|||
/*++
 | 
			
		||||
Copyright (c) 2006 Microsoft Corporation
 | 
			
		||||
 | 
			
		||||
Module Name:
 | 
			
		||||
 | 
			
		||||
    value.h
 | 
			
		||||
 | 
			
		||||
Abstract:
 | 
			
		||||
 | 
			
		||||
    Abstract class used to represent values in a model.
 | 
			
		||||
 | 
			
		||||
Author:
 | 
			
		||||
 | 
			
		||||
    Leonardo de Moura (leonardo) 2007-08-14.
 | 
			
		||||
 | 
			
		||||
Revision History:
 | 
			
		||||
 | 
			
		||||
--*/
 | 
			
		||||
#ifndef _VALUE_H_
 | 
			
		||||
#define _VALUE_H_
 | 
			
		||||
 | 
			
		||||
#include"core_model.h"
 | 
			
		||||
#include"ast.h"
 | 
			
		||||
#include"ref.h"
 | 
			
		||||
 | 
			
		||||
class model;
 | 
			
		||||
 | 
			
		||||
class value {
 | 
			
		||||
    partition_id m_partition_id;
 | 
			
		||||
    unsigned     m_ref_count;
 | 
			
		||||
    type_ast *   m_type;
 | 
			
		||||
 | 
			
		||||
    friend class model;
 | 
			
		||||
 | 
			
		||||
    void set_partition_id(partition_id id) { 
 | 
			
		||||
        m_partition_id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    value(type_ast * ty):
 | 
			
		||||
        m_partition_id(null_partition_id),
 | 
			
		||||
        m_ref_count(0),
 | 
			
		||||
        m_type(ty) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual ~value() {}
 | 
			
		||||
 | 
			
		||||
    void inc_ref() { m_ref_count ++; }
 | 
			
		||||
    
 | 
			
		||||
    void dec_ref() { 
 | 
			
		||||
        SASSERT(m_ref_count > 0);
 | 
			
		||||
        m_ref_count--;
 | 
			
		||||
        if (m_ref_count == 0) {
 | 
			
		||||
            dealloc(this);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    partition_id get_partition_id() { return m_partition_id; }
 | 
			
		||||
 | 
			
		||||
    type_ast * get_type() const { return m_type; }
 | 
			
		||||
 | 
			
		||||
    virtual void display(std::ostream & out) const = 0;
 | 
			
		||||
 | 
			
		||||
    virtual unsigned hash() const = 0;
 | 
			
		||||
 | 
			
		||||
    virtual bool operator==(const value & other) const = 0;
 | 
			
		||||
 | 
			
		||||
    virtual void infer_types(ast_vector<type_ast> & result) { /* default: do nothing */ }
 | 
			
		||||
    
 | 
			
		||||
    virtual void collect_used_partitions(svector<bool> & result) { /* default: do nothing */ }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
inline std::ostream & operator<<(std::ostream & target, const value & v) {
 | 
			
		||||
    v.display(target);
 | 
			
		||||
    return target;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class value_factory {
 | 
			
		||||
    family_id     m_fid;
 | 
			
		||||
public:
 | 
			
		||||
    value_factory(symbol fname, ast_manager & m):
 | 
			
		||||
        m_fid(m.get_family_id(fname)) {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    virtual ~value_factory() {}
 | 
			
		||||
    
 | 
			
		||||
    // Return some value of the given type
 | 
			
		||||
    virtual value * get_some_value(type_ast * ty) = 0; 
 | 
			
		||||
 | 
			
		||||
    // Return two distinct values of the given type
 | 
			
		||||
    virtual bool get_some_values(type_ast * ty, ref<value> & v1, ref<value> & v2) = 0;
 | 
			
		||||
    
 | 
			
		||||
    // Return a fresh value of the given type
 | 
			
		||||
    virtual value * get_fresh_value(type_ast * ty) = 0;
 | 
			
		||||
 | 
			
		||||
    virtual value * update_value(value * source, const svector<partition_id> & pid2pid) {
 | 
			
		||||
        return source;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    family_id get_family_id() const { return m_fid; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class bool_value : public value {
 | 
			
		||||
    friend class basic_factory;
 | 
			
		||||
    bool m_value;
 | 
			
		||||
 | 
			
		||||
    bool_value(bool v, type_ast * ty):
 | 
			
		||||
        value(ty),
 | 
			
		||||
        m_value(v) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
   
 | 
			
		||||
    bool get_value() const { 
 | 
			
		||||
        return m_value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void display(std::ostream & out) const;
 | 
			
		||||
 | 
			
		||||
    virtual unsigned hash() const;
 | 
			
		||||
 | 
			
		||||
    virtual bool operator==(const value & other) const;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class basic_factory : public value_factory {
 | 
			
		||||
    ast_ref<type_ast> m_bool;
 | 
			
		||||
    ref<bool_value> m_true;
 | 
			
		||||
    ref<bool_value> m_false;
 | 
			
		||||
public:
 | 
			
		||||
    basic_factory(ast_manager & m);
 | 
			
		||||
 | 
			
		||||
    virtual ~basic_factory() {}
 | 
			
		||||
 | 
			
		||||
    bool_value * get_true() const { 
 | 
			
		||||
        return m_true.get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool_value * get_false() const {
 | 
			
		||||
        return m_false.get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Return some value of the given type
 | 
			
		||||
    virtual value * get_some_value(type_ast * ty) {
 | 
			
		||||
        return get_false();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Return two distinct values of the given type
 | 
			
		||||
    virtual bool get_some_values(type_ast * ty, ref<value> & v1, ref<value> & v2) {
 | 
			
		||||
        v1 = get_false();
 | 
			
		||||
        v2 = get_true();
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // Return a fresh value of the given type
 | 
			
		||||
    virtual value * get_fresh_value(type_ast * ty) {
 | 
			
		||||
        // it is not possible to create new fresh values... 
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _VALUE_H_ */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										62
									
								
								src/util/smt2_util.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								src/util/smt2_util.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,62 @@
 | 
			
		|||
/*++
 | 
			
		||||
Copyright (c) 2011 Microsoft Corporation
 | 
			
		||||
 | 
			
		||||
Module Name:
 | 
			
		||||
 | 
			
		||||
    smt2_util.cpp
 | 
			
		||||
 | 
			
		||||
Abstract:
 | 
			
		||||
 | 
			
		||||
    Goodies for SMT2 standard
 | 
			
		||||
 | 
			
		||||
Author:
 | 
			
		||||
 | 
			
		||||
    Leonardo (leonardo) 2012-10-20
 | 
			
		||||
 | 
			
		||||
Notes:
 | 
			
		||||
 | 
			
		||||
--*/
 | 
			
		||||
#include"smt2_util.h"
 | 
			
		||||
 | 
			
		||||
bool is_smt2_simple_symbol_char(char s) {
 | 
			
		||||
    return 
 | 
			
		||||
        ('0' <= s && s <= '9') ||
 | 
			
		||||
        ('a' <= s && s <= 'z') ||
 | 
			
		||||
        ('A' <= s && s <= 'Z') ||
 | 
			
		||||
        s == '~' || s == '!' || s == '@' || s == '$' || s == '%' || s == '^' || s == '&' ||
 | 
			
		||||
        s == '*' || s == '_' || s == '-' || s == '+' || s == '=' || s == '<' || s == '>' ||
 | 
			
		||||
        s == '.' || s == '?' || s == '/';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool is_smt2_quoted_symbol(char const * s) {
 | 
			
		||||
    if (s == 0)
 | 
			
		||||
        return false;
 | 
			
		||||
    if ('0' <= s[0] && s[0] <= '9')
 | 
			
		||||
        return true;
 | 
			
		||||
    unsigned len = static_cast<unsigned>(strlen(s));
 | 
			
		||||
    for (unsigned i = 0; i < len; i++)
 | 
			
		||||
        if (!is_smt2_simple_symbol_char(s[i]))
 | 
			
		||||
            return true;
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool is_smt2_quoted_symbol(symbol const & s) {
 | 
			
		||||
    if (s.is_numerical())
 | 
			
		||||
        return false;
 | 
			
		||||
    return is_smt2_quoted_symbol(s.bare_str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string mk_smt2_quoted_symbol(symbol const & s) {
 | 
			
		||||
    SASSERT(is_smt2_quoted_symbol(s));
 | 
			
		||||
    string_buffer<> buffer;
 | 
			
		||||
    buffer.append('|');
 | 
			
		||||
    char const * str = s.bare_str();
 | 
			
		||||
    while (*str) {
 | 
			
		||||
        if (*str == '|' || *str == '\\')
 | 
			
		||||
            buffer.append('\\');
 | 
			
		||||
        buffer.append(*str);
 | 
			
		||||
        str++;
 | 
			
		||||
    }
 | 
			
		||||
    buffer.append('|');
 | 
			
		||||
    return std::string(buffer.c_str());
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								src/util/smt2_util.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/util/smt2_util.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
/*++
 | 
			
		||||
Copyright (c) 2011 Microsoft Corporation
 | 
			
		||||
 | 
			
		||||
Module Name:
 | 
			
		||||
 | 
			
		||||
    smt2_util.h
 | 
			
		||||
 | 
			
		||||
Abstract:
 | 
			
		||||
 | 
			
		||||
    Goodies for SMT2 standard
 | 
			
		||||
 | 
			
		||||
Author:
 | 
			
		||||
 | 
			
		||||
    Leonardo (leonardo) 2012-10-20
 | 
			
		||||
 | 
			
		||||
Notes:
 | 
			
		||||
 | 
			
		||||
--*/
 | 
			
		||||
#ifndef _SMT2_UTIL_H_
 | 
			
		||||
#define _SMT2_UTIL_H_
 | 
			
		||||
 | 
			
		||||
#include"symbol.h"
 | 
			
		||||
 | 
			
		||||
bool is_smt2_simple_symbol_char(char c);
 | 
			
		||||
bool is_smt2_quoted_symbol(char const * s);
 | 
			
		||||
bool is_smt2_quoted_symbol(symbol const & s);
 | 
			
		||||
std::string mk_smt2_quoted_symbol(symbol const & s);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue