better search for predicate location
This commit is contained in:
parent
08733b815c
commit
f41a8c19ef
24
pl/hacks.yap
24
pl/hacks.yap
@ -19,7 +19,7 @@
|
|||||||
:- module('$hacks',
|
:- module('$hacks',
|
||||||
[display_stack_info/4,
|
[display_stack_info/4,
|
||||||
display_stack_info/6,
|
display_stack_info/6,
|
||||||
display_pc/3,
|
display_pc/4,
|
||||||
code_location/3]).
|
code_location/3]).
|
||||||
|
|
||||||
/** hacks:context_variables(-NamedVariables)
|
/** hacks:context_variables(-NamedVariables)
|
||||||
@ -78,16 +78,26 @@ construct_code(Cl,Name,Arity,Mod,Where,Location) :-
|
|||||||
'$construct_code'(Clause,Name,Arity,Mod,Info,Location).
|
'$construct_code'(Clause,Name,Arity,Mod,Info,Location).
|
||||||
'$prepare_loc'(Info,_,Info).
|
'$prepare_loc'(Info,_,Info).
|
||||||
|
|
||||||
display_pc(PC) -->
|
display_pc(PC, Source) -->
|
||||||
{ integer(PC) },
|
{ integer(PC) },
|
||||||
{ '$pred_for_code'(PC,Name,Arity,Mod,Clause) },
|
{ '$pred_for_code'(PC,Name,Arity,Mod,Clause) },
|
||||||
pc_code(Clause,Name,Arity,Mod).
|
pc_code(Clause,Name,Arity,Mod, Source).
|
||||||
|
|
||||||
pc_code(-1,Name,Arity,Mod) --> !,
|
pc_code(0,_Name,_Arity,_Mod, 'top level' - []) --> !,
|
||||||
[ ' indexing code of ~a:~q/~d' - [Mod,Name,Arity] ].
|
{fail}.
|
||||||
pc_code(Cl,Name,Arity,Mod) -->
|
pc_code(-1,Name,Arity,Mod, '~a:~q/~d' - [Mod,Name,Arity]) --> !,
|
||||||
|
{ functor(S, Name,Arity),
|
||||||
|
nth_clause(Mod:S,1,Ref),
|
||||||
|
clause_property(Ref, file(File)),
|
||||||
|
clause_property(Ref, line_count(Line)) },
|
||||||
|
[ '~a:~d:0, ' - [File,Line] ].
|
||||||
|
pc_code(Cl,Name,Arity,Mod, 'clause ~d for ~a:~q/~d'-[Cl,Mod,Name,Arity]) -->
|
||||||
{ Cl > 0 },
|
{ Cl > 0 },
|
||||||
[ ' clause ~d of ~a:~q/~d' - [Cl,Mod,Name,Arity] ].
|
{ functor(S, Name,Arity),
|
||||||
|
nth_clause(Mod:S,Cl,Ref),
|
||||||
|
clause_property(Ref, file(File)),
|
||||||
|
clause_property(Ref, line_count(Line)) },
|
||||||
|
[ '~a:~d:0, ' - [File,Line] ].
|
||||||
|
|
||||||
|
|
||||||
display_stack_info(_,_,0,_) --> !.
|
display_stack_info(_,_,0,_) --> !.
|
||||||
|
Reference in New Issue
Block a user