fix control construct bugs, iter indentation (#947)

This commit is contained in:
Mark
2023-10-11 12:41:45 -06:00
parent b83631fb20
commit 1163d14ea1
3 changed files with 41 additions and 26 deletions

View File

@@ -86,22 +86,22 @@ impl<'a> EagerStackfulPreOrderHeapIter<'a> {
let arity = cell_as_atom_cell!(self.heap[s]).get_arity();
for idx in (s + 1 .. s + arity + 1).rev() {
if self.heap[idx].get_mark_bit() != self.mark_phase {
if self.heap[idx].get_mark_bit() != self.mark_phase {
self.iter_stack.push(self.heap[idx]);
self.heap[idx].set_mark_bit(self.mark_phase);
}
}
}
}
(HeapCellValueTag::Lis, l) => {
if self.heap[l+1].get_mark_bit() != self.mark_phase {
self.iter_stack.push(self.heap[l+1]);
self.heap[l+1].set_mark_bit(self.mark_phase);
}
if self.heap[l+1].get_mark_bit() != self.mark_phase {
self.iter_stack.push(self.heap[l+1]);
self.heap[l+1].set_mark_bit(self.mark_phase);
}
if self.heap[l].get_mark_bit() != self.mark_phase {
self.iter_stack.push(self.heap[l]);
self.heap[l].set_mark_bit(self.mark_phase);
}
if self.heap[l].get_mark_bit() != self.mark_phase {
self.iter_stack.push(self.heap[l]);
self.heap[l].set_mark_bit(self.mark_phase);
}
}
(HeapCellValueTag::AttrVar | HeapCellValueTag::Var, h) => {
let var_value = self.heap[h];

View File

@@ -328,6 +328,9 @@ staggered_sc(_, G) :- call(G).
% to reason about the programs. Also restricts the ability to run the program with alternative execution strategies
!.
:- non_counted_backtracking get_cp/1.
get_cp(B) :- '$get_cp'(B).
:- non_counted_backtracking set_cp/1.
set_cp(B) :- '$set_cp'(B).
@@ -359,24 +362,21 @@ cont_list_goal(Conts, '$call'(builtins:dispatch_call_list(Conts))).
:- non_counted_backtracking dispatch_prep/3.
dispatch_prep(Gs, B, [Cont|Conts]) :-
dispatch_prep(Gs, B, Conts) :-
( callable(Gs) ->
strip_module(Gs, M, Gs0),
( nonvar(Gs0),
dispatch_prep_(Gs0, B, [Cont|Conts]) ->
dispatch_prep_(Gs0, B, Conts) ->
true
; Gs0 == ! ->
Cont = '$call'(builtins:set_cp(B)),
Conts = []
Conts = ['$call'(builtins:set_cp(B))]
; nonvar(Gs0),
\+ callable(Gs0) ->
throw(dispatch_prep_error)
; Cont = Gs,
Conts = []
; Conts = [Gs]
)
; var(Gs) ->
Cont = Gs,
Conts = []
Conts = [Gs]
; throw(dispatch_prep_error)
).
@@ -387,20 +387,32 @@ dispatch_prep_((G1, G2), B, [Cont|Conts]) :-
dispatch_prep(G1, B, IConts1),
cont_list_goal(IConts1, Cont),
dispatch_prep(G2, B, Conts).
dispatch_prep_((G1 ; G2), B, [Cont|Conts]) :-
dispatch_prep(G1, B, IConts0),
dispatch_prep_((G1 ; G2), B, Conts) :-
( nonvar(G1) ->
( G1 = (G11 -> G12) ->
dispatch_prep(G11, B, IConts2),
dispatch_prep(G12, B, IConts3),
cont_list_goal(IConts2, Cont2),
cont_list_goal(IConts3, Cont3),
Cont0 = '$call'(builtins:staggered_if_then(Cont2, Cont3))
; dispatch_prep(G1, B, IConts0),
dispatch_prep(G2, B, IConts1),
cont_list_goal(IConts0, Cont0)
)
; dispatch_prep(G1, B1, IConts0),
cont_list_goal(IConts0, Cont0)
),
dispatch_prep(G2, B, IConts1),
cont_list_goal(IConts0, Cont0),
cont_list_goal(IConts1, Cont1),
Cont = '$call'(builtins:staggered_sc(Cont0, Cont1)),
Conts = [].
dispatch_prep_((G1 -> G2), B, [Cont|Conts]) :-
dispatch_prep(G1, B, IConts1),
Conts = ['$call'(builtins:staggered_sc(Cont0, Cont1))].
dispatch_prep_((G1 -> G2), B, Conts) :-
dispatch_prep(G1, B1, IConts1),
dispatch_prep(G2, B, IConts2),
cont_list_goal(IConts1, Cont1),
cont_list_goal(IConts2, Cont2),
Cont = '$call'(builtins:staggered_if_then(Cont1, Cont2)),
Conts = [].
Conts = ['$call'(builtins:get_cp(B1)),
'$call'(builtins:staggered_if_then(Cont1, Cont2))].
:- non_counted_backtracking dispatch_call_list/1.

View File

@@ -691,6 +691,9 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
(HeapCellValueTag::Cons, ptr_1) => {
Self::unify_constant(self, ptr_1, d2);
}
(HeapCellValueTag::CutPoint, n1) => {
Self::unify_fixnum(self, n1, d2);
}
_ => {
unreachable!();
}