handle SWI style goal expansion natively, instead of trying to be smart.

This commit is contained in:
Vitor Santos Costa 2009-05-24 19:18:52 -05:00
parent de3c042143
commit 99ac4f4d4a
3 changed files with 17 additions and 18 deletions

View File

@ -389,21 +389,5 @@ prolog:compile_aux_clauses([Cl|Cls]) :-
prolog:compile_aux_clauses(Cls).
% fix different semantics for arg/3.
user:goal_expansion(arg(X,Y,Z),_,arg:genarg(X,Y,Z)) :-
user:goal_expansion(arg(X,Y,Z),arg:genarg(X,Y,Z)) :-
nonvar(X), !.
%
% convert from SWI's goal expansion to YAP/SICStus old style goal
% expansion.
%
user:term_expansion(goal_expansion(A,B),O) :-
prolog_load_context(module, user), !,
O = goal_expansion(A,user,B).
user:term_expansion(user:goal_expansion(A,B),O) :- !,
O = user:goal_expansion(A,_,B).
user:term_expansion((goal_expansion(A,B) :- G), O) :-
prolog_load_context(module, user), !,
O = (goal_expansion(A,user,B) :- G).
user:term_expansion((goal_expansion(A,B) :- G),O) :-
O = (user:goal_expansion(A,_,B) :- G).

View File

@ -174,6 +174,10 @@ yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
:- dynamic goal_expansion/3.
:- multifile goal_expansion/2.
:- dynamic goal_expansion/2.
:- multifile term_expansion/2.
:- dynamic term_expansion/2.

View File

@ -298,7 +298,18 @@ module(N) :-
'$module_expansion'(G,G1,GO,M,M,HM,HVars).
'$module_expansion'(G, G1, GO, CurMod, MM, HM, HVars) :-
'$pred_goal_expansion_on',
user:goal_expansion(G, CurMod, GI), !,
( user:goal_expansion(G, CurMod, GI)
->
true
;
(
'$pred_exists'(goal_expansion(G,GI), CurMod)
->
call(CurMod:goal_expansion(G, GI))
)
;
user:goal_expansion(G, GI)
), !,
'$module_expansion'(GI, G1, GO, CurMod, MM, HM, HVars).
'$module_expansion'(G, G1, GO, CurMod, MM, HM,HVars) :-
% is this imported from some other module M1?