fix skip/1 and debugging stuff

formatting
This commit is contained in:
Vitor Santos Costa 2017-11-18 00:18:42 +00:00
parent 746a4b4ef8
commit bf78d70d66
10 changed files with 1694 additions and 1668 deletions

View File

@ -138,7 +138,7 @@ static inline Atom SearchAtom(const unsigned char *p, Atom a) {
/* search atom in chain */ /* search atom in chain */
while (a != NIL) { while (a != NIL) {
ae = RepAtom(a); ae = RepAtom(a);
if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) { if (strcmp(ae->UStrOfAE, p) == 0) {
return (a); return (a);
} }
a = ae->NextOfAE; a = ae->NextOfAE;

View File

@ -201,7 +201,7 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
if (LOCAL_ErrorMessage == NULL) { if (LOCAL_ErrorMessage == NULL) {
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE);
strcpy(LOCAL_ErrorMessage, strcpy(LOCAL_ErrorMessage,
"%% Trying to open unexisting file in LoadForeign"); "%% Trying to open non-existing file in LoadForeign");
} }
} }
#ifdef __osf__ #ifdef __osf__

3258
C/stack.c

File diff suppressed because it is too large Load Diff

View File

@ -224,6 +224,10 @@ if (ANACONDA)
set( PYTHON_INCLUDE_DIR $ENV{PREFIX}/include/python$ENV{PY_VER}m) set( PYTHON_INCLUDE_DIR $ENV{PREFIX}/include/python$ENV{PY_VER}m)
endif() endif()
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
if (APPLE) if (APPLE)
set(MACOSX_RPATH ON) set(MACOSX_RPATH ON)
if (NOT ANACONDA) if (NOT ANACONDA)

View File

@ -36,7 +36,7 @@
#include "YapErrors.h" #include "YapErrors.h"
#define MAX_ERROR_MSG_SIZE 10 #define MAX_ERROR_MSG_SIZE 1024
struct yami *Yap_Error__(const char *file, const char *function, int lineno, struct yami *Yap_Error__(const char *file, const char *function, int lineno,
yap_error_number err, YAP_Term wheret, ...); yap_error_number err, YAP_Term wheret, ...);

View File

@ -81,12 +81,13 @@ E(DOMAIN_ERROR_TIMEOUT_SPEC, DOMAIN_ERROR, "timeout_spec")
E(DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, DOMAIN_ERROR, "syntax_error_handler") E(DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, DOMAIN_ERROR, "syntax_error_handler")
E(DOMAIN_ERROR_WRITE_OPTION, DOMAIN_ERROR, "write_option") E(DOMAIN_ERROR_WRITE_OPTION, DOMAIN_ERROR, "write_option")
E(EVALUATION_ERROR_FLOAT_OVERFLOW, EVALUATION_ERROR, "float_overflow") E(EVALUATION_ERROR_DBMS, EVALUATION_ERROR, "DBMS_error")
E(EVALUATION_ERROR_FLOAT_OVERFLOW, EVALUATION_ERROR, "float_overflow")
E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow") E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow")
E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow") E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow")
E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined") E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined")
E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow") E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow")
E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor") E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor")
E(EXISTENCE_ERROR_ARRAY, EXISTENCE_ERROR, "array") E(EXISTENCE_ERROR_ARRAY, EXISTENCE_ERROR, "array")
E(EXISTENCE_ERROR_KEY, EXISTENCE_ERROR, "key, ") E(EXISTENCE_ERROR_KEY, EXISTENCE_ERROR, "key, ")

View File

@ -864,27 +864,24 @@ as those for `put` (see 6.11).
*/ */
static Int skip_1(USES_REGS1) { /* 'skip'(N) */ static Int skip_1(USES_REGS1) { /* 'skip'(N) */
Int n; Int n;
Term t2; Term t1;
int sno; int sno;
int ch; int ch;
if (IsVarTerm(t2 = Deref(ARG2))) { if (IsVarTerm(t1 = Deref(ARG1))) {
Yap_Error(INSTANTIATION_ERROR, t2, "skip/2"); Yap_Error(INSTANTIATION_ERROR, t1, "skip/1");
return FALSE; return FALSE;
} else if (!IsIntegerTerm(t2)) { } else if (!IsIntegerTerm(t1)) {
Yap_Error(TYPE_ERROR_INTEGER, t2, "skip/2"); Yap_Error(TYPE_ERROR_INTEGER, t1, "skip/1");
return FALSE;
} else if ((n = IntegerOfTerm(t2)) < 0) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "skip/2");
return FALSE; return FALSE;
} else if ((n = IntegerOfTerm(t1)) < 0) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t1, "skip/1");
return false;
} }
sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "skip/2");
if (sno < 0)
return (FALSE);
while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) != n && ch != -1) while ((ch = GLOBAL_Stream[sno].stream_wgetc(sno)) != n && ch != -1)
; ;
UNLOCK(GLOBAL_Stream[sno].streamlock); UNLOCK(GLOBAL_Stream[sno].streamlock);
return (TRUE); return true;
} }
/** @pred skip(+ _S_,- _C_) /** @pred skip(+ _S_,- _C_)

View File

@ -5,7 +5,7 @@ INCLUDE(UseSWIG)
include(FindPythonModule) include(FindPythonModule)
list (APPEND pl_library ${CMAKE_CURRENT_SOURCE_DIR}/prolog/jupyter.yap ${CMAKE_CURRENT_SOURCE_DIR}/prolog/yapi.yap ) list (APPEND pl_library ${CMAKE_CURRENT_SOURCE_DIR}/prolog/yapi.yap )
set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__init__.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py) set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__init__.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py)
@ -16,7 +16,7 @@ SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap4py.ya
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
set(YAP4PY_PL prolog/jupyter.yap prolog/yapi.yap) set(YAP4PY_PL prolog/yapi.yap)
set(YAP4PY_PY yap4py/__init__.py yap4py/__main__.py yap4py/yapi.py) set(YAP4PY_PY yap4py/__init__.py yap4py/__main__.py yap4py/yapi.py)
configure_file("setup.py.in" setup.py) configure_file("setup.py.in" setup.py)

View File

@ -1383,7 +1383,6 @@ Command = (H --> B) ->
; ;
'$system_catch'('$boot_clause'( Command, Where ), prolog, Error, '$system_catch'('$boot_clause'( Command, Where ), prolog, Error,
user:'$LoopError'(Error, consult) ), user:'$LoopError'(Error, consult) ),
fail fail
). ).

View File

@ -465,13 +465,11 @@ be lost.
current_prolog_flag(debug, false) current_prolog_flag(debug, false)
; ;
'__NB_getval__'('$debug_status',state(zip,Border,Spy), fail), '__NB_getval__'('$debug_status',state(zip,Border,Spy), fail),
( Border >= GoalNumber -> fail; Border < GoalNumber,
Spy == ignore -> true ; ( Spy == ignore ; '$pred_being_spied'(G, M) )
'$pred_being_spied'(G, M) -> Border == GoalNumber ;
true
)
), ),
!, writeln(go:G:M),
!,
'$execute_nonstop'(G,M). '$execute_nonstop'(G,M).
'$trace_goal'(G, M, GoalNumber, H) :- '$trace_goal'(G, M, GoalNumber, H) :-
'$undefined'(G, M), '$undefined'(G, M),
@ -611,7 +609,8 @@ be lost.
( Skip == creep -> true; '$id_goal'(GoalNumber) ; GoalNumber =< Border), ( Skip == creep -> true; '$id_goal'(GoalNumber) ; GoalNumber =< Border),
!, !,
'__NB_setval__'('$debug_status', state(creep, 0, stop)), '__NB_setval__'('$debug_status', state(creep, 0, stop)),
'$trace_port_'(Port, GoalNumber, G, Module, Info). '$trace_port_'(Port, GoalNumber, G, Module, Info),
writeln(Port:G).
'$trace_port'(_Port, _GoalNumber, _G, _Module, _CalledFromDebugger, _Info). '$trace_port'(_Port, _GoalNumber, _G, _Module, _CalledFromDebugger, _Info).
'$trace_port_'(call, GoalNumber, G, Module, Info) :- '$trace_port_'(call, GoalNumber, G, Module, Info) :-
@ -632,7 +631,7 @@ be lost.
'$TraceError'(E, GoalNumber, G, Module, Info). '$TraceError'(E, GoalNumber, G, Module, Info).
'$trace_port_'(external_exception(E), GoalNumber, G, Module, Info) :- '$trace_port_'(external_exception(E), GoalNumber, G, Module, Info) :-
'$TraceError'(E, GoalNumber, G, Module, Info). '$TraceError'(E, GoalNumber, G, Module, Info).
%%% - abort: forward throw while the call is newer than goal %%% - abort: forward throw while the call is newer than goal
'$TraceError'( abort, _, _, _, _). '$TraceError'( abort, _, _, _, _).
@ -744,38 +743,38 @@ be lost.
ignore( G ), ignore( G ),
% at this point we are done with leap or skip % at this point we are done with leap or skip
set_prolog_flag(debug, OldDeb), set_prolog_flag(debug, OldDeb),
% skip(10), % ' % skip( debugger_input, 10), % '
fail. fail.
'$action'(<,_,_,_,_,_) :- !, % <'Depth '$action'(<,_,_,_,_,_) :- !, % <'Depth
'$new_deb_depth', '$new_deb_depth',
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'('C',_,_,_,_,_) :- '$action'('C',_,_,_,_,_) :-
yap_flag(system_options, Opts), yap_flag(system_options, Opts),
lists:memberchk( call_tracer, Opts), lists:memberchk( call_tracer, Opts),
!, % <'Depth !, % <'Depth
skip(10), skip( debugger_input, 10),
'__NB_setval__'('$debug_status', state(creep, 0, stop)). '__NB_setval__'('$debug_status', state(creep, 0, stop)).
'$action'(^,_,_,G,_,_) :- !, % ' '$action'(^,_,_,G,_,_) :- !, % '
'$print_deb_sterm'(G), '$print_deb_sterm'(G),
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'(a,_,_,_,_,_) :- !, % 'a abort '$action'(a,_,_,_,_,_) :- !, % 'a abort
skip(10), skip( debugger_input, 10),
'$stop_creeping'(_), '$stop_creeping'(_),
nodebug, nodebug,
abort. abort.
'$action'(b,_,_,_,_,_) :- !, % 'b break '$action'(b,_,_,_,_,_) :- !, % 'b break
'$stop_creeping'(_), '$stop_creeping'(_),
skip(10), skip( debugger_input, 10),
break, break,
fail. fail.
'$action'('A',_,_,_,_,_) :- !, % 'b break '$action'('A',_,_,_,_,_) :- !, % 'b break
skip(10), skip( debugger_input, 10),
'$stack_dump', '$stack_dump',
fail. fail.
'$action'(c,_,_,_,_,_) :- !, % 'c creep '$action'(c,_,_,_,_,_) :- !, % 'c creep
skip(10), skip( debugger_input, 10),
'__NB_setval__'('$debug_status',status(creep,0,stop)). '__NB_setval__'('$debug_status',status(creep,0,stop)).
'$action'(e,_,_,_,_,_) :- !, % 'e exit '$action'(e,_,_,_,_,_) :- !, % 'e exit
halt. halt.
@ -784,11 +783,11 @@ be lost.
throw(forward(fail,GoalId)). throw(forward(fail,GoalId)).
'$action'(h,_,_,_,_,_) :- !, % 'h help '$action'(h,_,_,_,_,_) :- !, % 'h help
'$action_help', '$action_help',
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'(?,_,_,_,_,_) :- !, % '? help '$action'(?,_,_,_,_,_) :- !, % '? help
'$action_help', '$action_help',
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'(p,_,_,G,Module,_) :- !, % 'p print '$action'(p,_,_,G,Module,_) :- !, % 'p print
((Module = prolog ; Module = user) -> ((Module = prolog ; Module = user) ->
@ -796,7 +795,7 @@ be lost.
; ;
print(user_error,Module:G), nl(user_error) print(user_error,Module:G), nl(user_error)
), ),
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'(d,_,_,G,Module,_) :- !, % 'd display '$action'(d,_,_,G,Module,_) :- !, % 'd display
((Module = prolog ; Module = user) -> ((Module = prolog ; Module = user) ->
@ -804,23 +803,23 @@ be lost.
; ;
display(user_error,Module:G), nl(user_error) display(user_error,Module:G), nl(user_error)
), ),
skip(10), skip( debugger_input, 10),
fail. fail.
'$action'(l,_,_CallNumber,_,_,_) :- !, % 'l leap '$action'(l,_,_CallNumber,_,_,_) :- !, % 'l leap
skip(10), skip( debugger_input, 10),
'__NB_setval__'('$debug_status', state(leap, 0, stop)). '__NB_setval__'('$debug_status', state(leap, 0, stop)).
'$action'(z,_,_CallNumber,_,_,_H) :- !, % 'z zip, fast leap '$action'(z,_,_CallNumber,_,_,_H) :- !, % 'z zip, fast leap
skip(10), % 'z skip( debugger_input, 10), % 'z
'__NB_setval__'('$debug_status', state(zip, 0, stop)). '__NB_setval__'('$debug_status', state(zip, 0, stop)).
% skip first call (for current goal), % skip first call (for current goal),
% stop next time. % stop next time.
'$action'(k,_,CallNumber,_,_,_) :- !, % 'k zip, fast leap '$action'(k,_,CallNumber,_,_,_) :- !, % 'k zip, fast leap
skip(10), % ' skip( debugger_input, 10), % '
'__NB_setval__'('$debug_status', state(zip, CallNumber, ignore)). '__NB_setval__'('$debug_status', state(zip, CallNumber, ignore)).
% skip first call (for current goal), % skip first call (for current goal),
% stop next time. % stop next time.
'$action'(n,_,_,_,_,_) :- !, % 'n nodebug '$action'(n,_,_,_,_,_) :- !, % 'n nodebug
skip(10), % ' skip( debugger_input, 10), % '
% tell debugger never to stop. % tell debugger never to stop.
'__NB_setval__'('$debug_status', state(zip, 0, ignore)), '__NB_setval__'('$debug_status', state(zip, 0, ignore)),
nodebug. nodebug.
@ -829,30 +828,30 @@ be lost.
% set_prolog_flag(debug, true), % set_prolog_flag(debug, true),
throw(forward(redo,ScanNumber)). throw(forward(redo,ScanNumber)).
'$action'(s,P,CallNumber,_,_,_) :- !, % 's skip '$action'(s,P,CallNumber,_,_,_) :- !, % 's skip
skip(10), % ' skip( debugger_input, 10), % '
( (P=call; P=redo) -> ( (P=call; P=redo) ->
'__NB_setval__'('$debug_status', state(leap, CallNumber, ignore) ) ; '__NB_setval__'('$debug_status', state(leap, CallNumber, ignore) ) ;
'$ilgl'(s) % ' '$ilgl'(s) % '
). ).
'$action'(t,P,CallNumber,_,_,_) :- !, % 't fast skip '$action'(t,P,CallNumber,_,_,_) :- !, % 't fast skip
skip(10), % ' skip( debugger_input, 10), % '
( (P=call; P=redo) -> ( (P=call; P=redo) ->
'__NB_setval__'('$debug_status', state(zip, CallNumber, ignore)) ; '__NB_setval__'('$debug_status', state(zip, CallNumber, ignore)) ;
'$ilgl'(t) % ' '$ilgl'(t) % '
). ).
'$action'(q,P,CallNumber,_,_,_) :- !, % 'qst skip '$action'(q,P,CallNumber,_,_,_) :- !, % 'qst skip
skip(10), % ' skip( debugger_input, 10), % '
( (P=call; P=redo) -> ( (P=call; P=redo) ->
'__NB_setval__'('$debug_status', state(leap, CallNumber, stop)) ; '__NB_setval__'('$debug_status', state(leap, CallNumber, stop)) ;
'$ilgl'(t) % ' '$ilgl'(t) % '
). ).
'$action'(+,_,_,G,M,_) :- !, % '+ spy this '$action'(+,_,_,G,M,_) :- !, % '+ spy this
functor(G,F,N), spy(M:(F/N)), functor(G,F,N), spy(M:(F/N)),
skip(10), % ' skip( debugger_input, 10), % '
fail. fail.
'$action'(-,_,_,G,M,_) :- !, % '- nospy this '$action'(-,_,_,G,M,_) :- !, % '- nospy this
functor(G,F,N), nospy(M:(F/N)), functor(G,F,N), nospy(M:(F/N)),
skip(10), % ' skip( debugger_input, 10), % '
fail. fail.
'$action'(g,_,_,_,_,_) :- !, % 'g ancestors '$action'(g,_,_,_,_,_) :- !, % 'g ancestors
'$scan_number'(HowMany), % ' '$scan_number'(HowMany), % '
@ -861,7 +860,7 @@ be lost.
'$action'('T',exception(G),_,_,_,_) :- !, % 'T throw '$action'('T',exception(G),_,_,_,_) :- !, % 'T throw
throw( forward('$wrapper',G)). throw( forward('$wrapper',G)).
'$action'(C,_,_,_,_,_) :- '$action'(C,_,_,_,_,_) :-
skip(10), skip( debugger_input, 10),
'$ilgl'(C), '$ilgl'(C),
fail. fail.
@ -931,7 +930,7 @@ be lost.
'$deb_get_sterm_in_g'(L,G,A), '$deb_get_sterm_in_g'(L,G,A),
recorda('$debug_sub_skel',L,_), recorda('$debug_sub_skel',L,_),
format(user_error,'~n~w~n~n',[A]). format(user_error,'~n~w~n~n',[A]).
'$print_deb_sterm'(_) :- skip(10). '$print_deb_sterm'(_) :- skip( debugger_input, 10).
'$get_sterm_list'(L) :- '$get_sterm_list'(L) :-
get_code( debugger_input_input,C), get_code( debugger_input_input,C),
@ -972,7 +971,7 @@ be lost.
get_code( debugger_input,NC), get_code( debugger_input,NC),
'$get_deb_depth_char_by_char'(NC,XI,XF). '$get_deb_depth_char_by_char'(NC,XI,XF).
% reset when given garbage. % reset when given garbage.
'$get_deb_depth_char_by_char'(_C,_,10) :- skip(10). '$get_deb_depth_char_by_char'(_C,_,10) :- skip( debugger_input, 10).
'$set_deb_depth'(D) :- '$set_deb_depth'(D) :-
yap_flag(debugger_print_options,L), yap_flag(debugger_print_options,L),