From f23b8b5418bdb540cf08275ced772b9fc5202c62 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 28 Apr 2016 14:56:57 +0100 Subject: [PATCH] code source should never had the head in the module --- pl/meta.yap | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pl/meta.yap b/pl/meta.yap index 10b6f9e17..87de8fabb 100644 --- a/pl/meta.yap +++ b/pl/meta.yap @@ -2,7 +2,7 @@ @{ - @defgroup YAPMetaPredicates Using Meta-Calls with Modules + @defgroup YAPMetaPredicates Using Meta-Calls with Modules @ingroup YAPModules @pred meta_predicate(_G1_,...., _Gn) is directive @@ -151,8 +151,8 @@ meta_predicate declaration '$meta_expand'(G0, PredDef, CM, HVars, NG) :- G0 =.. [Name|GArgs], PredDef =.. [Name|GDefs], - functor(PredDef, Name, Arity ), - length(NGArgs, Arity), + functor(PredDef, Name, Arity ), + length(NGArgs, Arity), NG =.. [Name|NGArgs], '$expand_args'(GArgs, CM, GDefs, HVars, NGArgs). @@ -206,10 +206,10 @@ meta_predicate declaration % modules: % A4: module for body of clause (this is the one used in looking up predicates) % 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) :- var(V), !, @@ -328,12 +328,14 @@ meta_predicate declaration !. '$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 ), '$meta_predicate'(F, GM, Arity, PredDef), - !, + !, '$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_ @@ -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, HM:NH, true, HM:NH) :- !. '$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'(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). + expand_goal(Input, Output) :- '$expand_meta_call'(Input, [], Output ). @@ -518,7 +521,7 @@ expand_goal(Input, Output) :- current_predicate(:), current_predicate(?,:), db_files(:), - depth_bound_call(0,+), + depth_bound_call(0,+), discontiguous(:), ensure_loaded(:), exo_files(:),