diff --git a/C/exec.c b/C/exec.c index 8b240bad8..fc8edc6d9 100644 --- a/C/exec.c +++ b/C/exec.c @@ -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); diff --git a/pl/corout.yap b/pl/corout.yap index a81f00829..8370c40bb 100644 --- a/pl/corout.yap +++ b/pl/corout.yap @@ -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), !, diff --git a/pl/utils.yap b/pl/utils.yap index f1e1c8390..0170030b2 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -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,30 +187,29 @@ 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). -'$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), - yap_hacks:current_choice_point(CPF), - ( CP0 =:= CPF -> - Catcher = exit, ! - ; - true + ( call(Goal), + yap_hacks:current_choice_point(CPF), + ( CP0 =:= CPF -> + Result = exit, ! + ; true + ) + ; Result = fail ). -'$call_cleanup'(Goal,fail,Cleanup) :- - call(Cleanup), !, - fail. '$clean_call'(Cleanup) :- - call(Cleanup), !. + call(Cleanup), !. '$clean_call'(_). op(P,T,V) :- var(P), !,