misc_bugs_when_compiling_problog

This commit is contained in:
Vitor Santos Costa 2016-04-14 12:00:09 +01:00
parent 29fba0238d
commit 1aa20e24b7
29 changed files with 100 additions and 191 deletions

View File

@ -814,7 +814,6 @@ write_buffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
if (out->type & (YAP_STRING_WITH_BUFFER|YAP_STRING_MALLOC) ) { if (out->type & (YAP_STRING_WITH_BUFFER|YAP_STRING_MALLOC) ) {
char *s = s0; char *s = s0;
size_t n = strlen( s )+1; size_t n = strlen( s )+1;
memcpy( out->val.c, s0, n*sizeof(wchar_t));
out->val.c[n] = '\0'; out->val.c[n] = '\0';
sz_end = n+1; sz_end = n+1;
} else { } else {

View File

@ -72,11 +72,11 @@ if (MPI_C_FOUND)
add_library (yap_mpi SHARED ${MPI_SOURCES}) add_library (yap_mpi SHARED ${MPI_SOURCES})
target_link_libraries(yap_mpi libYap ${MPI_LIBRARIES}) target_link_libraries(yap_mpi libYap ${MPI_C_LIBRARIES})
set_target_properties (yap_mpi PROPERTIES PREFIX "") set_target_properties (yap_mpi PROPERTIES PREFIX "")
include_directories (${MPI_INCLUDE_DIRS}) include_directories (${MPI_C_INCLUDE_PATH})
add_definitions (-DHAVE_MPI_H=1) add_definitions (-DHAVE_MPI_H=1)

View File

@ -558,21 +558,6 @@ file_property(File, Type, Size, Date, Permissions, LinkName) :-
handle_system_internal(Error, off, file_property(File)). handle_system_internal(Error, off, file_property(File)).
file_exists(File, Permissions) :-
var(File), !,
throw(error(instantiation_error,file_exists(File, Permissions))).
file_exists(File, Permissions) :-
\+ atom(File), !,
throw(error(type_error(atom,File),file_exists(File, Permissions))).
file_exists(IFile, Permissions) :-
true_file_name(IFile, File),
file_property(File, _Type, _Size, _Date, FPermissions, _, Error),
var(Error),
process_permissions(Permissions, Perms),
FPermissions /\ Perms =:= Perms.
process_permissions(Number, Number) :- integer(Number).
% %
% environment manipulation. % environment manipulation.
% %

View File

@ -113,7 +113,7 @@ Int Yap_peek(int sno) {
} }
#endif #endif
/* buffer the character */ /* buffer the character */
if (s->encoding == LOCAL_encoding) { if (s->encoding == Yap_SystemEncoding() && 0) {
ch = fgetwc(s->file); ch = fgetwc(s->file);
ungetwc(ch, s->file); ungetwc(ch, s->file);
return ch; return ch;
@ -122,7 +122,7 @@ Int Yap_peek(int sno) {
olinecount = s->linecount; olinecount = s->linecount;
olinepos = s->linepos; olinepos = s->linepos;
ch = s->stream_wgetc(sno); ch = s->stream_wgetc(sno);
if (ch == EOFCHAR) { if (ch == EOFCHAR) {
s->stream_getc = EOFPeek; s->stream_getc = EOFPeek;
s->stream_wgetc = EOFWPeek; s->stream_wgetc = EOFWPeek;
s->status |= Push_Eof_Stream_f; s->status |= Push_Eof_Stream_f;
@ -136,7 +136,7 @@ Int Yap_peek(int sno) {
unsigned char cs[8]; unsigned char cs[8];
size_t n = put_utf8(cs, ch); size_t n = put_utf8(cs, ch);
while (n--) { while (n--) {
ungetc(cs[n - 1], s->file); ungetc(cs[n], s->file);
} }
} else if (s->encoding == ENC_UTF16_BE) { } else if (s->encoding == ENC_UTF16_BE) {
/* do the ungetc as if a write .. */ /* do the ungetc as if a write .. */

View File

@ -59,6 +59,9 @@ static char SccsId[] = "%W% %G%";
#if HAVE_WCTYPE_H #if HAVE_WCTYPE_H
#include <wctype.h> #include <wctype.h>
#endif #endif
#if HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#if HAVE_IO_H #if HAVE_IO_H
/* Windows */ /* Windows */
@ -135,29 +138,40 @@ static encoding_t enc_os_default( encoding_t rc)\
return rc; return rc;
} }
static encoding_t DefaultEncoding(void) { encoding_t Yap_SystemEncoding(void) {
int i = 0; int i = -1;
while (encvs[i]) { while (i == -1 || encvs[i]) {
char *v = getenv(encvs[i]); char *v;
if ( i == -1 ) {
if ((v = setlocale(LC_CTYPE, NULL)) == NULL ||
!strcmp(v,"C")) {
if ((v = getenv("LC_CTYPE")))
setlocale(LC_CTYPE, v);
else if ((v = getenv("LANG")))
setlocale(LC_CTYPE, v);
}
} else {
v = getenv(encvs[i]);
}
if (v) { if (v) {
int j = 0; int j = 0;
size_t sz = strlen(v);
const char *coding; const char *coding;
while ((coding = ematches[j].s) != NULL) { while ((coding = ematches[j].s) != NULL) {
size_t sz2 = strlen(coding); char *v1;
if (sz2 > sz) { if ((v1 = strstr(v, coding)) &&
j++; strlen(v1) == strlen(coding)) {
continue; return ematches[j].e;
}
if (!strcmp(coding+(sz-sz2), v) ) {
return enc_os_default(ematches[j].e);
} }
j++; j++;
} }
} }
i++; i++;
} }
return enc_os_default(ENC_ISO_ASCII); return ENC_ISO_ASCII;
}
static encoding_t DefaultEncoding(void) {
return enc_os_default(Yap_SystemEncoding());
} }
encoding_t Yap_DefaultEncoding(void) { encoding_t Yap_DefaultEncoding(void) {

View File

@ -43,6 +43,7 @@ typedef enum {
/// read the current environment, as set by the user or as Initial /// read the current environment, as set by the user or as Initial
encoding_t Yap_DefaultEncoding(void); encoding_t Yap_DefaultEncoding(void);
encoding_t Yap_SystemEncoding(void);
void Yap_SetDefaultEncoding(encoding_t new_encoding); void Yap_SetDefaultEncoding(encoding_t new_encoding);
#if HAVE_XLOCALE_H #if HAVE_XLOCALE_H

View File

@ -261,8 +261,8 @@ void Yap_DefaultStreamOps(StreamDesc *st) {
Yap_ConsoleOps(st); Yap_ConsoleOps(st);
} }
#ifndef _WIN32 #ifndef _WIN32
else if (st->file != NULL) { else if (st->file != NULL && 0 && !(st->status & InMemory_Stream_f)) {
if (st->encoding == LOCAL_encoding) { if (st->encoding == Yap_SystemEncoding()) {
st->stream_wgetc = get_wchar_from_file; st->stream_wgetc = get_wchar_from_file;
} else } else
st->stream_wgetc = get_wchar_from_FILE; st->stream_wgetc = get_wchar_from_FILE;
@ -1137,7 +1137,6 @@ do_open(Term file_name, Term t2,
const char *s_encoding; const char *s_encoding;
encoding_t encoding; encoding_t encoding;
Term tenc; Term tenc;
// original file name // original file name
if (IsVarTerm(file_name)) { if (IsVarTerm(file_name)) {
Yap_Error(INSTANTIATION_ERROR, file_name, "open/3"); Yap_Error(INSTANTIATION_ERROR, file_name, "open/3");

View File

@ -130,10 +130,10 @@ int Yap_open_buf_read_stream(const char *nbuf, size_t nchars, encoding_t *encp,
encoding = LOCAL_encoding; encoding = LOCAL_encoding;
#if MAY_READ #if MAY_READ
// like any file stream. // like any file stream.
f = fmemopen((void *)nbuf, nchars, "r"); st->file = f = fmemopen((void *)nbuf, nchars, "r");
flags = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f; flags = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f;
#else #else
f = NULL; sT->file = f = NULL;
flags = Input_Stream_f | InMemory_Stream_f; flags = Input_Stream_f | InMemory_Stream_f;
#endif #endif
Yap_initStream(sno, f, NULL, TermNil, encoding, flags, AtomRead); Yap_initStream(sno, f, NULL, TermNil, encoding, flags, AtomRead);
@ -369,7 +369,8 @@ bool Yap_CloseMemoryStream(int sno) {
} else { } else {
#if MAY_READ #if MAY_READ
fclose(GLOBAL_Stream[sno].file); fclose(GLOBAL_Stream[sno].file);
Yap_FreeAtomSpace(GLOBAL_Stream[sno].nbuf); if (GLOBAL_Stream[sno].status & FreeOnClose_Stream_f)
free(GLOBAL_Stream[sno].nbuf);
#else #else
if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE) if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf); Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf);

View File

@ -890,42 +890,7 @@ void Yap_CloseStreams(int loud) {
for (sno = 3; sno < MaxStreams; ++sno) { for (sno = 3; sno < MaxStreams; ++sno) {
if (GLOBAL_Stream[sno].status & Free_Stream_f) if (GLOBAL_Stream[sno].status & Free_Stream_f)
continue; continue;
if ((GLOBAL_Stream[sno].status & Popen_Stream_f)) { CloseStream( sno );
#if _MSC_VER
_pclose(GLOBAL_Stream[sno].file);
#else
pclose(GLOBAL_Stream[sno].file);
#endif
}
if (GLOBAL_Stream[sno].status & (Pipe_Stream_f | Socket_Stream_f))
close(GLOBAL_Stream[sno].u.pipe.fd);
#if USE_SOCKET
else if (GLOBAL_Stream[sno].status & (Socket_Stream_f)) {
Yap_CloseSocket(GLOBAL_Stream[sno].u.socket.fd,
GLOBAL_Stream[sno].u.socket.flags,
GLOBAL_Stream[sno].u.socket.domain);
}
#endif
else if (GLOBAL_Stream[sno].status & InMemory_Stream_f) {
if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE) {
Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf);
} else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
free(GLOBAL_Stream[sno].u.mem_string.buf);
}
} else if (!(GLOBAL_Stream[sno].status & Null_Stream_f)) {
fclose(GLOBAL_Stream[sno].file);
} else {
if (loud)
fprintf(Yap_stderr, "%% YAP Error: while closing stream: %s\n",
RepAtom(GLOBAL_Stream[sno].name)->StrOfAE);
}
if (LOCAL_c_input_stream == sno) {
LOCAL_c_input_stream = StdInStream;
} else if (LOCAL_c_output_stream == sno) {
LOCAL_c_output_stream = StdOutStream;
}
GLOBAL_Stream[sno].status = Free_Stream_f;
} }
} }
@ -947,10 +912,16 @@ static void CloseStream(int sno) {
close(GLOBAL_Stream[sno].u.pipe.fd); close(GLOBAL_Stream[sno].u.pipe.fd);
} else if (GLOBAL_Stream[sno].status & (InMemory_Stream_f)) { } else if (GLOBAL_Stream[sno].status & (InMemory_Stream_f)) {
Yap_CloseMemoryStream(sno); Yap_CloseMemoryStream(sno);
if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE) if (GLOBAL_Stream[sno].file == NULL) {
Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf); char *s = GLOBAL_Stream[sno].u.mem_string.buf;
else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) { if (s == LOCAL_FileNameBuf ||
free(GLOBAL_Stream[sno].u.mem_string.buf); s == LOCAL_FileNameBuf2)
return;
if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
Yap_FreeAtomSpace(s);
else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
free(s);
}
} }
} }
GLOBAL_Stream[sno].status = Free_Stream_f; GLOBAL_Stream[sno].status = Free_Stream_f;

View File

@ -521,14 +521,17 @@ static const char *myrealpath(const char *path, char *out) {
if (errno == ENOENT || errno == EACCES) { if (errno == ENOENT || errno == EACCES) {
char base[YAP_FILENAME_MAX]; char base[YAP_FILENAME_MAX];
strncpy(base, path, YAP_FILENAME_MAX - 1); strncpy(base, path, YAP_FILENAME_MAX - 1);
rc = realpath(dirname((char *)path), NULL); rc = realpath(dirname(base), NULL);
if (rc) { if (rc) {
const char *b = basename(base); const char *b = basename(base);
size_t e = strlen(rc); size_t e = strlen(rc);
size_t bs = strlen(b); size_t bs = strlen(b);
rc = realloc(rc, e + bs + 2); if (rc != out &&
rc != base) {
rc = realloc(rc, e + bs + 2);
}
#if _WIN32 #if _WIN32
if (rc[e - 1] != '\\' && rc[e - 1] != '/') { if (rc[e - 1] != '\\' && rc[e - 1] != '/') {
rc[e] = '\\'; rc[e] = '\\';
@ -797,7 +800,7 @@ static Term
* *
* @return * @return
*/ */
static Int prolog_realpath(USES_REGS1) { static Int real_path(USES_REGS1) {
Term t1 = Deref(ARG1); Term t1 = Deref(ARG1);
const char *cmd; const char *cmd;
@ -2145,7 +2148,7 @@ void Yap_InitSysPreds(void) {
Yap_InitCPred("prolog_to_os_filename", 2, prolog_to_os_filename, Yap_InitCPred("prolog_to_os_filename", 2, prolog_to_os_filename,
SyncPredFlag); SyncPredFlag);
Yap_InitCPred("absolute_file_system_path", 2, absolute_file_system_path, 0); Yap_InitCPred("absolute_file_system_path", 2, absolute_file_system_path, 0);
Yap_InitCPred("real_path", 2, prolog_realpath, 0); Yap_InitCPred("real_path", 2, real_path, 0);
Yap_InitCPred("true_file_name", 2, true_file_name, SyncPredFlag); Yap_InitCPred("true_file_name", 2, true_file_name, SyncPredFlag);
Yap_InitCPred("true_file_name", 3, true_file_name3, SyncPredFlag); Yap_InitCPred("true_file_name", 3, true_file_name3, SyncPredFlag);
#ifdef _WIN32 #ifdef _WIN32

View File

@ -187,7 +187,7 @@
% free-of-charge patent license to make, have made, use, offer to sell, % free-of-charge patent license to make, have made, use, offer to sell,
% sell, import and otherwise transfer the Package with respect to any % sell, import and otherwise transfer the Package with respect to any
% patent claims licensable by the Copyright Holder that are necessarily % patent claims licensable by the Copyright Holder that are necessarily
% infringed by the Package. If you institute patent litigation % infringed by the Pack<age. If you institute patent litigation
% (including a cross-claim or counterclaim) against any party alleging % (including a cross-claim or counterclaim) against any party alleging
% that the Package constitutes direct or contributory patent % that the Package constitutes direct or contributory patent
% infringement, then this Artistic License to you shall terminate on the % infringement, then this Artistic License to you shall terminate on the
@ -429,7 +429,7 @@ flag_validate_integer(Value):-
flag_validate_directory. flag_validate_directory.
flag_validate_directory(Value):- flag_validate_directory(Value):-
atomic(Value), atomic(Value),
catch(file_exists(Value), _, fail), catch(file_exists(Value), _, fail),
file_property(Value, type(directory)), !. file_property(Value, type(directory)), !.
flag_validate_directory(Value):- flag_validate_directory(Value):-

View File

@ -1,16 +0,0 @@
@x0
1.8030419430
@x1
1.5711506586
@x2
0.3874470553
@x3
0.7696186145
@x4
0.3435736975
@x5
-0.7166347511
@x6
0.9712276641
@x7
-1.4049657589

View File

@ -730,7 +730,7 @@ update_query(QueryID,Symbol,What_To_Update) :-
problog_flag(sigmoid_slope,Slope), problog_flag(sigmoid_slope,Slope),
problog_dir(PD), problog_dir(PD),
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'), ((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
convert_filename_to_problog_path('simplecudd', Simplecudd), convert_filename_to_problog_path('problogbdd', Simplecudd),
atomic_concat([Simplecudd, atomic_concat([Simplecudd,
' -i "', Probabilities_File, '"', ' -i "', Probabilities_File, '"',
' -l "', Query_Directory,'/query_',QueryID, '"', ' -l "', Query_Directory,'/query_',QueryID, '"',

View File

@ -353,7 +353,8 @@ do_learning_intern(Iterations,Epsilon) :-
format_learning(1,'~nIteration ~d of ~d~n',[CurrentIteration,EndIteration]), format_learning(1,'~nIteration ~d of ~d~n',[CurrentIteration,EndIteration]),
logger_set_variable(iteration,CurrentIteration), logger_set_variable(iteration,CurrentIteration),
leash(none),
% trace,
write_probabilities_file, write_probabilities_file,
once(llh_testset), once(llh_testset),
@ -410,14 +411,14 @@ init_learning :-
learning_initialized, learning_initialized,
!. !.
init_learning :- init_learning :-
convert_filename_to_problog_path('simplecudd_lfi', Path), convert_filename_to_problog_path('problogbdd_lfi', Path),
( (
file_exists(Path) file_exists(Path)
-> ->
true; true;
( (
problog_path(PD), problog_path(PD),
format(user_error, 'WARNING: Can not find file: simplecudd_lfi. Please place file in problog path: ~q~n',[PD]), format(user_error, 'WARNING: Can not find file: problogbdd_lfi. Please place file in problog path: ~q~n',[PD]),
fail fail
) )
), ),
@ -457,7 +458,7 @@ init_learning :-
format_learning(3,'~q training example(s)~n',[TrainingExampleCount]), format_learning(3,'~q training example(s)~n',[TrainingExampleCount]),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create arrays for probabilties and counting tables % Create arrays for probabilities and counting tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
once(initialize_fact_probabilities), once(initialize_fact_probabilities),
problog:probclause_id(N), problog:probclause_id(N),
@ -471,7 +472,6 @@ init_learning :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% build BDD script for every example % build BDD script for every example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
once(init_queries), once(init_queries),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -613,10 +613,11 @@ init_queries :-
format_learning(2,'Build BDDs for examples~n',[]), format_learning(2,'Build BDDs for examples~n',[]),
forall(user:example(Training_ID), forall(user:example(Training_ID),
( (
format_learning(3,'training example ~q: ',[Training_ID]), format_learning(3,'training example ~q: ',[Training_ID]),
init_one_query(Training_ID,training) init_one_query(Training_ID,training)
) )
), ),
writeln(Training_ID),
forall( forall(
( (
@ -885,7 +886,7 @@ update_query(QueryID,ClusterID ,Method,Command,PID,Output_File_Name) :-
create_bdd_output_file_name(QueryID,ClusterID,Iteration,Output_File_Name), create_bdd_output_file_name(QueryID,ClusterID,Iteration,Output_File_Name),
create_bdd_file_name(QueryID,ClusterID,BDD_File_Name), create_bdd_file_name(QueryID,ClusterID,BDD_File_Name),
convert_filename_to_problog_path('simplecudd_lfi',Absolute_Name), convert_filename_to_problog_path('problogbdd_lfi',Absolute_Name),
atomic_concat([Absolute_Name, atomic_concat([Absolute_Name,
' -i "', Input_File_Name, '"', ' -i "', Input_File_Name, '"',

View File

@ -1438,11 +1438,11 @@ static foreign_t python_to_term(PyObject *pVal, term_t t) {
return address_to_term(pVal, t); return address_to_term(pVal, t);
Py_ssize_t sz = PyUnicode_GetSize(pValR) + 1; Py_ssize_t sz = PyUnicode_GetSize(pValR) + 1;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
s = malloc(sizeof(char) * sz); char *s = malloc(sizeof(char) * sz);
PyObject *us = PyUnicode_EncodeUTF8((const Py_UNICODE *)pValR, sz, NULL); PyObject *us = PyUnicode_EncodeUTF8((const Py_UNICODE *)pValR, sz, NULL);
PyString_AsStringAndSize(us, &s, &sz); PyString_AsStringAndSize(us, &s, &sz);
foreign_t rc = repr_term(s, sz, t); foreign_t rc = repr_term(s, sz, t);
free(s); free((void *)s);
return rc; return rc;
#else #else
// new interface // new interface
@ -2150,9 +2150,8 @@ static foreign_t python_run_script(term_t cmd, term_t fun) {
return false; return false;
} }
static foreign_t python_builtin(out) { static foreign_t python_builtin(term_t out) {
return address_to_term(py_Builtin, out); return address_to_term(py_Builtin, out);
return true;
} }
static foreign_t init_python(void) { static foreign_t init_python(void) {

View File

@ -1361,7 +1361,7 @@ not(G) :- \+ '$execute'(G).
'$bootstrap' :- '$bootstrap' :-
bootstrap('init.yap'). bootstrap('pl/init.yap'),
module(user), module(user),
'$live'. '$live'.
@ -1575,7 +1575,7 @@ catch(G, C, A) :-
'$catch'(M:G,_,[C|A]). '$catch'(M:G,_,[C|A]).
'$catch'(MG,_,_) :- '$catch'(MG,_,_) :-
'$$save_by'(CP0), '$$save_by'(CP0),
'$execute'(MG), '$execute'(MG),
'$$save_by'(CP1), '$$save_by'(CP1),
% remove catch % remove catch

View File

@ -11,54 +11,7 @@
* File: checker.yap * * File: checker.yap *
* comments: style checker for Prolog * * comments: style checker for Prolog *
* * * *
* Last rev: $Date: 2008-03-31 22:56:22 $,$Author: vsc $ * * Last rev: $Date: 2008-03-31 22:56:22 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.23 2007/11/26 23:43:09 vsc
* fixes to support threads and assert correctly, even if inefficiently.
*
* Revision 1.22 2006/11/17 12:10:46 vsc
* style_checker was failing on DCGs
*
* Revision 1.21 2006/03/24 16:26:31 vsc
* code review
*
* Revision 1.20 2005/11/05 23:56:10 vsc
* should have meta-predicate definitions for calls,
* multifile and discontiguous.
* have discontiguous as a builtin, not just as a
* declaration.
*
* Revision 1.19 2005/10/28 17:38:50 vsc
* sveral updates
*
* Revision 1.18 2005/04/20 20:06:11 vsc
* try to improve error handling and warnings from within consults.
*
* Revision 1.17 2005/04/20 04:08:20 vsc
* fix warnings
*
* Revision 1.16 2005/01/13 05:47:27 vsc
* lgamma broke arithmetic optimisation
* integer_y has type y
* pass original source to checker (and maybe even use option in parser)
* use warning mechanism for checker messages.
*
* Revision 1.15 2004/06/29 19:12:01 vsc
* fix checker messages
*
* Revision 1.14 2004/06/29 19:04:46 vsc
* fix multithreaded version
* include new version of Ricardo's profiler
* new predicat atomic_concat
* allow multithreaded-debugging
* small fixes
*
* Revision 1.13 2004/03/19 11:35:42 vsc
* trim_trail for default machine
* be more aggressive about try-retry-trust chains.
* - handle cases where block starts with a wait
* - don't use _killed instructions, just let the thing rot by itself.
* *
* * * *
*************************************************************************/ *************************************************************************/

View File

@ -263,7 +263,7 @@ This is similar to <tt>call_cleanup/1</tt> with an additional
*/ */
call_cleanup(Goal, Cleanup) :- call_cleanup(Goal, Cleanup) :-
setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup). setup_call_catcher_cleanup(true, Goal, _Catcher, Cleanup).
call_cleanup(Goal, Catcher, Cleanup) :- call_cleanup(Goal, Catcher, Cleanup) :-
setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup). setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup).
@ -617,7 +617,7 @@ halt :-
/** @pred halt(+ _I_) is iso /** @pred halt(+ _I_) is iso
Halts Prolog, and exits to the calling application returning the code Halts Prolog, and exits to 1the calling application returning the code
given by the integer _I_. given by the integer _I_.
*/ */

View File

@ -70,7 +70,7 @@ attr_unify_hook(DelayList, _) :-
wake_delays(DelayList). wake_delays(DelayList).
wake_delays([]). wake_delays([]).
wake_delays(Delay.List) :- wake_delays([Delay|List]) :-
wake_delay(Delay), wake_delay(Delay),
wake_delays(List). wake_delays(List).

View File

@ -521,6 +521,10 @@ be lost.
current_prolog_flag( debug, false), current_prolog_flag( debug, false),
!, !,
'$execute_nonstop'(G,M). '$execute_nonstop'(G,M).
'$spycall'(once(G), M, _, _) :-
CP is '$last_choice_pt',
'$debugger_input',
once('$do_spy'(G, M, CP, spy)).
'$spycall'(G, M, _, _) :- '$spycall'(G, M, _, _) :-
'__NB_getval__'('$debug_jump',true, fail), '__NB_getval__'('$debug_jump',true, fail),
!, !,
@ -1033,13 +1037,15 @@ be lost.
'$debugger_skip_loop_spy2'(CPs,CPs1). '$debugger_skip_loop_spy2'(CPs,CPs1).
'$debugger_skip_loop_spy2'(CPs,CPs). '$debugger_skip_loop_spy2'(CPs,CPs).
'$debugger_expand_meta_call'( G, M, G1 ) :- '$debugger_expand_meta_call'( G, VL, G2 ) :-
'$expand_meta_call'( G, M, G0 ), '$expand_meta_call'( G, VL, G0 ),
'$yap_strip_module'( G0, M, G1 ),
( (
'$is_system_predicate'(G0,M) -> '$is_system_predicate'(G0,M) ->
'$debugger_process_meta_arguments'(G0, M, G1) '$debugger_process_meta_arguments'(G1, M, G2)
,writeln(d:G2)
; ;
G1 = G0 G1 = G2
). ).
'$debugger_process_meta_arguments'(G, M, G1) :- '$debugger_process_meta_arguments'(G, M, G1) :-

View File

@ -218,7 +218,7 @@ considered.
'$assert_list'(Clauses, Context, Module, VL, Pos). '$assert_list'(Clauses, Context, Module, VL, Pos).
'$assert_list'([], _Context, _Module, _VL, _Pos). '$assert_list'([], _Context, _Module, _VL, _Pos).
'$assert_list'(Clause.Clauses, Context, Module, VL, Pos) :- '$assert_list'([Clause|Clauses], Context, Module, VL, Pos) :-
'$command'(Clause, VL, Pos, Context), '$command'(Clause, VL, Pos, Context),
'$assert_list'(Clauses, Context, Module, VL, Pos). '$assert_list'(Clauses, Context, Module, VL, Pos).

View File

@ -84,8 +84,6 @@ Grammar related built-in predicates:
{}/3, {}/3,
('|')/4], ['$do_error'/2]). ('|')/4], ['$do_error'/2]).
:- use_module( library( expand_macros ) ).
% :- meta_predicate ^(?,0,?). % :- meta_predicate ^(?,0,?).
% ^(Xs, Goal, Xs) :- call(Goal). % ^(Xs, Goal, Xs) :- call(Goal).
@ -285,10 +283,6 @@ prolog:'\\+'(A, S0, S) :-
:- dynamic system:goal_expansion/2. :- dynamic system:goal_expansion/2.
:- dynamic prolog:'$goal_expansion_allowed'/0.
prolog:'$goal_expansion_allowed'.
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal) :- '$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal) :-
catch(prolog:'$translate_rule'( catch(prolog:'$translate_rule'(
(pseudo_nt --> Mod:NT), Rule), (pseudo_nt --> Mod:NT), Rule),
@ -323,7 +317,6 @@ do_c_built_in('C'(A,B,C), _, _, (A=[B|C])) :- !.
do_c_built_in(phrase(NT,Xs0, Xs),Mod, _, NewGoal) :- do_c_built_in(phrase(NT,Xs0, Xs),Mod, _, NewGoal) :-
nonvar(NT), nonvar(Mod), !, nonvar(NT), nonvar(Mod), !,
'$goal_expansion_allowed',
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal). '$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal).
do_c_built_in(phrase(NT,Xs),Mod,_,NewGoal) :- do_c_built_in(phrase(NT,Xs),Mod,_,NewGoal) :-

View File

@ -322,7 +322,7 @@ portray_clause(Clause) :-
!, !,
N is M+1, N is M+1,
'$list_transform'(L,N). '$list_transform'(L,N).
'$list_transform'('$VAR'(-1).L,M) :- !, '$list_transform'(['$VAR'(-1)|L],M) :- !,
'$list_transform'(L,M). '$list_transform'(L,M).
'$list_transform'(_.L,M) :- '$list_transform'([_|L],M) :-
'$list_transform'(L,M). '$list_transform'(L,M).

View File

@ -70,7 +70,7 @@ meta_predicate declaration
% I assume the clause has been processed, so the % I assume the clause has been processed, so the
% var case is long gone! Yes :) % var case is long gone! Yes :)
'$clean_cuts'(G,(yap_hacks:current_choicepoint(DCP),NG)) :- '$clean_cuts'(G,('$current_choicepoint'(DCP),NG)) :-
'$conj_has_cuts'(G,DCP,NG,OK), OK == ok, !. '$conj_has_cuts'(G,DCP,NG,OK), OK == ok, !.
'$clean_cuts'(G,G). '$clean_cuts'(G,G).
@ -284,7 +284,7 @@ meta_predicate declaration
'$expand_goals'(\+A,\+A1,(AO-> false;true),HM,SM,BM,HVars) :- !, '$expand_goals'(\+A,\+A1,(AO-> false;true),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO,HM,SM,BM,HVars). '$expand_goals'(A,A1,AO,HM,SM,BM,HVars).
'$expand_goals'(once(A),once(A1), '$expand_goals'(once(A),once(A1),
(yap_hacks:current_choice_point(CP),AO,'$$cut_by'(CP)),HM,SM,BM,HVars) :- !, ('$current_choice_point'(CP),AO,'$$cut_by'(CP)),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars), '$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
'$clean_cuts'(AO0, CP, AO). '$clean_cuts'(AO0, CP, AO).
'$expand_goals'(ignore(A),ignore(A1), '$expand_goals'(ignore(A),ignore(A1),
@ -299,19 +299,19 @@ meta_predicate declaration
'$expand_goals'(not(A),not(A1),(AO -> fail; true),HM,SM,BM,HVars) :- !, '$expand_goals'(not(A),not(A1),(AO -> fail; true),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO,HM,SM,BM,HVars). '$expand_goals'(A,A1,AO,HM,SM,BM,HVars).
'$expand_goals'(if(A,B,C),if(A1,B1,C1), '$expand_goals'(if(A,B,C),if(A1,B1,C1),
(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !, ('$current_choicepoint'(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars), '$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
'$expand_goals'(B,B1,BO,HM,SM,BM,HVars), '$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
'$expand_goals'(C,C1,CO,HM,SM,BM,HVars), '$expand_goals'(C,C1,CO,HM,SM,BM,HVars),
'$clean_cuts'(AO0, DCP, AO). '$clean_cuts'(AO0, DCP, AO).
'$expand_goals'((A*->B;C),(A1*->B1;C1), '$expand_goals'((A*->B;C),(A1*->B1;C1),
(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !, ('$current_choicepoint'(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars), '$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
'$expand_goals'(B,B1,BO,HM,SM,BM,HVars), '$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
'$expand_goals'(C,C1,CO,HM,SM,BM,HVars), '$expand_goals'(C,C1,CO,HM,SM,BM,HVars),
'$clean_cuts'(AO0, DCP, AO). '$clean_cuts'(AO0, DCP, AO).
'$expand_goals'((A*->B),(A1*->B1), '$expand_goals'((A*->B),(A1*->B1),
(yap_hacks:current_choicepoint(DCP),AO,BO),HM,SM,BM,HVars) :- !, ('$current_choicepoint'(DCP),AO,BO),HM,SM,BM,HVars) :- !,
'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars), '$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
'$expand_goals'(B,B1,BO,HM,SM,BM,HVars), '$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
'$clean_cuts'(AO0, DCP, AO). '$clean_cuts'(AO0, DCP, AO).

View File

@ -762,12 +762,12 @@ compile_predicates(Ps) :-
'$compile_predicate'(P, M, Call). '$compile_predicate'(P, M, Call).
'$compile_predicate'(Na/Ar, Mod, _Call) :- '$compile_predicate'(Na/Ar, Mod, _Call) :-
functor(G, Na, Ar), functor(G, Na, Ar),
findall((G.B),clause(Mod:G,B),Cls), findall([G|B],clause(Mod:G,B),Cls),
abolish(Mod:Na,Ar), abolish(Mod:Na,Ar),
'$add_all'(Cls, Mod). '$add_all'(Cls, Mod).
'$add_all'([], _). '$add_all'([], _).
'$add_all'((G.B).Cls, Mod) :- '$add_all'([[G|B]|Cls], Mod) :-
assert_static(Mod:(G:-B)), assert_static(Mod:(G:-B)),
'$add_all'(Cls, Mod). '$add_all'(Cls, Mod).

View File

@ -298,7 +298,7 @@ Note that all/3 will fail if no answers are found.
all(T, G same X,S) :- !, all(T same X,G,Sx), '$$produce'(Sx,S,X). all(T, G same X,S) :- !, all(T same X,G,Sx), '$$produce'(Sx,S,X).
all(T,G,S) :- all(T,G,S) :-
'$init_db_queue'(Ref), '$init_db_queue'(Ref),
( '$catch'(Error,'$clean_findall'(Ref,Error),_), ( catch(G, Error,'$clean_findall'(Ref,Error) ),
'$execute'(G), '$execute'(G),
'$db_enqueue'(Ref, T), '$db_enqueue'(Ref, T),
fail fail

View File

@ -330,7 +330,7 @@ alarm(Number, Goal, Left) :-
USecs is integer((Number-Secs)*1000000) mod 1000000, USecs is integer((Number-Secs)*1000000) mod 1000000,
on_signal(sig_alarm, _, Goal), on_signal(sig_alarm, _, Goal),
'$alarm'(Secs, USecs, Left, _). '$alarm'(Secs, USecs, Left, _).
alarm([Interval|USecs], Goal, Left.LUSecs) :- alarm([Interval|USecs], Goal, [Left|LUSecs]) :-
on_signal(sig_alarm, _, Goal), on_signal(sig_alarm, _, Goal),
'$alarm'(Interval, USecs, Left, LUSecs). '$alarm'(Interval, USecs, Left, LUSecs).

View File

@ -73,7 +73,7 @@ a postfix operator.
'$check_top_op'(_, _, [], _) :- !. '$check_top_op'(_, _, [], _) :- !.
'$check_top_op'(P, T, [Op|NV], G) :- !, '$check_top_op'(P, T, [Op|NV], G) :- !,
'$check_ops'(P, T, Op.NV, G). '$check_ops'(P, T, [Op|NV], G).
'$check_top_op'(P, T, V, G) :- '$check_top_op'(P, T, V, G) :-
atom(V), !, atom(V), !,
'$check_op_name'(P, T, V, G). '$check_op_name'(P, T, V, G).