Added call/5-12 (we alread have call_with_args/2-12); not sure they are worth. Alternative implementation for call_cleanup/2-3: previous implementation appears to be pruning cleanup goals before they are executed; needs testing.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1756 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura 2006-12-31 12:29:46 +00:00
parent 7c0175abbc
commit 9de3c0c7a9
3 changed files with 155 additions and 20 deletions

124
C/exec.c
View File

@ -445,6 +445,122 @@ p_execute4(void)
return(do_execute_n(t, CurrentModule, 3));
}
static Int
p_execute5(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
return(do_execute_n(t, CurrentModule, 4));
}
static Int
p_execute6(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
return(do_execute_n(t, CurrentModule, 5));
}
static Int
p_execute7(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
return(do_execute_n(t, CurrentModule, 6));
}
static Int
p_execute8(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
heap_store(Deref(ARG8));
return(do_execute_n(t, CurrentModule, 7));
}
static Int
p_execute9(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
heap_store(Deref(ARG8));
heap_store(Deref(ARG9));
return(do_execute_n(t, CurrentModule, 8));
}
static Int
p_execute10(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
heap_store(Deref(ARG8));
heap_store(Deref(ARG9));
heap_store(Deref(ARG10));
return(do_execute_n(t, CurrentModule, 9));
}
static Int
p_execute11(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
heap_store(Deref(ARG8));
heap_store(Deref(ARG9));
heap_store(Deref(ARG10));
heap_store(Deref(ARG11));
return(do_execute_n(t, CurrentModule, 10));
}
static Int
p_execute12(void)
{ /* '$execute'(Goal) */
Term t = Deref(ARG1);
heap_store(Deref(ARG2));
heap_store(Deref(ARG3));
heap_store(Deref(ARG4));
heap_store(Deref(ARG5));
heap_store(Deref(ARG6));
heap_store(Deref(ARG7));
heap_store(Deref(ARG8));
heap_store(Deref(ARG9));
heap_store(Deref(ARG10));
heap_store(Deref(ARG11));
heap_store(Deref(ARG12));
return(do_execute_n(t, CurrentModule, 11));
}
static Int
p_execute_clause(void)
{ /* '$execute_clause'(Goal) */
@ -1890,6 +2006,14 @@ Yap_InitExecFs(void)
Yap_InitCPred("$execute", 2, p_execute2, HiddenPredFlag);
Yap_InitCPred("$execute", 3, p_execute3, HiddenPredFlag);
Yap_InitCPred("$execute", 4, p_execute4, HiddenPredFlag);
Yap_InitCPred("$execute", 5, p_execute5, HiddenPredFlag);
Yap_InitCPred("$execute", 6, p_execute6, HiddenPredFlag);
Yap_InitCPred("$execute", 7, p_execute7, HiddenPredFlag);
Yap_InitCPred("$execute", 8, p_execute8, HiddenPredFlag);
Yap_InitCPred("$execute", 9, p_execute9, HiddenPredFlag);
Yap_InitCPred("$execute", 10, p_execute10, HiddenPredFlag);
Yap_InitCPred("$execute", 11, p_execute11, HiddenPredFlag);
Yap_InitCPred("$execute", 12, p_execute12, HiddenPredFlag);
Yap_InitCPred("$execute_in_mod", 2, p_execute_in_mod, HiddenPredFlag);
Yap_InitCPred("$call_with_args", 2, p_execute_0, HiddenPredFlag);
Yap_InitCPred("$call_with_args", 3, p_execute_1, HiddenPredFlag);

View File

@ -522,10 +522,6 @@ frozen(V, LG) :-
'$purge_done_goals'(G0, GF).
'$purge_done_goals'(['$redo_freeze'(Done, _, _)|G0], GF) :- nonvar(Done), !,
'$purge_done_goals'(G0, GF).
'$purge_done_goals'(['$redo_freeze'(Done, _, CallCleanup)|G0], GF) :-
nonvar(CallCleanup),
CallCleanup = _:'$clean_call'(_), !,
'$purge_done_goals'(G0, GF).
'$purge_done_goals'(['$redo_eq'(Done, _, _, _)|G0], GF) :- nonvar(Done), !,
'$purge_done_goals'(G0, GF).
'$purge_done_goals'(['$redo_ground'(Done, _, _)|G0], GF) :- nonvar(Done), !,

View File

@ -31,6 +31,22 @@ call(X,A1,A2) :- '$execute'(X,A1,A2).
call(X,A1,A2,A3) :- '$execute'(X,A1,A2,A3).
call(X,A1,A2,A3,A4) :- '$execute'(X,A1,A2,A3,A4).
call(X,A1,A2,A3,A4,A5) :- '$execute'(X,A1,A2,A3,A4,A5).
call(X,A1,A2,A3,A4,A5,A6) :- '$execute'(X,A1,A2,A3,A4,A5,A6).
call(X,A1,A2,A3,A4,A5,A6,A7) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7).
call(X,A1,A2,A3,A4,A5,A6,A7,A8) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11).
call_with_args(M:V) :- var(V), !,
'$do_error'(instantiation_error,call_with_args(M:V)).
call_with_args(_:M:A) :- !,
@ -171,27 +187,26 @@ call_cleanup(Goal, Cleanup) :-
call_cleanup(Goal, Catcher, Cleanup).
call_cleanup(Goal, Catcher, Cleanup) :-
catch('$call_cleanup'(Goal,Catcher,Cleanup),
catch('$call_cleanup'(Goal,Cleanup,Result),
Exception,
'$cleanup_exception'(Exception,Catcher,Cleanup)).
'$cleanup_exception'(Exception,Catcher,Cleanup)),
Result = exit.
'$cleanup_exception'(Exception, exception(Exception), Cleanup) :-
call(Cleanup).
'$call_cleanup'(Goal,Catcher,Cleanup) :-
'$freeze_goal'(Catcher, '$clean_call'(Cleanup)),
yap_hacks:trail_suspension_marker(Catcher),
'$call_cleanup'(Goal,Cleanup,Result) :-
'$freeze_goal'(Result, '$clean_call'(Cleanup)),
yap_hacks:trail_suspension_marker(Result),
yap_hacks:current_choice_point(CP0),
call(Goal),
( call(Goal),
yap_hacks:current_choice_point(CPF),
( CP0 =:= CPF ->
Catcher = exit, !
;
true
Result = exit, !
; true
)
; Result = fail
).
'$call_cleanup'(Goal,fail,Cleanup) :-
call(Cleanup), !,
fail.
'$clean_call'(Cleanup) :-
call(Cleanup), !.