This commit is contained in:
Vitor Santos Costa 2017-02-20 15:48:22 +00:00
commit f426d25bef
15 changed files with 84 additions and 201 deletions

View File

@ -1,4 +1,4 @@
/*************************************************************************
/*************************************************************************
* *
* YAP Prolog *
* *

View File

@ -450,10 +450,7 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
// ASCII, so both LATIN1 and UTF-8
// Yap_DebugPlWriteln(inp->val.t);
char *s;
if (s0)
s = (char *)s0;
else
s = Malloc(0);
s = Malloc(0);
if (snprintf(s, MaxTmp(PASS_REGS1) - 1, Int_FORMAT,
IntegerOfTerm(inp->val.t)) < 0) {
AUX_ERROR(inp->val.t, 2 * MaxTmp(PASS_REGS1), s, char);
@ -464,21 +461,9 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
}
if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) {
char *s;
size_t sz = 1024;
// Yap_DebugPlWriteln(inp->val.t);
if (s0) {
s = (char *)s0;
sz = strlen(s);
} else
s = Malloc(sz);
if (!s)
AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char);
while (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &s, sz - 1)) {
if (s0) {
s = Malloc(sz = 1024);
s0 = NULL;
} else
s = Realloc(s, sz + 1024);
if (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &s, 1024)) {
return NULL;
}
if (lengp)
*lengp = strlen(s);
@ -488,9 +473,6 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) {
// Yap_DebugPlWriteln(inp->val.t);
char *s;
if (s0)
s = 0;
else
s = Malloc(0);
if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), s, MaxTmp() - 1, 10)) {
AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char);

View File

@ -385,15 +385,16 @@ int Yap_FormatFloat(Float f, char **s, size_t sz) {
sno = Yap_open_buf_write_stream(GLOBAL_Stream[LOCAL_c_output_stream].encoding,
0);
if (sno < 0)
return FALSE;
return false;
wglb.lw = separator;
wglb.stream = GLOBAL_Stream + sno;
wrputf(f, &wglb);
wrputc('\0', wglb.stream);
so = Yap_MemExportStreamPtr(sno);
*s = Malloc( strlen(so) )+1;
strcpy(*s, so );
Yap_CloseStream(sno);
*s = so;
return TRUE;
return true;
}
/* writes a data base reference */
@ -567,8 +568,8 @@ static void write_string(const unsigned char *s,
do {
int delta;
ptr += (delta = get_utf8(ptr, -1, &chr) );
if (chr == '\0')
if (chr == '\0') {
break;
if (delta == 0) {chr = *ptr++; }
write_quoted(chr, qt, stream);
@ -1259,7 +1260,7 @@ char *Yap_TermToString(Term t, size_t *lengthp, encoding_t enc, int flags) {
int sno = Yap_open_buf_write_stream(enc, flags);
const char *sf;
DBTerm *e = LOCAL_BallTerm;
if (sno < 0)
return NULL;
LOCAL_c_output_stream = sno;

View File

@ -8,6 +8,14 @@ set (CXX_SOURCES
yapi.cpp
)
set (CXX_HEADERS
yapa.hh
yapdb.hh
yapi.h
yapie.hh
yapq.hh
- yapt.hh
-)
list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE)

View File

@ -1,9 +0,0 @@
set (CXX_SOURCES
yapa.hh
yapdb.hh
yapi.cpp
yapi.hh
yapie.hh
yapq.hh
yapt.hh
)

View File

@ -255,7 +255,7 @@ public:
class YAPApplTerm : public YAPTerm {
friend class YAPTerm;
YAPApplTerm(Term t0) { mk(t0); }
public:
YAPApplTerm(Functor f, Term ts[]) {
BACKUP_MACHINE_REGS();
@ -417,7 +417,7 @@ class YAPAtomTerm : public YAPTerm {
// Constructor: receives a C-atom;
YAPAtomTerm(Atom a) { mk(MkAtomTerm(a)); }
YAPAtomTerm(Term t) : YAPTerm(t) { IsAtomTerm(t); }
public:
// Constructor: receives an atom;
YAPAtomTerm(YAPAtom a) : YAPTerm() { mk(MkAtomTerm(a.a)); }

View File

@ -72,6 +72,8 @@ extern void *protected_pop_text_stack(int lvl, void *safe, bool tmp,
#define NUMBER_OF_CHARS 256
extern char *Yap_chtype;
#define Yap_strlen(s) strlen((void *)(s))
typedef enum {
BG = 0, /* initial state */
UC = 1, /* Upper case */

View File

@ -406,11 +406,3 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake
configure_file(${CMAKE_CURRENT_LIST_DIR}/../GitSHA1.c.in GitSHA1.c @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/os/YapIOConfig.h)
check_include_files( "stdio.h;cudd.h" HAVE_CTYPE_HUDD_H )
check_include_files( "stdio.h;cuddI.h" HAVE_CUDD_H )
check_include_files( "cudd.h;cuddInt.h" HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cudd_config.h" )

View File

@ -1,152 +1,47 @@
# - Try to find the CUDD BDD package
# Once done this will define
# Try to find CUDD headers and libraries.
#
# CUDD_FOUND - system has CUDD
# CUDD_LIBRARIES - Link these to use CUDD
# CUDD_INCLUDE_DIR - Include directory for using CUDD
# Usage of this module as follows:
#
# Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
# find_package(CUDD)
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# CUDD_ROOT Set this variable to the root installation of
# libcudd if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# CUDD_FOUND System has CUDD libraries and headers
# CUDD_LIBRARIES The CUDD library
# CUDD_INCLUDE_DIR The location of CUDD headers
SET( CUDD_FOUND "NO" )
set (CUDD_INCLUDE_SEARCH_PATH
${CUDD_ROOT_DIR}/include
${CMAKE_INSTALL_PREFIX}/include
/usr/local/yap/include
/usr/local/Yap/include
/usr/local/cudd/include
/usr/lib/cudd/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include/
/sw/include # Fink
/opt/local/include # MacPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
)
set (CUDD_LIB_SEARCH_PATH
${CUDD_ROOT_DIR}/lib
${CMAKE_INSTALL_PREFIX}/lib
/usr/lib
/usr/local/lib/cudd
/usr/local/cudd/lib
/usr/lib/cudd
/usr/lib/cudd/lib
/usr/freeware/lib )
if ($ENV{CUDD_ROOT})
list (APPEND CUDD_LIB_SEARCH_PATH
$ENV{CUDD_ROOT}/lib
$ENV{CUDD_ROOT}/lib-dbg
$ENV{CUDD_ROOT} )
list (APPEND CUDD_INCLUDE_SEARCH_PATH
$ENV{CUDD_ROOT}/include )
# Get hint from environment variable (if any)
if(NOT CUDD_ROOT AND DEFINED ENV{CUDD_ROOT})
set(CUDD_ROOT "$ENV{CUDD_ROOT}" CACHE PATH "CUDD base directory location (optional, used for nonstandard installation paths)")
mark_as_advanced(CUDD_ROOT)
endif()
if (${CUDD_ROOT})
list (APPEND CUDD_LIB_SEARCH_PATH
${CUDD_ROOT}/lib
${CUDD_ROOT}/lib-dbg
${CUDD_ROOT} )
list (APPEND CUDD_INCLUDE_SEARCH_PATH
${CUDD_ROOT}/include )
# Search path for nonstandard locations
if(CUDD_ROOT)
set(CUDD_INCLUDE_PATH PATHS "${CUDD_ROOT}/include" NO_DEFAULT_PATH)
set(CUDD_LIBRARY_PATH PATHS "${CUDD_ROOT}/lib" NO_DEFAULT_PATH)
endif()
# Check if we have cached results in case the last round was successful.
find_package(PkgConfig)
find_path(CUDD_INCLUDE_DIR
NAMES cudd.h cudd/cudd.h
${CUDD_INCLUDE_SEARCH_PATH}
)
mark_as_advanced(CUDD_INCLUDE_DIR)
if (CUDD_INCLUDE_DIR)
find_library(CUDD_LIBRARIES
NAMES cudd
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_LIBRARIES)
SET( CUDD_FOUND "YES" )
find_library(CUDD_DDDMP_LIBRARY
NAMES dddmp
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_DDMP_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_DDMP_LIBRARY} )
# Search path for nonstandard locations
if(CUDD_ROOT_DIR)
set(CUDD_INCLUDE_PATH PATHS "${CUDD_ROOT_DIR}/include" NO_DEFAULT_PATH)
set(CUDD_LIBRARY_PATH PATHS "${CUDD_ROOT_DIR}/lib" NO_DEFAULT_PATH)
endif()
find_library(CUDD_EPD_LIBRARY
NAMES epd
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_EPD_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_EPD_LIBRARY} )
endif()
find_library(CUDD_ST_LIBRARY
NAMES cuddst
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_ST_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_ST_LIBRARY} )
endif()
find_path(CUDD_INCLUDE_DIR NAMES cudd.h cudd/cudd.h HINTS ${CUDD_INCLUDE_PATH})
find_library(CUDD_LIBRARIES NAMES cudd CUDDVC-2.5.0 HINTS ${CUDD_LIBRARY_PATH})
find_library(CUDD_UTIL_LIBRARY
NAMES cuddutil
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_UTIL_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_ST_LIBRARY} )
endif()
include(FindPackageHandleStandardArgs)
find_library(CUDD_MTR_LIBRARY
NAMES mtr
PATHS
${CUDD_LIB_SEARCH_PATH}
)
find_package_handle_standard_args(CUDD DEFAULT_MSG CUDD_LIBRARIES CUDD_INCLUDE_DIR)
if (CUDD_MTR_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_MTR_LIBRARY} )
endif()
endif()
endif()
mark_as_advanced(CUDD_LIBRARIES)
mark_as_advanced (CUDD_FOUND)
find_package_handle_standard_args(CUDD DEFAULT_MSG CUDD_LIBRARIES CUDD_INCLUDE_DIR )
mark_as_advanced(CUDD_ROOT CUDD_LIBRARIES CUDD_INCLUDE_DIR)

View File

@ -17,6 +17,14 @@ macro_log_feature (CUDD_FOUND "CUDD"
if (CUDD_FOUND)
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} )
check_include_files( "stdio.h;cudd.h" HAVE_CTYPE_HUDD_H )
check_include_files( "stdio.h;cuddI.h" HAVE_CUDD_H )
check_include_files( "cudd.h;cuddInt.h" HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cudd_config.h" )
endif (CUDD_FOUND)

View File

@ -36,7 +36,7 @@ get_filename_component ( ABS_PYTHON_INCLUDE_PATH ${_ABS_PYTHON_INCLUDE_PATH} ABS
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'stdlib' ) )"
OUTPUT_VARIABLE _ABS_PYTHON_SYSLIB_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE )
set( _ABS_PYTHON_SYSLIB_PATH
${_ABS_PYTHON_SYSLIB_PATH}/../${CMAKE_SHARED_LIBRARY_PREFIX}python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m${CMAKE_SHARED_LIBRARY_SUFFIX} )
message("${_ABS_PYTHON_SYSLIB_PATH}")

16
configure vendored
View File

@ -68,11 +68,11 @@ set_config_var() {
cfg="${ENABLE_VARS}"
case "x$arg" in
"xy"|"xyes"|"xtrue")
VAR_VALUE=yes
VAR_VALUE=YES
;;
"xn"|"xno"|"xfalse")
found=y
VAR_VALUE=no
VAR_VALUE=NO
;;
**)
VAR_VALUE=""
@ -84,10 +84,10 @@ set_config_var() {
cfg="${ENABLE_VARS}"
case "x$arg" in
"xy"|"xyes"|"xtrue")
VAR_VALUE=no
VAR_VALUE=NO
;;
"xn"|"xno"|"xfalse")
VAR_VALUE=yes
VAR_VALUE=YES
;;
**)
VAR_VALUE=""
@ -99,13 +99,13 @@ set_config_var() {
name="${1#--with-}"
cfg="${WITH_VARS}"
case "x$arg" in
"x"|"xy"|"xyes"|"xtrue")
"x"|"xy"|"xyes"|"xtrue"|"xon")
is_with=n
VAR_VALUE=yes
VAR_VALUE=YES
``;;
"xn"|"xno"|"xfalse")
"xn"|"xno"|"xfalse"|"xoff")
is_with=n
VAR_VALUE=no
VAR_VALUE=NO
;;
**)
is_with=y

View File

@ -10,10 +10,12 @@ for the relative license.
#include <stdio.h>
#include "config.h"
#include "cudd_config.h"
#if HAVE_CUDD_CUDDINT_H
#include "cudd/cuddInt.h"
#elif HAVE_CUDDINT_H
#include "cuddInt.h"
#if HAVE_CUDD_CUDD_H
#include "cudd/cudd.h"
#include "cudd/mtr.h"
#elif HAVE_CUDD_H
#include "cudd.h"
#include "mtr.h"
#endif
#include "YapInterface.h"

View File

@ -116,7 +116,7 @@ PyObject *PythonLookup(const char *s, PyObject *oo) {
PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
YAP_Term hd, yt;
bool may_be_package = true;
py_Context = NULL;
yt = YAP_GetFromSlot(l);
@ -128,7 +128,7 @@ PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
return NULL;
}
yt = YAP_TailOfTerm(yt);
}
YAP_PutInSlot(l, yt);
return ob;
@ -1050,7 +1050,7 @@ PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
AOK( copy_to_dictionary(dict, targ, taux, true), NULL);
AOK( PL_get_arg(2, t, t) , NULL );
}
if (PL_is_functor(t, FUNCTOR_colon2)) {
AOK ( copy_to_dictionary(dict, t, taux, true), NULL);
}
@ -1069,7 +1069,7 @@ PyObject *compound_to_pytree(term_t t, PyObject *context) {
AOK( PL_get_name_arity(t, &name, &arity), NULL );
if (arity == 0)
return term_to_python(t, false, o);
AOK( PL_get_functor(t, &fun), NULL);
AOK( PL_get_functor(t, &fun), NULL);
if ((no = compound_to_data(t, o, fun, false)) != o && no) {
return no;
}

View File

@ -61,6 +61,7 @@ yio.yap
add_custom_target (${YAP_STARTUP} ALL SOURCES ${PL_SOURCES} ${YAPOS_PL_SOURCES} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
if ( NOT CMAKE_CROSSCOMPILING )
# Create a startup.yss on the top directory.
add_custom_command (TARGET ${YAP_STARTUP}
COMMAND yap-bin -B
@ -68,6 +69,7 @@ add_custom_command (TARGET ${YAP_STARTUP}
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
DEPENDS yap-bin ${PL_SOURCES}
)
endif ( NOT CMAKE_CROSSCOMPILING )
install (FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}