new builtins: nth_clause, nth_instance.

allow clause/3 on static predicates.
predicate_property(P,number_of_clauses(N)).
improve profiling code.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@728 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2002-12-13 20:00:41 +00:00
parent f7161d37c4
commit 8b867ea4de
7 changed files with 374 additions and 126 deletions

View File

@@ -521,7 +521,8 @@ debugging :-
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
CP is '$last_choice_pt',
(
'$fetch_clause'(G,M,Cl,Clause),
'$nth_instancep'(M:G,Cl,R),
instance(R,(G:-Clause)),
(Clause = true -> true ; '$call'(Clause,CP,Clause,M) )
;
Next is Cl+1, '$set_value'(spy_cl,Next), fail
@@ -576,10 +577,15 @@ debugging :-
('$undefined'('$set_depth_limit'(_),prolog) -> true ; '$set_depth_limit'(D)),
CP is '$last_choice_pt',
(
'$fetch_clause'(G,M,Cl,Clause),
(Clause = true -> true ;
'$creep_call'(Clause,M,CP)
)
'$nth_instancep'(M:G,Cl,R),
instance(R,(G:-Clause)),
(
Clause = true
->
true
;
'$creep_call'(Clause,M,CP)
)
;
Next is Cl+1, '$set_value'(spy_cl,Next), fail
).
@@ -638,21 +644,6 @@ debugging :-
'$creep',
'$execute'(G,M,Cl).
'$fetch_clause'(G,M,ClNum,Body) :-
% I'd like an easier way to keep a counter
'$set_value'('$fetching_clauses',1),
'$recordedp'(M:G,Clause,_),
'$get_value'('$fetching_clauses',Num),
( Num = ClNum ->
!,
Clause = (G :- Body)
;
Num1 is Num+1,
'$set_value'('$fetching_clauses',Num1),
fail
).
%'$creep_call'(G,_) :- write(user_error,'$creepcall'(G)), nl(user_error), fail.
'$creep_call'(V,M,_) :- var(V), !,
'$do_error'(instantiation_error,meta_call(M:V)).