diff -ruN klic-3.003-2002-03-09b/include/klic/g_methtab.h klic-3.003-2002-03-11/include/klic/g_methtab.h --- klic-3.003-2002-03-09b/include/klic/g_methtab.h Sat Mar 9 14:02:05 2002 +++ klic-3.003-2002-03-11/include/klic/g_methtab.h Mon Mar 11 13:21:48 2002 @@ -77,7 +77,7 @@ }; struct generator_object_method_table { - void (*active_unify)(/* q self, q other */); + int (*active_unify)(/* q self, q other */); q (*generate)(/* struct generator_object* self */); q (*suspend)(/* q reference, struct goalrec* goal */); long (*print)/* print what ? */ (/* struct generator_object* self, diff -ruN klic-3.003-2002-03-09b/include/klic/gg_macro.h klic-3.003-2002-03-11/include/klic/gg_macro.h --- klic-3.003-2002-03-09b/include/klic/gg_macro.h Sat Mar 9 16:41:10 2002 +++ klic-3.003-2002-03-11/include/klic/gg_macro.h Mon Mar 11 13:23:18 2002 @@ -41,7 +41,7 @@ #define GG_GCREQUEST GENERIC_GCREQUEST #define GG_RETURN do{ return g_allocp; }while(0) -#define GG_TERMINATE do{ set_heapp(g_allocp); return; }while(0) +#define GG_TERMINATE do{ set_heapp(g_allocp); return !0; }while(0) #define GG_SUSPEND(var) \ do{ \ @@ -176,7 +176,7 @@ /**********************************************************************/ #define GGDEF_UNIFY() \ -static void GG_rappend(active_unify) (q GG_SELF, q GG_TERM) +static int GG_rappend(active_unify) (q GG_SELF, q GG_TERM) #define GGDEF_SUSPEND() \ static q \ diff -ruN klic-3.003-2002-03-09b/include/klic/gg_methtab.h klic-3.003-2002-03-11/include/klic/gg_methtab.h --- klic-3.003-2002-03-09b/include/klic/gg_methtab.h Sun Feb 24 14:51:46 2002 +++ klic-3.003-2002-03-11/include/klic/gg_methtab.h Mon Mar 11 13:32:23 2002 @@ -8,10 +8,7 @@ #ifndef _KLIC_GG_METHTAB_H_ #define _KLIC_GG_METHTAB_H_ -extern q* GG_STD_UNIFY(); extern q GG_STD_SUSPEND(); -extern long GG_STD_PRINT(); -extern q* GG_STD_GC(); /* runtime/generic.c */ extern void GD_STD_DEALLOCATE(struct data_object* GD_SELF); @@ -23,7 +20,7 @@ struct generator_object_method_table GG_method_table = { #ifndef GGUSE_MY_UNIFY - GG_STD_UNIFY , +#error "please GGDEF_UNIFY and GGUSE_MY_UNIFY" #else GG_rappend(active_unify) , #endif @@ -42,13 +39,13 @@ #endif #ifndef GGUSE_MY_PRINT - GG_STD_PRINT , +#error "please GGDEF_PRINT and GGUSE_MY_PRINT" #else GG_rappend(print) , #endif #ifndef GGUSE_MY_GC - GG_STD_GC , +#error "please GGDEF_GC and GGUSE_MY_GC" #else GG_rappend(gc) , #endif diff -ruN klic-3.003-2002-03-09b/runtime/ge_exref.c klic-3.003-2002-03-11/runtime/ge_exref.c --- klic-3.003-2002-03-09b/runtime/ge_exref.c Sat Mar 9 16:41:10 2002 +++ klic-3.003-2002-03-11/runtime/ge_exref.c Mon Mar 11 13:23:28 2002 @@ -102,7 +102,7 @@ /* fprintf(stderr, "Node:%d unify EXREF-non-EXREF", my_node); */ } } - set_heapp(NULL); /* Cannot unify now */ + return 0; /* Cannot unify now */ } GGDEF_ENCODE() diff -ruN klic-3.003-2002-03-09b/runtime/gg_shbusy.c klic-3.003-2002-03-11/runtime/gg_shbusy.c --- klic-3.003-2002-03-09b/runtime/gg_shbusy.c Sat Mar 9 12:33:13 2002 +++ klic-3.003-2002-03-11/runtime/gg_shbusy.c Mon Mar 11 13:27:53 2002 @@ -34,12 +34,13 @@ struct generator_object* gobj; q pair = derefone(GG_SELF); - if( !isref(pair) || GG_SELF != derefone(pair) ){ One_more(); return; } + if( !isref(pair) || GG_SELF != derefone(pair) ){ One_more(); GG_TERMINATE; } gobj = n_lock(GG_SELF, pair); if( derefone(GG_SELF) == pair ){ n_unlock(pair, gobj); } One_more(); + GG_TERMINATE; } GGDEF_GENERATE() diff -ruN klic-3.003-2002-03-09b/runtime/gg_shvar.c klic-3.003-2002-03-11/runtime/gg_shvar.c --- klic-3.003-2002-03-09b/runtime/gg_shvar.c Sat Mar 9 13:22:44 2002 +++ klic-3.003-2002-03-11/runtime/gg_shvar.c Mon Mar 11 13:27:13 2002 @@ -63,9 +63,9 @@ struct generator_object *addi; Shvar *gobjp; q pair = derefone(GG_SELF); - if( !isref(pair) || GG_SELF != derefone(pair) ){ One_more(); return; } + if( !isref(pair) || GG_SELF != derefone(pair) ){ One_more(); GG_TERMINATE; } addi = n_lock(GG_SELF, pair); - if( pair != derefone(GG_SELF) ){ One_more(); return; } + if( pair != derefone(GG_SELF) ){ One_more(); GG_TERMINATE; } gobjp = (Shvar*) untag_generator_susp(addi); GG_SWITCH_ON_TERM(cons, atomic, func, dobj, susp); @@ -124,7 +124,7 @@ if( !isref(ytemp) || y != derefone(ytemp) ){ n_unlock(temp, xaddi); One_more(); - return; + GG_TERMINATE; } yaddi = generator_suspp(ytemp)->u.o; /* if yaddi is generator_susp */ @@ -145,7 +145,7 @@ xaddi = n_lock(x, temp); if( temp != derefone(x) ){ One_more(); - return; + GG_TERMINATE; } xobjp = (Shvar*) untag_generator_susp(xaddi); } @@ -159,7 +159,7 @@ if( derefone(y) != ytemp ){ n_unlock(temp,xaddi); One_more(); - return; + GG_TERMINATE; } yobjp = (Shvar*) untag_generator_susp(yaddi); if( yobjp->chain ){ @@ -211,7 +211,7 @@ g_allocp = heapp(); derefone(y) = tmpy; One_more(); - return; + GG_TERMINATE; } }else{ /* x is a simple variable */ xobjp = create_genhook(tag_local(y), x); diff -ruN klic-3.003-2002-03-09b/runtime/random.c klic-3.003-2002-03-11/runtime/random.c --- klic-3.003-2002-03-09b/runtime/random.c Sat Mar 9 16:41:10 2002 +++ klic-3.003-2002-03-11/runtime/random.c Mon Mar 11 13:23:48 2002 @@ -83,7 +83,7 @@ GGDEF_UNIFY() { - set_heapp(NULL); + return 0; } #define GGUSE_MY_GENERATE diff -ruN klic-3.003-2002-03-09b/runtime/unify.c klic-3.003-2002-03-11/runtime/unify.c --- klic-3.003-2002-03-09b/runtime/unify.c Sat Mar 9 12:09:04 2002 +++ klic-3.003-2002-03-11/runtime/unify.c Mon Mar 11 13:18:59 2002 @@ -86,18 +86,15 @@ /* generator_object */ struct generator_susp *gsusp = generator_suspp(susprecord); struct generator_object *gobj = untag_generator_susp(gsusp->u.o); - q *tempallocp; + int unified; q backpt = gsusp->backpt; set_heapp(allocp); - method_table_of(gobj)->active_unify(gsusp->backpt, y); - tempallocp = heapp(); - if(tempallocp != NULL) { + unified = method_table_of(gobj)->active_unify(gsusp->backpt, y); + if(unified) { /* Unify method was succeeded */ - allocp = tempallocp; -/* - derefone(backpt) = y; -*/ + allocp = heapp(); + /* derefone(backpt) = y; */ } else { /* failed */ q tmp; @@ -219,34 +216,29 @@ */ { declare_globals; + int unified; q* allocp = heapp(); - q *tmpallocp; /* At first, try unify method */ set_heapp(allocp); - method_table_of(untag_generator_susp(gsx->u.o))-> + unified = method_table_of(untag_generator_susp(gsx->u.o))-> active_unify(gsx->backpt, sy->backpt); - tmpallocp = heapp(); - if(tmpallocp != (q*)0) { + if(unified) { /* succeeded */ - allocp = tmpallocp; -/* - derefone(gsx->backpt) = sy->backpt; -*/ + allocp = heapp(); + /* derefone(gsx->backpt) = sy->backpt; */ } else { /* unify of x is failed */ if(is_generator_susp(sy->u)) { struct generator_susp *gsy = generator_suspp(sy); - q* tempallocp; + int unified; + set_heapp(allocp); - method_table_of(untag_generator_susp(gsy->u.o))-> + unified = method_table_of(untag_generator_susp(gsy->u.o))-> active_unify(gsy->backpt, gsx->backpt); - tempallocp = heapp(); - if(tempallocp != (q*)0) { - allocp = tempallocp; -/* - derefone(gsy->backpt) = gsx->backpt; -*/ + if(unified) { + allocp = heapp(); + /* derefone(gsy->backpt) = gsx->backpt; */ } else { /* x and y are both generator, but both failed. */