Ricardo Rocha's code for user managed suspension.
changed code from absmi.c to tab.macros.h
This commit is contained in:
parent
5db95de67d
commit
02893cc83f
@ -1516,3 +1516,4 @@ Yap_regtoregno(wamreg reg)
|
||||
#define copy_jmp_address(X)
|
||||
#define copy_jmp_addressa(X)
|
||||
#endif
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: opt.preds.c
|
||||
version: $Id: opt.preds.c,v 1.29 2008-04-11 16:26:19 ricroc Exp $
|
||||
version: $Id: opt.preds.c,v 1.29 2008/04/11 16:26:19 ricroc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@ -63,6 +63,8 @@ static Int p_or_statistics(void);
|
||||
#endif /* YAPOR */
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze(void);
|
||||
static Int p_wake(void);
|
||||
static Int p_table(void);
|
||||
static Int p_tabling_mode(void);
|
||||
static Int p_abolish_table(void);
|
||||
@ -125,6 +127,8 @@ void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("or_statistics", 0, p_or_statistics, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
Yap_InitCPred("freeze_choice_point", 1, p_freeze, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("wake_choice_point", 1, p_wake, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_table", 2, p_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
@ -521,6 +525,31 @@ Int p_or_statistics(void) {
|
||||
|
||||
|
||||
#ifdef TABLING
|
||||
static Int p_freeze(void) {
|
||||
Term term_arg, term_cp;
|
||||
|
||||
term_arg = Deref(ARG1);
|
||||
if (IsVarTerm(term_arg)) {
|
||||
choiceptr cp = freeze_current_cp();
|
||||
term_cp = MkIntegerTerm((Int) cp);
|
||||
return Yap_unify(ARG1, term_cp);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_wake(void) {
|
||||
Term term_arg;
|
||||
|
||||
term_arg = Deref(ARG1);
|
||||
if (IsIntegerTerm(term_arg)) {
|
||||
choiceptr cp = (choiceptr) IntegerOfTerm(term_arg);
|
||||
resume_frozen_cp(cp);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
Int p_table(void) {
|
||||
Term mod, t;
|
||||
|
@ -636,6 +636,51 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
choiceptr create_cp_and_freeze(void) {
|
||||
choiceptr freeze_cp;
|
||||
|
||||
// initialize and store freeze choice point
|
||||
// freeze_cp = (NORM_CP(YENV) - 1);
|
||||
freeze_cp = (NORM_CP(YENV) - 2);
|
||||
HBREG = H;
|
||||
store_yaam_reg_cpdepth(freeze_cp);
|
||||
freeze_cp->cp_tr = TR;
|
||||
freeze_cp->cp_ap = (yamop *)(TRUSTFAILCODE);
|
||||
freeze_cp->cp_h = H;
|
||||
freeze_cp->cp_b = B;
|
||||
freeze_cp->cp_env = ENV;
|
||||
freeze_cp->cp_cp = CPREG;
|
||||
// set_cut((CELL *)freeze_cp, B);
|
||||
B = freeze_cp;
|
||||
SET_BB(B);
|
||||
// adjust freeze registers
|
||||
B_FZ = freeze_cp;
|
||||
H_FZ = H;
|
||||
TR_FZ = TR;
|
||||
return freeze_cp;
|
||||
}
|
||||
*/
|
||||
|
||||
static inline choiceptr
|
||||
freeze_current_cp(void) {
|
||||
choiceptr freeze_cp = B;
|
||||
|
||||
B_FZ = freeze_cp;
|
||||
H_FZ = freeze_cp->cp_h;
|
||||
TR_FZ = freeze_cp->cp_tr;
|
||||
return freeze_cp;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
resume_frozen_cp(choiceptr frozen_cp) {
|
||||
restore_bindings(TR, frozen_cp->cp_tr);
|
||||
B = frozen_cp;
|
||||
TR = TR_FZ;
|
||||
TRAIL_LINK(B->cp_tr);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef YAPOR
|
||||
static inline
|
||||
|
Reference in New Issue
Block a user