debug && docs
This commit is contained in:
parent
a83d97f998
commit
e3ade13cfe
@ -1,4 +1,4 @@
|
||||
p/*************************************************************************
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
@ -19,9 +19,10 @@ p/*************************************************************************
|
||||
@file attributes.yap
|
||||
|
||||
@defgroup New_Style_Attribute_Declarations SWI Compatible attributes
|
||||
@{
|
||||
@ingroup attributes
|
||||
|
||||
@{
|
||||
|
||||
*/
|
||||
|
||||
:- system_module( attributes, [delayed_goals/4,
|
||||
|
12
pl/boot.yap
12
pl/boot.yap
@ -16,11 +16,11 @@
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
@file boot.yap
|
||||
@brief YAP bootstrap
|
||||
|
||||
@defgroup YAPControl Control Predicates
|
||||
@file boot.yap
|
||||
@brief YAP bootstrap
|
||||
|
||||
@defgroup YAPControl Control Predicates
|
||||
@ingroup builtins
|
||||
|
||||
@{
|
||||
|
||||
@ -523,8 +523,7 @@ initialize_prolog :-
|
||||
'$read_toplevel'(Command,Varnames),
|
||||
nb_setval('$spy_gn',1),
|
||||
% stop at spy-points if debugging is on.
|
||||
nb_setval('$debug_run',off),
|
||||
nb_setval('$debug_jump',off),
|
||||
nb_setval('$debug_state', state(creep,0,stop)),
|
||||
'$command'(Command,Varnames,_Pos,top),
|
||||
current_prolog_flag(break_level, BreakLevel),
|
||||
(
|
||||
@ -1120,6 +1119,7 @@ incore(G) :- '$execute'(G).
|
||||
'$enable_debugging':-
|
||||
current_prolog_flag(debug, false), !.
|
||||
'$enable_debugging' :-
|
||||
'__NB_setval__'('$debug_status', state(creep, 0, stop)),
|
||||
'$trace_on', !,
|
||||
'$creep'.
|
||||
'$enable_debugging'.
|
||||
|
@ -1,3 +1,10 @@
|
||||
/**
|
||||
@file bootutils.c
|
||||
@short utilities
|
||||
|
||||
@addtogroup Internal_Database
|
||||
*/
|
||||
|
||||
/** @pred recordaifnot(+ _K_, _T_,- _R_)
|
||||
|
||||
|
||||
|
@ -17,8 +17,12 @@
|
||||
|
||||
%% @{
|
||||
|
||||
/** @defgroup Profiling Profiling Prolog Programs
|
||||
@ingroup extensions
|
||||
/**
|
||||
@file callcount.yap
|
||||
@short support call counting.
|
||||
|
||||
@defgroup Profiling Profiling Prolog Programs
|
||||
@ingroup extensions
|
||||
|
||||
YAP includes two profilers. The count profiler keeps information on the
|
||||
number of times a predicate was called. This information can be used to
|
||||
|
@ -546,29 +546,30 @@ b_getval(GlobalVariable, Val) :-
|
||||
it saves the importante data about current streams and
|
||||
debugger state */
|
||||
|
||||
'$debug_state'(state(Trace, Debug, Jump, Run, SPY_GN, GList)) :-
|
||||
'$debug_state'(state(Trace, Debug, State, SPY_GN, GList, GDList)) :-
|
||||
'$init_debugger',
|
||||
nb_getval('$trace',Trace),
|
||||
nb_getval('$debug_jump',Jump),
|
||||
nb_getval('$debug_run',Run),
|
||||
nb_getval('$debug_state',State),
|
||||
current_prolog_flag(debug, Debug),
|
||||
nb_getval('$spy_gn',SPY_GN),
|
||||
b_getval('$spy_glist',GList).
|
||||
b_getval('$spy_glist',GList),
|
||||
b_getval('$spy_depth',GDList).
|
||||
|
||||
|
||||
'$debug_stop'( State ) :-
|
||||
'$debug_state'( State ),
|
||||
'$debug_stop' :-
|
||||
nb_setval('$debug_state', state(creep,0,stop)),
|
||||
b_setval('$trace',off),
|
||||
% set_prolog_flag(debug, false),
|
||||
set_prolog_flag(debug, false),
|
||||
b_setval('$spy_glist',[]),
|
||||
b_setval('$spy_gdlist',[]),
|
||||
'$disable_debugging'.
|
||||
|
||||
'$debug_restart'(state(Trace, Debug, Jump, Run, SPY_GN, GList)) :-
|
||||
'$debug_restart'(state(Trace, Debug, State, SPY_GN, GList, GDList)) :-
|
||||
b_setval('$spy_glist',GList),
|
||||
b_setval('$spy_gdlist',GDList),
|
||||
b_setval('$spy_gn',SPY_GN),
|
||||
set_prolog_flag(debug, Debug),
|
||||
b_setval('$debug_jump',Jump),
|
||||
b_setval('$debug_run',Run),
|
||||
nb_setval('$debug_state',State),
|
||||
b_setval('$trace',Trace),
|
||||
'$enable_debugging'.
|
||||
|
||||
@ -589,33 +590,20 @@ debugging.
|
||||
|
||||
*/
|
||||
break :-
|
||||
'$init_debugger',
|
||||
nb_getval('$trace',Trace),
|
||||
nb_setval('$trace',off),
|
||||
nb_getval('$debug_jump',Jump),
|
||||
nb_getval('$debug_run',Run),
|
||||
current_prolog_flag(debug, Debug),
|
||||
set_prolog_flag(debug, false),
|
||||
'$debug_state'(DState),
|
||||
'$debug_start',
|
||||
'$break'( true ),
|
||||
nb_getval('$spy_gn',SPY_GN),
|
||||
b_getval('$spy_glist',GList),
|
||||
b_setval('$spy_glist',[]),
|
||||
current_output(OutStream), current_input(InpStream),
|
||||
current_prolog_flag(break_level, BL ),
|
||||
NBL is BL+1,
|
||||
NBL is BL+1,
|
||||
set_prolog_flag(break_level, NBL ),
|
||||
format(user_error, '% Break (level ~w)~n', [NBL]),
|
||||
'$do_live',
|
||||
!,
|
||||
set_value('$live','$true'),
|
||||
b_setval('$spy_glist',GList),
|
||||
nb_setval('$spy_gn',SPY_GN),
|
||||
'$debug_restore'(DState),
|
||||
set_input(InpStream),
|
||||
set_output(OutStream),
|
||||
set_prolog_flag(debug, Debug),
|
||||
nb_setval('$debug_jump',Jump),
|
||||
nb_setval('$debug_run',Run),
|
||||
nb_setval('$trace',Trace),
|
||||
set_prolog_flag(break_level, BL ),
|
||||
'$break'( false ).
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
%%
|
||||
% @defgroup YAPBigLoad Loading Large Tables
|
||||
% @ingroup YAPConsulting
|
||||
%
|
||||
% @brief Fast and Exo Loading
|
||||
%
|
||||
|
@ -1,3 +1,17 @@
|
||||
|
||||
/**
|
||||
* @file dialect.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 10:50:33 2017
|
||||
*
|
||||
* @brief support Prolog dialects
|
||||
*
|
||||
* @defgroup Dialects
|
||||
* @ingroup builtins
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
:- module(dialect,
|
||||
[
|
||||
exists_source/1,
|
||||
@ -6,6 +20,9 @@
|
||||
|
||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||
|
||||
|
||||
%
|
||||
%%
|
||||
% @pred expects_dialect(+Dialect)
|
||||
%
|
||||
% True if YAP can enable support for a different Prolog dialect.
|
||||
|
@ -15,6 +15,19 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file directives.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 11:47:38 2017
|
||||
*
|
||||
* @brief Control File Loading
|
||||
%
|
||||
% @defgroup Directives
|
||||
@ @ingroup consult
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
:- system_module( '$_directives', [user_defined_directive/2], ['$all_directives'/1,
|
||||
'$exec_directives'/5]).
|
||||
|
12
pl/eam.yap
12
pl/eam.yap
@ -16,6 +16,18 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file eam.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 11:50:05 2017
|
||||
*
|
||||
* @brief Extended Abstract Machine
|
||||
* @defgroup EAM Extended Abstract Machine
|
||||
* @ingroup extensions
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_eam', [eamconsult/1,
|
||||
eamtrans/2], []).
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
/** @defgroup YAPError Error Handling
|
||||
/** @defgroup YAPErrorHandler Error Handling
|
||||
|
||||
@ingroup YAPControl
|
||||
@ingroup YAPErrors
|
||||
|
||||
The error handler is called when there is an execution error or a
|
||||
warning needs to be displayed. The handlers include a number of hooks
|
||||
|
12
pl/eval.yap
12
pl/eval.yap
@ -15,6 +15,18 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file eval.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 11:52:48 2017
|
||||
*
|
||||
* @brief compiling expressions
|
||||
*
|
||||
* @defgroup CompiledExpressions
|
||||
* @ingroup drectives
|
||||
*
|
||||
*
|
||||
*/
|
||||
:- system_module( '$_eval', [], ['$full_clause_optimisation'/4]).
|
||||
|
||||
:- use_system_module( terms, [new_variables_in_term/3,
|
||||
|
@ -15,6 +15,17 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file ground.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:01:27 2017
|
||||
*
|
||||
* @brief term operations
|
||||
*
|
||||
* @addtogroup YAPTypes
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
% grounds all free variables
|
||||
% as terms of the form '$VAR'(N)
|
||||
|
15
pl/hacks.yap
15
pl/hacks.yap
@ -16,6 +16,17 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file hacks.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:02:56 2017
|
||||
*
|
||||
* @brief Low-level access
|
||||
*
|
||||
* @defgroup Hacks Low-level access
|
||||
* @ingroup builtins
|
||||
*
|
||||
*/
|
||||
|
||||
%% @file pl/hacks.yap
|
||||
|
||||
@ -207,10 +218,6 @@ beautify_hidden_goal('$continue_with_command'(top,V,P,G,_),prolog) -->
|
||||
['Query'(G,V,P)].
|
||||
beautify_hidden_goal('$continue_with_command'(Command,V,P,G,Source),prolog) -->
|
||||
['TopLevel'(Command,G,V,P,Source)].
|
||||
beautify_hidden_goal('$spycall'(G,M,InControl,Redo),prolog) -->
|
||||
['DebuggerCall'(M:G, InControl, Redo)].
|
||||
beautify_hidden_goal('$spycall'(Goal, Mod, _CP, Expanded),prolog) -->
|
||||
['DebuggerCall'(Mod:Goal, Expanded)].
|
||||
beautify_hidden_goal('$system_catch'(G,Mod,Exc,Handler),prolog) -->
|
||||
[catch(Mod:G, Exc, Handler)].
|
||||
beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
|
||||
|
@ -15,6 +15,18 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file listing.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:05:19 2017
|
||||
*
|
||||
* @brief list predicates in a module
|
||||
*
|
||||
* @defgroup Listing list predicates in a module
|
||||
* @ingroup builtins
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_listing', [listing/0,
|
||||
listing/1,
|
||||
portray_clause/1,
|
||||
|
@ -212,20 +212,22 @@ compose_message( loaded(included,AbsFileName,Mod,Time,Space), _Level) --> !,
|
||||
compose_message( loaded(What,AbsoluteFileName,Mod,Time,Space), _Level) --> !,
|
||||
[ '~a ~a in module ~a, ~d msec ~d bytes' -
|
||||
[What, AbsoluteFileName,Mod,Time,Space] ].
|
||||
compose_message(trace_command(-1), _Leve) -->
|
||||
[ 'EOF is not a valid debugger command.' ].
|
||||
compose_message(trace_command(C), _Leve) -->
|
||||
[ '~c is not a valid debugger command.' - [C] ].
|
||||
!,
|
||||
[ '~a is not a valid debugger command.' - [C] ].
|
||||
compose_message(trace_help, _Leve) -->
|
||||
!,
|
||||
[ ' Please enter a valid debugger command (h for help).' ].
|
||||
compose_message(version(Version), _Leve) -->
|
||||
!,
|
||||
[ '~a' - [Version] ].
|
||||
compose_message(myddas_version(Version), _Leve) -->
|
||||
!,
|
||||
[ 'MYDDAS version ~a' - [Version] ].
|
||||
compose_message(yes, _Level) --> !,
|
||||
[ 'yes'- [] ].
|
||||
compose_message(Term, Level) -->
|
||||
{ '$show_consult_level'(LC) },
|
||||
{ '$show_consult_level'(LC) },
|
||||
location(Term, Level, LC),
|
||||
main_message( Term, Level, LC ),
|
||||
c_goal( Term, Level ),
|
||||
|
@ -366,8 +366,9 @@ o:p(B) :- n:g, X is 2+3, call(B).
|
||||
'$yap_strip_module'( BM:G0, M0N, G0N),
|
||||
'$user_expansion'(M0N:G0N, M1:G1),
|
||||
'$import_expansion'(M1:G1, M2:G2),
|
||||
'$meta_expansion'(M2:G2, M1, HVars, M2:B1F),
|
||||
'$end_goal_expansion'(B1F, G1F, GOF, HM, SM, M2, H).
|
||||
'$meta_expansion'(M2:G2, M1, HVars, M2B1F),
|
||||
'$yap_strip_module'(M2B1F, M3, B1F),
|
||||
'$end_goal_expansion'(B1F, G1F, GOF, HM, SM, M3, H).
|
||||
|
||||
'$end_goal_expansion'(G, G1F, GOF, HM, SM, BM, H) :-
|
||||
'$match_mod'(G, HM, SM, BM, G1F),
|
||||
@ -390,7 +391,7 @@ o:p(B) :- n:g, X is 2+3, call(B).
|
||||
(
|
||||
% \+ '$is_multifile'(G1,M),
|
||||
%->
|
||||
'$is_system_predicate'(G,prolog)
|
||||
'$is_system_predicate'(G,M)
|
||||
->
|
||||
O = G
|
||||
;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
@defgroup ModuleBuiltins Module Support
|
||||
|
||||
@ingroup YAPModules
|
||||
@{
|
||||
|
||||
**/
|
||||
@ -82,8 +83,8 @@
|
||||
%
|
||||
|
||||
/**
|
||||
\pred use_module( +Files ) is directive
|
||||
@load a module file
|
||||
@pred use_module( +Files ) is directive
|
||||
@brief load a module file
|
||||
|
||||
This predicate loads the file specified by _Files_, importing all
|
||||
their public predicates into the current type-in module. It is
|
||||
@ -193,7 +194,7 @@ X = 2 ? ;
|
||||
ERROR!!
|
||||
EXISTENCE ERROR- procedure c/1 is undefined, called from context prolog:$user_call/2
|
||||
Goal was c:c(_131290)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
vv~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The state of the module system after this error is undefined.
|
||||
|
||||
@ -322,10 +323,9 @@ system_module(Mod) :-
|
||||
'$is_system_module'(Mod).
|
||||
|
||||
'$trace_module'(X) :-
|
||||
telling(F),
|
||||
tell('P0:debug'),
|
||||
write(X),nl,
|
||||
tell(F), fail.
|
||||
open('P0:debug', append, S),
|
||||
fornat(S, '~w~n', [X]),
|
||||
close(S).
|
||||
'$trace_module'(_).
|
||||
|
||||
'$trace_module'(X,Y) :- X==Y, !.
|
||||
@ -338,19 +338,23 @@ system_module(Mod) :-
|
||||
tell(F),fail.
|
||||
'$trace_module'(_,_).
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @pred '$continue_imported'(+ModIn, +ModOut, +PredIn ,+PredOut)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
'$continue_imported'(Mod,Mod,Pred,Pred) :-
|
||||
'$pred_exists'(Pred, Mod),
|
||||
!.
|
||||
'$continue_imported'(FM,Mod,FPred,Pred) :-
|
||||
recorded('$import','$import'(IM,Mod,IPred,Pred,_,_),_),
|
||||
recorded('$import','$import'(IM,Mod,IPred,Pred,_,_),_),
|
||||
'$continue_imported'(FM, IM, FPred, IPred), !.
|
||||
'$continue_imported'(FM,Mod,FPred,Pred) :-
|
||||
prolog:'$parent_module'(Mod,IM),
|
||||
'$continue_imported'(FM, IM, FPred, Pred).
|
||||
|
||||
|
||||
|
||||
% be careful here not to generate an undefined exception.
|
||||
'$imported_predicate'(G, _ImportingMod, G, prolog) :-
|
||||
nonvar(G), '$is_system_predicate'(G, prolog), !.
|
||||
@ -359,19 +363,22 @@ system_module(Mod) :-
|
||||
var(ImportingMod) -> true ;
|
||||
'$undefined'(G, ImportingMod)
|
||||
),
|
||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
|
||||
ExportingMod \= ImportingMod,
|
||||
!.
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod),
|
||||
ExportingMod \= ImportingMod.
|
||||
|
||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I),
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod),
|
||||
!.
|
||||
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
|
||||
% SWI builtin
|
||||
'$get_undefined_pred'(G, _ImportingMod, G, user) :-
|
||||
'$get_undefined_predicates'(G, _ImportingMod, G, user) :-
|
||||
nonvar(G),
|
||||
'$pred_exists'(G, user), !.
|
||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||
'$pred_exists'(G, user).
|
||||
% autoload
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
recorded('$dialect',swi,_),
|
||||
prolog_flag(autoload, true),
|
||||
prolog_flag(unknown, OldUnk, fail),
|
||||
@ -384,10 +391,8 @@ system_module(Mod) :-
|
||||
fail
|
||||
),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||
% autoload
|
||||
|
||||
% parent module mechanism
|
||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
'$parent_module'(ImportingMod,ExportingModI),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||
|
||||
@ -428,7 +433,7 @@ be associated to a new file.
|
||||
\param[in] _Module_ is the name of the module to declare
|
||||
\param[in] _MSuper_ is the name of the context module. Use `prolog`or `system`
|
||||
if you do not need a context.
|
||||
\param[in] _File_ is the canonical name of the file from which the module is loaded
|
||||
\param[in] _File_ is the canonical name of the file from which the modulvvvvve is loaded
|
||||
\param[in] Line is the line-number of the :- module/2 directive.
|
||||
\param[in] If _Redefine_ `true`, allow associating the module to a new file
|
||||
*/
|
||||
@ -437,7 +442,7 @@ be associated to a new file.
|
||||
add_import_module(Name, Context, start).
|
||||
|
||||
/**
|
||||
\pred abolish_module( + Mod) is det
|
||||
@pred abolish_module( + Mod) is det
|
||||
get rid of a module and of all predicates included in the module.
|
||||
*/
|
||||
abolish_module(Mod) :-
|
||||
@ -578,9 +583,10 @@ export_list(Module, List) :-
|
||||
(C == y -> true; C == n).
|
||||
|
||||
/**
|
||||
@pred set_base_module( +ExportingModule ) is det
|
||||
All exported predicates from _ExportingModule_ are automatically available to the
|
||||
current source module.
|
||||
@pred set_base_module( +ExportingModule ) is det
|
||||
@brief All
|
||||
predicates exported from _ExportingModule_ are automatically available to the
|
||||
other source modules.
|
||||
|
||||
This built-in was introduced by SWI-Prolog. In YAP, by default, modules only
|
||||
inherit from `prolog`. This extension allows predicates in the current
|
||||
@ -789,4 +795,4 @@ module_state :-
|
||||
fail.
|
||||
module_state.
|
||||
|
||||
%% @}
|
||||
%% @}
|
||||
|
@ -1,4 +1,9 @@
|
||||
/**
|
||||
|
||||
@file newmod.yap
|
||||
@short support for creating a new module.
|
||||
|
||||
@ingroup ModuleBuiltins
|
||||
@pred module(+M) is det
|
||||
set the type-in module
|
||||
|
||||
|
71
pl/pl
71
pl/pl
@ -1,71 +0,0 @@
|
||||
/Users/vsc/git/yap-6.3/pl:
|
||||
total used in directory 1768 available 23068011
|
||||
-rw-r--r-- 1 vsc staff 13038 Apr 26 05:19 ##a##
|
||||
-rw-r--r-- 1 vsc staff 6533 Apr 26 05:02 #a#
|
||||
-rw-r--r-- 1 vsc staff 10769 Dec 22 00:56 #arith.yap#
|
||||
-rw-r--r-- 1 vsc staff 38238 Nov 30 2014 #threads.yap#
|
||||
drwxr-xr-x@ 69 vsc staff 2346 Jun 20 02:56 .
|
||||
lrwxr-xr-x 1 vsc staff 36 Apr 26 05:15 .##a# -> vsc@VITORs-MacBook-Pro-2.local.13727
|
||||
lrwxr-xr-x 1 vsc staff 36 Apr 26 04:54 .#a -> vsc@VITORs-MacBook-Pro-2.local.11698
|
||||
drwxr-xr-x@ 130 vsc staff 4420 Jun 20 22:22 ..
|
||||
-rw-r--r-- 1 vsc staff 1205 Jun 20 22:22 CMakeLists.txt
|
||||
-rw-r--r-- 1 vsc staff 1183 Dec 10 2014 CMakeLists.txt~
|
||||
-rw-r--r-- 1 vsc staff 6262 Apr 19 09:31 Makefile
|
||||
-rw-r--r-- 1 vsc staff 6534 Apr 26 04:54 a
|
||||
-rwxr-xr-x 1 vsc staff 23142 Jun 20 22:22 absf.yap
|
||||
-rw-r--r-- 1 vsc staff 10776 Jan 4 23:42 arith.yap
|
||||
-rw-r--r-- 1 vsc staff 3455 Jan 4 23:42 arithpreds.yap
|
||||
-rw-r--r-- 1 vsc staff 2791 Jun 20 22:22 arrays.yap
|
||||
-rw-r--r-- 1 vsc staff 6414 Apr 21 19:02 atoms.yap
|
||||
-rw-r--r-- 1 vsc staff 16735 Jun 20 22:22 attributes.yap
|
||||
-rw-r--r-- 1 vsc staff 34460 May 27 2014 b.yap~
|
||||
-rw-r--r-- 1 vsc staff 38891 Jun 20 02:56 boot.yap
|
||||
-rw-r--r-- 1 vsc staff 4347 Jan 4 23:42 callcount.yap
|
||||
-rw-r--r-- 1 vsc staff 6778 Jan 4 23:42 checker.yap
|
||||
-rw-r--r-- 1 vsc staff 3874 Jan 4 23:42 chtypes.yap
|
||||
-rw-r--r--@ 1 vsc staff 51193 Jun 20 22:22 consult.yap
|
||||
-rw-r--r-- 1 vsc staff 18465 May 3 18:46 control.yap
|
||||
-rw-r--r-- 1 vsc staff 18089 Jan 4 23:42 corout.yap
|
||||
-rw-r--r-- 1 vsc staff 4322 Jan 4 23:42 dbload.yap
|
||||
-rw-r--r-- 1 vsc staff 38783 Jun 8 15:38 debug.yap
|
||||
-rw-r--r-- 1 vsc staff 966 Jun 20 22:22 depth_bound.yap
|
||||
-rw-r--r-- 1 vsc staff 2458 Jun 20 22:22 dialect.yap
|
||||
-rw-r--r--@ 1 vsc staff 7586 Jun 20 22:22 directives.yap
|
||||
-rwxr--r-- 1 vsc staff 2326 Jan 4 23:42 eam.yap
|
||||
-rw-r--r-- 1 vsc staff 11527 Jun 6 08:02 errors.yap
|
||||
-rw-r--r-- 1 vsc staff 4055 May 18 23:28 eval.yap
|
||||
-rw-r--r-- 1 vsc staff 2885 Jun 5 07:42 flags.yap
|
||||
-rw-r--r-- 1 vsc staff 6596 Jan 4 23:42 grammar.yap
|
||||
-rw-r--r-- 1 vsc staff 1573 Jan 4 23:42 ground.yap
|
||||
-rw-r--r-- 1 vsc staff 7876 Feb 20 08:18 hacks.yap
|
||||
-rw-r--r--@ 1 vsc staff 8559 Jan 4 23:42 history.pl
|
||||
-rw-r--r-- 1 vsc staff 8403 Jun 20 19:28 init.yap
|
||||
-rw-r--r-- 1 vsc staff 8684 May 26 09:04 listing.yap
|
||||
-rw-r--r-- 1 vsc staff 2206 May 15 01:12 lists.yap
|
||||
-rw-r--r-- 1 vsc staff 7261 May 3 18:50 load_foreign.yap
|
||||
-rw-r--r-- 1 vsc staff 26328 Jun 6 08:31 messages.yap
|
||||
-rw-r--r--@ 1 vsc staff 55621 Jun 20 22:22 modules.yap
|
||||
-rw-r--r-- 1 vsc staff 5028 Jan 7 02:21 os.yap
|
||||
-rw-r--r-- 1 vsc staff 8061 May 26 08:43 preddecls.yap
|
||||
-rw-r--r-- 1 vsc staff 13022 May 26 08:52 preddyns.yap
|
||||
-rw-r--r-- 1 vsc staff 6687 May 26 08:37 preddyns.yap~
|
||||
-rw-r--r-- 1 vsc staff 23891 Jun 20 22:22 preds.yap
|
||||
-rw-r--r-- 1 vsc staff 7701 Jan 4 23:42 profile.yap
|
||||
-rwxr-xr-x@ 1 vsc staff 2178 Jun 20 02:26 protect.yap
|
||||
-rwxr-xr-x 1 vsc staff 25169 Jun 10 20:43 qly.yap
|
||||
-rw-r--r-- 1 vsc staff 405 Jun 9 2014 rev
|
||||
-rw-r--r-- 1 vsc staff 2050 Jan 4 23:42 save.yap
|
||||
-rw-r--r-- 1 vsc staff 7368 Apr 5 22:22 setof.yap
|
||||
-rw-r--r-- 1 vsc staff 10717 Jan 4 23:42 signals.yap
|
||||
-rw-r--r-- 1 vsc staff 4761 Apr 5 22:22 sort.yap
|
||||
-rw-r--r-- 1 vsc staff 12452 Jan 4 23:42 statistics.yap
|
||||
-rw-r--r-- 1 vsc staff 6781 May 15 00:52 strict_iso.yap
|
||||
-rw-r--r-- 1 vsc staff 2612 Jan 4 23:42 swi.yap
|
||||
-rw-r--r-- 1 vsc staff 18915 May 18 23:28 tabling.yap
|
||||
-rw-r--r-- 1 vsc staff 44648 May 18 23:28 threads.yap
|
||||
-rw-r--r-- 1 vsc staff 748 Jan 4 23:42 udi.yap
|
||||
-rw-r--r--@ 1 vsc staff 3753 Jun 8 19:56 undefined.yap
|
||||
-rw-r--r-- 1 vsc staff 9281 Jan 4 23:42 utils.yap
|
||||
-rw-r--r-- 1 vsc staff 804 Dec 2 2014 x~
|
||||
-rw-r--r-- 1 vsc staff 7555 Jan 4 23:42 yapor.yap
|
||||
-rw-r--r-- 1 vsc staff 9996 Jun 8 08:48 yio.yap
|
@ -4,7 +4,7 @@
|
||||
/** @file preddyns.yap */
|
||||
|
||||
/**
|
||||
* @ingroup Database
|
||||
* @addtogroup Database
|
||||
* @{
|
||||
|
||||
Next follow the main operations on dynamic predicates.
|
||||
|
@ -19,7 +19,7 @@
|
||||
/**
|
||||
* @file protect.yap
|
||||
* @addgroup ProtectCore Freeze System Configuration
|
||||
* @ingroup CoreUtilities
|
||||
* @ingroup YAPControl
|
||||
*
|
||||
* This protects current code from further changes
|
||||
* and also makes it impossible for some predicates to be seen
|
||||
|
11
pl/save.yap
11
pl/save.yap
@ -15,6 +15,17 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file save.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:10:47 2017
|
||||
*
|
||||
* @brief Old Style save
|
||||
*
|
||||
* @addtòxgroup QLY
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_save', [], []).
|
||||
|
||||
%%% Saving and restoring a computation
|
||||
|
294
pl/signals.yap
294
pl/signals.yap
@ -1,170 +1,170 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: signals.pl *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: signal handling in YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: signals.pl *
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: signal handling in YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%%! @addtogroup OS
|
||||
%% @{
|
||||
:- system_module( '$_signals', [alarm/3,
|
||||
on_exception/3,
|
||||
on_signal/3,
|
||||
raise_exception/1,
|
||||
read_sig/0], []).
|
||||
on_exception/3,
|
||||
on_signal/3,
|
||||
raise_exception/1,
|
||||
read_sig/0], []).
|
||||
|
||||
:- use_system_module( '$_boot', ['$meta_call'/2]).
|
||||
|
||||
:- use_system_module( '$_debug', ['$spycall'/4]).
|
||||
:- use_system_module( '$_debug', ['$trace'/1]).
|
||||
|
||||
:- use_system_module( '$_threads', ['$thread_gfetch'/1]).
|
||||
|
||||
/** @pred alarm(+ _Seconds_,+ _Callable_,+ _OldAlarm_)
|
||||
|
||||
|
||||
Arranges for YAP to be interrupted in _Seconds_ seconds, or in
|
||||
[ _Seconds_| _MicroSeconds_]. When interrupted, YAP will execute
|
||||
_Callable_ and then return to the previous execution. If
|
||||
_Seconds_ is `0`, no new alarm is scheduled. In any event,
|
||||
any previously set alarm is canceled.
|
||||
Arranges for YAP to be interrupted in _Seconds_ seconds, or in
|
||||
[ _Seconds_| _MicroSeconds_]. When interrupted, YAP will execute
|
||||
_Callable_ and then return to the previous execution. If
|
||||
_Seconds_ is `0`, no new alarm is scheduled. In any event,
|
||||
any previously set alarm is canceled.
|
||||
|
||||
The variable _OldAlarm_ unifies with the number of seconds remaining
|
||||
until any previously scheduled alarm was due to be delivered, or with
|
||||
`0` if there was no previously scheduled alarm.
|
||||
The variable _OldAlarm_ unifies with the number of seconds remaining
|
||||
until any previously scheduled alarm was due to be delivered, or with
|
||||
`0` if there was no previously scheduled alarm.
|
||||
|
||||
Note that execution of _Callable_ will wait if YAP is
|
||||
executing built-in predicates, such as Input/Output operations.
|
||||
Note that execution of _Callable_ will wait if YAP is
|
||||
executing built-in predicates, such as Input/Output operations.
|
||||
|
||||
The next example shows how _alarm/3_ can be used to implement a
|
||||
simple clock:
|
||||
The next example shows how _alarm/3_ can be used to implement a
|
||||
simple clock:
|
||||
|
||||
~~~~~
|
||||
loop :- loop.
|
||||
~~~~~
|
||||
loop :- loop.
|
||||
|
||||
ticker :- write('.'), flush_output,
|
||||
get_value(tick, yes),
|
||||
alarm(1,ticker,_).
|
||||
ticker :- write('.'), flush_output,
|
||||
get_value(tick, yes),
|
||||
alarm(1,ticker,_).
|
||||
|
||||
:- set_value(tick, yes), alarm(1,ticker,_), loop.
|
||||
~~~~~
|
||||
:- set_value(tick, yes), alarm(1,ticker,_), loop.
|
||||
~~~~~
|
||||
|
||||
The clock, `ticker`, writes a dot and then checks the flag
|
||||
`tick` to see whether it can continue ticking. If so, it calls
|
||||
itself again. Note that there is no guarantee that the each dot
|
||||
corresponds a second: for instance, if the YAP is waiting for
|
||||
user input, `ticker` will wait until the user types the entry in.
|
||||
The clock, `ticker`, writes a dot and then checks the flag
|
||||
`tick` to see whether it can continue ticking. If so, it calls
|
||||
itself again. Note that there is no guarantee that the each dot
|
||||
corresponds a second: for instance, if the YAP is waiting for
|
||||
user input, `ticker` will wait until the user types the entry in.
|
||||
|
||||
The next example shows how alarm/3 can be used to guarantee that
|
||||
a certain procedure does not take longer than a certain amount of time:
|
||||
The next example shows how alarm/3 can be used to guarantee that
|
||||
a certain procedure does not take longer than a certain amount of time:
|
||||
|
||||
~~~~~
|
||||
loop :- loop.
|
||||
~~~~~
|
||||
loop :- loop.
|
||||
|
||||
:- catch((alarm(10, throw(ball), _),loop),
|
||||
ball,
|
||||
format('Quota exhausted.~n',[])).
|
||||
~~~~~
|
||||
In this case after `10` seconds our `loop` is interrupted,
|
||||
`ball` is thrown, and the handler writes `Quota exhausted`.
|
||||
Execution then continues from the handler.
|
||||
:- catch((alarm(10, throw(ball), _),loop),
|
||||
ball,
|
||||
format('Quota exhausted.~n',[])).
|
||||
~~~~~
|
||||
In this case after `10` seconds our `loop` is interrupted,
|
||||
`ball` is thrown, and the handler writes `Quota exhausted`.
|
||||
Execution then continues from the handler.
|
||||
|
||||
Note that in this case `loop/0` always executes until the alarm is
|
||||
sent. Often, the code you are executing succeeds or fails before the
|
||||
alarm is actually delivered. In this case, you probably want to disable
|
||||
the alarm when you leave the procedure. The next procedure does exactly so:
|
||||
Note that in this case `loop/0` always executes until the alarm is
|
||||
sent. Often, the code you are executing succeeds or fails before the
|
||||
alarm is actually delivered. In this case, you probably want to disable
|
||||
the alarm when you leave the procedure. The next procedure does exactly so:
|
||||
|
||||
~~~~~
|
||||
once_with_alarm(Time,Goal,DoOnAlarm) :-
|
||||
catch(execute_once_with_alarm(Time, Goal), alarm, DoOnAlarm).
|
||||
~~~~~
|
||||
once_with_alarm(Time,Goal,DoOnAlarm) :-
|
||||
catch(execute_once_with_alarm(Time, Goal), alarm, DoOnAlarm).
|
||||
|
||||
execute_once_with_alarm(Time, Goal) :-
|
||||
alarm(Time, alarm, _),
|
||||
( call(Goal) -> alarm(0, alarm, _) ; alarm(0, alarm, _), fail).
|
||||
~~~~~
|
||||
execute_once_with_alarm(Time, Goal) :-
|
||||
alarm(Time, alarm, _),
|
||||
( call(Goal) -> alarm(0, alarm, _) ; alarm(0, alarm, _), fail).
|
||||
~~~~~
|
||||
|
||||
The procedure `once_with_alarm/3` has three arguments:
|
||||
the _Time_ to wait before the alarm is
|
||||
sent; the _Goal_ to execute; and the goal _DoOnAlarm_ to execute
|
||||
if the alarm is sent. It uses catch/3 to handle the case the
|
||||
`alarm` is sent. Then it starts the alarm, calls the goal
|
||||
_Goal_, and disables the alarm on success or failure.
|
||||
The procedure `once_with_alarm/3` has three arguments:
|
||||
the _Time_ to wait before the alarm is
|
||||
sent; the _Goal_ to execute; and the goal _DoOnAlarm_ to execute
|
||||
if the alarm is sent. It uses catch/3 to handle the case the
|
||||
`alarm` is sent. Then it starts the alarm, calls the goal
|
||||
_Goal_, and disables the alarm on success or failure.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred on_signal(+ _Signal_,? _OldAction_,+ _Callable_)
|
||||
|
||||
|
||||
Set the interrupt handler for soft interrupt _Signal_ to be
|
||||
_Callable_. _OldAction_ is unified with the previous handler.
|
||||
Set the interrupt handler for soft interrupt _Signal_ to be
|
||||
_Callable_. _OldAction_ is unified with the previous handler.
|
||||
|
||||
Only a subset of the software interrupts (signals) can have their
|
||||
handlers manipulated through on_signal/3.
|
||||
Their POSIX names, YAP names and default behavior is given below.
|
||||
The "YAP name" of the signal is the atom that is associated with
|
||||
each signal, and should be used as the first argument to
|
||||
on_signal/3. It is chosen so that it matches the signal's POSIX
|
||||
name.
|
||||
Only a subset of the software interrupts (signals) can have their
|
||||
handlers manipulated through on_signal/3.
|
||||
Their POSIX names, YAP names and default behavior is given below.
|
||||
The "YAP name" of the signal is the atom that is associated with
|
||||
each signal, and should be used as the first argument to
|
||||
on_signal/3. It is chosen so that it matches the signal's POSIX
|
||||
name.
|
||||
|
||||
on_signal/3 succeeds, unless when called with an invalid
|
||||
signal name or one that is not supported on this platform. No checks
|
||||
are made on the handler provided by the user.
|
||||
on_signal/3 succeeds, unless when called with an invalid
|
||||
signal name or one that is not supported on this platform. No checks
|
||||
are made on the handler provided by the user.
|
||||
|
||||
+ sig_up (Hangup)
|
||||
SIGHUP in Unix/Linux; Reconsult the initialization files
|
||||
~/.yaprc, ~/.prologrc and ~/prolog.ini.
|
||||
+ sig_usr1 and sig_usr2 (User signals)
|
||||
SIGUSR1 and SIGUSR2 in Unix/Linux; Print a message and halt.
|
||||
+ sig_up (Hangup)
|
||||
SIGHUP in Unix/Linux; Reconsult the initialization files
|
||||
~/.yaprc, ~/.prologrc and ~/prolog.ini.
|
||||
+ sig_usr1 and sig_usr2 (User signals)
|
||||
SIGUSR1 and SIGUSR2 in Unix/Linux; Print a message and halt.
|
||||
|
||||
|
||||
A special case is made, where if _Callable_ is bound to
|
||||
`default`, then the default handler is restored for that signal.
|
||||
A special case is made, where if _Callable_ is bound to
|
||||
`default`, then the default handler is restored for that signal.
|
||||
|
||||
A call in the form `on_signal( _S_, _H_, _H_)` can be used
|
||||
to retrieve a signal's current handler without changing it.
|
||||
A call in the form `on_signal( _S_, _H_, _H_)` can be used
|
||||
to retrieve a signal's current handler without changing it.
|
||||
|
||||
It must be noted that although a signal can be received at all times,
|
||||
the handler is not executed while YAP is waiting for a query at the
|
||||
prompt. The signal will be, however, registered and dealt with as soon
|
||||
as the user makes a query.
|
||||
It must be noted that although a signal can be received at all times,
|
||||
the handler is not executed while YAP is waiting for a query at the
|
||||
prompt. The signal will be, however, registered and dealt with as soon
|
||||
as the user makes a query.
|
||||
|
||||
Please also note, that neither POSIX Operating Systems nor YAP guarantee
|
||||
that the order of delivery and handling is going to correspond with the
|
||||
order of dispatch.
|
||||
Please also note, that neither POSIX Operating Systems nor YAP guarantee
|
||||
that the order of delivery and handling is going to correspond with the
|
||||
order of dispatch.
|
||||
*/
|
||||
:- meta_predicate on_signal(+,?,:), alarm(+,:,-).
|
||||
|
||||
'$creep'(G) :-
|
||||
% get the first signal from the mask
|
||||
% get the first signal from the mask
|
||||
'$first_signal'(Sig), !,
|
||||
% process it
|
||||
% process it
|
||||
'$do_signal'(Sig, G).
|
||||
'$creep'([M|G]) :-
|
||||
% noise, just go on with our life.
|
||||
% noise, just go on with our life.
|
||||
'$execute'(M:G).
|
||||
|
||||
'$do_signal'(sig_wake_up, G) :-
|
||||
'$awoken_goals'(LG),
|
||||
% if more signals alive, set creep flag
|
||||
% if more signals alive, set creep flag
|
||||
'$continue_signals',
|
||||
'$wake_up_goal'(G, LG).
|
||||
% never creep on entering system mode!!!
|
||||
% don't creep on meta-call.
|
||||
% never creep on entering system mode!!!
|
||||
% don't creep on meta-call.
|
||||
'$do_signal'(sig_creep, MG) :-
|
||||
'$disable_debugging',
|
||||
'$start_creep'(MG, creep).
|
||||
'$disable_debugging',
|
||||
'$start_creep'(MG, creep).
|
||||
'$do_signal'(sig_iti, [M|G]) :-
|
||||
'$thread_gfetch'(Goal),
|
||||
% if more signals alive, set creep flag
|
||||
% if more signals alive, set creep flag
|
||||
'$continue_signals',
|
||||
'$current_module'(M0),
|
||||
'$execute0'(Goal,M0),
|
||||
@ -177,61 +177,17 @@ order of dispatch.
|
||||
'$continue_signals',
|
||||
debug,
|
||||
'$execute'(M:G).
|
||||
'$do_signal'(sig_break, [M|G]) :-
|
||||
'$continue_signals',
|
||||
break,
|
||||
'$execute0'(G,M).
|
||||
'$do_signal'(sig_statistics, [M|G]) :-
|
||||
'$continue_signals',
|
||||
statistics,
|
||||
'$execute0'(G,M).
|
||||
% the next one should never be called...
|
||||
'$do_signal'(fail, [_|_]) :-
|
||||
fail.
|
||||
'$do_signal'(sig_stack_dump, [M|G]) :-
|
||||
'$continue_signals',
|
||||
'$hacks':'$stack_dump',
|
||||
'$execute0'(G,M).
|
||||
'$do_signal'(sig_fpe,G) :-
|
||||
'$signal_handler'(sig_fpe, G).
|
||||
'$do_signal'(sig_alarm, G) :-
|
||||
'$signal_handler'(sig_alarm, G).
|
||||
'$do_signal'(sig_vtalarm, G) :-
|
||||
'$signal_handler'(sig_vtalarm, G).
|
||||
'$do_signal'(sig_hup, G) :-
|
||||
'$signal_handler'(sig_hup, G).
|
||||
'$do_signal'(sig_usr1, G) :-
|
||||
'$signal_handler'(sig_usr1, G).
|
||||
'$do_signal'(sig_usr2, G) :-
|
||||
'$signal_handler'(sig_usr2, G).
|
||||
'$do_signal'(sig_pipe, G) :-
|
||||
'$signal_handler'(sig_pipe, G).
|
||||
|
||||
'$signal_handler'(Sig, [M|G]) :-
|
||||
'$signal_do'(Sig, Goal),
|
||||
% if more signals alive, set creep flag
|
||||
'$continue_signals',
|
||||
'$current_module'(M0),
|
||||
'$execute0'((Goal,M:G),M0).
|
||||
|
||||
% we may be creeping outside and coming back to system mode.
|
||||
'$start_creep'([_M|G], _) :-
|
||||
nonvar(G),
|
||||
G = '$$cut_by'(CP),
|
||||
!,
|
||||
'$$cut_by'(CP).
|
||||
'$start_creep'([Mod|G], _WhereFrom) :-
|
||||
CP is '$last_choice_pt',
|
||||
'$spycall'(G, Mod, CP, not_expanded).
|
||||
'$start_creep'([Mod|G], _WhereFrom) :-
|
||||
'$trace'([Mod|G]).
|
||||
|
||||
'$no_creep_call'('$execute_clause'(G,Mod,Ref,CP),_) :- !,
|
||||
'$enable_debugging',
|
||||
'$execute_clause'(G,Mod,Ref,CP).
|
||||
'$no_creep_call'('$execute_nonstop'(G, M),_) :- !,
|
||||
'$enable_debugging',
|
||||
'$enable_debugging',
|
||||
'$execute_nonstop'(G, M).
|
||||
'$no_creep_call'(G, M) :-
|
||||
'$enable_debugging',
|
||||
'$enable_debugging',
|
||||
'$execute_nonstop'(G, M).
|
||||
|
||||
|
||||
@ -240,9 +196,9 @@ nonvar(G),
|
||||
(
|
||||
'$is_metapredicate'(G, Mod)
|
||||
->
|
||||
'$meta_call'(G,Mod)
|
||||
'$meta_call'(G,Mod)
|
||||
;
|
||||
'$execute_nonstop'(G,Mod)
|
||||
'$execute_nonstop'(G,Mod)
|
||||
).
|
||||
|
||||
|
||||
@ -251,16 +207,16 @@ nonvar(G),
|
||||
'$signal_do'(Sig, Goal) :-
|
||||
'$signal_def'(Sig, Goal).
|
||||
|
||||
% reconsult init files.
|
||||
% reconsult init files. %
|
||||
'$signal_def'(sig_hup, (( exists('~/.yaprc') -> [-'~/.yaprc'] ; true ),
|
||||
( exists('~/.prologrc') -> [-'~/.prologrc'] ; true ),
|
||||
( exists('~/prolog.ini') -> [-'~/prolog.ini'] ; true ))).
|
||||
% die on signal default.
|
||||
( exists('~/.prologrc') -> [-'~/.prologrc'] ; true ),
|
||||
( exists('~/prolog.ini') -> [-'~/prolog.ini'] ; true ))).
|
||||
% die on signal default. %
|
||||
'$signal_def'(sig_usr1, throw(error(signal(usr1,[]),true))).
|
||||
'$signal_def'(sig_usr2, throw(error(signal(usr2,[]),true))).
|
||||
'$signal_def'(sig_pipe, throw(error(signal(pipe,[]),true))).
|
||||
'$signal_def'(sig_fpe, throw(error(signal(fpe,[]),true))).
|
||||
% ignore sig_alarm by default
|
||||
% ignore sig_alarm by default %
|
||||
'$signal_def'(sig_alarm, true).
|
||||
|
||||
|
||||
@ -289,10 +245,10 @@ on_signal(Signal,OldAction,Action) :-
|
||||
Goal = OldAction.
|
||||
on_signal(Signal,OldAction,Action) :-
|
||||
'$reset_signal'(Signal, OldAction),
|
||||
% 13211-2 speaks only about callable
|
||||
% 13211-2 speaks only about callable %
|
||||
( Action = M:Goal -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
|
||||
% the following disagrees with 13211-2:6.7.1.4 which disagrees with 13211-1:7.12.2a
|
||||
% but the following agrees with 13211-1:7.12.2a
|
||||
% the following disagrees with 13211-2:6.7.1.4 which disagrees with 13211-1:7.12.2a %
|
||||
% but the following agrees with 13211-1:7.12.2a %
|
||||
( nonvar(M) -> true ; throw(error(instantiation_error,on_signal/3)) ),
|
||||
( atom(M) -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
|
||||
( nonvar(Goal) -> true ; throw(error(instantiation_error,on_signal/3)) ),
|
||||
@ -336,8 +292,8 @@ read_sig :-
|
||||
fail.
|
||||
read_sig.
|
||||
|
||||
%
|
||||
% make thes predicates non-traceable.
|
||||
% %
|
||||
% make thes predicates non-traceable. %
|
||||
|
||||
:- '$set_no_trace'(current_choicepoint(_DCP), yap_hacks).
|
||||
:- '$set_no_trace'('$current_choice_point'(_DCP), _).
|
||||
|
25
pl/spy.yap
25
pl/spy.yap
@ -67,8 +67,7 @@ mode and the existing spy-points, when the debugger is on.
|
||||
'__NB_setval__'('$if_skip_mode',no_skip),
|
||||
'__NB_setval__'('$spy_glist',[]),
|
||||
'__NB_setval__'('$spy_gn',1),
|
||||
'__NB_setval__'('$debug_run',off),
|
||||
'__NB_setval__'('$debug_jump',false).
|
||||
'__NB_setval__'('$debug_state', state(creep,0,stop)).
|
||||
|
||||
|
||||
% First part : setting and reseting spy points
|
||||
@ -92,17 +91,9 @@ mode and the existing spy-points, when the debugger is on.
|
||||
|
||||
'$suspy_predicates_by_name'(A,S,M) :-
|
||||
% just check one such predicate exists
|
||||
(
|
||||
current_predicate(A,M:_)
|
||||
->
|
||||
M = EM,
|
||||
A = NA
|
||||
;
|
||||
recorded('$import','$import'(EM,M,GA,_,A,_),_),
|
||||
functor(GA,NA,_)
|
||||
),
|
||||
current_predicate(A,M:_),
|
||||
!,
|
||||
'$do_suspy_predicates_by_name'(NA,S,EM).
|
||||
'$do_suspy_predicates_by_name'(A,S,M).
|
||||
'$suspy_predicates_by_name'(A,spy,M) :- !,
|
||||
print_message(warning,no_match(spy(M:A))).
|
||||
'$suspy_predicates_by_name'(A,nospy,M) :-
|
||||
@ -111,10 +102,9 @@ mode and the existing spy-points, when the debugger is on.
|
||||
'$do_suspy_predicates_by_name'(A,S,M) :-
|
||||
current_predicate(A,M:T),
|
||||
functor(T,A,N),
|
||||
'$do_suspy'(S, A, N, T, M).
|
||||
'$do_suspy_predicates_by_name'(A, S, M) :-
|
||||
recorded('$import','$import'(EM,M,_,T,A,N),_),
|
||||
'$do_suspy'(S, A, N, T, EM).
|
||||
'$do_suspy'(S, A, N, T, M),
|
||||
fail.
|
||||
'$do_suspy_predicates_by_name'(_A, _S, _M).
|
||||
|
||||
|
||||
%
|
||||
@ -229,8 +219,7 @@ debug :-
|
||||
;
|
||||
set_prolog_flag(debug, false)
|
||||
),
|
||||
'__NB_setval__'('$debug_run',off),
|
||||
'__NB_setval__'('$debug_jump',false).
|
||||
'__NB_setval__'('$debug_state',state(creep,0,stop) ).
|
||||
|
||||
nodebug :-
|
||||
'$init_debugger',
|
||||
|
@ -14,6 +14,20 @@
|
||||
* comments: statistics on Prolog status *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file statistics.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:13:51 2017
|
||||
*
|
||||
* @brief System Status
|
||||
*
|
||||
* @defgroup Statistics System Status
|
||||
* @ingroup builtins
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_statistics', [key_statistics/3,
|
||||
statistics/0,
|
||||
statistics/2,
|
||||
|
@ -1,3 +1,14 @@
|
||||
/**
|
||||
* @file strict_iso.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:15:33 2017
|
||||
*
|
||||
* @brief StrictISO Mode
|
||||
*
|
||||
* @addtogroup YAPCompilerSettings
|
||||
*
|
||||
*
|
||||
*/
|
||||
:- system_module( '$_strict_iso', [], ['$check_iso_strict_clause'/1,
|
||||
'$iso_check_goal'/2]).
|
||||
|
||||
|
11
pl/swi.yap
11
pl/swi.yap
@ -1,3 +1,14 @@
|
||||
/**
|
||||
* @file swi.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:18:05 2017
|
||||
*
|
||||
* @brief SWI Emulation support
|
||||
*
|
||||
* @ingroup dialects
|
||||
*
|
||||
*
|
||||
*/
|
||||
:- module('$swi',
|
||||
[]).
|
||||
|
||||
|
12
pl/udi.yap
12
pl/udi.yap
@ -14,6 +14,18 @@
|
||||
* comments: support user defined indexing *
|
||||
* *
|
||||
*************************************************************************/
|
||||
/**
|
||||
* @file udi.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:19:04 2017
|
||||
*
|
||||
* @brief User Defined Extensions
|
||||
*
|
||||
* @addgroup UDI User Defined Extensions
|
||||
* @ingroup extensions
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_udi', [udi/1], []).
|
||||
|
||||
|
13
pl/utils.yap
13
pl/utils.yap
@ -15,6 +15,19 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file utils.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:21:01 2017
|
||||
*
|
||||
* @brief Utilities
|
||||
*
|
||||
* @defgroup MixBag Diverse Utilities
|
||||
* @ingroup builtin
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- system_module( '$_utils', [callable/1,
|
||||
current_op/3,
|
||||
nb_current/2,
|
||||
|
12
pl/yapor.yap
12
pl/yapor.yap
@ -1,3 +1,15 @@
|
||||
/**
|
||||
* @file yapor.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
|
||||
* @date Thu Oct 19 12:23:00 2017
|
||||
*
|
||||
* @brief Or-Parallelism
|
||||
*
|
||||
* @defgroup YapOR Or-Parallelism
|
||||
@ @ingroup extensions
|
||||
*
|
||||
*
|
||||
*/
|
||||
:- system_module( '$_utils', [callable/1,
|
||||
current_op/3,
|
||||
nb_current/2,
|
||||
|
Reference in New Issue
Block a user