diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index cb91525..62be4db 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -1,238 +1,238 @@ cmake_minimum_required(VERSION 2.8.11) project(xreate) cmake_policy(SET CMP0022 NEW) message("MODULES" ${CMAKE_MODULE_PATH}) # LLVM #====================== FIND_PACKAGE (LLVM REQUIRED) set(LLVM_VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message("LLVM LIB PATH:" ${LLVM_LIBRARY_DIRS}) message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIRS}) message(STATUS "INCLUDE DIR: ${LLVM_INCLUDE_DIRS}") add_definitions(${LLVM_DEFINITIONS}) message(STATUS "LLVM DEFS: " ${LLVM_DEFINITIONS}) execute_process( COMMAND llvm-config --libs OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "LLVM LIBS: " ${LLVM_LIBS}) # CLANG #====================== set(CLANG_LIBS clangCodeGen clangASTMatchers clangQuery clangTooling clangFrontend clangSerialization clangDriver clangParse clangSema clangAnalysis clangAST clangEdit clangLex clangBasic ) # POTASSCO #====================== -set(POTASSCO_PATH "/opt/potassco/clingo" CACHE PATH "Path to potassco sources") +set(CLINGO_PATH "/opt/potassco/clingo" CACHE PATH "Path to potassco sources") set(POTASSCO_INCLUDE_PATH - ${POTASSCO_PATH}/libgringo - ${POTASSCO_PATH}/libclasp - ${POTASSCO_PATH}/libclingo - ${POTASSCO_PATH}/libprogram_opts - ${POTASSCO_PATH}/liblp + ${CLINGO_PATH}/libgringo + ${CLINGO_PATH}/libclasp + ${CLINGO_PATH}/libclingo + ${CLINGO_PATH}/libprogram_opts + ${CLINGO_PATH}/liblp ) INCLUDE_DIRECTORIES(${POTASSCO_INCLUDE_PATH}) set(LIBCLASP_LIBS clingo clasp gringo program_opts reify lp ) message("CLASP LIBS: " ${LIBCLASP_LIBS}) # OTHER DEPENDENCIES #=========================== set(JEAYESON_INCLUDE_PATH ${CMAKE_HOME_DIRECTORY}/../vendors/jeayeson/include/ ) INCLUDE_DIRECTORIES(${JEAYESON_INCLUDE_PATH}) # COCO #=========================== set(COCO_EXECUTABLE "" CACHE PATH "Path to coco executable") set(COCO_FRAMES_PATH "" CACHE PATH "Path to coco frames") set(COCO_GRAMMAR_PATH ${CMAKE_HOME_DIRECTORY}/../grammar/) set(COCO_SOURCE_FILES_MAIN ${COCO_GRAMMAR_PATH}/main/Parser.cpp ${COCO_GRAMMAR_PATH}/main/Scanner.cpp ) set(COCO_SOURCE_FILES_MODULES ${COCO_GRAMMAR_PATH}/modules/Parser.cpp ${COCO_GRAMMAR_PATH}/modules/Scanner.cpp ) set(COCO_SOURCE_FILES ${COCO_SOURCE_FILES_MODULES} ${COCO_SOURCE_FILES_MAIN}) INCLUDE_DIRECTORIES(${COCO_GRAMMAR_PATH}) add_custom_command(OUTPUT ${COCO_SOURCE_FILES_MAIN} COMMAND ${COCO_GRAMMAR_PATH}/gen-grammar main ${COCO_EXECUTABLE} ${COCO_FRAMES_PATH} WORKING_DIRECTORY ${COCO_GRAMMAR_PATH} MAIN_DEPENDENCY ${COCO_GRAMMAR_PATH}/xreate.ATG ) add_custom_command(OUTPUT ${COCO_SOURCE_FILES_MODULES} COMMAND ${COCO_GRAMMAR_PATH}/gen-grammar modules ${COCO_EXECUTABLE} ${COCO_FRAMES_PATH} WORKING_DIRECTORY ${COCO_GRAMMAR_PATH} MAIN_DEPENDENCY ${COCO_GRAMMAR_PATH}/modules.ATG ) message(STATUS "COCO GRAMMAR BUILD STATUS:" ${COCO_OUTPUT}) # XREATE #====================== set(SOURCE_FILES analysis/temporalseqgraph.cpp pass/cfatemporalseqpass.cpp analysis/cfagraph.cpp pass/cfapass.cpp modules.cpp compilation/interpretation-instructions.cpp ExternLayer.cpp analysis/cfagraph.cpp compilation/latereasoning.cpp analysis/interpretation.cpp query/latex.cpp query/polymorph.cpp compilation/polymorph.cpp aux/latereasoning.cpp compilation/latex.cpp analysis/typeinference.cpp xreatemanager.cpp transcendlayer.cpp analysis/dfagraph.cpp llvmlayer.cpp pass/compilepass.cpp analysis/utils.cpp pass/dfapass.cpp compilation/targetinterpretation.cpp pass/interpretationpass.cpp ast.cpp aux/xreatemanager-decorators.cpp compilation/operators.cpp compilation/transformations.cpp compilation/transformersaturation.cpp pass/versionspass.cpp attachments.cpp compilation/containers.cpp compilation/advancedinstructions.cpp utils.cpp pass/abstractpass.cpp contextrule.cpp query/containers.cpp aux/serialization/expressionserializer.cpp ) set(XREATE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ ) INCLUDE_DIRECTORIES(${XREATE_INCLUDE_DIRS}) set(XREATE_PRIVATE_INCLUDE_DIRS ${XREATE_INCLUDE_DIRS} ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) add_library(${PROJECT_NAME} SHARED ${COCO_SOURCE_FILES} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} INTERFACE ${XREATE_INCLUDE_DIRS} ${COCO_GRAMMAR_PATH} ${JEAYESON_INCLUDE_PATH} ${LLVM_INCLUDE_DIRS} ${POTASSCO_INCLUDE_PATH} ) get_directory_property(DEFINITIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) message("definitions all: " ${DEFINITIONS_ALL}) target_compile_definitions(${PROJECT_NAME} INTERFACE ${DEFINITIONS_ALL}) get_directory_property(COMPILATION_OPTIONS_ALL DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) message("compilations all: " ${COMPILATION_OPTIONS_ALL}) target_compile_options(${PROJECT_NAME} INTERFACE ${COMPILATION_OPTIONS_ALL}) SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBCLASP_LIBS} ${CLANG_LIBS} ${LLVM_LIBS} tbb boost_system boost_filesystem ) #${CLANG_LIBS} #set (LINK_INTERFACE_LIBRARIES "") # FUNCTION(PREPEND var prefix) # SET(listVar "") # FOREACH(f ${ARGN}) # LIST(APPEND listVar "${prefix}/${f}") # ENDFOREACH(f) # SET(${var} "${listVar}" PARENT_SCOPE) # ENDFUNCTION(PREPEND) #set(COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "-j4") #cotire(xreate) # MACRO (ADD_PCH_RULE _header_filename _src_list) # SET(_gch_filename "${_header_filename}.gch") # LIST(APPEND ${_src_list} ${_gch_filename}) # SET (_args ${CMAKE_CXX_FLAGS}) # LIST(APPEND _args -c ${_header_filename} -o ${_gch_filename}) # GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) # foreach (_inc ${DIRINC}) # LIST(APPEND _args "-I" ${_inc}) # endforeach(_inc ${DIRINC}) # SEPARATE_ARGUMENTS(_args) # add_custom_command(OUTPUT ${_gch_filename} # COMMAND rm -f ${_gch_filename} # COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} # DEPENDS ${_header_filename}) # ENDMACRO(ADD_PCH_RULE _header_filename _src_list) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/ast.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/llvmlayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/clasplayer.h SOURCE_FILES) # ADD_PCH_RULE (${CMAKE_HOME_DIRECTORY}/src/pass/abstractpass.h SOURCE_FILES) diff --git a/documentation/index.xml b/documentation/index.xml index a1db8a3..f31c7d6 100644 --- a/documentation/index.xml +++ b/documentation/index.xml @@ -1,192 +1,318 @@ <?xxe-sn 2b06cb2u4g0 2?>Xreate Manual Xreate is an open source general purpose high level programming language designed to write efficient and safe computer programs. Here "high level" has very specific meaning as an ability to easily write, read, as well as adapt software to a constantly changing environment or business goals. In this respect, any software product can be evaluated on the basis of the three dimensions: efficiency, safety and adaptability. Unfortunately, those properties are proved to be largely contradictory for it is manageable to write either efficient(still unsafe) or safe(and impractical) code, but not both. Thus, the ultimate goal of the language is to allow developers to produce code with all these properties at the same time. Xreate's design principles allow to adopt any programming technique as long as it does not improve one dimension at the expense of another. To achieve aforementioned design goals Xreate has tree distinctive layers: Brute. Lowest layer is called Brute— this is code that is indented to be actually compiled. Code on this level implements actual software functionality. It resembles the usual imperative languages' apparatus and consists of executable instructions such as arithmetic, branching, input/output, etc. Transcend. Brute level alone is not enough to constitute full fledged language since a code requires various non executable metadata to express developer's intents, check correctness, validity and perform other types of analyses. In Xreate everything of this sort belongs to a layer called Transcend. Transcend features declarative nature that is appropriate to do management kind of work — it analyzes, oversees and controls brute by guiding compilation process. Everything that is on this level — logic or transcend facts and rules are gathered and sent to an external logic solver to make solutions that are brought back in order to guide compilation. Interpretation. And there is also Interpretation — intermediate level resembling features of dynamically typed languages that is used as a contact point and interpreter between brute and transcend and their low level and high level constructs and structures respectively. On a syntactic level Xreate is procedural language with extensive use of annotations — arbitrary unconstrained metadata that software developer can attach to a different language constructs, variables and code blocks. Annotations are completely invisible for the compiler proper and used by transcend rather as suggestions conveying additional information. Most severe and hard to resolve problems in software development stem from interaction of different components on a different levels. Each individual component often is thoroughly tested and works reliably. But combining them with complex interaction and extensive IO to build end-user software usually leads to a range of runtime errors, security vulnerabilities and performance degradation. Thus key emphasis of Xreate is on domain specific component level improvements and joint use of external resources. This aspect is covered in exploitation and containers chapters. Unlike academic languages, Xreate targets safe and reliable usage of effectful computations, such as IO, covered in virtualization, exploitation chapters and mutable structures covered in communication.
<?xxe-sn 2b06cb2u4g0 4?>Basic Example To demonstrate what Xreate is all about, basic example is given below: name="tests/introduction.cpp: Introduction.Doc_Example_1", lines=15 guard:: iAmVeryFast { div = function(a:: float, b:: float):: float { a / b } } guard:: iAmVerySafe { div = function(a:: float, b:: float):: float { if ( b == (0::float)):: float {0::float} else {a / b} } } test = function:: float; entry; iAmVerySecure { div(10, 5) } Here entry point of the program is a function test recognized so by the compiler because of annotation entry in its signature. There are also two functions div called specializations. Each specialization has a guard that defines condition that has to be met in order to invoke this particular specialization. In the example, specializations of div have iAmVeryFast and iAmVerySafe guards respectively. Let's say, developer provides two specializations where first is a very fast division implementation and second one is a very safe since it checks division by zero but at the same time is unbearably slow due to extra check instruction. This is a basis of polymorphism — client's code test is able to work with any specialization, and compiler should decide which one to invoke with the only hint it has — annotation iAmVerySecure - in the function test's signature. - + in the function test's + signature. All annotations(except entry) are custom defined by developer itself. This is when transcend comes into play. By adding transcend rule as shown below it is possible to associate annotation iAmVerySecure with invocation of specialization guarded by iAmVerySafe: name="tests/introduction.cpp: Introduction.Doc_Example_1", lines=15 dfa_callguard(SiteInv, iAmVerySafe):- dfa_callfn(SiteInv, div); SiteInv = s(_, _, ScopeInv); cfa_parent(ScopeInv, function(FnInv)); bind_func(FnInv, iAmVerySecure). Transcend rules are written in ASP syntax — common syntax to write logic programs. This particular rule reads that for any function annotated with iAmVerySecure, certain specialization iAmVerySafe is - chosen for div invocation. + chosen for div invocation. In this example an appropriate specialization is statically resolved, so other specialization isn't - even compiled. + even compiled. By providing custom rules it is possible to implement any polymorphism strategy, be it statically performed or dynamically. The example demonstrates basic workflow: transcend gathers available information about a program, such as annotations and using custom rules makes decisions to guide compilation process particularly by - selecting appropriate specializations as in this example. + selecting appropriate specializations as in this example. +
+ +
+ + + <?xxe-sn 2ba2e84701s 2?>Build and Run on Linux + + Major dependencies: + + + + + + + + gcc 7 + + + + + + llvm 5, clang 5 + + + + + + boost 1.66 + + + + + + coco + + + + + + clingo + + + + Building tested on OpenSuse Leap 15. Change + commands accordingly if using another distribution. + + Pull sources directly from + repository: + + git clone --recursive https://pgess@bitbucket.org/pgess/xreate.git + + Enter into source directory and run + following script to prepare building environment. Script installs required + system packages as well as Coco and Clingo from sources: + + + + + Carefully inspect scripts before + run + + + On OpenSuse + Leap 15: + + ./installation/prepare-opensuse-leap15 + + That was one time operation to prepare + environment. After that enter into build + directory and start actual tests building: + + cd build +make + + After successful build you can run xreate + tests: + + cd .. +./build/tests/xreate-tests + + + + + Pay attention that working dir should be + repository root + + + For consequent rebuilds after updates. etc + invoke cmake as follows: + + #working dir build +cmake -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_XREATE_TESTS=1 \ + -DCOCO_EXECUTABLE=<FILE> \ + -DCLINGO_PATH=<DIR> \ + -DCOCO_FRAMES_PATH=../vendors/coco/generator/ \ + -DCMAKE_CXX_COMPILER=g++ ../cpp +make + + Cmake's selected parameters: + + + + + + + + BUILD_XREATE_TESTS determines whether + to build tests + + + + + + COCO_EXECUTABLE full filename of Coco + executable + + + + + + CLINGO_PATH Directory of Clingo + installation + +
diff --git a/installation/prepare-opensuse-leap15 b/installation/prepare-opensuse-leap15 old mode 100644 new mode 100755 index 9100666..e17360a --- a/installation/prepare-opensuse-leap15 +++ b/installation/prepare-opensuse-leap15 @@ -1,65 +1,67 @@ #!/bin/bash # VERSIONS OF MAJOR DEPENDENCIES: # OPENSUSE LEAP 15 # LLVM: 5.0.1 # CLANG: 5.0.1 # GCC: 7.3.1 CLINGO_PATH=/opt/potassco/clingo COCO_PATH=/opt/coco -XREATE_PATH=/opt/xreate - CLASP_VERSION=95cc1182f +SCRIPT=`realpath $0` +XREATE_PATH=`dirname $SCRIPT`/.. + # PREREQUISITES # sudo zypper in \ git wget unzip make \ gcc7-c++ scons bison re2c\ llvm5-devel libboost_headers1_66_0-devel \ cmake gtest tbb-devel clang5-devel \ libxml2-devel libboost_system1_66_0-devel libboost_filesystem1_66_0-devel # COCO CPP # The Compiler Generator Coco/R # http://www.ssw.uni-linz.ac.at/coco/#CPP # mkdir $COCO_PATH cd $COCO_PATH wget http://www.ssw.uni-linz.ac.at/coco/CPP/CocoSourcesCPP.zip unzip ./CocoSourcesCPP.zip make # CLINGO # A grounder and solver for logic programs. # https://github.com/potassco/clingo # mkdir -p $CLINGO_PATH cd $CLINGO_PATH git clone https://github.com/potassco/clingo.git ./ &&\ git reset --hard $CLASP_VERSION git apply $XREATE_PATH/installation/docker/patches/potassco-patch-95cc11 scons configure --build-dir=debug &&\ sed -i "s/, '-fvisibility=hidden'//" build/debug.py &&\ sed -i "s/CXXFLAGS = \[\(.*\)\]/CXXFLAGS = \['-fPIC', \1\]/" build/debug.py &&\ sed -i "s/WITH_LUA = 'auto'/WITH_LUA = None/" build/debug.py &&\ sed -i "s/WITH_PYTHON = 'auto'/WITH_PYTHON = None/" build/debug.py &&\ sed -i "s/'-std=c++11'/'-std=c++14'/" build/debug.py &&\ cat build/debug.py &&\ scons --build-dir=debug # XREATE # cd $XREATE_PATH/vendors/jeayeson +git pull ./configure mkdir ../../build cd ../../build ln -s $COCO_PATH/Copyright.frame $XREATE_PATH/vendors/coco/generator/Copyright.frame ln -s $COCO_PATH/Scanner.frame $XREATE_PATH/vendors/coco/generator/Scanner.frame mkdir $XREATE_PATH/grammar/main $XREATE_PATH/grammar/modules -cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_XREATE_TESTS=1 -DCOCO_EXECUTABLE=$COCO_PATH/Coco -DCOCO_FRAMES_PATH=$XREATE_PATH/vendors/coco/generator/ -DCMAKE_CXX_COMPILER=g++ ../cpp +cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_XREATE_TESTS=1 -DCOCO_EXECUTABLE=$COCO_PATH/Coco -DCLINGO_PATH=$CLINGO_PATH -DCOCO_FRAMES_PATH=$XREATE_PATH/vendors/coco/generator/ -DCMAKE_CXX_COMPILER=g++ ../cpp diff --git a/vendors/jeayeson b/vendors/jeayeson index e277cb8..ecbed0b 160000 --- a/vendors/jeayeson +++ b/vendors/jeayeson @@ -1 +1 @@ -Subproject commit e277cb8677a0a1ba15c5bf53f448ac3c92c345d9 +Subproject commit ecbed0bc286c2e053c4b0cf7277c2892b8e49603