diff: clpr/cfloat.m minor style improvements
Fergus Henderson
fjh at kryten.cs.mu.OZ.AU
Tue Sep 2 23:53:36 AEST 1997
clpr/cfloat.m:
Rename the cfloat "trail" as the cfloat "choicepoint stack",
since the latter more accurately reflects its purpose.
Index: cfloat.m
===================================================================
RCS file: /home/staff/zs/imp/clpr/cfloat.m,v
retrieving revision 1.1
diff -u -u -r1.1 cfloat.m
--- 1.1 1997/08/27 17:11:05
+++ cfloat.m 1997/09/01 08:20:28
@@ -312,42 +312,41 @@
#endif
/*
-** There are three trails:
+** There are three data structures involved in trailing:
** - the Mercury trail
-** - the cfloat.m trail-info free list
+** - the cfloat.m choice point stack
** - the CLP(R) trail
** The Mercury trail contains function trail entries which point to
-** the cfloat.m trail. (The reason why those two are separate is modularity.)
-** The cfloat.m trail is organized as a doubly-linked list.
-** The cfloat.m trail entries store the CLP(R) global variables, including
+** the cfloat.m choice point stack.
+** The cfloat.m choice point stack is represented a doubly-linked list.
+** Its entries store the values of the CLP(R) global variables, including
** the `trtop' variable, which points to the top of the CLP(R) trail.
*/
-/* XXX rename as `choicepoint' */
-typedef struct ML_cfloat_trail_entry {
+typedef struct ML_cfloat_choicepoint {
int stamp;
int slack_id;
int solver_id;
int trtop;
- struct ML_cfloat_trail_entry *prev;
- struct ML_cfloat_trail_entry *next;
-} ML_cfloat_trail_entry;
+ struct ML_cfloat_choicepoint *prev;
+ struct ML_cfloat_choicepoint *next;
+} ML_cfloat_choicepoint;
-ML_cfloat_trail_entry ML_cfloat_first_trail_entry;
-ML_cfloat_trail_entry * ML_cfloat_trail_ptr = &ML_cfloat_first_trail_entry;
+ML_cfloat_choicepoint ML_cfloat_first_choicepoint;
+ML_cfloat_choicepoint * ML_cfloat_current_cp = &ML_cfloat_first_choicepoint;
/* XXX efficiency could be improved -- we should use a free list here */
-#define ML_cfloat_next_trail_entry() \
- ( ML_cfloat_trail_ptr->next == NULL ? \
- (ML_cfloat_trail_ptr->next = make(ML_cfloat_trail_entry), \
- ML_cfloat_trail_ptr->next->next = NULL, \
- ML_cfloat_trail_ptr->next->prev = ML_cfloat_trail_ptr, \
- ML_cfloat_trail_ptr = ML_cfloat_trail_ptr->next) \
+#define ML_cfloat_next_choicepoint() \
+ ( ML_cfloat_current_cp->next == NULL ? \
+ (ML_cfloat_current_cp->next = make(ML_cfloat_choicepoint), \
+ ML_cfloat_current_cp->next->next = NULL, \
+ ML_cfloat_current_cp->next->prev = ML_cfloat_current_cp,\
+ ML_cfloat_current_cp = ML_cfloat_current_cp->next) \
: \
- (ML_cfloat_trail_ptr = ML_cfloat_trail_ptr->next) \
+ (ML_cfloat_current_cp = ML_cfloat_current_cp->next) \
)
-#define ML_cfloat_prev_trail_entry() \
- (ML_cfloat_trail_ptr = ML_cfloat_trail_ptr->prev)
+#define ML_cfloat_prev_choicepoint() \
+ (ML_cfloat_current_cp = ML_cfloat_current_cp->prev)
#define ML_cfloat_maybe_trail_solver() \
do { \
@@ -366,27 +365,27 @@
:- pragma(c_code, "
void ML_cfloat_trail_solver(void) {
- ML_cfloat_trail_entry *trail_entry = ML_cfloat_next_trail_entry();
- trail_entry->stamp = stamp;
- trail_entry->slack_id = slack_id;
- trail_entry->solver_id = solver_id;
- trail_entry->trtop = trtop;
- MR_trail_function(ML_cfloat_untrail_func, (Word) trail_entry);
+ ML_cfloat_choicepoint *choicepoint = ML_cfloat_next_choicepoint();
+ choicepoint->stamp = stamp;
+ choicepoint->slack_id = slack_id;
+ choicepoint->solver_id = solver_id;
+ choicepoint->trtop = trtop;
+ MR_trail_function(ML_cfloat_untrail_func, (Word) choicepoint);
stamp = MR_current_choicepoint_id();
}
void ML_cfloat_untrail_func(Word datum, MR_untrail_reason reason) {
- ML_cfloat_trail_entry *trail_entry = (ML_cfloat_trail_entry *) datum;
+ ML_cfloat_choicepoint *choicepoint = (ML_cfloat_choicepoint *) datum;
switch (reason) {
case MR_undo:
case MR_exception:
{
int old_trtop, i;
- stamp = trail_entry->stamp;
- slack_id = trail_entry->slack_id;
- solver_id = trail_entry->solver_id;
- old_trtop = trail_entry->trtop;
+ stamp = choicepoint->stamp;
+ slack_id = choicepoint->slack_id;
+ solver_id = choicepoint->solver_id;
+ old_trtop = choicepoint->trtop;
for (i = trtop - 1; i >= old_trtop; i--) {
solver_backtrack((Word) trail[i]);
}
@@ -394,7 +393,7 @@
break;
}
case MR_commit:
- stamp = trail_entry->stamp;
+ stamp = choicepoint->stamp;
if (nlin_count != 0) {
fprintf(stderr, ""cfloat.m: warning: ""
""non-linear goals delayed, ""
@@ -404,7 +403,7 @@
default:
fatal_error(""cfloat.m: unknown MR_untrail_reason"");
}
- ML_cfloat_prev_trail_entry();
+ ML_cfloat_prev_choicepoint();
}
").
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list