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 */
while (a != NIL) {
ae = RepAtom(a);
if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) {
if (strcmp(ae->UStrOfAE, p) == 0) {
return (a);
}
a = ae->NextOfAE;

View File

@ -201,7 +201,7 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
if (LOCAL_ErrorMessage == NULL) {
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE);
strcpy(LOCAL_ErrorMessage,
"%% Trying to open unexisting file in LoadForeign");
"%% Trying to open non-existing file in LoadForeign");
}
}
#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)
endif()
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
if (APPLE)
set(MACOSX_RPATH ON)
if (NOT ANACONDA)

View File

@ -36,7 +36,7 @@
#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,
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_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_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow")
E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined")
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_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) */
Int n;
Term t2;
Term t1;
int sno;
int ch;
if (IsVarTerm(t2 = Deref(ARG2))) {
Yap_Error(INSTANTIATION_ERROR, t2, "skip/2");
if (IsVarTerm(t1 = Deref(ARG1))) {
Yap_Error(INSTANTIATION_ERROR, t1, "skip/1");
return FALSE;
} else if (!IsIntegerTerm(t2)) {
Yap_Error(TYPE_ERROR_INTEGER, t2, "skip/2");
return FALSE;
} else if ((n = IntegerOfTerm(t2)) < 0) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t2, "skip/2");
} else if (!IsIntegerTerm(t1)) {
Yap_Error(TYPE_ERROR_INTEGER, t1, "skip/1");
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)
;
UNLOCK(GLOBAL_Stream[sno].streamlock);
return (TRUE);
return true;
}
/** @pred skip(+ _S_,- _C_)

View File

@ -5,7 +5,7 @@ INCLUDE(UseSWIG)
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)
@ -16,7 +16,7 @@ SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap4py.ya
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)
configure_file("setup.py.in" setup.py)

View File

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

View File

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