SWI-portability changes
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2088 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -4,44 +4,54 @@
|
||||
% Purpose: Prolog hacking
|
||||
|
||||
:- module(yap_hacks, [
|
||||
current_choicepoint/1,
|
||||
cut_by/1,
|
||||
cut_at/1,
|
||||
current_choicepoints/1,
|
||||
choicepoint/7,
|
||||
current_continuations/1,
|
||||
continuation/4,
|
||||
stack_dump/0
|
||||
stack_dump/0,
|
||||
stack_dump/1
|
||||
]).
|
||||
|
||||
stack_dump :-
|
||||
stack_dump(-1).
|
||||
|
||||
stack_dump(Max) :-
|
||||
current_choicepoints(CPs),
|
||||
current_continuations([Env|Envs]),
|
||||
continuation(Env,_,ContP,_),
|
||||
length(CPs, LCPs),
|
||||
length(Envs, LEnvs),
|
||||
format(user_error,'~n~n~tStack Dump~t~40+~n~nAddress~tChoiceP~16+ Cur/Next Clause Goal~n',[LCPs,LEnvs]),
|
||||
display_stack_info(CPs,Envs,ContP).
|
||||
display_stack_info(CPs,Envs,Max,ContP).
|
||||
|
||||
display_stack_info([],[],_).
|
||||
display_stack_info([CP|CPs],[],_) :-
|
||||
display_stack_info(_,_,0,_) :- !.
|
||||
display_stack_info([],[],_,_).
|
||||
display_stack_info([CP|CPs],[],I,_) :-
|
||||
show_lone_cp(CP),
|
||||
display_stack_info(CPs,[],_).
|
||||
display_stack_info([],[Env|Envs],Cont) :-
|
||||
I1 is I-1,
|
||||
display_stack_info(CPs,[],I1,_).
|
||||
display_stack_info([],[Env|Envs],I,Cont) :-
|
||||
show_env(Env, Cont, NCont),
|
||||
display_stack_info([], Envs, NCont).
|
||||
display_stack_info([CP|LCPs],[Env|LEnvs],Cont) :-
|
||||
continuation(Env, _, NCont, CB),
|
||||
I1 is I-1,
|
||||
display_stack_info([], Envs, I1, NCont).
|
||||
display_stack_info([CP|LCPs],[Env|LEnvs],I,Cont) :-
|
||||
continuation(Env, _, NCont, CB),
|
||||
I1 is I-1,
|
||||
( CP == Env, CB < CP ->
|
||||
% if we follow choice-point and we cut to before choice-point
|
||||
% we are the same goal
|
||||
show_cp(CP, 'Cur'), %
|
||||
display_stack_info(LCPs, LEnvs, NCont)
|
||||
display_stack_info(LCPs, LEnvs, I1, NCont)
|
||||
;
|
||||
CP > Env ->
|
||||
show_cp(CP, 'Next'),
|
||||
display_stack_info(LCPs,[Env|LEnvs],Cont)
|
||||
display_stack_info(LCPs,[Env|LEnvs],I1,Cont)
|
||||
;
|
||||
show_env(Env,Cont,NCont),
|
||||
display_stack_info([CP|LCPs],LEnvs,NCont)
|
||||
display_stack_info([CP|LCPs],LEnvs,I1,NCont)
|
||||
).
|
||||
|
||||
show_cp(CP, Continuation) :-
|
||||
|
||||
Reference in New Issue
Block a user