preliminary cont work

This commit is contained in:
Mark Thom
2019-12-19 20:02:10 -04:00
15 changed files with 359 additions and 144 deletions

29
src/prolog/lib/cont.pl Normal file
View File

@@ -0,0 +1,29 @@
:- module(cont, [reset/3, shift/1]).
reset(Goal, Cont, Term) :-
call(Goal),
'$reset_cont_marker',
'$bind_from_register'(Cont, 3),
'$bind_from_register'(Term, 4).
shift(Term) :-
'$nextEP'(first, E, P),
get_chunks(E, P, L),
Cont = cont(call_continuation(L)),
'$write_cont_and_term'(_, _, Cont, Term),
'$unwind_environments'.
get_chunks(E, P, L) :-
( '$points_to_cont_reset_marker'(P) ->
L = []
; '$get_chunk'(E,P,TB),
L = [TB|Rest],
'$nextEP'(E, NextE, NextP),
get_chunks(NextE, NextP, Rest)
).
call_continuation(L) :- '$call_continuation'(L).
'$write_cont_and_term'(_, _, _, _).