Boot fixes.
This commit is contained in:
parent
3c91e1c9a0
commit
b2cec5467c
21
C/cdmgr.c
21
C/cdmgr.c
@ -1014,20 +1014,6 @@ bool Yap_unknown(Term t) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int
|
||||
undef_handler(USES_REGS1) { /* '$undef_handler'(+S,+Mod) */
|
||||
PredEntry *pe;
|
||||
Int out;
|
||||
|
||||
pe = get_pred(Deref(ARG1), Deref(ARG2), "undef_handler");
|
||||
if (EndOfPAEntr(pe))
|
||||
return FALSE;
|
||||
PELOCK(27, pe);
|
||||
UndefCode = pe;
|
||||
UNLOCKPE(44, pe);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int source_pred(PredEntry *p, yamop *q) {
|
||||
if (p->PredFlags & (DynamicPredFlag | LogUpdatePredFlag))
|
||||
return FALSE;
|
||||
@ -2701,16 +2687,16 @@ static Int undefp_handler(USES_REGS1) { /* '$undefp_handler'(P,Mod) */
|
||||
PredEntry *pe;
|
||||
|
||||
pe = get_pred(Deref(ARG1), Deref(ARG2), "undefined/1");
|
||||
PELOCK(59, pe);
|
||||
if (EndOfPAEntr(pe))
|
||||
return false;
|
||||
PELOCK(59, pe);
|
||||
if (pe->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
UNLOCKPE(58, pe);
|
||||
UNLOCKPE(59, pe);
|
||||
return false;
|
||||
}
|
||||
UndefCode = pe;
|
||||
UNLOCKPE(59, pe);
|
||||
return FALSE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Int p_undefined(USES_REGS1) { /* '$undefined'(P,Mod) */
|
||||
@ -4667,7 +4653,6 @@ void Yap_InitCdMgr(void) {
|
||||
Yap_InitCPred("$call_count_reset", 0, p_call_count_reset,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$set_pred_module", 2, p_set_pred_module, SafePredFlag);
|
||||
Yap_InitCPred("$undef_handler", 2, undef_handler, SafePredFlag);
|
||||
Yap_InitCPred("$set_pred_owner", 2, p_set_pred_owner, SafePredFlag);
|
||||
Yap_InitCPred("$hide_predicate", 2, hide_predicate, SafePredFlag);
|
||||
Yap_InitCPred("$stash_predicate", 2, p_stash_predicate, SafePredFlag);
|
||||
|
26
pl/boot.yap
26
pl/boot.yap
@ -266,27 +266,27 @@ private(_).
|
||||
!,
|
||||
format(user_error, '~a:~d:0: unprocessed ~a ~w ~n', [F0, L,Level,Msg]).
|
||||
'$early_print_message'(Level, Msg) :-
|
||||
format(user_error, 'unprocessed ~a ~w ~n', [Level,Msg]).
|
||||
format(user_error, 'unprocessed ~a ~w ~n', [Level,Msg]).
|
||||
|
||||
'$handle_error'(_Action,_G0,_M0) :- fail.
|
||||
'$handle_error'(_Action,_G0,_M0) :- fail.
|
||||
|
||||
% cases where we cannot afford to ever fail.
|
||||
'$undefp0'([ImportingMod|G], _) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G,G0I,_,_),_), !,
|
||||
% writeln('$execute0'(G0I, ExportingModI)),
|
||||
'$execute0'(G0I, ExportingModI).
|
||||
'$undefp0'([_|print_message(Context, Msg)], _) :- !,
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G,G0I,_,_),_), !,
|
||||
% writeln('$execute0'(G0I, ExportingModI)),
|
||||
'$execute0'(G0I, ExportingModI).
|
||||
'$undefp0'([_|print_message(Context, Msg)], _) :-
|
||||
!,
|
||||
'$early_print_message'(Context, Msg).
|
||||
% undef handler
|
||||
'$undefp0'([M0|G0], Action) :-
|
||||
% make sure we do not loop on undefined predicates
|
||||
yap_flag( unknown, Action, fail),
|
||||
Action \= fail,
|
||||
'$handle_error'(Action,G0,M0),
|
||||
clause_location(Call, Caller),
|
||||
source_module(M),
|
||||
strip_module(M:Goal,M1,NGoal),
|
||||
throw(error(Error, [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(Head)]])).
|
||||
yap_flag( unknown, Action, fail),
|
||||
'$handle_error'(Action,G0,M0),
|
||||
clause_location(Call, Caller),
|
||||
source_module(M),
|
||||
strip_module(M0:G0,M1,NGoal),
|
||||
throw(error(evaluation(undefined,M0:G0), [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(M0:G0)]])).
|
||||
|
||||
|
||||
|
||||
|
@ -931,40 +931,6 @@ prolog:print_message(Severity, _Term) :-
|
||||
format('No handler for ~a message ~q,~n',[Severity, _Term]).
|
||||
|
||||
|
||||
% cases where we cannot afford to ever fail.
|
||||
'$undefp'([ImportingMod|G], _) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G,G0I,_,_),_), !,
|
||||
% writeln('$execute'(G0I, ExportingModI)),
|
||||
'$execute0'(G0I, ExportingModI).
|
||||
% undef handler
|
||||
'$undefp'([M0|G0], Action) :-
|
||||
% make sure we do not loop on undefined predicates
|
||||
'$stop_creeping'(Current),
|
||||
yap_flag( unknown, Action, fail),
|
||||
Action\=fail,
|
||||
% yap_flag( debug, Debug, false),
|
||||
(
|
||||
'$undefp_search'(M0:G0, NM:NG),
|
||||
( M0 \== NM -> true ; G0 \== NG ),
|
||||
NG \= fail
|
||||
->
|
||||
yap_flag( unknown, _, Action),
|
||||
% yap_flag( debug, _, Debug),
|
||||
(
|
||||
Current == true
|
||||
->
|
||||
% carry on signal processing
|
||||
'$start_creep'([NM|NG], creep)
|
||||
;
|
||||
'$execute0'(NG, NM)
|
||||
)
|
||||
;
|
||||
yap_flag( unknown, _, Action),
|
||||
'$handle_error'(Action,G0,M0)
|
||||
).
|
||||
|
||||
:- '$undef_handler'('$undefp'(_,_), prolog).
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -105,6 +105,34 @@ followed by the failure of that call.
|
||||
expand_goal(MG, FMG).
|
||||
|
||||
|
||||
% undef handler
|
||||
'$undefp'([M0|G0], Action) :-
|
||||
% make sure we do not loop on undefined predicates
|
||||
yap_flag( unknown, Action, fail),
|
||||
'$stop_creeping'(Current),
|
||||
% yap_flag( debug, Debug, false),
|
||||
(
|
||||
'$undefp_search'(M0:G0, NM:NG),
|
||||
( M0 \== NM -> true ; G0 \== NG ),
|
||||
NG \= fail
|
||||
->
|
||||
yap_flag( unknown, _, Action),
|
||||
% yap_flag( debug, _, Debug),
|
||||
(
|
||||
Current == true
|
||||
->
|
||||
% carry on signal processing
|
||||
'$start_creep'([NM|NG], creep)
|
||||
;
|
||||
'$execute0'(NG, NM)
|
||||
)
|
||||
;
|
||||
yap_flag( unknown, _, Action),
|
||||
'$handle_error'(Action,G0,M0)
|
||||
).
|
||||
|
||||
:- '$undefp_handler'('$undefp'(_,_), prolog).
|
||||
|
||||
/** @pred unknown(- _O_,+ _N_)
|
||||
|
||||
The unknown predicate, informs about what the user wants to be done
|
||||
|
Reference in New Issue
Block a user