code source should never had the head in the module
This commit is contained in:
parent
9b89e6fd92
commit
f23b8b5418
23
pl/meta.yap
23
pl/meta.yap
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
||||||
@defgroup YAPMetaPredicates Using Meta-Calls with Modules
|
@defgroup YAPMetaPredicates Using Meta-Calls with Modules
|
||||||
@ingroup YAPModules
|
@ingroup YAPModules
|
||||||
|
|
||||||
@pred meta_predicate(_G1_,...., _Gn) is directive
|
@pred meta_predicate(_G1_,...., _Gn) is directive
|
||||||
@ -151,8 +151,8 @@ meta_predicate declaration
|
|||||||
'$meta_expand'(G0, PredDef, CM, HVars, NG) :-
|
'$meta_expand'(G0, PredDef, CM, HVars, NG) :-
|
||||||
G0 =.. [Name|GArgs],
|
G0 =.. [Name|GArgs],
|
||||||
PredDef =.. [Name|GDefs],
|
PredDef =.. [Name|GDefs],
|
||||||
functor(PredDef, Name, Arity ),
|
functor(PredDef, Name, Arity ),
|
||||||
length(NGArgs, Arity),
|
length(NGArgs, Arity),
|
||||||
NG =.. [Name|NGArgs],
|
NG =.. [Name|NGArgs],
|
||||||
'$expand_args'(GArgs, CM, GDefs, HVars, NGArgs).
|
'$expand_args'(GArgs, CM, GDefs, HVars, NGArgs).
|
||||||
|
|
||||||
@ -206,10 +206,10 @@ meta_predicate declaration
|
|||||||
% modules:
|
% modules:
|
||||||
% A4: module for body of clause (this is the one used in looking up predicates)
|
% A4: module for body of clause (this is the one used in looking up predicates)
|
||||||
% A5: context module (this is the current context
|
% A5: context module (this is the current context
|
||||||
% A6: head module (this is the one used in compiling and accessing).
|
% A6: head module (this is the one used in compiling and accessing).
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
%'$expand_goals'(V,NG,NG,HM,SM,BM,HVars):-l writeln(V), fail.
|
%'$expand_goals'(V,NG,NG,HM,SM,BM,HVars):- writeln(V), fail.
|
||||||
'$expand_goals'(V,NG,NGO,HM,SM,BM,HVars-H) :-
|
'$expand_goals'(V,NG,NGO,HM,SM,BM,HVars-H) :-
|
||||||
var(V),
|
var(V),
|
||||||
!,
|
!,
|
||||||
@ -328,12 +328,14 @@ meta_predicate declaration
|
|||||||
!.
|
!.
|
||||||
'$import_expansion'(MG, MG).
|
'$import_expansion'(MG, MG).
|
||||||
|
|
||||||
'$meta_expansion'(GM:G, BM, HVars, GM:GF) :-
|
'$meta_expansion'(GMG, BM, HVars, GM:GF) :-
|
||||||
|
'$yap_strip_module'(GMG, GM, G ),
|
||||||
functor(G, F, Arity ),
|
functor(G, F, Arity ),
|
||||||
'$meta_predicate'(F, GM, Arity, PredDef),
|
'$meta_predicate'(F, GM, Arity, PredDef),
|
||||||
!,
|
!,
|
||||||
'$meta_expand'(G, PredDef, BM, HVars, GF).
|
'$meta_expand'(G, PredDef, BM, HVars, GF).
|
||||||
'$meta_expansion'(GM:G, _BM, _HVars, GM:G).
|
'$meta_expansion'(GMG, _BM, _HVars, GM:G) :-
|
||||||
|
'$yap_strip_module'(GMG, GM, G ).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform meta-variable and user expansion on a goal _G_
|
* @brief Perform meta-variable and user expansion on a goal _G_
|
||||||
@ -398,7 +400,7 @@ o:p(B) :- n:g, X is 2+3, call(B).
|
|||||||
'$build_up'(HM, NH, SM, true, NH, true, NH) :- HM == SM, !.
|
'$build_up'(HM, NH, SM, true, NH, true, NH) :- HM == SM, !.
|
||||||
'$build_up'(HM, NH, _SM, true, HM:NH, true, HM:NH) :- !.
|
'$build_up'(HM, NH, _SM, true, HM:NH, true, HM:NH) :- !.
|
||||||
'$build_up'(HM, NH, SM, B1, (NH :- B1), BO, ( NH :- BO)) :- HM == SM, !.
|
'$build_up'(HM, NH, SM, B1, (NH :- B1), BO, ( NH :- BO)) :- HM == SM, !.
|
||||||
'$build_up'(HM, NH, _SM, B1, (HM:NH :- B1), BO, ( HM:NH :- BO)) :- !.
|
'$build_up'(HM, NH, _SM, B1, (NH :- B1), BO, ( HM:NH :- BO)) :- !.
|
||||||
|
|
||||||
'$expand_clause_body'(true, _NH1, _HM1, _SM, _M, true, true ) :- !.
|
'$expand_clause_body'(true, _NH1, _HM1, _SM, _M, true, true ) :- !.
|
||||||
'$expand_clause_body'(B, H, HM, SM, M, B1, BO ) :-
|
'$expand_clause_body'(B, H, HM, SM, M, B1, BO ) :-
|
||||||
@ -463,6 +465,7 @@ o:p(B) :- n:g, X is 2+3, call(B).
|
|||||||
'$build_up'(HM, NH, SM0, B1, Cl1, BO, ClO).
|
'$build_up'(HM, NH, SM0, B1, Cl1, BO, ClO).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
expand_goal(Input, Output) :-
|
expand_goal(Input, Output) :-
|
||||||
'$expand_meta_call'(Input, [], Output ).
|
'$expand_meta_call'(Input, [], Output ).
|
||||||
|
|
||||||
@ -518,7 +521,7 @@ expand_goal(Input, Output) :-
|
|||||||
current_predicate(:),
|
current_predicate(:),
|
||||||
current_predicate(?,:),
|
current_predicate(?,:),
|
||||||
db_files(:),
|
db_files(:),
|
||||||
depth_bound_call(0,+),
|
depth_bound_call(0,+),
|
||||||
discontiguous(:),
|
discontiguous(:),
|
||||||
ensure_loaded(:),
|
ensure_loaded(:),
|
||||||
exo_files(:),
|
exo_files(:),
|
||||||
|
Reference in New Issue
Block a user