diff --git a/H/Yapproto.h b/H/Yapproto.h index 6fa38dff5..54e63a568 100644 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -379,7 +379,7 @@ int STD_PROTO(Yap_rational_tree_loop, (CELL *, CELL *, CELL **, CELL ** void STD_PROTO(Yap_InitAbsmi,(void)); void STD_PROTO(Yap_InitUnify,(void)); void STD_PROTO(Yap_TrimTrail,(void)); -void STD_PROTO(Yap_Unifiable,(Term d0, Term d1)); +int STD_PROTO(Yap_Unifiable,(Term d0, Term d1)); int STD_PROTO(Yap_IUnify,(register CELL d0,register CELL d1)); /* userpreds.c */ @@ -397,6 +397,8 @@ int STD_PROTO(Yap_SizeGroundTerm,(Term, int)); int STD_PROTO(Yap_IsGroundTerm,(Term)); void STD_PROTO(Yap_InitUtilCPreds,(void)); Int STD_PROTO(Yap_TermHash,(Term, Int, Int, int)); +Int STD_PROTO(Yap_NumberVars,(Term, Int)); +Term STD_PROTO(Yap_UnNumberTerm,(Term)); /* yap.c */ diff --git a/Makefile.in b/Makefile.in index 7f1588a2f..e4e0b704d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -115,6 +115,15 @@ INTERFACE_HEADERS = \ $(srcdir)/include/yap_structs.h \ $(srcdir)/include/YapInterface.h \ $(srcdir)/include/SWI-Prolog.h \ + $(srcdir)/H/TermExt.h \ + $(srcdir)/H/YapTags.h \ + $(srcdir)/H/Tags_32bits.h \ + $(srcdir)/H/Tags_32Ops.h \ + $(srcdir)/H/Tags_32LowTag.h \ + $(srcdir)/H/Tags_64bits.h \ + $(srcdir)/H/Tags_24bits.h \ + $(srcdir)/H/YapTerm.h \ + $(srcdir)/include/YapRegs.h \ $(srcdir)/library/dialect/bprolog/fli/bprolog.h \ $(srcdir)/os/SWI-Stream.h @@ -136,13 +145,7 @@ IOLIB_HEADERS=$(srcdir)/os/pl-buffer.h \ $(srcdir)/H/pl-yap.h @ENABLE_WINCONSOLE@ $(srcdir)/os/windows/dirent.h $(srcdir)/os/windows/utf8.h $(srcdir)/os/windows/utf8.c $(srcdir)/os/windows/uxnt.h $(srcdir)/os/windows/mswchar.h $(srcdir)/os/windows/popen.c HEADERS = \ - $(srcdir)/H/TermExt.h \ $(srcdir)/H/Atoms.h \ - $(srcdir)/H/Tags_32bits.h \ - $(srcdir)/H/Tags_32Ops.h \ - $(srcdir)/H/Tags_32LowTag.h \ - $(srcdir)/H/Tags_64bits.h \ - $(srcdir)/H/Tags_24bits.h \ $(srcdir)/H/sshift.h \ $(srcdir)/H/Yap.h \ $(srcdir)/H/Yatom.h \ @@ -407,7 +410,7 @@ all: parms.h startup.yss @ENABLE_WINCONSOLE@ pl-yap@EXEC_SUFFIX@ Makefile: $(srcdir)/Makefile.in -$(srcdir)/H/Yap.h: config.h +$(srcdir)/H/Yap.h: config.h YapTermConfig.h $(srcdir)/H/YapTags.h config.h: parms.h @@ -774,10 +777,12 @@ install_unix: startup.yss libYap.a @ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE) install) #@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/pyswip; $(MAKE) install) mkdir -p $(DESTDIR)$(INCLUDEDIR) - $(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR) + mkdir -p $(DESTDIR)$(INCLUDEDIR)/src + $(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/src for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done - $(INSTALL) config.h $(DESTDIR)$(INCLUDEDIR)/config.h - $(INSTALL) parms.h $(DESTDIR)$(INCLUDEDIR)/parms.h + $(INSTALL) config.h $(DESTDIR)$(INCLUDEDIR)/src/config.h + $(INSTALL) parms.h $(DESTDIR)$(INCLUDEDIR)/src/parms.h + $(INSTALL) YapTermConfig.h $(DESTDIR)$(INCLUDEDIR) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install) @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) install) @ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install) @@ -859,7 +864,7 @@ TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS) depend: $(HEADERS) $(C_SOURCES) -@if test "$(GCC)" = yes; then\ - $(CC) -MM $(CFLAGS) -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/os $(C_SOURCES) >> Makefile;\ + $(CC) -MM $(CFLAGS) -D__YAP_NOT_INSTALLED__=1 -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/os $(C_SOURCES) >> Makefile;\ else\ makedepend -f - -- $(CFLAGS) -I$(srcdir)/include -- $(C_SOURCES) |\ sed 's|.*/\([^:]*\):|\1:|' >> Makefile ;\ diff --git a/config.h.in b/config.h.in index 19d719fb5..79941dd18 100644 --- a/config.h.in +++ b/config.h.in @@ -135,14 +135,7 @@ /* Define byte order */ #undef WORDS_BIGENDIAN -/* Define sizes of some basic types */ -#undef SIZEOF_INT_P -#undef SIZEOF_INT -#undef SIZEOF_SHORT_INT -#undef SIZEOF_LONG_INT -#undef SIZEOF_LONG_LONG_INT -#undef SIZEOF_FLOAT -#undef SIZEOF_DOUBLE +#include "YapTermConfig.h" /* Define representation of floats */ /* only one of the following shoud be set */ diff --git a/configure b/configure index af1a526c9..b78c7971f 100755 --- a/configure +++ b/configure @@ -2617,6 +2617,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers YapTermConfig.h" + mycflags="$CFLAGS" @@ -10860,6 +10862,7 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "YapTermConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS YapTermConfig.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "GPL/Makefile") CONFIG_FILES="$CONFIG_FILES GPL/Makefile" ;; "library/Makefile") CONFIG_FILES="$CONFIG_FILES library/Makefile" ;; diff --git a/configure.in b/configure.in index 49252c1dd..a2fd80031 100644 --- a/configure.in +++ b/configure.in @@ -45,6 +45,7 @@ dnl EXTRA_LIBS_FOR_SWIDLLS= libs that are required when lding a SWI so AC_INIT(console/yap.c) AC_CONFIG_HEADER(config.h) +AC_CONFIG_HEADER(YapTermConfig.h) dnl store the environment's compilation flags mycflags="$CFLAGS" diff --git a/docs/yap.tex b/docs/yap.tex index dd4d5d2f9..c3de0939b 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -3272,6 +3272,12 @@ compound term. Instantiates each variable in term @var{T} to a term of the form: @code{'$VAR'(@var{I})}, with @var{I} increasing from @var{N1} to @var{Nn}. +@item unnumbervars(@var{T},+@var{NT}) +@findex unnumbervars/2 +@syindex unnumbervars/2 +@cnindex unnumbervars/2 +Replace every @code{'$VAR'(@var{I})} by a free variable. + @item ground(@var{T}) @findex ground/1 @syindex ground/1 @@ -16171,6 +16177,7 @@ The user can create a new uninstantiated variable using the primitive @findex YAP_IsAtomTerm (C-Interface function) @findex YAP_IsPairTerm (C-Interface function) @findex YAP_IsApplTerm (C-Interface function) +@findex YAP_IsCompoundTerm (C-Interface function) The following primitives can be used to discriminate among the different types of non-variable terms: @example @@ -16180,6 +16187,7 @@ of non-variable terms: YAP_Bool YAP_IsAtomTerm(YAP_Term @var{t}) YAP_Bool YAP_IsPairTerm(YAP_Term @var{t}) YAP_Bool YAP_IsApplTerm(YAP_Term @var{t}) + YAP_Bool YAP_IsCompoundTerm(YAP_Term @var{t}) @end example The next primitive gives the type of a Prolog term: @@ -16603,6 +16611,22 @@ The next function succeeds if two terms are variant terms, and returns @end example @noindent +The next functions deal with numbering variables in terms: +@example + int YAP_NumberVars(YAP_Term t, YAP_Int first_number) + YAP_Term YAP_UnNumberVars(YAP_Term t) + int YAP_IsNumberedVariable(YAP_Term t) +@end example +@noindent + +The next one returns the length of a well-formed list @var{t}, or +@code{-1} otherwise: +@example + Int YAP_ListLength(YAP_Term t) +@end example +@noindent + + Last, this function succeeds if two terms are unifiable: @code{=@=/2}: @example diff --git a/include/YapTags.h b/include/YapTags.h deleted file mode 100644 index 587900b54..000000000 --- a/include/YapTags.h +++ /dev/null @@ -1,119 +0,0 @@ -/***********************************************************************/ - - /* - absrectype Term = Int + Float + Atom + Pair + Appl + Ref + Var - - with AbsAppl(t) : *CELL -> Term - and RepAppl(t) : Term -> *CELL - - and AbsPair(t) : *CELL -> Term - and RepPair(t) : Term -> *CELL - - and IsIntTerm(t) = ... - and IsAtomTerm(t) = ... - and IsVarTerm(t) = ... - and IsPairTerm(t) = ... - and IsApplTerm(t) = ... - and IsFloatTerm(t) = ... - and IsRefTerm(t) = ... - and IsNonVarTerm(t) = ! IsVar(t) - and IsNumterm(t) = IsIntTerm(t) || IsFloatTerm(t) - and IsAtomicTerm(t) = IsNumTerm(t) || IsAtomTerm(t) - and IsPrimitiveTerm(t) = IsAtomicTerm(t) || IsRefTerm(t) - - and MkIntTerm(n) = ... - and MkFloatTerm(f) = ... - and MkAtomTerm(a) = ... - and MkVarTerm(r) = ... - and MkApplTerm(f,n,args) = ... - and MkPairTerm(hd,tl) = ... - and MkRefTerm(R) = ... - - and PtrOfTerm(t) : Term -> CELL * = ... - and IntOfTerm(t) : Term -> int = ... - and FloatOfTerm(t) : Term -> flt = ... - and AtomOfTerm(t) : Term -> Atom = ... - and VarOfTerm(t) : Term -> *Term = .... - and HeadOfTerm(t) : Term -> Term = ... - and TailOfTerm(t) : Term -> Term = ... - and FunctorOfTerm(t) : Term -> Functor = ... - and ArgOfTerm(i,t) : Term -> Term= ... - and RefOfTerm(t) : Term -> DBRef = ... - - */ - -/* - YAP can use several different tag schemes, according to the kind of - machine we are experimenting with. -*/ - -#if LONG_ADDRESSES && defined(OLD_TAG_SCHEME) - -#include "Tags_32bits.h" - -#endif /* LONG_ADDRESSES && defined(OLD_TAG_SCHEME) */ - -/* AIX will by default place mmaped segments at 0x30000000. This is - incompatible with the high tag scheme. Linux-ELF also does not like - if you place things in the lower addresses (power to the libc people). -*/ - -#if defined(__APPLE__) -/* mmap on __APPLE__ is not the greatest idea. It overwrites memory allocated by malloc */ -#undef USE_DL_MALLOC -#ifndef USE_SYSTEM_MALLOC -#define USE_SYSTEM_MALLOC 1 -#endif -#elif (defined(_AIX) || (defined(__APPLE__) && !defined(__LP64__)) || defined(_WIN32) || defined(sparc) || defined(__sparc) || defined(mips) || defined(__FreeBSD__) || defined(_POWER) || defined(__POWERPC__) || defined(__linux__) || defined(IN_SECOND_QUADRANT) || defined(__CYGWIN__)) || defined(__NetBSD__) || defined(__DragonFly__) -#define USE_LOW32_TAGS 1 -#endif - -#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS) - -#include "Tags_32Ops.h" - -#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS) */ - -#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && defined(USE_LOW32_TAGS) - -#include "Tags_32LowTag.h" - -#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) */ - -#if LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME) - -#include "Tags_64bits.h" - -#endif /* LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME) */ - -#if !LONG_ADDRESSES - -#include "Tags_24bits.h" - -#endif /* !LONG_ADDRESSES */ - -#ifdef TAG_LOW_BITS_32 - -#if !GC_NO_TAGS -#define MBIT 0x80000000 -#define RBIT 0x40000000 - -#if IN_SECOND_QUADRANT -#define INVERT_RBIT 1 /* RBIT is 1 by default */ -#endif -#endif /* !GC_NO_TAGS */ - -#else - -#if !GC_NO_TAGS -#if defined(YAPOR_SBA) && defined(__linux__) -#define MBIT /* 0x20000000 */ MKTAG(0x1,0) /* mark bit */ -#else -#define RBIT /* 0x20000000 */ MKTAG(0x1,0) /* relocation chain bit */ -#define MBIT /* 0x40000000 */ MKTAG(0x2,0) /* mark bit */ -#endif -#endif /* !GC_NO_TAGS */ - -#endif - -#define TermSize sizeof(Term) diff --git a/library/Makefile.in b/library/Makefile.in index e5be0239a..1e135fd88 100644 --- a/library/Makefile.in +++ b/library/Makefile.in @@ -101,6 +101,7 @@ DIALECT_SWI= \ DIALECT_BP= \ $(srcdir)/dialect/bprolog/actionrules.pl \ + $(srcdir)/dialect/bprolog/arrays.yap \ $(srcdir)/dialect/bprolog/compile_foreach.pl \ $(srcdir)/dialect/bprolog/foreach.pl \ $(srcdir)/dialect/bprolog/hashtable.yap @@ -109,6 +110,7 @@ install: $(PROGRAMS) install_myddas mkdir -p $(DESTDIR)$(SHAREDIR)/Yap mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi + mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect/bprolog for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done for p in $(DIALECT_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/dialect; done for p in $(DIALECT_SWI); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi; done