enumerate_aux(X,_,WF) :- kernel_waitflags:find_waitflag_info(WF,Info,Prio,LWF), % linear in size of waitflag store !
var(LWF), Info == element_of_avl(X),
!,
debug_println(9,found_element_of_avl_trigger(Prio,X)),
LWF = Prio.
enumerate_aux(X,_,WF) :- var(X), !, frozen(X,G), %trace, print(frozen(X,G)),nl,
trigger_enumerators(G,X,Triggered),
(Triggered == true -> true ; add_message('ENUMERATE','Could not trigger ENUMERATE: ',X), enumerate_aux(X,X,WF)).
enumerate_aux(fd(X,GS),_,WF) :- !, kernel_objects:enumerate_basic_type_wf(fd(X,GS),global(GS),WF).
enumerate_aux(int(X),_,WF) :- !,
kernel_objects:enumerate_basic_type_wf(int(X),integer,WF).
enumerate_aux((A,B),WF1,WF) :- !, % should we look for a element_of_avl(X) waitflag in WF store ?
enumerate_aux(A,WF1,WF), enumerate_aux(B,WF1,WF).
enumerate_aux(rec(Fields),WF1,WF) :- !, % ditto
maplist(enumerate_field(WF1,WF),Fields).
enumerate_aux(Obj,_,_WF) :- %kernel_waitflags:portray_waitflags(_WF),trace,
add_error(external_functions,'Cannot ENUMERATE value yet: ',Obj).